From 2665f88e22057c3c9fd17dcc2bedbd40b2ae5cac Mon Sep 17 00:00:00 2001 From: Bryan Wilder Field Lozano Date: Wed, 13 Nov 2024 22:48:39 -0800 Subject: [PATCH] Build with unity in build-artifact.yaml, don't use unity in build.yaml (#15027) Optimize CI throughput by using Unity for main CI build steps. Don't use unity in the test builds. This way we have builds that verify with or without unity. --- .github/workflows/build-artifact.yaml | 3 +-- .github/workflows/build.yaml | 5 ++--- build_metal.sh | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-artifact.yaml b/.github/workflows/build-artifact.yaml index ea0a012949f..f0dad00701a 100644 --- a/.github/workflows/build-artifact.yaml +++ b/.github/workflows/build-artifact.yaml @@ -137,8 +137,7 @@ jobs: # NOTE: may be inaccurate if we have >1 build runner on the same machine, using the same local cache ccache -z - # Disable Unity builds to detect any bitrot from not building each TU independently - build_command="./build_metal.sh --build-type ${{ inputs.build-type }} --build-all --enable-ccache --disable-unity-builds" + build_command="./build_metal.sh --build-type ${{ inputs.build-type }} --build-all --enable-ccache" echo "${{ inputs.tracy }}" if [ "${{ inputs.tracy }}" = "true" ]; then build_command="$build_command --enable-profiler" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 329fddf8acc..3d654358041 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -43,9 +43,8 @@ jobs: -e ARCH_NAME=${{ matrix.arch }} docker_os_arch: ${{ matrix.build.os }}-amd64 run_args: | - nice -n 19 cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build.type }} -DCMAKE_CXX_COMPILER=${{ matrix.build.cxx_compiler }} -DCMAKE_C_COMPILER=${{ matrix.build.c_compiler }} -G Ninja -DTT_METAL_BUILD_TESTS=ON -DTTNN_BUILD_TESTS=ON -DTT_UMD_BUILD_TESTS=ON - nice -n 19 cmake --build build - + build_command="./build_metal.sh --build-type ${{ matrix.build.type }} --cxx-compiler-path ${{ matrix.build.cxx_compiler }} --c-compiler-path ${{ matrix.build.c_compiler }} --build-tests --build-programming-examples --disable-unity-builds" + nice -n 19 $build_command - name: Check disk space run: | df -h diff --git a/build_metal.sh b/build_metal.sh index b021b6ed543..2d9aebf7780 100755 --- a/build_metal.sh +++ b/build_metal.sh @@ -22,12 +22,15 @@ show_help() { echo " --build-umd-tests Build umd Testcases." echo " --build-programming-examples Build programming examples." echo " --build-tt-train Build tt-train." + echo " --build-all Build all optional components." echo " --release Set the build type as Release." echo " --development Set the build type as RelWithDebInfo." echo " --debug Set the build type as Debug." echo " --clean Remove build workspaces." echo " --build-static-libs Build tt_metal (not ttnn) as a static lib (BUILD_SHARED_LIBS=OFF)" echo " --disable-unity-builds Disable Unity builds" + echo " --cxx-compiler-path Set path to C++ compiler." + echo " --c-compiler-path Set path to C++ compiler." } clean() { @@ -54,11 +57,13 @@ build_tt_train="OFF" build_static_libs="OFF" unity_builds="ON" build_all="OFF" +cxx_compiler_path="" +c_compiler_path="" declare -a cmake_args OPTIONS=h,e,c,t,a,m,s,u,b:,p -LONGOPTIONS=help,build-all,export-compile-commands,enable-ccache,enable-time-trace,enable-asan,enable-msan,enable-tsan,enable-ubsan,build-type:,enable-profiler,install-prefix:,build-tests,build-ttnn-tests,build-metal-tests,build-umd-tests,build-programming-examples,build-tt-train,build-static-libs,disable-unity-builds,release,development,debug,clean +LONGOPTIONS=help,build-all,export-compile-commands,enable-ccache,enable-time-trace,enable-asan,enable-msan,enable-tsan,enable-ubsan,build-type:,enable-profiler,install-prefix:,build-tests,build-ttnn-tests,build-metal-tests,build-umd-tests,build-programming-examples,build-tt-train,build-static-libs,disable-unity-builds,release,development,debug,clean,cxx-compiler-path:,c-compiler-path: # Parse the options PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@") @@ -112,6 +117,10 @@ while true; do build_all="ON";; --disable-unity-builds) unity_builds="OFF";; + --cxx-compiler-path) + cxx_compiler_path="$2";shift;; + --c-compiler-path) + c_compiler_path="$2";shift;; --release) build_type="Release";; --development) @@ -175,6 +184,15 @@ cmake_args+=("-G" "Ninja") cmake_args+=("-DCMAKE_BUILD_TYPE=$build_type") cmake_args+=("-DCMAKE_INSTALL_PREFIX=$cmake_install_prefix") +if [ "$cxx_compiler_path" != "" ]; then + echo "INFO: C++ compiler: $cxx_compiler_path" + cmake_args+=("-DCMAKE_CXX_COMPILER=$cxx_compiler_path") +fi +if [ "$c_compiler_path" != "" ]; then + echo "INFO: C compiler: $c_compiler_path" + cmake_args+=("-DCMAKE_C_COMPILER=$c_compiler_path") +fi + if [ "$enable_ccache" = "ON" ]; then cmake_args+=("-DCMAKE_DISABLE_PRECOMPILE_HEADERS=TRUE") cmake_args+=("-DENABLE_CCACHE=TRUE")