Integration with XCODE? Anyone created a CUDA template project?

Everyone,

First off, CUDA is amazing… With my 8-Core and the FX5600… Dang… Watching the nbody demo is awesome!

Has anyone created a CUDA project template for XCODE 3.0?

At the moment it appears that all the CUDA samples are over make files, but there are no XCODE project templates…

Anyone out there created one? If not, was there a specific IDE/debug environment (Eclipse e.g.) that was used for the MAC OSX inside the Nvidia CUDA group?

Thanks in advance,

Chris Aiken
Aiken Development LLC

I use CMake (www.cmake.org) and FindCUDA.cmake (FindCuda.cmake) to generate visual studio/makefiles/xcode projects for windows/linux/mac. It works great for me.

Note: I haven’t actually tried FindCUDA.cmake on mac os x yet. I don’t have an intel mac to try it on. You may need to add a few search paths to FindCUDA.cmake so that it finds the compiler and libraries on mac.

Thanks for the help! I will try this and reply back with the results.

Regards,

Chris Aiken

Aiken Development LLC

Good information, thanks!

I have a native Xcode 3.0 plugin for nvcc which I’ll post here in a day or two (after a wee bit of testing) ;)

It’s missing a few options - mostly for intermediate file handling, but for straight compiles most of it works ok.

Here’s a snapshot.

Unpack NVCuda.pbplugin.zip and put the bundle into ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins, then restart Xcode.

Xcode should recognise .cu files and add them to the dependancy graph. If you have a target with cuda sources, there should be a CodeGeneration section after the GCC 4.0 sections called “NVIDIA Cuda”.

Note that everything in that section is separate from the project wide GCC options, so there are separate preprocessor macros, optimisation etc, however I used the include path from the project settings (i.e. HEADER_SEARCH_PATHS) so you only need to do those once. Adding in dyld or frameworks as usual will sort out the linker flags and search paths.

Also, the dependancy graph at this stage doesn’t know about the -hostcompilation option and so defaults to ‘ld’, in which case you’d have to link against all the relevant libs. But you can force the linker if need be by setting a user defined variable “LD” to either gcc or g++.

I haven’t really run anything with this, but let me know if it you have any issues.

llamatron,

I really appreciate the posting. I will try this ASAP and give you the feedback!

This should provide a more much comfortable CUDA development environment.

Unfortunately, I am out of the office and will not be in front of the machine until the early next. As soon as I get back, I will give this a try.

Hopefully, I can return the favor some day.

Regards,

Chris Aiken

Aiken Development LLC

Anonymous browsers: use the link on the bottom to the lite version of the forum to see the attachments in llamatron’s post.

Hi Akin,

Did CMake work for you?

llamatron,

Thank you very much for the Xcode plugin! I have installed it as described and it almost works, but I’m having some linker errors when trying to compile one of the basic sample codes from the tutorials. As I am just getting started with CUDA, it is likely a problem with my own code organization, but I can’t get it running on the command line either. (The example projects in the SDK compile and run fine.) Do you have a sample Xcode project you could post?

Thanks again,

Aaron

All: I’ve finally got a simple project, the matrix multiplication example, building and running correctly on Xcode with the CUDA Xcode plugin! It is attached here. Note that emulation is enabled and I haven’t tested it on real NVIDIA hardware. This is working for me on a MacBook Pro with OS 10.5.3 and CUDA 1.1 beta.

Hope this helps!

I loaded the plugin for Xcode and tried your sample project just by loading it and hitting “build and go”. The message I got was build succeeded, but couldn’t find the executable. What did i miss?

Are you using Xcode 3.0 or 3.1? I built this with 3.1 (which comes with the iPhone SDK beta), so it may be a project compatibility issue. Try creating a new project and copying the files in, making sure to set the correct project variables. I’ve taken notes on what I did to get it running here.

I am a beginner . Forgive me for my question .
I unpacked NVCuda.pbplugin.zip and got a folder named Contents . But I couldn’t find the folder ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins
(may be ~/Library/Application /Support/Developer/Shared/Xcode/Plug-ins
or ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins )
My PC is MacBook Pro, and I am using 0SX 10.5.4 . So maybe the path name is quite different .I tried finding Plug-ins folder, but no proper result . Please tell me how I should do . Thank you very much.

Just create the folder if it doesn’t exist. The correct folder, again, is:

~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins

Hi All,
I just tried the process explained in this thread (Built and install NVCuda.pbplugin)
When I build the XCodeTest project I get this:

"

Building target “XcodeTest” of project “XcodeTest” with configuration “Release” — (1 error, 2 warnings)
Checking Dependencies
warning: no rule to process file ‘$(PROJECT_DIR)/test.cu’ of type sourcecode.cuda for architecture ppc
warning: no rule to process file ‘$(PROJECT_DIR)/matrixMul_kernel.cu’ of type sourcecode.cuda for architecture ppc
warning: no rule to process file ‘$(PROJECT_DIR)/test.cu’ of type sourcecode.cuda for architecture ppc
warning: no rule to process file ‘$(PROJECT_DIR)/matrixMul_kernel.cu’ of type sourcecode.cuda for architecture ppc
cd /Users/JM/Downloads/XcodeTest
/Developer/usr/bin/g+±4.0 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/JM/Downloads/XcodeTest/build/Release -L/Users/JM/Downloads/XcodeTest -F/Users/JM/Downloads/XcodeTest/build/Release -filelist /Users/JM/Downloads/XcodeTest/build/XcodeTest.build/Release/XcodeTest.build/Objects-normal/ppc/XcodeTest.LinkFileList -mmacosx-version-min=10.5 -lcudart -o /Users/JM/Downloads/XcodeTest/build/XcodeTest.build/Release/XcodeTest.build/Objects-normal/ppc/XcodeTest
ld warning: in /Users/JM/Downloads/XcodeTest/libcudart.dylib, file is not of required architecture
Undefined symbols:
“runTest()”, referenced from:
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
“runTest()”, referenced from:
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Build failed (1 error, 2 warnings)

"

What am I doing wrong ?
Thanks in advance
JM

hi jmgiorgi

I have the exact same problem. Could you please tell me how you solved it. Thanks

Hi,

Nice work with the Xcode project it runs fine for me, I was wondering though if you’d mind explaining what’s going on in the project though, for a begginer it would be really useful to know. I’ve tried compiling some of the examples using your template but it doesn’t seem to work out.

I have the same problem and I get these errors:

Checking Dependencies
warning: no rule to process file ‘$(PROJECT_DIR)/test.cu’ of type text for architecture i386
warning: no rule to process file ‘$(PROJECT_DIR)/matrixMul_kernel.cu’ of type text for architecture i386
cd /Users/me/Downloads/Folx/XcodeTest
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/g+±4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/me/Downloads/Folx/XcodeTest/build/Debug -L/usr/local/cuda/lib -L/Users/me/Downloads/Folx/XcodeTest -L/usr/local/cuda/lib -F/Users/me/Downloads/Folx/XcodeTest/build/Debug -filelist /Users/me/Downloads/Folx/XcodeTest/build/XcodeTest.build/Debug/XcodeTest.build/Objects-normal/i386/XcodeTest.LinkFileList -Wl,-rpath,/usr/local/cuda/lib -mmacosx-version-min=10.5 -lcudart -lcuda -lcudart -lcuda -prebind -o /Users/me/Downloads/Folx/XcodeTest/build/Debug/XcodeTest
Undefined symbols:
“runTest()”, referenced from:
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

(the folx program is where I downloaded your code to.)
any help would be great. I’m more worried about the warnings.

accidentally posted duplicate… this message can be removed