Imagine kernels are coded in a programming language called KernelC, using the
expression syntax of the C language. The
code appears to operate on a single record at one time, but the 8 clusters on
Imagine each run the same kernel on different elements of the stream
simultaneously, in SIMD fashion. Kernels may access local variables, read
input streams, and write output streams, but may not make arbitrary memory
references. The Kernel Scheduler compiles KernelC code into a microcode
program, which is a sequence of VLIW instructions.
This example KernelC kernel interacts with the above StreamC
code. It produces two streams, c and d. The first stream is the sum
of the two input streams, while the second stream is the difference of the two
input streams.
loop(input_stream0) {
input_stream0 >> a;
input_stream1 >> b;
c = a + b;
d = a - b;
output_stream0 << c;
output_stream1 << d;
}
Imagine repeats the kernel until the input streams (stored in
the SRF by the Host Processor) are emptied. Details of the KernelC
language syntax is available under section 3 of the ips_user.pdf
document.
The following figures show a scheduled kernel. Figure 1 is
a single pass through the stereo-depth extraction kernel. It shows all the
functional units in Imagine and their respective usage with time in the y-axis. Figure 2 shows
the kernel after software pipelining.
Figure 1: One Kernel iteration
Figure 2: Scheduled and Pipelined Kernel