Forum Discussion
Altera_Forum
Honored Contributor
11 years agoChannel problem
Hi There are two kernel functions to communicate with each other by using channels. __kernel void producer(...) { // N threads int sum = get_global_id(0); write_cha...
Altera_Forum
Honored Contributor
11 years agoThanks !!
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,