Visible to Intel only — Ixiasoft
Visible to Intel only — Ixiasoft
5.4.5.3. Implementing Blocking Channel Reads
Where:
channel_id identifies the buffer to which the channel connects, and it must match the channel_id of the corresponding write channel (write_channel_intel).
<type> defines a channel data width. Ensure that the variable the kernel assigns to read the channel data is convertible from <type>.
//Defines chan, a kernel file-scope channel variable.
channel long chan;
/*Defines the kernel, which reads eight bytes (size of long) from the channel and writes it back to global memory.*/
__kernel void kernel_read_channel (__global long * dst); {
for (int i = 0; i < N; i++) {
//Reads the eight bytes from the channel.
dst[i] = read_channel_intel(chan);
}
}
Implementing Nonblocking Channel Reads
On a successful read (valid set to true), the value read from the channel is returned by the read_channel_nb_intel function. On a failed read (valid set to false), the return value of the read_channel_nb_intel function is not defined.
channel long chan;
__kernel void kernel_read_channel (__global long * dst) {
int i = 0;
while (i < N) {
bool valid0, valid1;
long data0 = read_channel_nb_intel(chan, &valid0);
long data1 = read_channel_nb_intel(chan, &valid1);
if (valid0) {
process(data0);
}
if (valid1) {
process(data1);
}
}
}
Did you find the information on this page useful?
Feedback Message
Characters remaining: