Fit the printf bug in loop
authorJunyan He <junyan.he@linux.intel.com>
Tue, 14 Oct 2014 07:52:04 +0000 (15:52 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Tue, 14 Oct 2014 23:55:58 +0000 (07:55 +0800)
commit2e798926251ed1c7df7f24854be8a2ae126ef426
tree104a9910fddfc15e2d9b55300bca41039cd5da51
parent894ad412a6c9b4c9c6418818d2870aa09a7b1300
Fit the printf bug in loop

The static analyse for printf can not totally work
when the printf inst is within the loop and the loop
can not be unrolled. This causes the printf just to
print one info for a loop and to lose all the others.
We now increment the exec number every time the printf
inst is triggered. The number is stored for output all
the message later.
The problem is that we can not caculate the exact loops
number for each printf inst. The wrong loop number will
cause the data overwritten. We now assume all the printf
inst are in loop and store the data like this:
| PRINTF1_DATA  PRINTF2_DATA ... | PRINTF1_DATA  PRINTF2_DATA ... | ...
|       DATA_LOOP_ONE            |          DATA_LOOP_TWO         | ...
Although this may cause some space wasted.

Another problem is that we need to decide the size of printf buffer
because the loop upbound can not be caculated. We just set
it yo 1M for small info slot request and 4M for big one.

Signed-off-by: Junyan He <junyan.he@linux.intel.com>
Tested-by: Zhigang Gong <zhigang.gong@linux.intel.com>
backend/src/ir/printf.cpp
backend/src/llvm/llvm_printf_parser.cpp
kernels/test_printf.cl
src/cl_command_queue_gen7.c