Skip to content

Commit 88d7e2c

Browse files
authored
Merge pull request #336 from opencompl/sasha/new-ci
2 parents 9d4edc0 + 7d7473f commit 88d7e2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+540
-326
lines changed

.github/workflows/ci-pivoted.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ jobs:
1919
run-experiments:
2020
runs-on: ubuntu-latest
2121
container:
22-
image: ghcr.io/opencompl/snitch-toolchain:2.10
22+
image: ghcr.io/opencompl/snitch-toolchain:4.0.0
2323
options: --volume ${{ github.workspace }}:/src
2424
steps:
2525
- uses: actions/checkout@v3
2626
with:
2727
submodules: recursive
2828
- name: Install dependencies in venv
2929
run: |
30-
python3 -m venv venv
31-
. venv/bin/activate
32-
pip install -r /src/requirements.txt
30+
uv venv -p 3.11
31+
uv pip install -r /src/requirements.txt
32+
uv pip install /opt/snitch_cluster/
3333
- name: Clean and make pivoted
3434
run: |
35-
. venv/bin/activate
35+
. .venv/bin/activate
3636
cp results/pivoted.csv results/pivoted_old.csv.txt
3737
make clean
3838
make

Snakefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ rule profile_to_csv:
350350

351351
rule trace_to_profile:
352352
input:
353-
txt="kernels/{kernel}/{shape}/{variant}.logs/trace_hart_00000000.trace.txt",
354-
json="kernels/{kernel}/{shape}/{variant}.logs/trace_hart_00000000.trace.json",
353+
txt="kernels/{kernel}/{shape}/{variant}.logs/trace_hart_00000.trace.txt",
354+
json="kernels/{kernel}/{shape}/{variant}.logs/trace_hart_00000.trace.json",
355355
output:
356356
"kernels/{kernel}/{shape}/{variant}.profile.json",
357357
params:
@@ -369,23 +369,23 @@ rule trace_to_profile:
369369

370370
rule dasm_to_trace:
371371
input:
372-
"{test}.logs/trace_hart_00000000.dasm",
373-
output:
374-
txt="{test}.logs/trace_hart_00000000.trace.txt",
375-
json="{test}.logs/trace_hart_00000000.trace.json",
372+
"{test}.logs/trace_hart_00000.dasm",
373+
log:
374+
txt="{test}.logs/trace_hart_00000.trace.txt",
375+
json="{test}.logs/trace_hart_00000.trace.json",
376376
params:
377377
spike=config["spike"],
378378
gentrace=config["gentrace"],
379379
shell:
380-
"{params.spike} < {input} | {params.gentrace} --permissive -d {output.json} > {output.txt}"
380+
"{params.spike} < {input} | {params.gentrace} --permissive --dump-hart-perf {log.json} -o {log.txt}"
381381

382382

383383
# Rule used to generate traces for debugging purposes, not used for csv generation
384384
rule dasm_to_trace_debug:
385385
input:
386-
"{test}.logs/logs/trace_hart_00000000.dasm",
386+
"{test}.logs/logs/trace_hart_00000.dasm",
387387
output:
388-
txt="{test}.logs/logs/trace_hart_00000000.trace.txt",
388+
txt="{test}.logs/logs/trace_hart_00000.trace.txt",
389389
params:
390390
spike=config["spike"],
391391
gentrace=config["gentrace"],
@@ -397,7 +397,7 @@ rule verilator:
397397
input:
398398
"{test}.x",
399399
output:
400-
expand("{{test}}.logs/trace_hart_0000000{hart}.dasm", hart=range(9)),
400+
expand("{{test}}.logs/trace_hart_0000{hart}.dasm", hart=range(9)),
401401
params:
402402
workdir="{test}.logs",
403403
vltsim=config["vltsim"],
@@ -548,7 +548,7 @@ rule cc_compile_c:
548548
cc=config["cc"],
549549
cflags=config["cflags"],
550550
shell:
551-
"{params.cc} -I$(dirname {input}) -I$(dirname {output}) {params.cflags} -S -o {output} {input.c}"
551+
"{params.cc} -I$(dirname {input}) -I$(dirname {output}) {params.cflags} -S -x c++ -o {output} {input.c}"
552552

553553

554554
rule cc_compile_ll:
@@ -615,7 +615,7 @@ rule cc_compile_shared_main:
615615
cc=config["cc"],
616616
cflags=config["cflags"],
617617
shell:
618-
"{params.cc} -I$(dirname {input.h}) {params.cflags} -S -o {output} {input.c}"
618+
"{params.cc} -I$(dirname {input.h}) {params.cflags} -S -x c++ -o {output} {input.c}"
619619

620620

621621
###########################################################

default.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xdsl-opt: xdsl-opt # from virtualenv
33
mlir-opt: /usr/bin/mlir-opt-16
44
mlir-translate: /usr/bin/mlir-translate-16
5-
cc: /opt/snitch-llvm/bin/riscv32-unknown-elf-clang
5+
cc: /opt/snitch-llvm/bin/clang++
66
spike: /opt/snitch-spike/bin/spike-dasm
77
vltsim: /opt/snitch-rtl/bin/snitch_cluster.vlt
88
gentrace: /opt/snitch_cluster/util/trace/gen_trace.py
@@ -60,13 +60,14 @@ ldflags:
6060
- -fuse-ld=/opt/snitch-llvm/bin/ld.lld
6161
- -nostartfiles
6262
- -nostdlib
63-
- -lclang_rt.builtins-riscv32
64-
- -lc
65-
- -lsnRuntime
66-
- -L/opt/snitch-llvm/lib/clang/12.0.1/lib/
67-
- -T/opt/snitch_cluster/sw/snRuntime/base.ld
63+
- -L/opt/snitch-llvm/lib/clang/15.0.0/lib/
64+
- -L/opt/snitch_cluster/target/snitch_cluster/sw/runtime/
6865
- -L/opt/snitch_cluster/target/snitch_cluster/sw/runtime/rtl
6966
- -L/opt/snitch_cluster/target/snitch_cluster/sw/runtime/rtl/build
67+
- -T/opt/snitch_cluster/sw/snRuntime/base.ld
68+
- -lc
69+
- -lsnRuntime
70+
- -lclang_rt.builtins-riscv32
7071
xdsl-passes:
7172
- test-lower-linalg-to-snitch
7273
mlir-opt-flags-linalg:

docker/venv.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ FORCE_VENV=0
88
if [[ -d /src/xdsl ]]; then
99
pushd /src/xdsl > /dev/null
1010
if [[ 1 -eq ${FORCE_VENV} ]] || [[ ! -d ${VENV_DIR} ]] || [[ ! -f ${VENV_DIR}/bin/activate ]]; then
11-
python3 -m venv ${VENV_DIR}
11+
uv venv -p 3.11 ${VENV_DIR}
1212
source ${VENV_DIR}/bin/activate
13-
pip install --upgrade pip
14-
pip install -r /src/requirements.txt
13+
uv pip install -r /src/requirements.txt
14+
uv pip install /opt/snitch_cluster/
1515
else
1616
source ${VENV_DIR}/bin/activate
1717
fi

kernels/conv2d_d1_s1_3x3/baseline.c.template

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
#include <stdint.h>
44

5-
void conv_2d_nchw_fchw_d1_s1_3x3(const double* restrict x, const double* restrict y,
6-
double* restrict z) {
5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
9+
void conv_2d_nchw_fchw_d1_s1_3x3(const double* x, const double* y,
10+
double* z) {
711
for (int row = 0; row < NEW_H; ++row) {
812
for (int col = 0; col < NEW_W; ++col) {
913
for (int i = 0; i < N; i++) {
@@ -27,3 +31,7 @@ void conv_2d_nchw_fchw_d1_s1_3x3(const double* restrict x, const double* restric
2731
}
2832
}
2933
}
34+
35+
#ifdef __cplusplus
36+
}
37+
#endif

kernels/conv2d_d1_s1_3x3/data.h.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@
88
#define NEW_H {{M}}
99
#define NEW_W {{N}}
1010

11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
1115
extern const double X[N * C * H * W];
1216
extern const double Y[F * C * 3 * 3];
1317
extern const double Z_IN[N * F * NEW_H * NEW_W];
1418
extern const double Z_OUT[N * F * NEW_H * NEW_W];
1519

20+
#ifdef __cplusplus
21+
}
22+
#endif
23+
1624
#define TEST_COUNT (N * F * NEW_H * NEW_W)

kernels/conv2d_d1_s1_3x3/main.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <math.h>
66

77
// Kernel provided via external definition
8-
void conv_2d_nchw_fchw_d1_s1_3x3(double *x, double *y, double *z);
8+
extern "C" void conv_2d_nchw_fchw_d1_s1_3x3(double *x, double *y, double *z);
99

1010
int main() {
1111
// Allocate shared local memory
@@ -18,9 +18,10 @@ int main() {
1818

1919
// Copy data in shared local memory
2020
if (snrt_is_dm_core()) {
21-
snrt_dma_start_1d(local_x, X, N * C * H * W * sizeof(double));
22-
snrt_dma_start_1d(local_y, Y, F * C * 3 * 3 * sizeof(double));
23-
snrt_dma_start_1d(local_z, Z_IN, N * F * NEW_H * NEW_W * sizeof(double));
21+
snrt_dma_start_1d(local_x, (volatile void *)X, N * C * H * W * sizeof(double));
22+
snrt_dma_start_1d(local_y, (volatile void *)Y, F * C * 3 * 3 * sizeof(double));
23+
snrt_dma_start_1d(local_z, (volatile void *)Z_IN,
24+
N * F * NEW_H * NEW_W * sizeof(double));
2425
snrt_dma_wait_all();
2526
}
2627

kernels/ddot/128xf64/baseline.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

33
#include <stdint.h>
44

5-
void ddot(const double* restrict x, const double* restrict y, double* restrict g) {
5+
#ifdef __cplusplus
6+
extern "C" {
7+
#endif
8+
9+
void ddot(const double* x, const double* y, double* g) {
610
double acc = *g;
711
for (uint32_t i = 0; i < N; ++i) {
812
acc += x[i] * y[i];
913
}
1014
*g = acc;
1115
}
16+
17+
#ifdef __cplusplus
18+
}
19+
#endif

kernels/ddot/128xf64/data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "data.h"
2+
13
#define N 128
24

35
const double X[N] = {

kernels/ddot/128xf64/snrt.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
44

55
#include <stdint.h>
66

7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
711
// x[ N ]
812
// y[ N ]
913
// g[ 1 ]
10-
void ddot(const double* restrict x, const double* restrict y, double* restrict g) {
14+
void ddot(const double* x, const double* y, double* g) {
1115
snrt_ssr_loop_1d(SNRT_SSR_DM_ALL,
1216
// Bounds
1317
N,
1418
// Strides
1519
sizeof(double));
1620

17-
snrt_ssr_read(SNRT_SSR_DM0, SNRT_SSR_1D, x);
18-
snrt_ssr_read(SNRT_SSR_DM1, SNRT_SSR_1D, y);
21+
snrt_ssr_read(SNRT_SSR_DM0, SNRT_SSR_1D, (volatile void*)x);
22+
snrt_ssr_read(SNRT_SSR_DM1, SNRT_SSR_1D, (volatile void*)y);
1923

2024
snrt_ssr_enable();
2125

@@ -32,3 +36,7 @@ void ddot(const double* restrict x, const double* restrict y, double* restrict g
3236

3337
snrt_ssr_disable();
3438
}
39+
40+
#ifdef __cplusplus
41+
}
42+
#endif

0 commit comments

Comments
 (0)