Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Short answer: <a href="https://developer.apple.com/library/mac/#documentation/Performance/Conceptual/OpenCL_MacProgGuide/XCodeHelloWorld/XCodeHelloWorld.html">https://developer.apple.com/library/mac/#documentation/Performance/Conceptual/OpenCL_MacProgGuide/XCodeHelloWorld/XCodeHelloWorld.html</a></p> <p>Long answer for command liners:</p> <p>With a recent Xcode (and Lion or higher), you don't even need to call <code>clCreateProgramWithSource</code>, just write your kernel and call it from your app, there are some additional compiling steps needed though.</p> <p>I'm taking the OpenCL Hello World example from Apple here using default compiler flags (see <a href="https://developer.apple.com/library/mac/#documentation/Performance/Conceptual/OpenCL_MacProgGuide/ExampleHelloWorld/Example_HelloWorld.html">https://developer.apple.com/library/mac/#documentation/Performance/Conceptual/OpenCL_MacProgGuide/ExampleHelloWorld/Example_HelloWorld.html</a>) and showing the steps Xcode would do in the background.</p> <p>To get you started, do a:</p> <pre><code>/System/Library/Frameworks/OpenCL.framework/Libraries/openclc -x cl -cl-std=CL1.1 -cl-auto-vectorize-enable -emit-gcl mykernel.cl </code></pre> <p>This will create 2 files, mykernel.cl.h and mykernel.cl.c (and mykernel.cl.c does all the magic of loading your kernel into the app). Next you'll need to compile the kernel:</p> <pre><code>/System/Library/Frameworks/OpenCL.framework/Libraries/openclc -x cl -cl-std=CL1.1 -Os -triple i386-applecl-darwin -emit-llvm-bc -o mykernel.cl.i386.bc mykernel.cl /System/Library/Frameworks/OpenCL.framework/Libraries/openclc -x cl -cl-std=CL1.1 -Os -triple x86_64-applecl-darwin -emit-llvm-bc -o mykernel.cl.x86_64.bc mykernel.cl /System/Library/Frameworks/OpenCL.framework/Libraries/openclc -x cl -cl-std=CL1.1 -Os -triple gpu_32-applecl-darwin -emit-llvm-bc -o mykernel.cl.gpu_32.bc mykernel.cl </code></pre> <p>And last but not least, build the app itself:</p> <pre><code>clang -c -Os -Wall -arch x86_64 -o mykernel.cl.o mykernel.cl.c clang -c -Os -Wall -arch x86_64 -o square.o square.c clang -framework OpenCL -o square mykernel.cl.o square.o </code></pre> <p>And that's it. You won't see any <code>clCreateProgramWithBinary</code> or <code>clCreateProgramWithSource</code> in Apple's sample code. Everything is done via mykernel.cl.c generated by <code>openclc</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. COReally informative, thanks a lot!
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload