We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Showing results for 
Search instead for 
Did you mean: 
Visitor gknowles
Registered: ‎01-12-2014

Use hierarchy in a C/CL kernel



I want to build a complex C/CL kernel in SDAccel using hierarchy (ie break the design down into multiple C files) to simplify the design. I noticed that xocc only accepts a single kernel file. 


For a test example I modified the krnl_vadd example to move the loop to a separate file, eg


void loop( int*,int, int, int*);


#define N 128
__kernel void __attribute__ ((reqd_work_group_size(1, 1, 1)))
__global int* a,
__global int* b,
__global int* c,
const int length) {

// optimized kernel code
int result[N], tempa[N];
int iterations = length/N;

for (int i = 0; i < N; i++)
tempa[i] = a[i];

for(int i=0; i < iterations; i++)
int j;
loop(tempa, i, N, result);
// for(j=0; j < N; j++)
// result[j] = a[i*N+j];

read_b_write_c: // simultaneously both read and write are supported
for(j=0; j < N; j++)
c[i*N+j] = result[j] + b[i*N+j];



and created a file loop.c which I added to the project:

void loop( int* a, int i, int N, int* result)
for(int j=0; j < N; j++)
result[j] = a[i*N+j];


It all compiled ok (for sw_emu) but when I run the executable I get the following error:


/opt/Xilinx/SDx/2017.4//data/emulation/unified/cpu_em/generic_pcie/model/genericpciemodel: symbol lookup error: /tmp/gknowles/2349/cpu_em/device0/binary_0/dltmp: undefined symbol: loop


Any ideas?





0 Kudos
3 Replies
Xilinx Employee
Xilinx Employee
Registered: ‎07-18-2014

Re: Use hierarchy in a C/CL kernel

Hi @gknowles,


I am not sure if xocc support this or not. 

But I can suggest one work-around. You can define sub-functions inside header file (.h) and include the header file in main kernel file (.cl). Hopefully this will allow you to divide your kernel code into multiple files ( one .cl and many .h files). 



0 Kudos
Visitor gknowles
Registered: ‎01-12-2014

Re: Use hierarchy in a C/CL kernel



Thanks for your reply. By random good luck I found a solution. If you go to the "Application project settings" page, and left click on the name of the hardware function inside your binary container, it gives the option to add extra source files to the kernel!!! So you add them here and NOT to the project.


I tried using a similar idea to yours with chains of #include, but it didn't work.


Perhaps I missed it, but where is this in the documentation XILINX????




Xilinx Employee
Xilinx Employee
Registered: ‎09-08-2011

Re: Use hierarchy in a C/CL kernel

Hi gknowles,


   Good catch! For other people to have as a reference gknowles in the GUI went here:





And from in that window you can then choose the extra sources for the krnl.




And then choose okay. Which will add them to the Krnl build and allow the extra src.


Thanks again gknowles for bringing this up.


Can you mark your comment as resolved so others can find your solution?





If at first you don't succeed, try redefining success?
0 Kudos