Skip to content

Commit

Permalink
[runtime] Add matrix dimensions macros parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sermazz committed Jul 20, 2023
1 parent 99fad2d commit a6b35ee
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions software/runtime/runtime.mk
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ DEFINES += -DQLR_FIFO_SIZE=$(qlr_fifo_size)
ifneq ($(qlr_fifo_size), 0)
DEFINES += -DQLR_CFG_BASE=$(qlr_cfg_base) -DQLR_MAX_REQUESTS=$(qlr_max_requests) -DQLR_MAX_RF_READS=$(qlr_max_rf_reads)
endif
# For systolic benchmarks' matrix dims
ifneq ($(DIM_M),)
DEFINES += -DDIM_M=$(DIM_M)
endif
ifneq ($(DIM_N),)
DEFINES += -DDIM_N=$(DIM_N)
endif
ifneq ($(DIM_P),)
DEFINES += -DDIM_P=$(DIM_P)
endif
ifneq ($(REP_COUNT),)
DEFINES += -DREP_COUNT=$(REP_COUNT)
endif
ifneq ($(SYSTOLIC_LENGTH),)
DEFINES += -DSYSTOLIC_LENGTH=$(SYSTOLIC_LENGTH)
endif

# Specify cross compilation target. This can be omitted if LLVM is built with riscv as default target
RISCV_LLVM_TARGET ?= --target=$(RISCV_TARGET) --sysroot=$(GCC_INSTALL_DIR)/$(RISCV_TARGET) --gcc-toolchain=$(GCC_INSTALL_DIR)
Expand Down
2 changes: 2 additions & 0 deletions software/runtime/systolic/conv_qlr.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
#define K 3 // hardcoded, do not change

// Repetition count
#ifndef REP_COUNT
#define REP_COUNT 1
#endif
// Systolic Length (must be divisor of NUM_CORES)
#ifndef SYSTOLIC_LENGTH
#define SYSTOLIC_LENGTH 16
Expand Down
26 changes: 26 additions & 0 deletions software/runtime/systolic/xqueue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023 ETH Zurich and University of Bologna.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Author: Sergio Mazzola, ETH Zurich

static inline void queue_push(void *const queue, int32_t data, int32_t *const ret) {
asm volatile("q.push.w %0, %1, (%2)" : "+r"(*ret) : "r"(data), "r"(queue) : "memory");
}

inline void queue_pop(void *const queue, int32_t *const ret) {
asm volatile("q.pop.w %0, 0(%1)" : "=r"(*ret) : "r"(queue) : "memory");
}

0 comments on commit a6b35ee

Please sign in to comment.