-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added - Driver Functionality: - Introduced a cluster driver as part of the `runtime_host` that currently includes support for the snitch cluster. - Device Functionality: Introduced the `devices` folder to add device specific code and add external runtimes. - CONVOLVE Cluster Target: - Added a new cluster target named `CONVOLVE`. - VSCode Configuration: - Add VSCode configuration to enable automatic configuration of the C/C++ extension and support for the integrated CMake build flow on the IIS workstations. Changed - Refactored Test Infrastructure: - Split into generic and target-specific tests. - Organized subtests by execution environment (`host`, `snitchCluster`). - Clear distinction made between host code and cluster code. This allows to specify the ISA and ABI for the cluster and host code separately - Refactored CMake Flow**: - Refactored CMake build flow to collect all source into static `runtime_host` and `runtime_cluster_<type>` library and keep ISA flags private. - Improve README**: - Added explanation to use the C/C++ extension for VSCode on the IIS workstations. - Simplified formatting commands Fixed - ISA Compatibility and Naked Functions: - Addressed invalid instructions by ensuring that the trampoline function and interrupt handlers are correctly compiled with the appropriate ISA and ABI configurations. - Fixed issues with improperly generated stack frames for functions executed before cluster initialization by enforcing the use of naked functions. - Compiler Warnings - Avoid `warning: trap_vector changed binding to STB_WEAK`
- Loading branch information
Showing
54 changed files
with
2,333 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
*~ | ||
.ninja* | ||
**/build/* | ||
|
||
.vscode/settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "cMake", | ||
"configurationProvider": "ms-vscode.cmake-tools", | ||
"compileCommands": "${config:cmake.buildDirectory}/compile_commands.json" | ||
} | ||
], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# | ||
# Moritz Scherer <[email protected]> | ||
# Viviane Potocnik <[email protected]> | ||
# Philip Wiese <[email protected]> | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
|
||
|
@@ -27,16 +28,39 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | |
|
||
project(chimera-sdk LANGUAGES C ASM) | ||
|
||
# WIESEP: It is important to set the ISA and ABI for the host and the cluster snitch | ||
set(ABI ilp32) | ||
set(ISA_CLUSTER_SNITCH rv32im) | ||
set(ISA_HOST rv32imc) | ||
|
||
message(STATUS "[CHIMERA-SDK] ABI : ${ABI}") | ||
message(STATUS "[CHIMERA-SDK] ISA_HOST : ${ISA_HOST}") | ||
message(STATUS "[CHIMERA-SDK] ISA_CLUSTER_SNITCH : ${ISA_CLUSTER_SNITCH}") | ||
if (${DISASSEMBLE_LIBRARIES}) | ||
message(STATUS "[CHIMERA-SDK] DISASSEMBLE_LIBRARIES : ON") | ||
else() | ||
message(STATUS "[CHIMERA-SDK] DISASSEMBLE_LIBRARIES : OFF") | ||
endif() | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/Utils.cmake) | ||
|
||
################################################################################ | ||
# Add subdirectories # | ||
################################################################################ | ||
# WIESEP: Targets have to be included before the other folders to make them available | ||
# Depending on the target, the following static libraries have to added by the targets: | ||
# - runtime_host | ||
# - runtime_cluster_snitch | ||
add_subdirectory(targets) | ||
add_subdirectory(hal) | ||
|
||
add_library(chimera-sdk INTERFACE) | ||
target_link_libraries(chimera-sdk INTERFACE hal) | ||
target_link_libraries(chimera-sdk INTERFACE runtime) | ||
target_sources(chimera-sdk INTERFACE $<TARGET_OBJECTS:runtime>) | ||
# Include other subdirectories | ||
add_subdirectory(hal) | ||
add_subdirectory(devices) | ||
add_subdirectory(drivers) | ||
|
||
################################################################################ | ||
# Testing # | ||
################################################################################ | ||
enable_testing() | ||
|
||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Philip Wiese <[email protected]> | ||
|
||
# Define mappings for devices | ||
set(DEVICE_MAPPINGS | ||
chimera-convolve:snitch_cluster | ||
chimera-open:snitch_cluster | ||
chimera-host: | ||
) | ||
|
||
# Call the macro | ||
add_chimera_subdirectories(${TARGET_PLATFORM} "Device" ${DEVICE_MAPPINGS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Philip Wiese <[email protected]> | ||
|
||
|
||
################################################################################ | ||
# Snitch Cluster Runtime Library # | ||
################################################################################ | ||
file(GLOB_RECURSE C_SOURCES_SNITCH | ||
"trampoline_snitchCluster.c" | ||
) | ||
|
||
target_sources(runtime_cluster_snitch PRIVATE ${C_SOURCES_SNITCH}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2024 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Philip Wiese <[email protected]> | ||
|
||
#include <stdint.h> | ||
|
||
// Persistent trampoline function pointer for each core | ||
extern void (*_trampoline_function)(void *); | ||
|
||
// Peristent argument storage for the trampoline function | ||
extern void *_trampoline_args; | ||
|
||
// Persistant stack pointer storage for each core | ||
extern void *_trampoline_stack; | ||
|
||
/** | ||
* @brief Trampoline function for the cluster core. | ||
* This function will set up the stack pointer and call the function. | ||
* | ||
* @warning Make sure that this function is compiled with ISA for the Snitch cores (RV32IM) | ||
* | ||
*/ | ||
// WIESEP: Make sure the compiler does not allocate a stack frame | ||
void __attribute__((naked)) _trampoline() { | ||
asm volatile( | ||
// Get hart ID (hardware thread ID) | ||
"csrr t1, mhartid\n" // Load mhartid into a0 | ||
|
||
// Load global pointer | ||
".option push\n" | ||
".option norelax\n" // Disable relaxation to ensure `la` behaves as expected | ||
"la gp, __global_pointer$\n" // Load address of global pointer | ||
".option pop\n" | ||
|
||
// Set thread pointer (tp) to zero | ||
"mv tp, zero\n" | ||
|
||
// Set up stack pointer | ||
"la a0, _trampoline_stack\n" // Load address of _trampoline_stack | ||
"slli t1, t1, 2\n" // Multiply hart ID by 4 (size of pointer) | ||
"add a0, a0, t1\n" // Compute the address of _trampoline_stack[hartId] | ||
"lw sp, 0(a0)\n" // Load stack pointer from the computed address | ||
|
||
// Load function pointer and arguments | ||
"la a0, _trampoline_function\n" // Load address of _trampoline_function | ||
"add a0, a0, t1\n" // Compute address of _trampoline_function[hartId] | ||
"lw a1, 0(a0)\n" // Load function pointer into a1 | ||
|
||
"la a0, _trampoline_args\n" // Load address of _trampoline_args | ||
"add a0, a0, t1\n" // Compute address of _trampoline_args[hartId] | ||
"lw a0, 0(a0)\n" // Load argument pointer into a0 | ||
|
||
// Call the offloaded function | ||
"jr a1\n" // Jump and link to the function pointer in a1 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Philip Wiese <[email protected]> | ||
|
||
# Define mappings for drivers | ||
set(DRIVER_MAPPINGS | ||
chimera-convolve:cluster | ||
chimera-open:cluster | ||
chimera-host: | ||
) | ||
|
||
# Call the macro | ||
add_chimera_subdirectories(${TARGET_PLATFORM} "Driver" ${DRIVER_MAPPINGS}) | ||
|
||
|
||
# WIESEP: Export this directory as root include directory for the drivers | ||
target_include_directories(runtime_host PUBLIC ${CMAKE_CURRENT_LIST_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2024 ETH Zurich and University of Bologna. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Philip Wiese <[email protected]> | ||
|
||
|
||
################################################################################ | ||
# Host Runtime Library # | ||
################################################################################ | ||
file(GLOB_RECURSE C_SOURCES | ||
"offload_snitchCluster.c" | ||
) | ||
|
||
target_sources(runtime_host PRIVATE ${C_SOURCES}) |
Oops, something went wrong.