748 B
748 B
Example 01
This example compares the timings of adding vectors on the CPU versus adding vectors on the GPU, the latter of which has different implementations.
Compiling
clang++ -std=c++0x -framework OpenCL version01.cpp -o version01.out
To ignore deprecation warnings, add the flag -Wno-deprecated-declarations.
About
The code runs the following implementations of adding large vectors (131072 elements; 8 * 32 * 512). The vectors are added together 1000 times.
- CPU
- GPU, where 32 * 512 threads are spawned and each thread thus gets 8 elements to calculate
- GPU, same as before but each iteration involves writing the buffers (to demonstrate overhead)
- GPU, where 8 * 32 * 512 threads are spawned - one for each element