Skip to content
Merged
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
path = test/benchmark/CGRA-Bench
url = https://github.com/tancheng/CGRA-Bench.git
ignore = all
[submodule "test-benchmark-zeonica-testbench"]
path = test/benchmark/Zeonica_Testbench
url = https://github.com/sarchlab/Zeonica_Testbench.git
ignore = all
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ Build LLVM & Neura
$ /workspace/llvm-project/build/bin/llvm-lit test.mlir -v
```

Sync `test/e2e` outputs into Zeonica_Testbench (submodule)
--------------------------------------------------------
This repo vendors [`sarchlab/Zeonica_Testbench`](https://github.com/sarchlab/Zeonica_Testbench.git) as a git submodule at `test/benchmark/Zeonica_Testbench`.

After running e2e compilation/tests, you can sync the generated artifacts into the testbench repo:
```sh
$ ./tools/sync_e2e_outputs_to_zeonica_testbench.sh
```

Mapping (per kernel `K`):
- `test/e2e/K/tmp-generated-dfg.{dot,yaml}` -> `test/benchmark/Zeonica_Testbench/kernel/K/K-dfg.{dot,yaml}`
- `test/e2e/K/tmp-generated-instructions.{asm,yaml}` -> `test/benchmark/Zeonica_Testbench/kernel/K/K-instructions.{asm,yaml}`
19 changes: 12 additions & 7 deletions lib/NeuraDialect/Transforms/GenerateCodePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ struct GenerateCodePass
setUniqueDestination(pi, producer_direction.str());
else if (!regs.empty())
setUniqueDestination(pi, "$" + std::to_string(regs.back().regId));
}
}
}

// Egress: on source tile at first_link_ts, move [$src_reg] -> [out_dir].
void placeSrcEgress(const Topology &topology, int src_tile_id, int time_step,
Expand Down Expand Up @@ -706,7 +706,8 @@ struct GenerateCodePass
const bool should_rewire_to_register =
IsCtrl || (consumer_placement.time_step > deposit_time_step);
if (should_rewire_to_register) {
setConsumerSourceExact(consumer_operation, value_at_consumer, "$" + std::to_string(register_id));
setConsumerSourceExact(consumer_operation, value_at_consumer,
"$" + std::to_string(register_id));
return true;
}
}
Expand Down Expand Up @@ -804,7 +805,7 @@ struct GenerateCodePass
} else {
return collectDataMovConsumers(forwarder);
}
}
}

template<bool IsCtrl>
void rewriteMovConsumers(Operation *forwarder,
Expand Down Expand Up @@ -1491,7 +1492,8 @@ struct GenerateCodePass
return a->time_step < b->time_step;
});

yaml_out << " - index_per_ii: " << index_per_ii << "\n operations:\n";
yaml_out << " - index_per_ii: " << index_per_ii
<< "\n operations:\n";
for (const Instruction *inst : operations) {
yaml_out << " - opcode: \"" << inst->opcode << "\"\n";
if (inst->id >= 0)
Expand All @@ -1502,13 +1504,15 @@ struct GenerateCodePass
if (!inst->src_operands.empty()) {
yaml_out << " src_operands:\n";
for (const Operand &opnd : inst->src_operands)
yaml_out << " - operand: \"" << opnd.operand << "\"\n color: \"" << opnd.color << "\"\n";
yaml_out << " - operand: \"" << opnd.operand
<< "\"\n color: \"" << opnd.color << "\"\n";
}
// destinations.
if (!inst->dst_operands.empty()) {
yaml_out << " dst_operands:\n";
for (const Operand &opnd : inst->dst_operands)
yaml_out << " - operand: \"" << opnd.operand << "\"\n color: \"" << opnd.color << "\"\n";
yaml_out << " - operand: \"" << opnd.operand
<< "\"\n color: \"" << opnd.color << "\"\n";
}
}
}
Expand Down Expand Up @@ -1577,7 +1581,8 @@ struct GenerateCodePass
for (size_t i = 0; i < instructions.size(); ++i) {
const Instruction *inst = instructions[i];
asm_out << " " << inst->opcode;
for (const Operand &operand : inst->src_operands) asm_out << ", " << formatOperand(operand);
for (const Operand &operand : inst->src_operands)
asm_out << ", " << formatOperand(operand);
if (!inst->dst_operands.empty()) {
asm_out << " -> ";
for (size_t j = 0; j < inst->dst_operands.size(); ++j) {
Expand Down
1 change: 1 addition & 0 deletions test/benchmark/Zeonica_Testbench
Submodule Zeonica_Testbench added at 45e85e
17 changes: 17 additions & 0 deletions test/benchmark/axpy/axpy_int.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Keep the function name matching "kernel" so llvm-extract --rfunc=".*kernel.*" can find it.
extern "C" void kernel_axpy_int(int n, int a, const int *x, int *y) {
for (int i = 0; i < n; ++i) {
y[i] = a * x[i] + y[i];
}
}

// Provide a tiny main so clang emits a complete TU; tests extract only the kernel anyway.
int main() {
const int N = 16;
static int x[N];
static int y[N];
kernel_axpy_int(N, /*a=*/3, x, y);
return 0;
}


22 changes: 22 additions & 0 deletions test/benchmark/gemv/gemv_int.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// A simple int GEMV: y = A*x + y.
// Use fixed small sizes to keep the generated IR stable-ish.
extern "C" void kernel_gemv_int(const int *A, const int *x, int *y) {
const int N = 4;
for (int i = 0; i < N; ++i) {
int acc = 0;
for (int j = 0; j < N; ++j) {
acc += A[i * N + j] * x[j];
}
y[i] = acc;
}
}

int main() {
static int A[16];
static int x[4];
static int y[4];
kernel_gemv_int(A, x, y);
return 0;
}


Loading