C# 对OpenCL的UWP支持

C# 对OpenCL的UWP支持,c#,c++,windows,uwp,opencl,C#,C++,Windows,Uwp,Opencl,我试图弄清楚是否有可能为UWP创建一个GPGPU程序 我尝试将一个简单的OpenCLC程序编译为Windows运行时组件,然后使用C#UWP应用程序中的组件。一切都会编译,但当我尝试实例化OpenCL上下文时,程序失败,导致代码为999的错误(未知错误) 同样的代码也适用于基本控制台应用程序 以下代码仅供参考 int err; // error code returned from api calls float data[DATA_SIZ

我试图弄清楚是否有可能为UWP创建一个GPGPU程序

我尝试将一个简单的OpenCLC程序编译为Windows运行时组件,然后使用C#UWP应用程序中的组件。一切都会编译,但当我尝试实例化OpenCL上下文时,程序失败,导致代码为999的错误(未知错误)

同样的代码也适用于基本控制台应用程序

以下代码仅供参考

int err;                            // error code returned from api calls

float data[DATA_SIZE];              // original data set given to device
float results[DATA_SIZE];           // results returned from device
unsigned int correct;               // number of correct results returned

size_t global;                      // global domain size for our calculation
size_t local;                       // local domain size for our calculation

cl_platform_id cpPlatform;
cl_device_id device_id;             // compute device id 
cl_context context;                 // compute context
cl_command_queue commands;          // compute command queue
cl_program program;                 // compute program
cl_kernel kernel;                   // compute kernel

cl_mem input;                       // device memory used for the input array
cl_mem output;                      // device memory used for the output array

                                    // Fill our data set with random float values

int i = 0;
unsigned int count = DATA_SIZE;
for (i = 0; i < count; i++)
    data[i] = rand() / (float)RAND_MAX;

// Bind to platform
err = clGetPlatformIDs(1, &cpPlatform, NULL);

// Connect to a compute device
int gpu = 1;
err = clGetDeviceIDs(cpPlatform, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);
if (err != CL_SUCCESS)
{
    printf("Error: Failed to create a device group!\n");
    return EXIT_FAILURE;
}

// Create a compute context 
context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
// ============= This is where err is filled with 999. =============
// ============= The context is null after the call. ===============
if (!context)
{
    printf("Error: Failed to create a compute context!\n");
    return EXIT_FAILURE;
}
int err;//api调用返回的错误代码
浮点数据[数据大小];//提供给设备的原始数据集
浮点结果[数据大小];//从设备返回的结果
无符号整数正确;//返回的正确结果数
大小\u t全局;//用于我们计算的全局域大小
大小\u t本地;//我们计算的本地域大小
cl_平台\u id cpPlatform;
cl_设备_id设备_id;//计算设备id
cl_上下文;//计算上下文
cl_命令_队列命令;//计算命令队列
cl_项目计划;//计算程序
cl_内核;//计算内核
cl_mem输入;//用于输入阵列的设备内存
cl_mem输出;//用于输出阵列的设备内存
//用随机浮点值填充数据集
int i=0;
无符号整数计数=数据大小;
对于(i=0;i
我觉得奇怪的是,我能够检测设备并正确地实例化平台和设备(它正确地显示了我的GeForce 970 GTX)。但是,它无法实例化上下文并执行其余代码


这是UWP的限制吗?如果是的话,那么是否有理由认为桌面网桥也是徒劳的呢?

对我来说也是如此。但是有一个音符!不可能为GeForce GPU创建上下文,但同时我可以为IntelHD创建上下文!不幸的是,下一个指令会导致其他错误。