- added a fourth version, which includes additional overhead also in version 01 (indexing, determining ratio, etc) - added a 'verbose' command line option, where if verbose is true then ratios of timings will be outputted, otherwise just durations will be outputted - made certain variables to be constants - cleaned up comments and what not - removed all instances of kernelfunctor
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