Working with objects and hls::task
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
Research direction
Start by reproducing the example in main.cc with hls_task.h using the provided Makefile, then run Vitis HLS csynth_design and the C simulation. Inspect the hls::task interface and the compiler diagnostics to establish whether non-static methods or lambdas are supported. Done means documenting a validated usage pattern or clearly recording the limitation and supported alternative.
Written by the indexing model from the issue text.
Description
Hi everyone,
I have a question regarding the usage of hls::task when using an OOP structure for the design.
Suppose to have the following design in main.cc:
#include <hls_task.h>
class Counter {
unsigned int _cnt=0;
public:
Counter(void) = default;
void stream(
hls::stream<bool>& inStream,
hls::stream<unsigned int>& outStream
) {
if (inStream.read()) {
outStream.write(_cnt++);
}
}
};
void dut(
hls::stream<bool>& inStream,
hls::stream<unsigned int>& outStream
) {
#pragma HLS dataflow
hls_thread_local Counter cnt;
hls_thread_local hls::task t(cnt.stream, inStream, outStream);
}
Using the following Makefile:
VITIS_ROOT := /eda/xilinx/Vitis_HLS/2022.2/include
CXX := /usr/bin/g++
all:
$(CXX) main.cc -o main.out -I$(VITIS_ROOT)
When compiling the design:
fab@fedora: $ make
/usr/bin/g++ main.cc -o main.out -I/eda/xilinx/Vitis_HLS/2022.2/include
main.cc: In function ‘void dut(hls::stream<bool>&, hls::stream<unsigned int>&)’:
main.cc:25:36: error: invalid use of non-static member function ‘void Counter::stream(hls::stream<bool>&, hls::stream<unsigned int>&)’
25 | hls_thread_local hls::task t(cnt.stream, inStream, outStream);
If we try in Vitis HLS:
vitis_hls> csynth_design
INFO: [HLS 200-1510] Running: csynth_design
INFO: [HLS 200-111] Finished File checks and directory preparation: CPU user time: 0.01 seconds. CPU system time: 0.01 seconds. Elapsed time: 0.01 seconds; current allocated memory: 772.094 MB.
INFO: [HLS 200-10] Analyzing design file 'main.cc' ...
ERROR: [HLS 207-2295] reference to non-static member function must be called (main.cc:25:36)
Since when compiling this design I get the error ERROR: Invalid use of non-static member function from the compiler, what is the best solution to wrap the method of a class so that it can be used in an hls::task? With exposed objects like the one I posted here, I can define some helper functions and use the objects as global variables, but now I am starting to call the tasks inside the class itself and this is not feasible anymore. I tried a lambda but it doesn't work. This is the error I get in execution of the C simulation:
terminate called after throwing an instance of 'std::system_error'
what(): Resource temporarily unavailable.
Thanks in advance :)
- Dominant language
- ReScript
- Stars
- 810
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Xilinx/Vitis-HLS-Introductory-Examples
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Xilinx/Vitis-HLS-Introductory-Examples#23 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
RTL blackbox flow Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in Xilinx/Vitis-HLS-Introductory-Examples
Similar issues
-
mlir
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
llvm/llvm-project#224908 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
secondlife/sl-vscode-plugin#147 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
objectionary/phie#149 ·