gcc - Proper way of compiling OpenCL applications and using available compiler options -


i newbie in opencl stuffs.

whats best way compiler opencl project ?

  1. using supported compiler (gcc or clang):

    when use compiler gcc or clang, how control these options? have set inside source code, or, likewise normal compilation flow can pass them on command line. looking @ khornos-manual-1.2, there few options provided cl_int clbuildprogram optimizations. :

    gcc|clang -o3 -i<includes> opencl_app.c -framework opencl option -lm 

    actually, tried , received error :

    gcc: error: unrecognized command line option '<option>' 
  2. alternatively, using openclc:

    i have seen people using openclc compiler using makefile.

i know best way (if there 2 separate ways), , how control usage of different compile time options.

you might aware important reiterate. opencl standard contains 2 things:

  1. opencl c language , programming model (i think recent standard include c++)
  2. opencl host library manage device

gcc , clang compilers host side of opencl project. there no way provide compiler options opencl device code compilations using host compiler since not aware of opencl. except clang there flag accept opencl device code, .cl file contains kernels. way can use clang , provide flags , options if remember correctly, have either llvm ir or spir output not device executable object. can load spir object device using device's run-time environment(opencl drivers). can checkout these links:

using clang compile kernels

llvm ir generation

spir

other alternative use tools provided target platform. each vendor claims support opencl, should have run-time environment. usually, have separate cli tools compile opencl device code. in case(i guess) have drivers apple, therefore have openclc.

intel cli example

now main question (best way compile opencl). depends want do. didn't specify kind of requirements have had speculate.

if want have off-line compilation without host program, considerations above you. otherwise, have use opencl library , have on-line compilation kernels, preferred products needs portability. since if compile kernels @ start of program, directly use provided environment , don't need provide libraries each target platform.

therefore, if have opencl project, have decide how compile. if want use generic flags , not rely on third party tools. suggest have class builds kernels , provides flags want.


Comments