Skip to content

Commit ffefd95

Browse files
committed
sw: Allow cluster level overwrites of CMake definitions
Less hardcoding of Spatz configurations but instead put the burden on higher-level settings.
1 parent 9974c6a commit ffefd95

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

sw/snRuntime/CMakeLists.txt

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,25 @@ if(SPATZ_CLUSTER_CFG MATCHES "^(spatz_cluster\.(default|mempool|smallvrf|32b|dou
3030
elseif("${SPATZ_CLUSTER_CFG}" MATCHES "^spatz_cluster.carfield\\.(l2|dram)\\.hjson$")
3131
set(_plat_folder "cheshire")
3232
else()
33-
message(FATAL_ERROR
34-
"Unknown configuration SPATZ_CLUSTER_CFG: ${SPATZ_CLUSTER_CFG} for platform assignment")
33+
if(NOT DEFINED SPATZ_CLUSTER_PLATFORM)
34+
message(WARNING
35+
"Unknown configuration SPATZ_CLUSTER_CFG: ${SPATZ_CLUSTER_CFG} for platform assignment")
36+
else()
37+
message(STATUS
38+
"Overwriting platform with SPATZ_CLUSTER_PLATFORM: ${SPATZ_CLUSTER_PLATFORM}")
39+
set(_plat_folder "${SPATZ_CLUSTER_PLATFORM}")
40+
endif()
41+
endif()
42+
43+
# 3. Check for platform folder assignment and throw a FATAL_ERROR if missing
44+
if(NOT _plat_folder)
45+
# Check if a platform was set (either by the match above or externally)
46+
# If no platform was set AND the platform folder is missing, throw FATAL_ERROR
47+
message(FATAL_ERROR
48+
"Could not determine platform folder. "
49+
"Configuration 'SPATZ_CLUSTER_CFG' was unmatched AND "
50+
"required variable 'SPATZ_CLUSTER_PLATFORM' is not set.")
51+
3552
endif()
3653

3754
set(PLATFORM_SOURCE_FOLDER "src/platforms/${_plat_folder}" CACHE STRING "Path to the platform-specific sources")
@@ -60,6 +77,16 @@ string(TOUPPER "${_key}" _key)
6077
set(_orig_var "MEM_${_key}_ORIGIN")
6178
set(_size_var "MEM_${_key}_SIZE")
6279

80+
if(NOT DEFINED ${_orig_var} AND DEFINED SPATZ_CLUSTER_MEMORY_ORIGIN)
81+
message(STATUS "Overriding memory origin with SPATZ_CLUSTER_MEMORY_ORIGIN: ${SPATZ_CLUSTER_MEMORY_ORIGIN}")
82+
set(_orig_var "SPATZ_CLUSTER_MEMORY_ORIGIN")
83+
endif()
84+
85+
if(NOT DEFINED ${_size_var} AND DEFINED SPATZ_CLUSTER_MEMORY_SIZE)
86+
message(STATUS "Overriding memory size with SPATZ_CLUSTER_MEMORY_SIZE: ${SPATZ_CLUSTER_MEMORY_SIZE}")
87+
set(_size_var "SPATZ_CLUSTER_MEMORY_SIZE")
88+
endif()
89+
6390
if(DEFINED ${_orig_var} AND DEFINED ${_size_var})
6491
# perform the lookup
6592
set(MEM_DRAM_ORIGIN "${${_orig_var}}" CACHE STRING "Base address of external memory")

0 commit comments

Comments
 (0)