参考:https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/clGetPlatformInfo.htmlhtml
cl_int clGetPlatformIDs( cl_uint num_entries, //想要获取的平台数量 cl_platform_id *platforms, // cl_platform_id 指针,获取的平台会保存在这个地址中 cl_uint *num_platforms //环境中存在的平台数量 ) 返回值小于0表示获取平台失败
获取平台信息app
cl_int clGetPlatformInfo( cl_platform_id platform, // cl_platform_id 平台 cl_platform_info param_name, // 信息类型 size_t param_value_size, // 所要保存的字节数 void *param_value, // 所要保存的地址 size_t *param_value_size_ret // 实际信息的数据大小 )
信息类型ide
cl_platform_info | Return Type | Description |
---|---|---|
CL_PLATFORM_PROFILE |
char[] | 确认平台是支持彻底版本的opencl仍是嵌入式版本的ui FULL_PROFILEthis EMBEDDED_PROFILE spa |
CL_PLATFORM_VERSION |
char[] |
|
CL_PLATFORM_NAME |
char[] | Platform name string. |
CL_PLATFORM_VENDOR |
char[] | 返回和平台相关的厂商 |
CL_PLATFORM_EXTENSIONS |
char[] | Returns a space-separated list of extension names (the extension names themselves do not contain any spaces) supported by the platform. Extensions defined here must be supported by all devices associated with this platform. |
// 获取设备 cl_int clGetDeviceIDs( cl_platform_id platform, cl_device_type device_type, //设备类型 cl_uint num_entries, // 想要获取的数量 cl_device_id *devices, // 保存设备的地址 cl_uint *num_devices // 总设备数 )
获取设备信息scala
// 获取设备信息 cl_int clGetDeviceInfo( cl_device_id device, cl_device_info param_name, // 信息类型 size_t param_value_size, //所要保存的信息字节数 void *param_value, // 信息保存的地址 size_t *param_value_size_ret //信息应有的字节数 ) // 几个重要的设备信息类型参数 参数名 类型 含义 CL_DEVICE_EXTENSIONS char[] 支持的扩展类型 CL_DEVICE_GLOBAL_MEM_SIZE cl_ulong 全局设备内存大小 CL_DEVICE_ADDRESS_BITS cl_uint 设备地址空间大小
// 建立上下文,根据设备列表 cl_context clCreateContext( cl_context_properties *properties, //属性列表 cl_uint num_devices, // 设备数量 const cl_device_id *devices, // 设备列表 void *pfn_notify ( const char *errinfo, const void *private_info, size_t cb, void *user_data ), void *user_data, //提供报错信息 cl_int *errcode_ret //错误信息大小 ) // 建立上下文,根据设备类型 cl_context clCreateContextFromType ( cl_context_properties *properties, cl_device_type device_type, void (*pfn_notify) ( const char *errinfo, const void *private_info, size_t cb, void *user_data), void *user_data, cl_int *errcode_ret )
// 返回结果是上下文
获取上下文信息指针
// 获取上下文信息 cl_int clGetContextInfo ( cl_context context, // 上下文 cl_context_info param_name, // 信息参数名称 size_t param_value_size, // 所要保存的大小 void *param_value, // 保存的地址 size_t param_value_size_ret // 信息的大小 )
cl_context_info | Return Type | Information returned in param_value |
---|---|---|
CL_CONTEXT_REFERENCE_COUNT |
cl_uint | Return the context reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks. |
CL_CONTEXT_DEVICES |
cl_device_id[] | Return the list of devices in context . |
CL_CONTEXT_PROPERTIES |
cl_context_properties[] | Return the properties argument specified in clCreateContext |
管理上下文的引用code
// 引用计数加1 cl_int clRetainContext (cl_context context) // 引用计数减1 cl_int clReleaseContext (cl_context context) // 建立时,计数为1,当为0时释放
cl_int clGetPlatformIDs( |
cl_uint num_entries |