器件 - 2022.1 简体中文

Vitis 统一软件平台文档 应用加速开发 (UG1393)

Document ID
UG1393
Release Date
2022-05-25
Version
2022.1 简体中文

找到赛灵思平台后,应用需识别对应的赛灵思器件。

以下代码演示了使用 API clGetDeviceIDs 查找所有赛灵思器件(上限为 16 个器件)的过程。

cl_device_id devices[16];  // compute device id
char cl_device_name[1001];
    
err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ACCELERATOR, 
  16, devices, &num_devices);
    
printf("INFO: Found %d devices\n", num_devices);
    
//iterate all devices to select the target device.
for (uint i=0; i<num_devices; i++) {
  err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 1024, cl_device_name, 0);
  printf("CL_DEVICE_NAME %s\n", cl_device_name);
}
重要: clGetDeviceIDs API 通过 platform_idCL_DEVICE_TYPE_ACCELERATOR 来调用,以接收所有可用的赛灵思器件。