0

嗨,我正在学习 openCL 并遵循一本书的示例并尝试执行以下操作

//Obtain the GPU data (platform, device and context)
PlatformDevice gpu = retrieveDevice(CL_DEVICE_TYPE_GPU);
assert(gpu.allDat![enter image description here][1]aPresent());
const char * kernalSource = "__kernel void multiplication(__global float* GridA, __global float* GridB,__global float* val ){int igrid = get_global_id(0);float a = GridA[igrid];float b = GridB[igrid];val[igrid] = a * b;}";

//Create Program
cl_program program = clCreateProgramWithSource(gpu.context,1, (const char**) kernalSource,NULL,&err);

当我到达最后一行时,它会产生以下错误

Unhandled exception at 0x53349301 (nvopencl.dll) in OpenCLPracticeSetup.exe: 0xC0000005: Access violation reading location 0x656B5F5F.

我猜这是 Visual Studio 2012 的设置问题,但由于没有看到 nvopencl.dll 的错误,所以在网上找不到任何东西 这是我更改的属性

c/c++ General - 我的附加包含目录是:\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include\CL Linker General - 我的附加库目录是:\NVIDIA GPU Computing Toolkit\CUDA\v4.2\lib\Win32输入 - OpenCL.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib; odbccp32.lib;%(附加依赖项)

谢谢

4

1 回答 1

0

我找到了我的问题的答案,我应该参考源代码。

谢谢

于 2013-02-10T18:37:17.120 回答