Why does a blocked channel in one kernel also block other kernels' running?
Hi,
@HRZ
I noticed the following scenario:
I have two kernels, say Producer and Consumer. I put them into two DIFFERENT command queues, so they can be launched and run concurrently. Meanwhile, there is a channel whose depth is set N between them. Each work item in the producer writes one value to the channel and the each work item in the consumer reads the channel. I use NDRange and the number of workitems is W.
Then
When W < N, everything is OK;
When W > N, the execution of Producer is blocked. But the Consumer also cannot be executed.
Since the Consumer is in a different queue from the Producer, why is it also blocked? Actually I guess it is even not launched.
I show a simple code sample here. In this example, N = 8 and W = 32. The "printf" in line 13 cannot be executed. Even if I commented line 16 (channel read), it still cannot be executed. So I conclude that the consumer is not launched. If I'm right, why? My original thought was: even if the producer is blocked, eventually it will be unblocked as long as the consumer is able to execute and keep reading the channel and making space for the channel.
Thank you!
channel ulong ch1 __attribute__ ((depth(8)));
__attribute__((max_work_group_size(32)))
__kernel void producer(buf_addr_space const int * restrict buf_in)
{
size_t gid = get_global_id(0);
write_channel_intel(ch1, buf_in[gid]);
}
__attribute__((max_work_group_size(32)))
__kernel void consumer(buf_addr_space int * restrict buf_out)
{
printf("--------- test ------------\n");
size_t gid = get_global_id(0);
int val = 5 + read_channel_intel(ch1);
buf_out[gid] = val;
}