PEC*_*PEC 17 compiler-errors deprecated opencl visual-studio-2013
我使用本教程开始使用VS中的opencl:
https://opencl.codeplex.com/wikipage?title=OpenCL%20Tutorials%20-%201
我在设置主程序时遇到问题.这是到目前为止的代码:
const char* clewErrorString(cl_int error) {
//stuff
}
int main(int argc, char **argv) {
cl_int errcode_ret;
cl_uint num_entries;
// Platform
cl_platform_id platforms;
cl_uint num_platforms;
num_entries = 1;
cout << "Getting platform id..." << endl;
errcode_ret = clGetPlatformIDs(num_entries, &platforms, &num_platforms);
if (errcode_ret != CL_SUCCESS) {
cout << "Error getting platform id: " << clewErrorString(errcode_ret) << endl;
exit(errcode_ret);
}
cout << "Success!" << endl;
// Device
cl_device_type device_type = CL_DEVICE_TYPE_GPU;
num_entries = 1;
cl_device_id devices;
cl_uint num_devices;
cout << "Getting device id..." << endl;
errcode_ret = clGetDeviceIDs(platforms, device_type, num_entries, &devices, &num_devices);
if (errcode_ret != CL_SUCCESS) {
cout << "Error getting device id: " << clewErrorString(errcode_ret) << endl;
exit(errcode_ret);
}
cout << "Success!" << endl;
// Context
cl_context context;
cout << "Creating context..." << endl;
context = clCreateContext(0, num_devices, &devices, NULL, NULL, &errcode_ret);
if (errcode_ret < 0) {
cout << "Error creating context: " << clewErrorString(errcode_ret) << endl;
exit(errcode_ret);
}
cout << "Success!" << endl;
// Command-queue
cl_command_queue queue;
cout << "Creating command queue..." << endl;
queue = clCreateCommandQueue(context, devices, 0, &errcode_ret);
if (errcode_ret != CL_SUCCESS) {
cout << "Error creating command queue: " << clewErrorString(errcode_ret) << endl;
exit(errcode_ret);
}
cout << "Success!" << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是这不能编译:error C4996: 'clCreateCommandQueue': was declared deprecated
当我尝试编译时,我得到了一个.我还不了解整个设置过程,所以我不知道是否搞砸了.根据chronos,该功能似乎并未被弃用:https:
//www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clCreateCommandQueue.html
如果我删除命令队列部分,其余运行没有问题.我怎样才能做到这一点?
jpr*_*ice 35
该clCreateCommandQueue
函数自OpenCL 2.0起已弃用,并替换为clCreateCommandQueueWithProperties
.如果您只针对支持OpenCL 2.0的设备(在撰写本文时最近的一些Intel和AMD处理器),您可以安全地使用此新功能.
如果您需要在尚未支持OpenCL 2.0的设备上运行代码,则可以使用clCreateCommandQueue
OpenCL标头提供的预处理器宏继续使用不推荐使用的函数,例如:
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#include <CL/cl.h>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
15110 次 |
最近记录: |