Tracker: Benchmarking codegen hacks
Closed this issue · 2 comments
sampsyo commented
This issue is about things to change in code generation which are just hacks to make benchmarking easier. The idea is to avoid manual modifications to the output C++ code so we can directly evaluate what we generate. The spirit behind these hacks is not elegance; we just need to get the job done by any means necessary in the easiest possible way.
Here's what I am aware of so far:
- Software integers. It's useful for debugging purposes to compile the "HLS" output code using a normal software compiler (i.e., gcc or clang). This means that the code needs to avoid using
ap_int
when doing that. I can see several ways to do that:- Insert an
#ifdef
(which activates only in an HLS compiler) around atemplate
hack to replaceap_int
withint
. - Add a new backend mode, called like
vivado-sw
or something, that just generatesint
in place ofap_int
. - Like the above, but use
ac_int
, as mentioned in #105 (comment). (This would be nice but not in the spirit of a dumb-as-possible hack.)
- Insert an
- SDSoC pragmas. We need to add the
#pragma SDS
nonsense that makes the whole SDSoC compiler toolchain go. An easy, inelegant way to do this would be to add a construct to the language that just specifies a string to output before the function declaration; we pass this string through unchanged. - Trip count pragmas for estimation. In estimation mode (but not when generating real hardware), the HLS tool wants to know the estimated trip count for
while
loops (which it obviously can't deduce by itself) so it can estimate the time the execution will take. We could also use the pass-through string approach for this.
Less important, but just nice-to-have features include:
- Character literals. See https://github.com/cucapra/fuse-benchmarks/pull/70#issuecomment-510670942. These should have type
bit<8>
.
sa2257 commented
For Software integers I'm manually adding
#ifdef __SDSCC__
#include "ap_int.h"
#else
template < int N >
using ap_int = int;
#endif