okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-q4-geometry (fc1c4e429): the model shape is fixed at build time (-DSTRATA_GEOMETRY / -DSTRATA_GEOMETRY_FILE); the default Flash-Next build is unchanged (CUDA SASS 3573/3573, HIP gfx1201 3920/3920, gfx1151 path-string offsets only, SYCL 22/22 checksums, Metal 10/10 tokens, CUDA 130/130 tokens); Qwen4 test shapes q4_lite/q4_mid/q4_big pass logits gate 2 on CUDA (Qwen4 prep)4dad59ab3

main
3.0 KiB47 linesraw
1# cmake/strata_geometry.cmake - choose the model shape the kernels are compiled for (include/strata/core/geometry.hpp).
2#
3#   -DSTRATA_GEOMETRY=<name>        include/strata/core/geometries/<name>.hpp   (default: flash_next)
4#   -DSTRATA_GEOMETRY_FILE=<path>   any geometry header, for a shape that is not in the tree yet (day one of a new model)
5#
6# With neither set (or STRATA_GEOMETRY=flash_next) nothing is added: no include directory, no definition, so the compile
7# commands are the ones the build had before shapes were selectable.  Otherwise a one-line header
8# <build>/strata_geometry/strata/core/geometry_selected.hpp names the chosen file and its directory goes first on the include
9# path (geometry.hpp picks it up with __has_include).  Included by CMakeLists.txt, metal/CMakeLists.txt and sycl/CMakeLists.txt
10# before any target is declared.
11set(STRATA_GEOMETRY "flash_next" CACHE STRING "model shape the kernels are compiled for: a header in include/strata/core/geometries")
12set(STRATA_GEOMETRY_FILE "" CACHE FILEPATH "a geometry header outside the tree (overrides STRATA_GEOMETRY)")
13
14get_filename_component(_strata_geo_root "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
15set(_strata_geo_dir "${_strata_geo_root}/include/strata/core/geometries")
16file(GLOB _strata_geo_all RELATIVE "${_strata_geo_dir}" "${_strata_geo_dir}/*.hpp")
17string(REGEX REPLACE "\.hpp" "" _strata_geo_names "${_strata_geo_all}")
18list(SORT _strata_geo_names)
19
20set(_strata_geo_header "")
21if(STRATA_GEOMETRY_FILE)
22  if(NOT EXISTS "${STRATA_GEOMETRY_FILE}")
23    message(FATAL_ERROR "STRATA_GEOMETRY_FILE=${STRATA_GEOMETRY_FILE} does not exist")
24  endif()
25  get_filename_component(_strata_geo_header "${STRATA_GEOMETRY_FILE}" ABSOLUTE)
26  get_filename_component(_strata_geo_label "${STRATA_GEOMETRY_FILE}" NAME_WE)
27elseif(NOT STRATA_GEOMETRY STREQUAL "flash_next")
28  if(NOT EXISTS "${_strata_geo_dir}/${STRATA_GEOMETRY}.hpp")
29    string(REPLACE ";" ", " _strata_geo_list "${_strata_geo_names}")
30    message(FATAL_ERROR "STRATA_GEOMETRY=${STRATA_GEOMETRY}: no include/strata/core/geometries/${STRATA_GEOMETRY}.hpp (have: ${_strata_geo_list})")
31  endif()
32  set(_strata_geo_header "${_strata_geo_dir}/${STRATA_GEOMETRY}.hpp")
33  set(_strata_geo_label "${STRATA_GEOMETRY}")
34endif()
35
36if(_strata_geo_header)
37  set(_strata_geo_out "${CMAKE_BINARY_DIR}/strata_geometry")
38  file(MAKE_DIRECTORY "${_strata_geo_out}/strata/core")
39  file(WRITE "${_strata_geo_out}/strata/core/geometry_selected.hpp.tmp"
40       "// written by cmake/strata_geometry.cmake: the shape this build is compiled for\n#pragma once\n#include \"${_strata_geo_header}\"\n")
41  configure_file("${_strata_geo_out}/strata/core/geometry_selected.hpp.tmp" "${_strata_geo_out}/strata/core/geometry_selected.hpp" COPYONLY)
42  include_directories(BEFORE "${_strata_geo_out}")
43  set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_strata_geo_header}")
44  message(STATUS "strata: compiled geometry ${_strata_geo_label} (${_strata_geo_header})")
45else()
46  message(STATUS "strata: compiled geometry flash_next (default)")
47endif()