clgetplatforminfo分割故障
clGetPlatformInfo Segmentation Fault
我有一个使用opencl的简单main.cpp文件。(请参阅最后(我在Windows 10 Linux子系统(Ubuntu 14(下使用Bash,以使我更容易(我认为(,因此我不必在Windows上使用Mingw或其他内容。
无论如何,我使用以下内容编译了该简单的main.cpp文件:
g++ -o main main.cpp -I "/mnt/c/Program Files (x86)/AMD APP SDK/3.0/include" -L "/mnt/c/Program Files (x86)/AMD APP SDK/3.0/lib/x86_64" -lOpenCL
我尝试运行程序时会出现细分故障。它发生在第33行(错误= clgetPlatformids(
main.cpp
#include <stdio.h>
#include <stdlib.h>
#ifdef APPLE
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
void displayPlatformInfo(cl_platform_id id, cl_platform_info param_name, const char* paramNameAsStr)
{
cl_int error = 0;
size_t paramSize = 0;
error = clGetPlatformInfo( id, param_name, 0, NULL, ¶mSize);
char* moreInfo = (char*)alloca(sizeof(char)*paramSize);
error = clGetPlatformInfo( id, param_name, paramSize, moreInfo, NULL);
if (error != CL_SUCCESS) {
perror("Unable to find any OpenCL Plaform Information");
return;
}
printf("%s: %sn", paramNameAsStr, moreInfo);
}
int main() {
cl_platform_id* platforms;
cl_uint numOfPlatforms;
cl_int error;
error = clGetPlatformIDs(0, NULL, &numOfPlatforms);
if (error <0 ) {
perror("Unable to find any openCL Platforms");
exit(1);
}
printf("Number of OpenCL platform found: %dn",numOfPlatforms);
platforms = (cl_platform_id*) alloca(sizeof(cl_platform_id)* numOfPlatforms);
for (cl_uint i = 0; i < numOfPlatforms; ++i) {
displayPlatformInfo( platforms[i], CL_PLATFORM_PROFILE, "CL_PLATFORM_PROFILE");
displayPlatformInfo( platforms[i], CL_PLATFORM_VERSION, "CL_PLATFORM_VERSION");
displayPlatformInfo( platforms[i], CL_PLATFORM_NAME, "CL_PLATFORM_NAME");
displayPlatformInfo( platforms[i], CL_PLATFORM_VENDOR, "CL_PLATFORM_VENDOR");
displayPlatformInfo( platforms[i], CL_PLATFORM_EXTENSIONS,"CL_PLATFORM_EXTENSIONS");
}
return 0;
}
为平台放一个值。
值大于找到的平台数量。
示例:
numOfPlatforms = 10;
相关文章:
- 分割故障C++矩阵
- C ,二进制树的高度,而不是检查我的子树是否为空,而是在检查我的子树是否是叶子节点.抛出分割故障
- 我正在为此代码分割故障
- 在执行strcpy时获取分割故障错误
- 空隙指针分割故障
- Xcode会产生分割故障,而不是例外
- OPENCV C 中的分割故障误差
- 分割故障:核心倾倒C 矢量对字符串:
- C 2D数组导致分割故障(核心倾倒)
- 分割故障/错误读数变量-C 列表
- DLSYM导致分割故障
- 使用C 中的操作员删除的分割故障
- 使用Linux X64下的Libmozjs-52(SpidermonKey)进行分割故障
- 使用长变量时分割故障(11)错误
- C - 返回字符串时的分割故障
- 创建VertexArray时的分割故障
- 向量分割故障的向量
- 从std :: fileSystem ::路径对象的类中退出时的分割故障
- C 矢量分割故障
- 基于向量的数据格式的分割故障误差