平台 - 2022.1 简体中文

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

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

初始化时,主机应用需要识别由一个或多个赛灵思器件组成的平台。以下代码片段显示了识别赛灵思平台的常用方法。

cl_platform_id platform_id;         // platform id

err = clGetPlatformIDs(16, platforms, &platform_count);
    
// Find Xilinx Platform
for (unsigned int iplat=0; iplat<platform_count; iplat++) {
  err = clGetPlatformInfo(platforms[iplat], 
    CL_PLATFORM_VENDOR, 
    1000, 
    (void *)cl_platform_vendor,
    NULL);

  if (strcmp(cl_platform_vendor, "Xilinx") == 0) { 
  // Xilinx Platform found
  platform_id = platforms[iplat];
  }
}

OpenCL API 调用 clGetPlatformIDs 用于发现给定系统的可用 OpenCL 平台组合。随后, clGetPlatformInfo 用于识别基于赛灵思器件的平台,方法是将 cl_platform_vendor 与字符串 "Xilinx" 相匹配。