cpu - Possible to write only in OpenCL? -
let i've got nice algorithm want code run on both cpus , gpus. know can target x86 opencl.
should prepare 2 versions of code (for cpus , gpus) written 1 in opencl, other in traditional way? or maybe can make 1 implementation in opencl, , run amd's sdk on machines without proper gpu? drawbacks running opencl on cpu have, compared implementation in pure c?
(note: understand need write opencl initialization , input/output in traditional way. question covers computational part of program)
you might try going down path of writing in opencl. way have 1 version of code runs on both cpu , gpu... in theory.
in practice, optimum performance might want tweak code particular hardware targeting. example, x86 cpu might benefit using vectors while nvidia gpu might not or @ (in fact different versions of hardware same manufacturer have different characteristics).
to target gpu, you'll need opencl version of algorithm anyway. when tweaking particular hardware, can go down path of using #define/#ifdef , rewrite or tweak parts of algorithm need it. may work algorithm , save duplicating whole lot of code.
a disadvantage of opencl is harder use coding or using c library. if library/algorithm else , written in opencl, forcing them include opencl libraries , have opencl runtime on system. can harder debug - no console printing (but there extensions support this) , haven't got experience opencl debuggers doubt traditional debuggers.
Comments
Post a Comment