Skip to content

Commit

Permalink
superbuild: Add jobs switch for sub-builds (ispc#2568)
Browse files Browse the repository at this point in the history
*   Set parallel level for sub-builds (ninja).
    Useful for thinly provisioned machines.
    Adds BUILD_TYPE switch for each component built.
    | `superbuild/CMakeLists.txt`
  • Loading branch information
e3m3 authored Aug 2, 2023
1 parent 936391a commit 1c6074b
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions superbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ set(CCACHE_DIR "default" CACHE STRING "ccache cache directory")
set(PREBUILT_STAGE2 "NO" CACHE STRING "Provide pre-built stage2 archive to skip pre ispc-stage2 jobs")
set(PREBUILT_STAGE2_PATH "NO" CACHE STRING "Provide pre-built stage2 toolchain path")
set(STAGE2_TOOLCHAIN_INSTALL_PREFIX "NO" CACHE STRING "Path to install stage2 Clang/LLVM to")
set(BUILD_TYPE_ISPC "Release" CACHE STRING "Set the build type for ISPC build")
set(BUILD_TYPE_LLVM "Release" CACHE STRING "Set the build type for LLVM build")
set(BUILD_TYPE_SPIRV_TRANSLATOR "Release" CACHE STRING "Set the build type for SPIR-V Translator build")
set(BUILD_TYPE_VC_INTRINSICS "Release" CACHE STRING "Set the build type for VC Intrinsics build")
set(BUILD_TYPE_L0 "Release" CACHE STRING "Set the build type for L0 build")
option(LLVM_DISABLE_ASSERTIONS "Enable LLVM build without assertions" ON)
option(EXTERNAL_VERBOSE "Enable verbose for external project build and install commands" OFF)
option(CCACHE "Enable ccache to speed up repetitive builds" OFF)
Expand Down Expand Up @@ -124,6 +129,20 @@ if (EXTERNAL_VERBOSE)
set(EXTERNAL_VERBOSE_FLAG "-v")
endif()

if (CMAKE_BUILD_PARALLEL_LEVEL)
list(APPEND NINJA_JOBS -j ${CMAKE_BUILD_PARALLEL_LEVEL})
else()
list(APPEND NINJA_JOBS "")
endif()

if (CMAKE_BUILD_TYPE)
set(BUILD_TYPE_ISPC ${CMAKE_BUILD_TYPE})
set(BUILD_TYPE_LLVM ${CMAKE_BUILD_TYPE})
set(BUILD_TYPE_SPIRV_TRANSLATOR ${CMAKE_BUILD_TYPE})
set(BUILD_TYPE_VC_INTRINSICS ${CMAKE_BUILD_TYPE})
set(BUILD_TYPE_L0 ${CMAKE_BUILD_TYPE})
endif()

message(STATUS "LLVM_VERSION is ${LLVM_VERSION}")
message(STATUS "LLVM_URL is ${LLVM_URL}")
message(STATUS "VC_INTRINSICS_URL is ${VC_INTRINSICS_URL}")
Expand All @@ -146,6 +165,13 @@ message(STATUS "STAGE2_TOOLCHAIN_INSTALL_PREFIX is ${STAGE2_TOOLCHAIN_INSTALL_PR
message(STATUS "LLVM_DISABLE_ASSERTIONS is ${LLVM_DISABLE_ASSERTIONS}")
message(STATUS "LTO is ${LTO}")
message(STATUS "PGO is ${PGO}")
message(STATUS "CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_BUILD_PARALLEL_LEVEL is ${CMAKE_BUILD_PARALLEL_LEVEL}")
message(STATUS "BUILD_TYPE_ISPC is ${BUILD_TYPE_ISPC}")
message(STATUS "BUILD_TYPE_LLVM is ${BUILD_TYPE_LLVM}")
message(STATUS "BUILD_TYPE_SPIRV_TRANSLATOR is ${BUILD_TYPE_SPIRV_TRANSLATOR}")
message(STATUS "BUILD_TYPE_VC_INTRINSICS is ${BUILD_TYPE_VC_INTRINSICS}")
message(STATUS "BUILD_TYPE_L0 is ${BUILD_TYPE_L0}")
message(STATUS "BUILD_STAGE2_TOOLCHAIN_ONLY is ${BUILD_STAGE2_TOOLCHAIN_ONLY}")
message(STATUS "BUILD_SPIRV_TRANSLATOR_ONLY is ${BUILD_SPIRV_TRANSLATOR_ONLY}")
message(STATUS "BUILD_VC_INTRINSICS_ONLY is ${BUILD_VC_INTRINSICS_ONLY}")
Expand Down Expand Up @@ -285,7 +311,7 @@ endif()

# common LLVM cmake configuration flags.
list(APPEND LLVM_COMMON_CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=${BUILD_TYPE_LLVM}
-DLLVM_ENABLE_DUMP=OFF
-DLLVM_INSTALL_UTILS=ON
-DLLVM_ENABLE_ZLIB=OFF
Expand Down Expand Up @@ -449,7 +475,7 @@ message(STATUS "LLVM stage2 cmake arguments ${LLVM_STAGE2_CMAKE_ARGS}")

# ISPC cmake arguments.
list(APPEND ISPC_COMMON_CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=${BUILD_TYPE_ISPC}
-DISPC_CROSS=ON
-DXE_ENABLED=ON
-DISPC_PREPARE_PACKAGE=ON
Expand Down Expand Up @@ -775,6 +801,7 @@ list(APPEND NINJA_COMMAND_WITH_ENV_STAGE1
"CCACHE_CONFIGPATH=${CCACHE_DEFAULT_CONF}"
${NINJA_EXE}
${EXTERNAL_VERBOSE_FLAG}
${NINJA_JOBS}
)
list(APPEND NINJA_COMMAND_WITH_ENV_STAGE2
${CMAKE_COMMAND}
Expand All @@ -784,6 +811,7 @@ list(APPEND NINJA_COMMAND_WITH_ENV_STAGE2
"PATH=${ENV_PATH_STAGE2_ESC_SEM}"
${NINJA_EXE}
${EXTERNAL_VERBOSE_FLAG}
${NINJA_JOBS}
)
list(APPEND NINJA_COMMAND_WITH_ENV_STAGE3
${CMAKE_COMMAND}
Expand All @@ -793,7 +821,11 @@ list(APPEND NINJA_COMMAND_WITH_ENV_STAGE3
"PATH=${ENV_PATH_STAGE3_ESC_SEM}"
${NINJA_EXE}
${EXTERNAL_VERBOSE_FLAG}
${NINJA_JOBS}
)
message(STATUS "NINJA_COMMAND_WITH_ENV_STAGE1 is ${NINJA_COMMAND_WITH_ENV_STAGE1}")
message(STATUS "NINJA_COMMAND_WITH_ENV_STAGE2 is ${NINJA_COMMAND_WITH_ENV_STAGE2}")
message(STATUS "NINJA_COMMAND_WITH_ENV_STAGE3 is ${NINJA_COMMAND_WITH_ENV_STAGE3}")

if (BUILD_SPIRV_TRANSLATOR_ONLY)
message(STATUS "BUILD SPIRV-LLVM-Translator only")
Expand All @@ -809,7 +841,7 @@ if (BUILD_SPIRV_TRANSLATOR_ONLY)
CMAKE_GENERATOR Ninja
CMAKE_ARGS
-DLLVM_DIR=${PREBUILT_STAGE2_PATH}/lib/cmake/llvm
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=${BUILD_TYPE_SPIRV_TRANSLATOR}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/stage2-toolchain.cmake
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
BUILD_IN_SOURCE OFF
Expand All @@ -833,7 +865,7 @@ if (BUILD_VC_INTRINSICS_ONLY)
CMAKE_GENERATOR Ninja
CMAKE_ARGS
-DLLVM_DIR=${PREBUILT_STAGE2_PATH}/lib/cmake/llvm
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=${BUILD_TYPE_VC_INTRINSICS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/stage2-toolchain.cmake
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
BUILD_IN_SOURCE OFF
Expand All @@ -858,7 +890,7 @@ if (BUILD_L0_LOADER_ONLY)
CMAKE_ARGS
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/stage2-l0-toolchain.cmake
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=${BUILD_TYPE_L0}
BUILD_COMMAND ${NINJA_COMMAND_WITH_ENV_STAGE2}
INSTALL_COMMAND ${NINJA_COMMAND_WITH_ENV_STAGE2} install
)
Expand Down Expand Up @@ -899,7 +931,7 @@ if (PGO OR NOT SKIP_STAGE2_DEPS)
CMAKE_ARGS
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_BINARY_DIR}/stage2-l0-toolchain.cmake
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/stage2
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_TYPE=${BUILD_TYPE_L0}
SOURCE_DIR l0-source
BUILD_IN_SOURCE OFF
PREFIX bl0
Expand Down

0 comments on commit 1c6074b

Please sign in to comment.