Skip to content

Commit

Permalink
hero: Added libomptarget dev
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilKoe committed Apr 26, 2024
1 parent afd51d3 commit b0326e0
Show file tree
Hide file tree
Showing 8 changed files with 742 additions and 18 deletions.
2 changes: 1 addition & 1 deletion hw/system/spatz_cluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ lint/tmp/files: ${BENDER}
## Build SW into sw/build with the LLVM toolchain
sw: clean.sw
mkdir -p sw/build
cd sw/build && ${CMAKE} -DLLVM_PATH=${LLVM_INSTALL_DIR} -DGCC_PATH=${GCC_INSTALL_DIR} -DHTIF_SERVER=${HTIF_SERVER}-DSPATZ_CFG_FILENAME=${SPATZ_CFG_FILENAME} -DPYTHON=${PYTHON} .. && make
cd sw/build && ${CMAKE} -DLLVM_PATH=${LLVM_INSTALL_DIR} -DGCC_PATH=${GCC_INSTALL_DIR} -DHTIF_SERVER=${HTIF_SERVER} -DSPATZ_CFG_FILENAME=${SPATZ_CFG_FILENAME} -DPYTHON=${PYTHON} .. && make

# VSIM
## Build SW into sw/build with the LLVM toolchain (including tests) for Questasim simulator
Expand Down
4 changes: 4 additions & 0 deletions sw/snRuntime/link/common.ld.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ MEMORY

SECTIONS
{
.init :
{
. = ALIGN(4);
}
/* The program code and other data goes into DRAM */
.text :
{
Expand Down
8 changes: 4 additions & 4 deletions sw/snRuntime/src/team.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ uint32_t snrt_cluster_compute_core_idx() {

uint32_t snrt_cluster_compute_core_num() {
// TODO: Actually derive this from the device tree!
return snrt_cluster_core_num() - 1;
return snrt_cluster_core_num();
}

uint32_t snrt_cluster_dm_core_idx() {
// TODO: Actually derive this from the device tree!
return snrt_cluster_core_num() - 1;
return 0;
}

uint32_t snrt_cluster_dm_core_num() {
Expand All @@ -68,12 +68,12 @@ uint32_t snrt_cluster_dm_core_num() {

int snrt_is_compute_core() {
// TODO: Actually derive this from the device tree!
return snrt_cluster_core_idx() < snrt_cluster_core_num() - 1;
return 1;
}

int snrt_is_dm_core() {
// TODO: Actually derive this from the device tree!
return !snrt_is_compute_core();
return snrt_cluster_core_idx() == snrt_cluster_dm_core_idx();
}

uint32_t _snrt_barrier_reg_ptr() {
Expand Down
36 changes: 23 additions & 13 deletions sw/spatzBenchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,30 @@ add_compile_options(-O3 -g -ffunction-sections)

# Macro to regenerate the golden values and compile a module
macro(add_spatz_test_oneParam name file param1)
set(target_name ${name}_M${param1})
add_snitch_test(${target_name} ${file})
target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME})
target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}.h")
if (BUILD_TESTS)
set(target_name ${name}_M${param1})
add_snitch_test(${target_name} ${file})
target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME})
target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}.h")
endif()
endmacro()

macro(add_spatz_test_twoParam name file param1 param2)
if (BUILD_TESTS)
set(target_name ${name}_M${param1}_N${param2})
add_snitch_test(${target_name} ${file})
target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME})
target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}_${param2}.h")
endif()
endmacro()

macro(add_spatz_test_threeParam name file param1 param2 param3)
if (BUILD_TESTS)
set(target_name ${name}_M${param1}_N${param2}_K${param3})
add_snitch_test(${target_name} ${file})
target_link_libraries(test-${SNITCH_TEST_PREFIX}${target_name} benchmark ${SNITCH_RUNTIME})
target_compile_definitions(test-${SNITCH_TEST_PREFIX}${target_name} PUBLIC DATAHEADER="data/data_${param1}_${param2}_${param3}.h")
endif()
endmacro()

# Benchmark library
Expand All @@ -54,8 +60,8 @@ add_library(hp-fmatmul hp-fmatmul/kernel/hp-fmatmul.c)
add_library(widening-hp-fmatmul widening-hp-fmatmul/kernel/widening-fmatmul.c)
add_library(widening-bp-fmatmul widening-bp-fmatmul/kernel/widening-fmatmul.c)

add_library(sdotp-hp-fmatmul sdotp-hp-fmatmul/kernel/sdotp-fmatmul.c)
add_library(sdotp-bp-fmatmul sdotp-bp-fmatmul/kernel/sdotp-fmatmul.c)
# add_library(sdotp-hp-fmatmul sdotp-hp-fmatmul/kernel/sdotp-fmatmul.c)
# add_library(sdotp-bp-fmatmul sdotp-bp-fmatmul/kernel/sdotp-fmatmul.c)

add_library(dp-faxpy dp-faxpy/kernel/faxpy.c)

Expand Down Expand Up @@ -88,14 +94,16 @@ add_spatz_test_threeParam(widening-bp-fmatmul widening-bp-fmatmul/main.c 64 128
add_spatz_test_threeParam(widening-bp-fmatmul widening-bp-fmatmul/main.c 128 128 128)
add_spatz_test_threeParam(widening-bp-fmatmul widening-bp-fmatmul/main.c 128 256 128)

add_spatz_test_threeParam(sdotp-hp-fmatmul sdotp-hp-fmatmul/main.c 64 64 64 )
add_spatz_test_threeParam(sdotp-hp-fmatmul sdotp-hp-fmatmul/main.c 64 128 64 )
add_spatz_test_threeParam(sdotp-hp-fmatmul sdotp-hp-fmatmul/main.c 128 128 128)
# Hero toolchain doew not support sftop at the moment

add_spatz_test_threeParam(sdotp-bp-fmatmul sdotp-bp-fmatmul/main.c 64 64 64 )
add_spatz_test_threeParam(sdotp-bp-fmatmul sdotp-bp-fmatmul/main.c 64 128 64 )
add_spatz_test_threeParam(sdotp-bp-fmatmul sdotp-bp-fmatmul/main.c 128 128 128)
add_spatz_test_threeParam(sdotp-bp-fmatmul sdotp-bp-fmatmul/main.c 128 256 128)
# add_spatz_test_threeParam(sdotp-hp-fmatmul sdotp-hp-fmatmul/main.c 64 64 64 )
# add_spatz_test_threeParam(sdotp-hp-fmatmul sdotp-hp-fmatmul/main.c 64 128 64 )
# add_spatz_test_threeParam(sdotp-hp-fmatmul sdotp-hp-fmatmul/main.c 128 128 128)

# add_spatz_test_threeParam(sdotp-bp-fmatmul sdotp-bp-fmatmul/main.c 64 64 64 )
# add_spatz_test_threeParam(sdotp-bp-fmatmul sdotp-bp-fmatmul/main.c 64 128 64 )
# add_spatz_test_threeParam(sdotp-bp-fmatmul sdotp-bp-fmatmul/main.c 128 128 128)
# add_spatz_test_threeParam(sdotp-bp-fmatmul sdotp-bp-fmatmul/main.c 128 256 128)

add_spatz_test_oneParam(dp-faxpy dp-faxpy/main.c 256)
add_spatz_test_oneParam(dp-faxpy dp-faxpy/main.c 1024)
Expand All @@ -110,3 +118,5 @@ add_spatz_test_twoParam(dp-fft dp-fft/main.c 128 2)

add_spatz_test_twoParam(sp-fft sp-fft/main.c 256 2)
add_spatz_test_twoParam(sp-fft sp-fft/main.c 512 2)

add_library(omptarget omptarget/main.c omptarget/sw_mailbox.c)
94 changes: 94 additions & 0 deletions sw/spatzBenchmarks/omptarget/io.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright 2023 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Robert Balas <[email protected]>
//

/* Description: Memory mapped register I/O access
*/

#ifndef __IO_H
#define __IO_H

#include <stdint.h>


/* generic I/O write */
static inline void writeb(uint8_t val, uintptr_t addr)
{
asm volatile("sb %0, 0(%1)"
:
: "r"(val), "r"((volatile uint8_t *)addr)
: "memory");
}

static inline void writeh(uint16_t val, uintptr_t addr)
{
asm volatile("sh %0, 0(%1)"
:
: "r"(val), "r"((volatile uint16_t *)addr)
: "memory");
}

static inline void writew(uint32_t val, uintptr_t addr)
{
asm volatile("sw %0, 0(%1)"
:
: "r"(val), "r"((volatile uint32_t *)addr)
: "memory");
}

static inline void writed(uint64_t val, uintptr_t addr)
{
asm volatile("sd %0, 0(%1)"
:
: "r"(val), "r"((volatile uint64_t *)addr)
: "memory");
}

/* generic I/O read */
static inline uint8_t readb(const uintptr_t addr)
{
uint8_t val;

asm volatile("lb %0, 0(%1)"
: "=r"(val)
: "r"((const volatile uint8_t *)addr)
: "memory");
return val;
}

static inline uint16_t readh(const uintptr_t addr)
{
uint16_t val;

asm volatile("lh %0, 0(%1)"
: "=r"(val)
: "r"((const volatile uint16_t *)addr)
: "memory");
return val;
}

static inline uint32_t readw(const uintptr_t addr)
{
uint32_t val;

asm volatile("lw %0, 0(%1)"
: "=r"(val)
: "r"((const volatile uint32_t *)addr)
: "memory");
return val;
}

static inline uint64_t readd(const uintptr_t addr)
{
uint64_t val;

asm volatile("ld %0, 0(%1)"
: "=r"(val)
: "r"((const volatile uint64_t *)addr)
: "memory");
return val;
}
#endif
Loading

0 comments on commit b0326e0

Please sign in to comment.