我在 Netbeans 中创建了新的 C++Application 并想编译简单的 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.mk QMAKE= SUBPROJECTS= .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' mkdir -p build/Debug/GNU-Linux- x86 rm -f build/Debug/GNU-Linux-x86/cudaMain.od /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 build/Debug/GNU-Linux-x86/cudaMain.o cudaMain.cu nvcc fatal :未知选项“MMD”
所以我可以通过在没有这些选项的命令行中手动编译来避免这个错误:
me@comp:/root/NetBeansProjects/my_CUDA_1# /usr/local/cuda-5.0/bin/nvcc -m64 -c -g -I/usr/local/cuda-5.0/include -I/us r/local/cuda -5.0/samples/common/inc -o build/Debug/GNU-Linux-x86/cudaMain.o cudaMain.cu cudaMain.cu(28):警告:变量“c”已声明但从未被引用
cudaMain.cu(28):警告:变量“c”已声明但从未被引用
me@comp:/root/NetBeansProjects/my_CUDA_1# ls
如何,在 Netbeans 中配置什么以在 IDE 中获取此类设置?