Compiling the Julia example from “CUDA by Example” on Mac

This is just a little note to remind myself later how to do this. Perhaps it will be helpful for others in the same situation.

I’ve been reading CUDA By Example recently to (1) learn how to do some really exciting stuff and (2) to be ready for the GPU Technology Conference, which I’m attending this week. I finally was able to build the sample applications on my new Mac (which is totally amazing, by the way). Here’s how to do it.

Step 1: Get Xcode and the CUDA Toolkit. (Xcode is available for free on the App Store.)

Step 2: Get the “GPU By Example” sample code.

Step 3: Modify the #include lines in gl_helper.h.

/*#include <GL/glut.h>
#include <GL/glext.h>
#include <GL/glx.h> */

#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>

Step 4: Modify the CUDA code to add a missing “__device__” decoration in julia_gpu.cu:

    __device__ cuComplex( float a, float b ) : r(a), i(b)  {}

Step 5: Compile:

nvcc julia_gpu.cu -o julia_gpu -Xlinker -framework,OpenGL,-framework,GLUT

Not exactly straightforward . . . but pretty enough.

This entry was posted in Computing, Fodder for Techno-weenies. Bookmark the permalink.

One Response to Compiling the Julia example from “CUDA by Example” on Mac

  1. This is great help; The __device__ part was missing in Julia example in the book.

    __device__ cuComplex( float a, float b ) : r(a), i(b) {}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>