CLGetInfoString
CLGetInfoString
为OpenCL对象或者设备返回一个属性的字符串值.
bool CLGetInfoString(
int handle, // OpenCL对象处理或者OpenCL设备号码
ENUM_OPENCL_PROPERTY_STRING prop, // 被请求的属性
string& value // 引用字符串
);参数
- handle
[in] OpenCL对象处理或者OpenCL设备号码. OpenCL设备编号开始于零.
- prop
[in] 从 ENUM_OPENCL_PROPERTY_STRING 详表被请求的属性类型, 应当被包含的值.
- value
[out] 接收属性值的字符串.
返回值
成功则返回true, 否则返回 false. 有关错误信息,使用 GetLastError() 函数.
ENUM_OPENCL_PROPERTY_STRING
| 标识符 | 描述 |
|---|---|
| CL_PLATFORM_PROFILE | CL_PLATFORM_PROFILE - OpenCL简介. 简介名称可以是以下值中的某一个: - FULL_PROFILE - 实现支持OpenCL(功能定义为核心规范的一部分而无需为OpenCL支持额外的扩展) ; - EMBEDDED_PROFILE - 实现支持OpenCL作为增补. 修订简介被定义为每个OpenCL版本的子集. |
| CL_PLATFORM_VERSION | OpenCL版本 |
| CL_PLATFORM_VENDOR | 平台供应商名称 |
| CL_PLATFORM_EXTENSIONS | 由平台支持的扩展名列表。扩展名应该能被所有与这个平台相 |
| CL_DEVICE_NAME | 设备名称 |
| CL_DEVICE_VENDOR | 供应商名称 |
| CL_DRIVER_VERSION | major_number.minor_number格式OpenCL设备版本 |
| CL_DEVICE_PROFILE | OpenCL设备简介. 简介名称可以是以下值的某一个: - FULL_PROFILE - 实现支持OpenCL(功能定义为核心规范的一部分而无需为OpenCL支持额外的扩展); - EMBEDDED_PROFILE -实现支持OpenCL作为增补. 修订简介被定义为每个OpenCL版本的子集. |
| CL_DEVICE_VERSION | “OpenCL |
| CL_DEVICE_EXTENSIONS | 设备所支持的扩展名列表。列表可以包含由供应商支持的扩展,以及一个或多个批准名称: cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp16 cl_khr_gl_sharing cl_khr_gl_event cl_khr_d3d10_sharing cl_khr_dx9_media_sharing cl_khr_d3d11_sharing |
| CL_DEVICE_BUILT_IN_KERNELS | 可支持的内核列表用 “;“分割. |
| CL_DEVICE_OPENCL_C_VERSION | 这个设备的编译器所支持的最大版本。版本格式: “OpenCL |
| CL_ERROR_DESCRIPTION | OpenCL错误的文本描述 |
例如:
void OnStart()
{
int cl_ctx;
string str;
//--- 初始化 OpenCL 上下文
if((cl_ctx=CLContextCreate(CL_USE_GPU_ONLY))==INVALID_HANDLE)
{
Print("OpenCL not found");
return;
}
//--- 显示平台信息
if(CLGetInfoString(cl_ctx,CL_PLATFORM_NAME,str))
Print("OpenCL platform name: ",str);
if(CLGetInfoString(cl_ctx,CL_PLATFORM_VENDOR,str))
Print("OpenCL platform vendor: ",str);
if(CLGetInfoString(cl_ctx,CL_PLATFORM_VERSION,str))
Print("OpenCL platform ver: ",str);
if(CLGetInfoString(cl_ctx,CL_PLATFORM_PROFILE,str))
Print("OpenCL platform profile: ",str);
if(CLGetInfoString(cl_ctx,CL_PLATFORM_EXTENSIONS,str))
Print("OpenCL platform ext: ",str);
//--- 显示设备信息
if(CLGetInfoString(cl_ctx,CL_DEVICE_NAME,str))
Print("OpenCL device name: ",str);
if(CLGetInfoString(cl_ctx,CL_DEVICE_PROFILE,str))
Print("OpenCL device profile: ",str);
if(CLGetInfoString(cl_ctx,CL_DEVICE_BUILT_IN_KERNELS,str))
Print("OpenCL device kernels: ",str);
if(CLGetInfoString(cl_ctx,CL_DEVICE_EXTENSIONS,str))
Print("OpenCL device ext: ",str);
if(CLGetInfoString(cl_ctx,CL_DEVICE_VENDOR,str))
Print("OpenCL device vendor: ",str);
if(CLGetInfoString(cl_ctx,CL_DEVICE_VERSION,str))
Print("OpenCL device ver: ",str);
if(CLGetInfoString(cl_ctx,CL_DEVICE_OPENCL_C_VERSION,str))
Print("OpenCL open c ver: ",str);
//--- 显示OpenCL设备的常规信息
Print("OpenCL type: ",EnumToString((ENUM_CL_DEVICE_TYPE)CLGetInfoInteger(cl_ctx,CL_DEVICE_TYPE)));
Print("OpenCL vendor ID: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_VENDOR_ID));
Print("OpenCL units: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_MAX_COMPUTE_UNITS));
Print("OpenCL freq: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_MAX_CLOCK_FREQUENCY));
Print("OpenCL global mem: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_GLOBAL_MEM_SIZE));
Print("OpenCL local mem: ",CLGetInfoInteger(cl_ctx,CL_DEVICE_LOCAL_MEM_SIZE));
//--- free OpenCL context
CLContextFree(cl_ctx);
}