From 38a3cd8b8dea0826a790e73dea5ccfd27656f486 Mon Sep 17 00:00:00 2001 From: Kyle Mabee Date: Wed, 15 Jan 2025 14:45:06 +0000 Subject: [PATCH] LightMetal - Add build_metal.sh --disable-light-metal-trace flag to set cmake/C++ define TT_ENABLE_LIGHT_METAL_TRACE=OFF/0 - Keep "Light Metal Tracing" feature compile-time define set by default for simpler testing, but have quick option here to disable it if needed from perspective of host API "Capture" functions, and also the Light Metal enable/disable newly added APIS, they all become compile time NOP --- CMakeLists.txt | 5 +++++ build_metal.sh | 13 ++++++++++++- .../api/tt-metalium/host_api_capture_helpers.hpp | 3 --- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d22ef1e4530b..00667b4c2678 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,7 @@ message(STATUS "Build TT METAL Tests: ${TT_METAL_BUILD_TESTS}") message(STATUS "Build TTNN Tests: ${TTNN_BUILD_TESTS}") message(STATUS "Build with Unity builds: ${TT_UNITY_BUILDS}") message(STATUS "Build with Shared TTNN Sublibraries: ${ENABLE_TTNN_SHARED_SUBLIBS}") +message(STATUS "Build with LightMetal Trace Enabled: ${TT_ENABLE_LIGHT_METAL_TRACE}") ############################################################################################################################ @@ -248,6 +249,10 @@ add_link_options( "$<$:-fsanitize=undefined>" ) +if(TT_ENABLE_LIGHT_METAL_TRACE) + add_compile_definitions(TT_ENABLE_LIGHT_METAL_TRACE) +endif() + if(ENABLE_CODE_TIMERS) add_compile_definitions(TT_ENABLE_CODE_TIMERS) endif() diff --git a/build_metal.sh b/build_metal.sh index 3e47dd263a3c..732fef6b7cd6 100755 --- a/build_metal.sh +++ b/build_metal.sh @@ -29,6 +29,7 @@ show_help() { 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 " --disable-light-metal-trace Disable Light Metal tracing to binary." echo " --cxx-compiler-path Set path to C++ compiler." echo " --c-compiler-path Set path to C++ compiler." echo " --ttnn-shared-sub-libs Use shared libraries for ttnn." @@ -57,6 +58,7 @@ build_programming_examples="OFF" build_tt_train="OFF" build_static_libs="OFF" unity_builds="ON" +light_metal_trace="ON" build_all="OFF" cxx_compiler_path="" c_compiler_path="" @@ -65,7 +67,7 @@ ttnn_shared_sub_libs="OFF" 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,cxx-compiler-path:,c-compiler-path:,ttnn-shared-sub-libs +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,disable-light-metal-trace,release,development,debug,clean,cxx-compiler-path:,c-compiler-path:,ttnn-shared-sub-libs # Parse the options PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@") @@ -121,6 +123,8 @@ while true; do ttnn_shared_sub_libs="ON";; --disable-unity-builds) unity_builds="OFF";; + --disable-light-metal-trace) + light_metal_trace="OFF";; --cxx-compiler-path) cxx_compiler_path="$2";shift;; --c-compiler-path) @@ -182,6 +186,7 @@ echo "INFO: Install Prefix: $cmake_install_prefix" echo "INFO: Build tests: $build_tests" echo "INFO: Enable Unity builds: $unity_builds" echo "INFO: TTNN Shared sub libs : $ttnn_shared_sub_libs" +echo "INFO: Enable Light Metal Trace: $light_metal_trace" # Prepare cmake arguments cmake_args+=("-B" "$build_dir") @@ -272,6 +277,12 @@ else cmake_args+=("-DTT_UNITY_BUILDS=OFF") fi +if [ "$light_metal_trace" = "ON" ]; then + cmake_args+=("-DTT_ENABLE_LIGHT_METAL_TRACE=ON") +else + cmake_args+=("-DTT_ENABLE_LIGHT_METAL_TRACE=OFF") +fi + if [ "$build_all" = "ON" ]; then cmake_args+=("-DTT_METAL_BUILD_TESTS=ON") cmake_args+=("-DTTNN_BUILD_TESTS=ON") diff --git a/tt_metal/api/tt-metalium/host_api_capture_helpers.hpp b/tt_metal/api/tt-metalium/host_api_capture_helpers.hpp index edfd6e486375..c85c75402891 100644 --- a/tt_metal/api/tt-metalium/host_api_capture_helpers.hpp +++ b/tt_metal/api/tt-metalium/host_api_capture_helpers.hpp @@ -11,9 +11,6 @@ #include "span.hpp" #include "tracehost/types_to_flatbuffer.hpp" -// FIXME (kmabee) - Temp hack, remove before merge and integrate as cmake define. -#define TT_ENABLE_LIGHT_METAL_TRACE 1 - ////////////////////////////////////////////////////////////// // TRACE GUARD & TRACE MACRO // //////////////////////////////////////////////////////////////