UPGRADE YOUR BROWSER

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!

Use hierarchy in a C/CL kernel

Reply
Highlighted
Visitor
Posts: 4
Registered: ‎01-12-2014

Use hierarchy in a C/CL kernel

Hi

 

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)))
krnl_vadd(
__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;
read_a:
__attribute__((xcl_pipeline_loop))
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
__attribute__((xcl_pipeline_loop))
for(j=0; j < N; j++)
c[i*N+j] = result[j] + b[i*N+j];
}

return;
}

 

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?

 

Greg

 

 

Xilinx Employee
Posts: 99
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). 

 

-Heera

Visitor
Posts: 4
Registered: ‎01-12-2014

Re: Use hierarchy in a C/CL kernel

Hi

 

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????

 

Cheers

 

Xilinx Employee
Posts: 147
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:

 

Step_1.PNG

 

 

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

 

Src_selection.PNG

 

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?

 

Thanks,

 

Evan

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