Skip to content

Commit

Permalink
LightMetal - Add build_metal.sh --disable-light-metal-trace flag to s…
Browse files Browse the repository at this point in the history
…et 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
  • Loading branch information
kmabeeTT committed Jan 20, 2025
1 parent e92c032 commit 38a3cd8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

############################################################################################################################

Expand Down Expand Up @@ -248,6 +249,10 @@ add_link_options(
"$<$<BOOL:${ENABLE_UBSAN}>:-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()
Expand Down
13 changes: 12 additions & 1 deletion build_metal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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=""
Expand All @@ -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" -- "$@")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 0 additions & 3 deletions tt_metal/api/tt-metalium/host_api_capture_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
//////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 38a3cd8

Please sign in to comment.