a framework for applying gpu parallel computing to an
TRANSCRIPT
A Framework for Applying GPU Parallel Computing to
an Agricultural Model Kei TANAKA
Agricultural Research Center (ARC) National Agriculture and Food Research
Organization (NARO), Japan
Contents
• Background and Objectives
• GPGPU
• Aparapi
• Comparison of the execution time of DVI calculation of SIMRIW
– Normal, Multithreading, GPU
• Future works
• Summary
2012/8/26 APAN2012, Colombo 2
Background • Tool for Predicting the Possibility of
Rice Cultivation (2009)
• For the calculation of cultivation possibility data
– 15,000 points (1 degree grid)
– 8 cultivars 6 conditions (air-temp., CO2) 17,520 times/points 365 days of transplanting dates
– Core i7 860
– 7 days by normal, 2 days by multithreading
2012/8/26 APAN2012, Colombo 3
Objectives
• Shortening of the computing time to generate the cultivating possibility data
• Number or target crops increase Points (-> 0.1 degree grid) for more detailed Parameter set simulation
• Concurrent Programming
– Multithreading by CPU -> GPGPU
2012/8/26 APAN2012, Colombo 4
GPGPU
• General-Purpose Computing on Graphics Processing Units (GPGPU)
• Single Instruction Multiple Data (SIMD) – Executing the same processing at a time for different
data by one instruction
– Suitable fields: physics, fluid calculation, climatic simulation, image and speech processing
• Calculation of cultivation possibility data – A crop model has a lot of conditional jump instructions
– A lot of same calculations with different meteorological data and parameter values for a crop growth model
2012/8/26 APAN2012, Colombo 5
Development Environment for GPGPU
• Compute Unified Device Architecture (CUDA)
– for NVIDIA GPU
• ATI Stream SDK
– for AMD GPU
• Open Computing Language (OpenCL)
– Framework that can be executed on different type GPU
– Supported by many companies
2012/8/26 APAN2012, Colombo 6
GPGPU Programming with Java
• Development in Java
– Java Agricultural Model Framework (JAMF)
– Crop models implemented with JAMF
• Java Libraries to use OpenCL – Aparapi, Java bindings for OpenCL (JOCL), JavaCL, jOpenCL
• Aparapi
– All codes including the kernel function (parallel computation part) can be written in Java
2012/8/26 APAN2012, Colombo 7
Aparapi (code)
• The parallel computation part is described in the run method of the Kernel class, and it will be executed by the execute method (as well as Thread class)
2012/8/26 APAN2012, Colombo 8
final int[] square = new int[size]; final int[] in = new int[size]; // populating in[0..size] omitted
for (int i=0; i<size; i++){ square[i] = in[i] * in[i]; }
new Kernel(){ @Override public void run(){ int i = getGlobalID(); square[i] = in[i] * in[i]; } }.execute(size);
Aparapi (execution)
• Executable in various environments by the same code (write once, run anywhere) – When the following conditions are satisfied -> GPU
mode Otherwise -> Java Thread Pool (JTP) mode
– Installed the compatible GPU and OpenCL driver
– Convertible from the Java parallel code to the OpenCL code
2012/8/26 APAN2012, Colombo 9
Java code javac
Java bytecode
java
OpenCL code execute
GPU mode
JTP mode
Comparison of the Execution Time DVI Calculation of SIMRIW
• GeForce GTS 250 (2009)
• Test Program: DVI calculation of SIMRIW
– Comparison among Normal, JTP, GPU mode
2012/8/26 APAN2012, Colombo 10
10
100
1000
10000
100 1000 10000 100000 1000000
Exe
cu
tio
n tim
e(m
s)
The number of the crop model execution(times)
Comparison of the Execution Time (DVI calculation of SIMRIW)
Normal
JTP
GPU
GPU+Conversion
4.5 times faster
28 times faster
0.75s
3.35s
20.0s
Future Works
• Effect of GPGPU when the entire SIMRIW and other crop models are calculated
• Effect when latest GPU (GTX670) is installed
• Applying the code tuning for GPGPU
– In this presentation, only Aparapi was applied to Java code
2012/8/26 APAN2012, Colombo 11
Summary
• Aparapi was adopted to develop GPGPU program using only Java
• GPGPU was effective for the crop growth model calculation with the fairly large frequency – 1 million execution conversion time incl. – Compared with Normal mode 28 times – Compared with JTP mode 4.5 times
• Because the cost of GPU for 3D game is hundreds US$, it is excellent in cost-effectiveness
• A further performance improvement can be expected by the latest GPU, and code tuning
2012/8/26 APAN2012, Colombo 12