Skip to content

Commit

Permalink
feat(tapa_source): update tapa source
Browse files Browse the repository at this point in the history
  • Loading branch information
vagrantxiao24 committed Dec 9, 2024
1 parent aa9f16c commit fc9a2f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
19 changes: 8 additions & 11 deletions getting_started/tapa_aie_source/design/VecAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,30 @@
#include <tapa.h>
#define DATA_NUM 4096

[[tapa::target("aie", "xilinx")]] void read_mem(tapa::mmap<const uint32_t> f, tapa::ostream<uint32_t>& g) {


[[tapa::target("aie", "xilinx")]] void read_mem(tapa::mmap<const uint32_t> mem_in, tapa::ostream<uint32_t>& stream_out) {

for (int i = 0; i < DATA_NUM; i++) {
g << f[i];
stream_out.write(mem_in[i]);
}
}


[[tapa::target("aie", "xilinx")]] void
add_kernel(tapa::istream<uint32_t>& a,
tapa::istream<uint32_t>& b,
tapa::ostream<uint32_t>& c) {
[[tapa::target("aie", "xilinx")]] void add_kernel(tapa::istream<uint32_t>& stream_in1, tapa::istream<uint32_t>& stream_in2, tapa::ostream<uint32_t>& stream_out) {

// Compute the addition
[[tapa::pipeline(1)]] for (int i = 0; i < DATA_NUM; i++) {
c.write(a.read() + b.read());
stream_out.write(stream_in1.read() + stream_in2.read());
}
}

[[tapa::target("aie", "xilinx")]] void write_mem(tapa::istream<uint32_t>& d, tapa::mmap<uint32_t>e) {
[[tapa::target("aie", "xilinx")]] void write_mem(tapa::istream<uint32_t>& stream_in, tapa::mmap<uint32_t> mem_out) {

for (int i = 0; i < DATA_NUM; i++) {
d >> e[i];
mem_out[i] = stream_in.read();
}
}


[[tapa::target("aie", "xilinx")]] void VecAdd(tapa::mmap<const uint32_t> mem_in1, tapa::mmap<const uint32_t> mem_in2, tapa::mmap<uint32_t> mem_out) {

tapa::stream<uint32_t> stream_in1("input_stream_1");
Expand Down
25 changes: 10 additions & 15 deletions getting_started/tapa_source/design/VecAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,29 @@
// Includes
#include <cstdint>
#include <tapa.h>
#define DATA_SIZE 4096
#define DATA_NUM 4096

void read_mem1(tapa::mmap<const uint32_t> mem_in, tapa::ostream<uint32_t>& stream_out) {

for (int i = 0; i < DATA_SIZE; i++) {
stream_out << mem_in[i];
}
}

void read_mem2(tapa::mmap<const uint32_t> mem_in, tapa::ostream<uint32_t>& stream_out) {
void read_mem(tapa::mmap<const uint32_t> mem_in, tapa::ostream<uint32_t>& stream_out) {

for (int i = 0; i < DATA_SIZE; i++) {
stream_out << mem_in[i];
for (int i = 0; i < DATA_NUM; i++) {
stream_out.write(mem_in[i]);
}
}

void add_kernel(tapa::istream<uint32_t>& stream_in1, tapa::istream<uint32_t>& stream_in2, tapa::ostream<uint32_t>& stream_out) {

// Compute the addition
for (int i = 0; i < DATA_SIZE; i++) {
stream_out << (stream_in1.read() + stream_in2.read());
for (int i = 0; i < DATA_NUM; i++) {
stream_out.write(stream_in1.read() + stream_in2.read());
}
}

void write_mem(tapa::istream<uint32_t>& stream_in, tapa::mmap<uint32_t> mem_out) {

for (int i = 0; i < DATA_SIZE; i++) {
stream_in >> mem_out[i];
for (int i = 0; i < DATA_NUM; i++) {
mem_out[i] = stream_in.read();
}
}

Expand All @@ -43,8 +38,8 @@ void VecAdd(tapa::mmap<const uint32_t> mem_in1, tapa::mmap<const uint32_t> mem_i
tapa::stream<uint32_t> stream_out("output_stream");

tapa::task()
.invoke(read_mem1, mem_in1, stream_in1)
.invoke(read_mem1, mem_in2, stream_in2)
.invoke(read_mem, mem_in1, stream_in1)
.invoke(read_mem, mem_in2, stream_in2)
.invoke(add_kernel, stream_in1, stream_in2, stream_out)
.invoke(write_mem, stream_out, mem_out);

Expand Down

0 comments on commit fc9a2f5

Please sign in to comment.