我在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.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.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 build / Debug / GNU-Linux-x86 / cudaMain.o cudaMain.cu nvcc致命: 未知选项'MMD'
所以我可以通过在没有这些选项的情况下从命令行手动编译来避免此错误:
我@排版:/根/的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中进行此类设置?
答案 0 :(得分:2)
项目 - &GT;属性 - &GT;生成 选项卡上的专家:启用依赖关系检查 - &gt;取消选中此