Thanks !!
Blocking channel/pipe mean producer will produce data to fifo , and consumer take the data in order .
NonBlocking is that consumer could coun
So , I can't write the code as below - use a barrier to ensure the data are transferred to fifo , then send a final flag to consumer to finish execution.
---------------------------------------
channel int ch1;
channel int ch2;
__kernel void producer(...) //NDRange
{
// N threads
int sum = get_global_id(0);
write_channel_altera(ch1 , sum);
mem_fence(CLK_CHANNEL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);
if(gid ==0){
int end = 1;
write_channel_altera(ch2 , end);
}
}
__kernel void consumer(__global int *out) // Task
{
int s , end = 0;
for(; ; ){
s = read_channel_altera(ch1);
*out+=s;
end = read_channel_altera(ch2);
if(end == 1)
return;
}
}
-----------------------------------------------
Regards,