Skip to content

Commit

Permalink
LightMetal - Add build_metal.sh --enable-light-metal-trace flag to se…
Browse files Browse the repository at this point in the history
…t cmake/C++ define TT_ENABLE_LIGHT_METAL_TRACE=ON/1

 - Without this, "Light Metal Tracing" feature is disabled 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 16, 2025
1 parent b5bd350 commit 4554497
Show file tree
Hide file tree
Showing 3 changed files with 15 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
11 changes: 10 additions & 1 deletion build_metal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ show_help() {
echo " -s, --enable-tsan Enable ThreadSanitizer."
echo " -u, --enable-ubsan Enable UndefinedBehaviorSanitizer."
echo " -p, --enable-profiler Enable Tracy profiler."
echo " --enable-light-metal-trace Enable Light Metal tracing to binary."
echo " --install-prefix Where to install build artifacts."
echo " --build-tests Build All Testcases."
echo " --build-ttnn-tests Build ttnn Testcases."
Expand Down Expand Up @@ -49,6 +50,7 @@ enable_tsan="OFF"
enable_ubsan="OFF"
build_type="Release"
enable_profiler="OFF"
enable_light_metal_trace="OFF"
build_tests="OFF"
build_ttnn_tests="OFF"
build_metal_tests="OFF"
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,enable-light-metal-trace,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

# Parse the options
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@")
Expand Down Expand Up @@ -99,6 +101,8 @@ while true; do
build_type="$2";shift;;
-p|--enable-profiler)
enable_profiler="ON";;
--enable-light-metal-trace)
enable_light_metal_trace="ON";;
--install-prefix)
install_prefix="$2";shift;;
--build-tests)
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: $enable_light_metal_trace"

# Prepare cmake arguments
cmake_args+=("-B" "$build_dir")
Expand Down Expand Up @@ -273,6 +278,10 @@ else
cmake_args+=("-DTT_UNITY_BUILDS=OFF")
fi

if [ "$enable_light_metal_trace" = "ON" ]; then
cmake_args+=("-DTT_ENABLE_LIGHT_METAL_TRACE=ON")
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/impl/lightmetal/host_api_capture_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#include "tt_metal/tt_stl/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 4554497

Please sign in to comment.