Skip to content

Commit

Permalink
sw: Make compatible with non-12 LLVM versions (#46)
Browse files Browse the repository at this point in the history
Co-authored-by: Luca Colagrande <[email protected]>
  • Loading branch information
paulsc96 and colluca authored Sep 12, 2023
1 parent 9e7a4a9 commit 06bf7dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions sw/blas/gemm/src/gemm.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void gemm_fp64_opt(uint32_t M, uint32_t N, uint32_t K, double* A, uint32_t ldA,
for (uint32_t m = 0; m < M; m++) {
uint32_t n = 0;
for (uint32_t n0 = 0; n0 < N / unroll; n0++) {
register double c[unroll];
double c[unroll];

// Load intermediate result
if (*ALPHA) {
Expand Down Expand Up @@ -234,7 +234,7 @@ void gemm_fp32_opt(const uint32_t M, const uint32_t N, const uint32_t K,
for (uint32_t n0 = 0; n0 < N / unroll; n0++) {
float* _C = &C[m * ldC + n / 2];
const register float zero = 0.0;
register v2f32 c[unroll], reduce_reg[unroll];
v2f32 c[unroll], reduce_reg[unroll];

asm volatile(
"lw t0, 0(%[ALPHA]) \n"
Expand Down Expand Up @@ -384,8 +384,8 @@ void gemm_fp16_opt(uint32_t M, uint32_t N, uint32_t K, __fp16* A, uint32_t ldA,
for (uint32_t n0 = 0; n0 < N / unroll; n0++) {
__fp16* _C = &C[m * ldC + n];
const register float zero = 0.0;
register v4f16 c[unroll];
register v2f32 reduce_reg[unroll];
v4f16 c[unroll];
v2f32 reduce_reg[unroll];
uint32_t alpha;

asm volatile(
Expand Down Expand Up @@ -568,8 +568,8 @@ void gemm_fp16_ex_opt(uint32_t M, uint32_t N, uint32_t K, __fp16* A,
for (uint32_t n0 = 0; n0 < N / unroll; n0++) {
__fp16* _C = &C[m * ldC + n];
const register float zero = 0.0;
register v4f16 c[unroll];
register v2f32 reduce_reg[unroll];
v4f16 c[unroll];
v2f32 reduce_reg[unroll];
uint32_t alpha;

asm volatile(
Expand Down Expand Up @@ -735,8 +735,8 @@ void gemm_fp8_ex_opt(uint32_t M, uint32_t N, uint32_t K, char* A, uint32_t ldA,
for (uint32_t n0 = 0; n0 < N / unroll; n0++) {
char* _C = &C[m * ldC + n];
const register float zero = 0.0;
register v8f8 c[unroll];
register v4f16 reduce_reg[unroll];
v8f8 c[unroll];
v4f16 reduce_reg[unroll];
uint32_t alpha;

asm volatile(
Expand Down
3 changes: 2 additions & 1 deletion target/snitch_cluster/sw/toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ DEBUG ?= OFF # ON to turn on debugging symbols

# Compiler toolchain
LLVM_BINROOT ?= $(dir $(shell which riscv32-unknown-elf-clang))
LLVM_VER ?= $(shell $(LLVM_BINROOT)/llvm-config --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
RISCV_CC ?= $(LLVM_BINROOT)/clang
RISCV_LD ?= $(LLVM_BINROOT)/ld.lld
RISCV_AR ?= $(LLVM_BINROOT)/llvm-ar
Expand Down Expand Up @@ -48,7 +49,7 @@ RISCV_LDFLAGS += -fuse-ld=$(RISCV_LD)
RISCV_LDFLAGS += -nostartfiles
RISCV_LDFLAGS += -nostdlib
RISCV_LDFLAGS += -lc
RISCV_LDFLAGS += -L$(LLVM_BINROOT)/../lib/clang/12.0.1/lib/
RISCV_LDFLAGS += -L$(LLVM_BINROOT)/../lib/clang/$(LLVM_VER)/lib/
RISCV_LDFLAGS += -lclang_rt.builtins-riscv32

# Archiver flags
Expand Down

0 comments on commit 06bf7dd

Please sign in to comment.