Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide

ID 683846
Date 10/04/2021

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

6.6.3. Using OpenCL ICD Extension APIs

When using ICD, if you are calling an OpenCL host API function that is not officially mentioned in the OpenCL specification, you must first call the clGetExtensionFunctionAddress function to obtain a function pointer to that host API function and then call the host API function using that function pointer. This applies to all non-standard calls that include IntelFPGA in their function name.

Consider the following example code snippet:

extern CL_API_ENTRY cl_int CL_API_CALL
           cl_device_id                     /*device_id*/,
           cl_program                       /*program*/,
           cl_bool                          /*read_enqueue_kernels*/,
           cl_bool                          /*read_auto_enqueued*/,
           cl_bool                          /*clear_counters_after_readback*/,
           size_t                           /*param_value_size*/,
           void *                           /*param_value*/,
           size_t *                         /*param_value_size_ret*/,
           cl_int *                         /*errcode_ret*/ );

Replace the following function call:

cl_int status = clGetProfileDataDeviceIntelFPGA (device, program, false,
                                                           true, false, 0, NULL, 
                                                           NULL, NULL);

with code using the following syntax to define and load the function pointer:

typedef cl_int (*clGetProfileDataDevice_fn) (cl_device_id, cl_program,
                                                       cl_bool, cl_bool, cl_bool,
                                                       size_t, void *, 
                                                       size_t *, cl_int *);
clGetProfileDataDevice_fn get_profile_data_ptr = (clGetProfileDataDevice_fn) 
clGetExtensionFunctionAddressForPlatform (platform, "clGetProfileDataDeviceIntelFPGA");

and use the function pointer as the function call:

cl_int status = (get_profile_data_ptr) (device, program, false, true,
                                                  false, 0, NULL, NULL, NULL);