Intel® FPGA SDK for OpenCL™ Pro Edition: 入门指南

ID 683188
日期 3/28/2022
Public
文档目录

2.6.3. 构建主机应用程序

<local_path_to exm_opencl_hello_world>\hello_world\hello_world.sln文件包含主机解决方案。在Microsoft Visual Studio中打开此.sln文件后,您可以在main.cpp文件中构建OpenCL™主机应用程序。
如果您使用Microsoft Visual Studio,那么您需要FCD和Khronos提供的Installable Client Driver (ICD)。ICD驱动程序将主机链接到OpenCL.dll,这需要安装FPGA Client Driver (FCD)。关于安装FCD,请参考安装FPGA板级

要使用FCD和ICD设置Microsoft Visual Studio,需要在构建主机应用程序前执行以下任务:

  1. 使用 aocl diagnose -icd-only 命令来验证是否正确设置了FCD和ICD。如果FCD和ICD都被正确地安装,那么您应该会看到以下输出:
    ICD System Diagnostics 
    -------------------------------------------------------------------- 
    Using the following location for ICD installation: 
    	HKEY_LOCAL_MACHINE\Software\Khronos\OpenCL\Vendors 
    
    Found 1 icd entry at that location: 
    	<INTELFPGAOCLSDKROOT>\windows64\bin\alteracl_icd.dll   REG_DWORD   0x0 
    
    Checking validity of found icd entries: 
    	<INTELFPGAOCLSDKROOT>\windows64\bin\alteracl_icd.dll   REG_DWORD   0x0 is 
    correctly registered on the system 
    
    Using the following location for fcd installations: 
    	HKEY_LOCAL_MACHINE\Software\Intel\OpenCL\Boards 
    
    Found 1 fcd entry at that location: 
    	<path_to_OpenCL_BSP>\a10_ref\windows64\bin\altera_a10_ref_mmd.dll 
    REG_DWORD 0x0 
    
    Checking validity of found fcd entries: 
    	<path_to_OpenCL_bsp>\a10_ref\windows64\bin\altera_a10_ref_mmd.dll 
    REG_DWORD 0x0 is correctly registered on the system 
    
    Number of Platforms = 1 
    	1. Intel(R) FPGA SDK for OpenCL(TM)             | Intel(R) Corporation | 
    OpenCL 1.0 Intel(R) FPGA SDK for OpenCL(TM), Version  <version_number>
    -------------------------------------------------------------------- 
    ICD diagnostics PASSED 
    --------------------------------------------------------------------
  2. 如果FCD和ICD都没有被正确设置,那么请参考安装FPGA板级来了解FCD设置,参考Intel FPGA SDK for OpenCL Pro Edition Programming GuideAccessing Custom Platform-Specific FunctionsLinking Your Host Application to the Khronos ICD Loader Library部分来了解更多信息。
  3. 将主机应用程序链接到OpenCL.lib库。
    1. 在Solution下,右击主机应用程序名称并选择Properties,然后选择Configuration Properties > Linker > Input
    2. Additional Dependencies域中,输入OpenCL.lib
    注意: 由于您使用FCD和ICD,所以请不要将主机程序链接到alteracl.lib或者直接链接到Custom Platform的MMD库。
请执行以下任务来构建hello_world主机应用程序:
  1. 在Microsoft Visual Studio中打开 <local_path_to_exm_opencl_hello_world>\hello_world\hello_world.sln文件。
  2. 验证构建配置是否正确。默认的构建配置是Debug,但您可以使用Release。您必须选择与解决方案平台匹配的选项(例如,对于x64架构,选择x64)。
  3. 通过选择Build > Build Solution菜单选项或者按下F7键来构建解决方案。
    hello_world.exe可执行文件位于 <local_path_to_exm_opencl_hello_world>\hello_world\bin文件夹中。
  4. 验证构建是否正确。一个以类似于下图所示消息为结尾的输出通知您构建成功:
    1> Build succeeded.
    1>
    1> Time Elapsed 00:00:03:29
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    注意: 您可以忽略LNK4009: PDB 'vc90.pdb' was not found with...警告消息,因为它们对构建没有影响。如果您使用以前版本的Microsoft Visual Studio构建了Windows库,那么编译器可能会发出此类警告消息。