The code just calculates the sum of the two vectors.
How to compile and run the sample codes is shown as follows.
cd cpp
make
sbatch pbs_sample1.sh
cat sample1.cpulog
cat sample1.gpulog
This example shows how GPU calculates fast. The calculation is basically the same as the sample1.
How to compile and run the sample codes is shown as follows.
cd cpp
make
sbatch pbs_sample2.sh
cat sample2.cpulog
cat sample2.gpulog
This example shows how 2D array is treated. We solve 2D poission equation by Jacobi method.
In the method, the gravitational potential is obtained by the following iterative procedure.
How to compile and run the sample codes is shown as follows.
cd cpp
make
sbatch pbs_sample3.sh
cat sample3.cpulog
cat sample3.gpulog
Check the gravitational potential by gnuplot. Follow the instruction in the analysis server..
cd /gwork0/<username>/gpusample/cpp
gnuplot
splot "xy-gpu.dat" u 1:2:4 w l
splot "xy-cpu.dat" u 1:2:4 w l
- 青山龍美, GPU チュートリアル CUDA篇
- how to cast a 2-dimensional thrust::device_vector<thrust::device_vector> to raw pointer, stack overflow
This example shows how the summation of all components of a vector are obtained.
See the code for CPU and GPU. This code implementation is the simplest and slowest one, so if you want to use faster code, see the references.
How to compile and run the sample codes is shown as follows.
cd cpp
make
sbatch pbs_sample4.sh
cat sample4.cpulog
cat sample4.gpulog