我一直在努力让OpenCL与visual studio合作 .
我按照this指南配置AMD OpenCL SDK.
这是我的简短示例程序
#include "stdafx.h"
#include <CL/cl.h>
#include <stdio.h>
#include <iostream>
using namespace std;
const char *source =
"__kernel void memset( __global uint *dst ) \n"
"{ \n"
" dst[get_global_id(0)] = get_global_id(0); \n"
"} \n";
int main()
{
cl_platform_id platform;
clGetPlatformIDs(1, &platform, NULL);
cl_device_id device;
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);
cl_context context = clCreateContext
(
NULL,
1,
&device,
NULL,
NULL,
NULL
);
cl_command_queue queue = clCreateCommandQueueWithProperties
(
context,
device,
0,
NULL
);
return 0;
}
但是当我运行它时,我得到了这个运行时错误
无法在动态链接库中找到过程入口点clCreateCommandQueueWithProperties
我使用dll export viewer查看了dll,该函数确实出现在 OpenCL.dll
中 .
EDIT
我认为Mats Petersson是对的,我在我的电脑上进行了文件搜索,发现了多个OpenCL.dll文件
我不确定如何以合理的方式解决这个问题....
EDIT
这里也许值得注意的是,当我删除对 clCreateCommandQueueWithProperties
的调用时程序运行正常 .
2 回答
我的一些朋友建议将OpenCL.DLL文件复制到我的项目目录中 .
这非常有效 .
我的程序必须加载错误的dll文件 .
我用位于C:\ Program Files(x86)\ AMD APP SDK \ 3.0 \ bin \ x86 \ OpenCL.dll中的C替换了C:\ Windows \ System32 \ OpenCL.dll
和
我用位于C:\ Program Files(x86)\ AMD APP SDK \ 3.0 \ bin \ x86_64 \ OpenCL.dll中的C替换了C:\ Windows \ SysWOW64 \ OpenCL.dll
这对我有用 .