CUDA, Objective-C and Xcode — Part 1
Posted: July 20th, 2009 | Author: Thomas | Filed under: Apple, CUDA, Development | Tags: Cocoa, CUDA, Objective-C, Xcode | 5 Comments »Xcode is the preferred integrated development enviroment (IDE) for most Cocoa developers. It offers good support for a variety of languages, esp. C, C++ and Objective-C. It is possible to extend Xcode to handle matters which Apple does not support out of the box. This post shows how to integrate CUDA with Xcode.
This howto guide was written for Xcode 3.1.3, Mac OS X 10.5.7 and CUDA 2.2. Keep in mind, that later versions may break the following procedure.
To use CUDA the basic files from NVIDIA are required.
- CUDA Toolkit 2.2 for Mac OS
- CUDA SDK 2.2.1 code samples for Mac OS
- (optional) CUDA Visual Profiler v1.2 for Mac OS
When installing these files, take care to choose custom install and mark the CUDA.kext to be installed. See the note on my earlier post about this.
In the next step two files are required: a plug-in to introduce .cu files to Xcode and a template to set up Xcode for CUDA programming. You can download both files from the NVIDA forum in the CUDA on Mac OS X section, specifically posting #29 in this thread. Some very talented guy called Paul T. Thompson created a plug-in and a template. Download the two files labeled “CUDA_Projects.zip” and “NVCuda.pbplugin.zip”.
As described by Paul, these files need to be copied to specific places in your $HOME directory. Here’s the summary:
“CUDA_Projects.zip”
- Extract the file CUDA_Projects.zip
- Copy the folder CUDA Projects to the folder
$HOME/Library/Application Support/Developer/Shared/Xcode/Project Templates/
If some of the folders do not exist in your $HOME folder, simply create them.
“NVCuda.pbplugin.zip”
- Extract the file NVCuda.plugin.zip
- Copy the file NVCuda.plugin to the folder
$HOME/Library/Application Support/Developer/Shared/Xcode/Plug-ins/
Again, if some folders do not exist in your $HOME folder, simply create them.
Basically, that is all, what needs to be done. Launch Xcode and verify the correct installation of CUDA and the plug-in as well as the template. When creating a New Project… , there should be a new choice if the template was copied to the correct location:
User Templates > CUDA Projects > CUDA C:C++ App
Select this and create a new CUDA C:C++ App. To verify the NVCuda.pbplugin, select
Project > Edit Project Settings > Build
Near the bottom of the list should be a section named NVIDIA CUDA – CodeGeneration. If you see this, the plug-in was installed correctly. By default, Device Emulation is active. In the screenshot below it is deactivated.
So far — so good. In a soon™ to be published follow up I will explain how to combine Cocoa and CUDA.


[...] the last blog entry it was discussed what needs to be installed to get a combination of CUDA, Objective-C and [...]
[...] post: CrimsonMagic » Blog Archive » CUDA, Objective-C and Xcode — Part 1 Share and [...]
thank!
Thank you for this description – I’ll try it out as soon as I can – but I’m quite desperate that it will lead me to a running Cuda project with Xcode
keep up the good work
Thank you sooo much. I was planning to enroll in a CUDA course in the univ and needed a running IDE to help during the course work and your walkthrough got me running in no time !
Thanks alot and much appreciation. Keep the good work.