Closed lifeformg closed 10 months ago
Hi @lifeformg, the only supported way to instantiate tasks is tapa::task()::invoke(...)...
. I'm not sure what exactly you mean by "dynamically link subtasks to the parent task", but if you just want to instantiate a sequence of tasks, that is supported. See https://tapa.readthedocs.io/en/release/api.html#task for documentation and https://github.com/UCLA-VAST/tapa/blob/c2617e3e8fe9ab916f16410fd01cd90bebefcc8e/apps/network/network.cpp#L102 for a concrete example.
Thank you for your reply @Blaok . Simply put, this is my top-level function:
void SystolicArray(tapa::mmap<const data_t> A, tapa::mmap<const data_t> B,
tapa::mmap<data_t> C, const int K) {
tapa::stream<data_t> row_fifo[M][N + 1];
tapa::stream<data_t> col_fifo[M + 1][N];
tapa::stream<data_t> c_out_fifo[M][N];
tapa::task task;
// Initialize and connect PE
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N; ++j) {
// Connect the stream to the adjacent PE or external input/back_hole
auto& left = row_fifo[i][j];
auto& top = col_fifo[i][j];
auto& button = col_fifo[i + 1][j];
auto& right = row_fifo[i][j + 1];
auto& c_out = c_out_fifo[i][j];
task.invoke(pe, left, top, button, right, c_out);
if (i == M - 1) {
task.invoke<tapa::detach>(black_hole, button);
}
if (j == N - 1) {
task.invoke<tapa::detach>(black_hole, right);
}
}
}
task.invoke(read_A, A, row_fifo, K)
.invoke(read_B, B, col_fifo, K)
.invoke(write_C, C, c_out_fifo, K);
}
It can't compile into xo because I separated task and invoke. I did this because I wanted to connect some streams to PE in a more complex way. As you can see, this code is part of a simple systolic array.
@lifeformg TAPA does not support your code in its current form; you'll have to refactor your code to make it compatible. :) See https://tapa.readthedocs.io/en/release/tutorial.html#less-repetitive-code-with-stream-mmap-array for what is supported.
Original VecAdd:
If I change it to:
C Simulation is all fine, but hardware simulation failed.
Why is it like this? The reason I'm doing this is because I need to dynamically link subtasks to the parent task, like through a loop (is there another way to do it?).