我在Netbeans中创建了新的c++应用程序,并希望编译简单的CUDA,如:
#include <cstdlib>
// includes, system
#include <stdio.h>
// includes CUDA Runtime
#include <cuda_runtime.h>
// includes help
#include <helper_cuda.h>
#include <helper_functions.h> // helper utility functions
/*
*
*/
__global__ void add(int* a , int* b, int* c){
*c=*a+*b;
}
int main(int argc, char** argv) {
int a,b,c; //host copies of a,b,c
int* d_a,*d_b,*d_c; //device copies of a,b,c
int size=sizeof(int);
//allocate space for device copies of a,b,c
cudaMalloc((void**)&d_a,size);
cudaMalloc((void**)&d_b,size);
cudaMalloc((void**)&d_c,size);
//setup input
a=2;
b=7;
//copy inputs to device
cudaMemcpy(d_a,&a,size,cudaMemcpyHostToDevice);
cudaMemcpy(d_b,&b,size,cudaMemcpyHostToDevice);
//launch add() kernel on GPU device
add<<<1,1>>>(d_a,d_b,d_c);
return 0;
}
当我使用IDE构建时,它就是这样做的:
"/usr/bin/make" -f nbproject/Makefile-Debug。mkqmake =子项目=.build-conf make[1]:进入目录
/root/NetBeansProjects/my_CUDA_1' "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/libmy_cuda_1.a make[2]: Entering directory
/root/netbeansprojects/my_CUDA_1' mkdirrm -f build/Debug/GNU-Linux-x86/cudaMain.o。d/usr/local/cuda - 5.0 -/- bin/nvcc
-c -g -I/usr/local/cuda-5.0/include -I/usr/local/cuda-5.0/samples/common/inc -MMD -MP -MF build/Debug/GNU-Linux-x86/cudaMain.od - o构建/调试/GNU-Linux-x86/cudaMain。o cudaMain。Cu NVCC致命:未知选项'MMD'
所以我可以通过从命令行手动编译而不使用这些选项来避免此错误:
me@comp:/根/NetBeansProjects/my_CUDA_1 #/usr/local/cuda-5.0/include-I/us r/local/cuda-5.0/samples/common/inc -o build/Debug/GNU-Linux-x86/cudaMaino cudaMain。铜cudaMain.cu (28):警告:变量"c"被声明但从未被引用
cudmain .cu(28): warning:变量"c"被声明了,但是没有引用
me@comp:/根/NetBeansProjects/my_CUDA_1 # ls
如何在Netbeans中配置以在IDE中获得此类设置?
Project->Properties->Buildon tab Expert: Enable make Dependency Checking ->取消选中