Open cqray1990 opened 2 years ago
/**
static const int WORK_SIZE = 256;
CUresult result = N; \ if (result != 0) { \ printf("CUDA call on line %d returned error %d\n", LINE, \ result); \ exit(1); \ } }
int main(int argc, char **argv) { CUmodule module; CUcontext context; CUdevice device; CUdeviceptr deviceArray; CUfunction process;
void *kernelArguments[] = { &deviceArray }; int deviceCount; unsigned int idata[WORK_SIZE], odata[WORK_SIZE]; for (int i = 0; i < WORK_SIZE; ++i) { idata[i] = i; } CHECK_CUDA_RESULT(cuInit(0)); CHECK_CUDA_RESULT(cuDeviceGetCount(&deviceCount)); if (deviceCount == 0) { printf("No CUDA-compatible devices found\n"); exit(1); } CHECK_CUDA_RESULT(cuDeviceGet(&device, 0)); CHECK_CUDA_RESULT(cuCtxCreate(&context, 0, device)); CHECK_CUDA_RESULT(cuModuleLoad(&module, "bitreverse.fatbin")); CHECK_CUDA_RESULT(cuModuleGetFunction(&process, module, "bitreverse")); CHECK_CUDA_RESULT(cuMemAlloc(&deviceArray, sizeof(int) * WORK_SIZE)); CHECK_CUDA_RESULT( cuMemcpyHtoD(deviceArray, idata, sizeof(int) * WORK_SIZE)); CHECK_CUDA_RESULT( cuLaunchKernel(process, 1, 1, 1, WORK_SIZE, 1, 1, 0, NULL, kernelArguments, NULL)); CHECK_CUDA_RESULT( cuMemcpyDtoH(odata, deviceArray, sizeof(int) * WORK_SIZE)); for (int i = 0; i < WORK_SIZE; ++i) { printf("Input value: %u, output value: %u\n", idata[i], odata[i]); } CHECK_CUDA_RESULT(cuMemFree(deviceArray)); CHECK_CUDA_RESULT(cuCtxDestroy(context)); return 0;
} :对‘cuDeviceGetCount’未定义的引用 HSigmoid.cu:58:对‘cuModuleLoad’未定义的引用 /cudaHelloworld/src/HSigmoid.cu:59:对‘cuModuleGetFunction’未定义的引用 cudaHelloworld/src/HSigmoid.cu:61:对‘cuMemAlloc_v2’未定义的引用 cudaHelloworld/src/HSigmoid.cu:62:对‘cuMemcpyHtoD_v2’未定义的引用 cudaHelloworld/src/HSigmoid.cu:68:对‘cuMemcpyDtoH_v2’未定义的引用 cudaHelloworld/src/HSigmoid.cu:75:对‘cuMemFree_v2’未定义的引用 /cudaHelloworld/src/HSigmoid.cu:76:对‘cuCtxDestroy_v2’未定义的引用
/**
include
include
include
include
static const int WORK_SIZE = 256;
/**
define CHECK_CUDA_RESULT(N) { \
CUresult result = N; \ if (result != 0) { \ printf("CUDA call on line %d returned error %d\n", LINE, \ result); \ exit(1); \ } }
int main(int argc, char **argv) { CUmodule module; CUcontext context; CUdevice device; CUdeviceptr deviceArray; CUfunction process;
} :对‘cuDeviceGetCount’未定义的引用 HSigmoid.cu:58:对‘cuModuleLoad’未定义的引用 /cudaHelloworld/src/HSigmoid.cu:59:对‘cuModuleGetFunction’未定义的引用 cudaHelloworld/src/HSigmoid.cu:61:对‘cuMemAlloc_v2’未定义的引用 cudaHelloworld/src/HSigmoid.cu:62:对‘cuMemcpyHtoD_v2’未定义的引用 cudaHelloworld/src/HSigmoid.cu:68:对‘cuMemcpyDtoH_v2’未定义的引用 cudaHelloworld/src/HSigmoid.cu:75:对‘cuMemFree_v2’未定义的引用 /cudaHelloworld/src/HSigmoid.cu:76:对‘cuCtxDestroy_v2’未定义的引用