开发者

Can't Build a simple Cuda Program using Xcode !

开发者 https://www.devze.com 2023-01-17 21:20 出处:网络
I\'m using Xcode 3.2 on Mac OS 10.6 to build a very simple HelloWorld program for CUDA but it fails to build .. any ideas !!!

I'm using Xcode 3.2 on Mac OS 10.6 to build a very simple HelloWorld program for CUDA but it fails to build .. any ideas !!!

this is the code :

    #include <iostream>
#include <stdio.h开发者_StackOverflow中文版>
#include <stdlib.h>
#include <assert.h>
#include <CUDA/CUDA.h>

__device__ char napis_device[14];

__global__ void helloWorldOnDevice(void){
 napis_device[0]='H';
 napis_device[1]='e';
 napis_device[2]='l';
 napis_device[3]='l';
 napis_device[4]='o';
 napis_device[5]=' ';
 napis_device[6]='W';
 napis_device[7]='o';
 napis_device[8]='r';
 napis_device[9]='l';
 napis_device[10]='d';
 napis_device[11]='\n';

}



int main (int argc, char * const argv[]) {
    helloWorldOnDevice<<<1,1>>> ();
 cudaThreadSynchronize();
 char napis_host[14];
 const char *symbol="napis device";
 cudaMemcpyFromSymbol (napis_host, symbol, sizeof(char)*13, 0, cudaMemcpyDeviceToHost);

     return 0;
}

The error appears at this line helloWorldOnDevice<<<1,1>>> ();

Expected primary-expression before '<' token !!!!!!


You're compiling your program with gcc coming with Xcode. Should use nvcc compiler instead to compile CUDA code. Normally I would use a Makefile to tell that *.cu to be compiled by nvcc and *.cpp by gcc, then link produced objects to an executable.

0

精彩评论

暂无评论...
验证码 换一张
取 消