Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide
A newer version of this document is available. Customers should click here to go to the newest version.
Visible to Intel only — GUID: ewa1452613689582
Ixiasoft
Visible to Intel only — GUID: ewa1452613689582
Ixiasoft
11.1.6. Specifying an OpenCL Library when Compiling an OpenCL Kernel
You may include multiple instances of -l <library file name> and -L <library directory> in the offline compiler command.
For example, if you create a library that includes the functions my_div_fd(), my_sqrtfd(), and myrsqrtfd(), the OpenCL kernel code might resemble the following:
#include “lib_header.hcl”
kernel void test_lib (
global double * restrict in,
global double * restrict out,
int N) {
int i = get_global_id(0);
for (int k =0; k < N; k++) {
double x = in[i*N + k];
out[i*N + k] = my_divfd
(my_rsqrtfd(x),
my_sqrtfd(my_rsqrtfd (x)));
}
}
The corresponding lib_header.h file might resemble the following:
double my_sqrtfd (double x);
double my_rsqrtfd(double x);
double my_divfd(double a, double b);