Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15549 Discussions

Passing of pointers through channels

Honored Contributor II

Here I want my kernel2 to be autorun kernel and as we cannot pass any arguments to kernel2, we are passing an address of a buffer from Kernel1 to Kernel2 through channel and trying to access the contents of that buffer from Kernel2. It's giving segmentation fault. 

1. Is their any limitation for the size of pointers to be passed through channels ? 

2. Can we use memcpy from host ? 



Implementation is as shown below: pragma OPENCL EXTENSION cl_altera_channels : enable 

channel long ch; 


__kernel void Kernel1(__global uchar *fptr) 

write_channel_altera(ch, fptr); 




__kernel void Kernel2() 

__global uchar *fptrTemp = read_channel_altera(ch); 

printf("%d\n", fptrTemp[0]); //segmentation fault 




voi main() 


unsigned char *fptr; 

unsigned char *fptr_dup; 

fptr = (unsigned char *)valloc(100); 

fptr_dup = (unsigned char *)valloc(3968 * 2224); 



for(int i=0;i<100;i++) 



//memcpy(fptr, fptrIn, 100);//it leads to segmentation fault 


//Below implementation leads to segmentation fault 

//for(int i=0;i<3968 * 2224;i++) 

// fptr_dup=fptrin







In main.cpp, if we are using memcpy() to copy contents from fptrIn to fptr then it is throwing segmentation fault. 

Instead of memcpy() if we are using for loop to copy contents, then it's working for less number of iterations(In above implementation it's 100).  

If we increase iterations to (3968*2224) then again it is giving segmentation fault.
0 Kudos
3 Replies
Honored Contributor II

Autorum kernels do not have an interface to host or external memory and you cannot access external memory directly from an autorun kernel, even if you pass the pointer through channels. Instead of passing the pointer, you should pass the actual data through channels to the autorun kernel. Autorun kernels should be accompanied by another non-autorun kernel that reads data from external memory and streams it to the autorun kernel via a channel.

Honored Contributor II

Thanks for the reply. currently i am not using autorun kernel

I need to pass a 4K Image(3840x2160) pixels from kernel1 to kernel2 via channels.  

1. Is there any restriction on the size of buffer to pass address from one kernel to another ? 

2. "Instead of passing pointer, send the actual data" For this we need to pass an array of size pix[3840x2160], which is really big. Is their any alternative approach for passing this kind of huge buffers from one kernel to other.
Honored Contributor II

You should not keep all the image on the FPGA, it is certainly too big for that purpose. If you are doing image filtering/processing, most such algorithms can be "streamed". i.e., store the image in off-chip memory and stream it pixel by pixel to your compute kernel. You can also temporarily store parts of the image in a shift register buffer. If, however, you cannot stream your computation, then you should "block" it. i.e. store all the image in off-chip memory, transfer one [rectangular] part/block of it to a local buffer, compute it, write it back to off-chip memory, then go to the next block. 


Autorun kernels work well for "streaming" applications. The size of all local buffers, be it shift register, multi-pored RAM/ROM or FIFOs/channels is limited by the amount of on-chip memory available on your FPGA/