Intel Software: Intel FPGA SDK for OpenCL, Quartus Prime, Quartus Prime Pro, Quartus Prime Standard

Type: Answers, KDB Area

Area: Embedded, OpenCL


Last Modified: November 30, 2018
Version Found: v17.1
Bug ID: FB: 1408570460;

Why do I get the error “‘clGetProfileDataDeviceIntelFPGA’ was not declared in this scope” when compiling OpenCL host code?

Description

The library function clGetProfileDataDeviceIntelFPGA must be called in the host code when dynamically profiling an autorun kernel.  If this function is called directly, the host code compilation may fail with an error like the ones below.

Linux (gcc)

    error: ‘clGetProfileDataDeviceIntelFPGA’ was not declared in this scope

 

Windows (Microsoft Visual Studio)

    error: unresolved external symbol clGetProfileDataDeviceIntelFPGA

 

If the system is using the ICD driver, non-standard functions such as *IntelFPGA functions cannot be used directly. The OpenCL call clGetExtensionFunctionAddress must be used to get a function pointer for the non-standard function and that pointer must be used to call it. 

Workaround/Fix

Using the prototype of the function, located in CL/ext.h

    extern CL_API_ENTRY cl_int CL_API_CALL

    clGetProfileDataDeviceIntelFPGA(

            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 function call

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

with code using the syntax below

    cl_int (*get_profile_fn)(cl_device_id, cl_program, cl_bool,cl_bool,cl_bool,size_t, void *,size_t *,cl_int *);

    get_profile_fn = (cl_int (*) (cl_device_id, cl_program, cl_bool,cl_bool,cl_bool,size_t, void *,size_t *,cl_int *))clGetExtensionFunctionAddress("clGetProfileDataDeviceIntelFPGA");

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