From a0a8e5aa609b3981221ce64d076a01f5e5e609d0 Mon Sep 17 00:00:00 2001 From: Yan Zaretskiy Date: Mon, 10 Jun 2024 16:31:27 +0000 Subject: [PATCH] #0: Use LLVM's libc++ as the standard library --- .github/actions/install-metal-deps/action.yml | 7 + .../install-metal-deps/dependencies.json | 2 - .../actions/install-metal-dev-deps/action.yml | 6 - CMakeLists.txt | 34 +++-- INSTALLING.md | 5 +- cmake/CPM_boost.cmake | 35 ----- cmake/dependencies.cmake | 80 ++++++++++++ cmake/helper_functions.cmake | 2 +- cmake/umd_device.cmake | 121 +++--------------- scripts/docker/requirements.txt | 1 - tests/CMakeLists.txt | 2 +- tests/tt_eager/ops/test_eltwise_unary_op.cpp | 2 +- .../tt_metal/unit_tests/CMakeLists.txt | 1 - .../tt_metal/unit_tests_common/CMakeLists.txt | 3 +- .../common/test_bit_utils.cpp | 10 +- .../unit_tests_common/watcher/test_assert.cpp | 4 +- .../watcher/test_noc_sanitize.cpp | 4 +- .../unit_tests_fast_dispatch/CMakeLists.txt | 1 - .../CMakeLists.txt | 1 - .../unit_tests_frequent/CMakeLists.txt | 3 +- tests/ttnn/unit_tests/gtests/CMakeLists.txt | 1 - tt_eager/queue/CMakeLists.txt | 2 +- tt_eager/tensor/CMakeLists.txt | 2 +- tt_eager/tensor/host_buffer/functions.hpp | 20 +-- tt_eager/tt_dnn/op_library/CMakeLists.txt | 2 +- .../eltwise_binary/eltwise_binary_op.cpp | 3 +- .../eltwise_unary/eltwise_unary_op.cpp | 3 +- .../moreh_matmul/moreh_matmul_op.cpp | 3 +- tt_eager/tt_dnn/op_library/operation.hpp | 2 +- tt_metal/CMakeLists.txt | 11 +- tt_metal/common/CMakeLists.txt | 2 +- tt_metal/hw/inc/bit_utils.h | 9 +- tt_metal/impl/debug/watcher_server.cpp | 29 ++++- tt_metal/impl/debug/watcher_server.hpp | 4 +- tt_metal/jit_build/settings.hpp | 20 +-- tt_metal/tools/CMakeLists.txt | 1 - tt_metal/tt_stl/reflection.hpp | 7 +- ttnn/CMakeLists.txt | 2 +- ttnn/cpp/ttnn/op_library/binary/binary_op.cpp | 3 +- 39 files changed, 210 insertions(+), 240 deletions(-) delete mode 100644 cmake/CPM_boost.cmake create mode 100644 cmake/dependencies.cmake diff --git a/.github/actions/install-metal-deps/action.yml b/.github/actions/install-metal-deps/action.yml index ca87310ae11..fc6cc4f3dc3 100644 --- a/.github/actions/install-metal-deps/action.yml +++ b/.github/actions/install-metal-deps/action.yml @@ -30,3 +30,10 @@ runs: echo $DEPENDENCIES sudo apt update sudo apt install -y $DEPENDENCIES + - name: Install Clang-17 + shell: bash + run: | + wget https://apt.llvm.org/llvm.sh + chmod u+x llvm.sh + sudo ./llvm.sh 17 + sudo apt install -y libc++-17-dev libc++abi-17-dev diff --git a/.github/actions/install-metal-deps/dependencies.json b/.github/actions/install-metal-deps/dependencies.json index 17175fe9745..439824427a9 100644 --- a/.github/actions/install-metal-deps/dependencies.json +++ b/.github/actions/install-metal-deps/dependencies.json @@ -3,7 +3,6 @@ "software-properties-common=0.99.9.12", "build-essential=12.8ubuntu1.1", "python3.8-venv=3.8.10-0ubuntu1~20.04.9", - "libyaml-cpp-dev=0.6.2-4ubuntu1", "libhwloc-dev", "graphviz", "patchelf" @@ -12,7 +11,6 @@ "software-properties-common", "build-essential", "python3.10-venv", - "libyaml-cpp-dev", "libhwloc-dev", "graphviz", "patchelf" diff --git a/.github/actions/install-metal-dev-deps/action.yml b/.github/actions/install-metal-dev-deps/action.yml index dcf1588a201..0d520b7f676 100644 --- a/.github/actions/install-metal-dev-deps/action.yml +++ b/.github/actions/install-metal-dev-deps/action.yml @@ -37,9 +37,3 @@ runs: tar -xvf doxygen-1.9.6.linux.bin.tar.gz cd doxygen-1.9.6 sudo make install - - name: Install Clang-17 - shell: bash - run: | - wget https://apt.llvm.org/llvm.sh - chmod u+x llvm.sh - sudo ./llvm.sh 17 diff --git a/CMakeLists.txt b/CMakeLists.txt index f54ab3c0766..c315db90207 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,14 +7,20 @@ cmake_policy(VERSION 3.16) # Use Clang-17 by default until we upgrade to Ubuntu version that supports higher GCC # No longer support GCC-9 as it does not support C++20 -find_program(CLANG_17 clang++-17) -if(CLANG_17) - message(STATUS "Found Clang-17 here: ${CLANG_17}") - set(CMAKE_CXX_COMPILER "${CLANG_17}") -else() - message(WARNING "Clang++-17 not found!!!") +find_program(CLANGPP_17 clang++-17) +find_program(CLANG_17 clang-17) + +if (NOT CLANGPP_17) + message(FATAL_ERROR "clang++-17 not found") endif() +if (NOT CLANG_17) + message(FATAL_ERROR "clang-17 not found") +endif() + +set(CMAKE_CXX_COMPILER "${CLANGPP_17}") +set(CMAKE_C_COMPILER "${CLANG_17}") + if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "CMake generation is not allowed within source directory!! Please set a build folder with '-B'!!") endif() @@ -32,22 +38,14 @@ CHECK_COMPILERS() ############################################################################################################################ # Find all required libraries to build ############################################################################################################################ -include(${PROJECT_SOURCE_DIR}/cmake/CPM_boost.cmake) +include(${PROJECT_SOURCE_DIR}/cmake/dependencies.cmake) + find_package (Python3 COMPONENTS Interpreter Development) find_library(NUMA_LIBRARY NAMES numa) if (NOT NUMA_LIBRARY) message(FATAL_ERROR "NUMA library not found") endif() -CPMAddPackage( - NAME googletest - GITHUB_REPOSITORY google/googletest - GIT_TAG release-1.12.1 - VERSION 1.12.1 - OPTIONS "INSTALL_GTEST OFF" -) - - ############################################################################################################################ # Setting build type flags # Will default to assert build, unless CONFIG env variable is set or manually set -DCMAKE_BUILD_TYPE @@ -98,7 +96,7 @@ set(CMAKE_INSTALL_DATAROOTDIR "${PROJECT_BINARY_DIR}/tmp/share") ############################################################################################################################ add_library(metal_common_libs INTERFACE) target_link_libraries(metal_common_libs INTERFACE - dl z pthread atomic stdc++ hwloc numa # system libraries, hwloc has no cmake support, find_package won't find it + dl z pthread atomic c++ c++abi hwloc numa # system libraries, hwloc has no cmake support, find_package won't find it ) # Note on flags: @@ -112,7 +110,7 @@ CHECK_COMPILER_WARNINGS() # <- add any extra compile warning flags for buil add_library(compiler_flags INTERFACE) target_link_libraries(compiler_flags INTERFACE compiler_warnings) -target_compile_options(compiler_flags INTERFACE -mavx2 -fPIC -DFMT_HEADER_ONLY -fvisibility-inlines-hidden -fno-lto) +target_compile_options(compiler_flags INTERFACE -mavx2 -fPIC -DFMT_HEADER_ONLY -fvisibility-inlines-hidden -fno-lto -stdlib=libc++) if(TT_METAL_VERSIM_DISABLED) target_compile_options(compiler_flags INTERFACE -DTT_METAL_VERSIM_DISABLED) diff --git a/INSTALLING.md b/INSTALLING.md index 7cd0ac78c95..21fc455d136 100644 --- a/INSTALLING.md +++ b/INSTALLING.md @@ -26,12 +26,11 @@ Note the current compatability matrix: ```sh sudo apt update -sudo apt install software-properties-common=0.99.9.12 build-essential=12.8ubuntu1.1 python3.8-venv=3.8.10-0ubuntu1~20.04.9 libyaml-cpp-dev=0.6.2-4ubuntu1 libhwloc-dev graphviz - -# Install Clang-17 for C++20 support!! +sudo apt install software-properties-common=0.99.9.12 build-essential=12.8ubuntu1.1 python3.8-venv=3.8.10-0ubuntu1~20.04.9 libhwloc-dev graphviz wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh sudo ./llvm.sh 17 +sudo apt install libc++-17-dev libc++abi-17-dev ``` --- diff --git a/cmake/CPM_boost.cmake b/cmake/CPM_boost.cmake deleted file mode 100644 index 00069deda24..00000000000 --- a/cmake/CPM_boost.cmake +++ /dev/null @@ -1,35 +0,0 @@ - -set(ENV{CPM_SOURCE_CACHE} "${PROJECT_SOURCE_DIR}/.cpmcache") - -include(${PROJECT_SOURCE_DIR}/cmake/CPM.cmake) -set(BoostPackages - Align - Config - Container_Hash - Core - Detail - Format - Interprocess - Smart_Ptr - Assert - Integer - Type_Traits - Optional - Static_Assert - Throw_Exception - Move - Utility - Preprocessor - Date_Time - Numeric_Conversion - Mpl -) - -foreach(package ${BoostPackages}) - CPMAddPackage( - NAME Boost${package} - GITHUB_REPOSITORY boostorg/${package} - GIT_TAG boost-1.76.0 - DOWNLOAD_ONLY YES - ) -endforeach() diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake new file mode 100644 index 00000000000..54d4ec3731e --- /dev/null +++ b/cmake/dependencies.cmake @@ -0,0 +1,80 @@ + +set(ENV{CPM_SOURCE_CACHE} "${PROJECT_SOURCE_DIR}/.cpmcache") + +############################################################################################################################ +# Boost +############################################################################################################################ + +include(${PROJECT_SOURCE_DIR}/cmake/CPM.cmake) +set(BoostPackages + Align + Config + Container_Hash + Core + Describe + Detail + Format + Interprocess + Intrusive + Smart_Ptr + Assert + Integer + Type_Traits + Optional + Static_Assert + Throw_Exception + Move + Utility + Preprocessor + Date_Time + Numeric_Conversion + Mpl + Mp11 +) + +foreach(package ${BoostPackages}) + CPMAddPackage( + NAME Boost${package} + GITHUB_REPOSITORY boostorg/${package} + GIT_TAG boost-1.85.0 + DOWNLOAD_ONLY YES + ) +endforeach() + +############################################################################################################################ +# yaml-cpp +############################################################################################################################ + +CPMAddPackage( + NAME yaml-cpp + GITHUB_REPOSITORY jbeder/yaml-cpp + GIT_TAG 0.8.0 + OPTIONS + "YAML_CPP_BUILD_TESTS OFF" + "YAML_CPP_BUILD_TOOLS OFF" +) + +if (yaml-cpp_ADDED) + target_compile_options(yaml-cpp PUBLIC -stdlib=libc++) + target_link_libraries(yaml-cpp PUBLIC c++ c++abi) + set_target_properties(yaml-cpp PROPERTIES DEBUG_POSTFIX "") +endif() + +############################################################################################################################ +# googletest +############################################################################################################################ + +CPMAddPackage( + NAME googletest + GITHUB_REPOSITORY google/googletest + GIT_TAG v1.13.0 + VERSION 1.13.0 + OPTIONS "INSTALL_GTEST OFF" +) + +if (googletest_ADDED) + target_compile_options(gtest PRIVATE -stdlib=libc++ -Wno-implicit-int-float-conversion) + target_compile_options(gtest_main PRIVATE -stdlib=libc++) + target_link_libraries(gtest PRIVATE c++ c++abi) + target_link_libraries(gtest_main PRIVATE c++ c++abi) +endif() diff --git a/cmake/helper_functions.cmake b/cmake/helper_functions.cmake index a77b4b0aecc..ebcc2d4ad53 100644 --- a/cmake/helper_functions.cmake +++ b/cmake/helper_functions.cmake @@ -34,7 +34,7 @@ function(CREATE_PGM_EXAMPLES_EXE TESTLIST SUBDIR) get_filename_component(TEST_TARGET ${TEST} NAME) add_executable(${TEST_TARGET} ${TEST}) - target_link_libraries(${TEST_TARGET} PUBLIC tt_metal stdc++fs yaml-cpp m pthread) + target_link_libraries(${TEST_TARGET} PUBLIC tt_metal yaml-cpp::yaml-cpp m pthread) target_include_directories(${TEST_TARGET} PRIVATE ${UMD_HOME} ${PROJECT_SOURCE_DIR} diff --git a/cmake/umd_device.cmake b/cmake/umd_device.cmake index ca822fc2d6c..e35a987adf4 100644 --- a/cmake/umd_device.cmake +++ b/cmake/umd_device.cmake @@ -1,107 +1,24 @@ +set(UMD_SRC + ${UMD_HOME}/device/architecture_implementation.cpp + ${UMD_HOME}/device/blackhole_implementation.cpp + ${UMD_HOME}/device/cpuset_lib.cpp + ${UMD_HOME}/device/grayskull_implementation.cpp + ${UMD_HOME}/device/tlb.cpp + ${UMD_HOME}/device/tt_cluster_descriptor.cpp + ${UMD_HOME}/device/tt_device.cpp + ${UMD_HOME}/device/tt_emulation_stub.cpp + ${UMD_HOME}/device/tt_silicon_driver.cpp + ${UMD_HOME}/device/tt_silicon_driver_common.cpp + ${UMD_HOME}/device/tt_soc_descriptor.cpp + ${UMD_HOME}/device/tt_versim_stub.cpp + ${UMD_HOME}/device/wormhole_implementation.cpp +) -### THIS CMAKE IS TO BUILD THE UMD_DEVICE SHARED LIBRARY ### -### All variables/compiler flags declared in this file are passed to umd/device .mk file to build device ### - -set(WARNINGS "-Werror -Wdelete-non-virtual-dtor -Wreturn-type -Wswitch -Wuninitialized -Wno-unused-parameter" CACHE STRING "Warnings to enable") - -if(CMAKE_BUILD_TYPE STREQUAL "ci") - set(CONFIG_LDFLAGS "${CONFIG_LDFLAGS} -Wl,--verbose") -elseif(CMAKE_BUILD_TYPE STREQUAL "asan") - set(CONFIG_LDFLAGS "${CONFIG_LDFLAGS} -fsanitize=address") -elseif(CMAKE_BUILD_TYPE STREQUAL "ubsan") - set(CONFIG_LDFLAGS "${CONFIG_LDFLAGS} -fsanitize=undefined") -endif() - -if(NOT TT_METAL_VERSIM_DISABLED) - set(UMD_VERSIM_STUB 0) -else() - set(UMD_VERSIM_STUB 1) -endif() -if($ENV{ENABLE_TRACY}) - set(CONFIG_LDFLAGS "${CONFIG_LDFLAGS} -ltracy -rdynamic") -endif() - -# MUST have the RPATH set, or else can't find the tracy lib -set(LDFLAGS_ "-L${PROJECT_BINARY_DIR}/lib -Wl,-rpath,${PROJECT_BINARY_DIR}/lib ${CONFIG_LDFLAGS} -ldl -lz -lpthread -latomic -lhwloc -lstdc++") -set(SHARED_LIB_FLAGS_ "-shared -fPIC") -set(STATIC_LIB_FLAGS_ "-fPIC") +add_library(umd_device OBJECT ${UMD_SRC}) +target_include_directories(umd_device PRIVATE ${UMD_HOME} ${UMD_HOME}/third_party/fmt/include) -set (CMAKE_CXX_FLAGS_ "--std=c++17 -fvisibility-inlines-hidden") foreach(lib ${BoostPackages}) - set(CMAKE_CXX_FLAGS_ "${CMAKE_CXX_FLAGS_} -I${Boost${lib}_SOURCE_DIR}/include") + target_include_directories(umd_device PRIVATE ${Boost${lib}_SOURCE_DIR}/include) endforeach() -set(UMD_OUTPUT > /dev/null 2>&1) -if(DEFINED ENV{VERBOSE}) - if($ENV{VERBOSE} STREQUAL 1) - set(UMD_OUTPUT "") - endif() -endif() - -# This will build the shared library libdevice.so in build/lib where tt_metal can then find and link it -include(ExternalProject) -ExternalProject_Add( - umd_device - PREFIX ${UMD_HOME} - SOURCE_DIR ${UMD_HOME} - BINARY_DIR ${PROJECT_BINARY_DIR} - INSTALL_DIR ${PROJECT_BINARY_DIR} - STAMP_DIR "${PROJECT_BINARY_DIR}/tmp/umd_stamp" - TMP_DIR "${PROJECT_BINARY_DIR}/tmp/umd_tmp" - DOWNLOAD_COMMAND "" - CONFIGURE_COMMAND "" - INSTALL_COMMAND "" - BUILD_COMMAND - make -f ${UMD_HOME}/device/module.mk umd_device - OUT=${PROJECT_BINARY_DIR} - LIBDIR=${PROJECT_BINARY_DIR}/lib - OBJDIR=${PROJECT_BINARY_DIR}/obj - UMD_HOME=${UMD_HOME} - UMD_VERSIM_STUB=${UMD_VERSIM_STUB} - UMD_VERSIM_HEADERS=${TT_METAL_VERSIM_ROOT}/versim/ - UMD_USER_ROOT=$ENV{TT_METAL_HOME} - WARNINGS=${WARNINGS} - SHARED_LIB_FLAGS=${SHARED_LIB_FLAGS_} - STATIC_LIB_FLAGS=${STATIC_LIB_FLAGS_} - LDFLAGS=${LDFLAGS_} - CXXFLAGS=${CMAKE_CXX_FLAGS_} - DEVICE_CXX=${CMAKE_CXX_COMPILER} - ${UMD_OUTPUT} -) -# add_dependencies(umd_device umd_boost) -if($ENV{ENABLE_TRACY}) - add_dependencies(umd_device TracyClient) -endif() - -# If in production build for python packaging, need to use objs built by umd_device -if(NOT BUILD_SHARED_LIBS) - set(UMD_OBJS - ${UMD_OBJS} - ${PROJECT_BINARY_DIR}/obj/umd/device/architecture_implementation.o - ${PROJECT_BINARY_DIR}/obj/umd/device/blackhole_implementation.o - ${PROJECT_BINARY_DIR}/obj/umd/device/cpuset_lib.o - ${PROJECT_BINARY_DIR}/obj/umd/device/grayskull_implementation.o - ${PROJECT_BINARY_DIR}/obj/umd/device/tt_cluster_descriptor.o - ${PROJECT_BINARY_DIR}/obj/umd/device/tt_device.o - ${PROJECT_BINARY_DIR}/obj/umd/device/tt_emulation_stub.o - ${PROJECT_BINARY_DIR}/obj/umd/device/tt_silicon_driver_common.o - ${PROJECT_BINARY_DIR}/obj/umd/device/tt_silicon_driver.o - ${PROJECT_BINARY_DIR}/obj/umd/device/tt_soc_descriptor.o - ${PROJECT_BINARY_DIR}/obj/umd/device/tt_versim_stub.o - ${PROJECT_BINARY_DIR}/obj/umd/device/tlb.o - ${PROJECT_BINARY_DIR}/obj/umd/device/wormhole_implementation.o - ) - set(UMD_STATIC_LIB ${PROJECT_BINARY_DIR}/lib/libdevice.a) - - # Build static lib with objs created after umd_device is built - add_custom_command( - OUTPUT ${UMD_STATIC_LIB} - COMMAND ar rcs ${UMD_STATIC_LIB} ${UMD_OBJS} - DEPENDS umd_device - COMMENT "Creating static device library" - ) - add_custom_target( - umd_static_lib_target ALL - DEPENDS ${UMD_STATIC_LIB} - ) -endif() +target_link_libraries(umd_device PUBLIC yaml-cpp::yaml-cpp rt compiler_flags) diff --git a/scripts/docker/requirements.txt b/scripts/docker/requirements.txt index 149d6533703..939edef3dce 100644 --- a/scripts/docker/requirements.txt +++ b/scripts/docker/requirements.txt @@ -2,7 +2,6 @@ apt-utils dialog software-properties-common=0.99.9.12 build-essential=12.8ubuntu1.1 -libyaml-cpp-dev=0.6.2-4ubuntu1 git git-lfs pandoc diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 603ba16a917..298f918ef54 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,7 +2,7 @@ enable_testing() include(GoogleTest) add_library(test_common_libs INTERFACE) -target_link_libraries(test_common_libs INTERFACE pthread stdc++fs gtest gtest_main) +target_link_libraries(test_common_libs INTERFACE pthread gtest gtest_main) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tt_metal/tt_metal) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tt_eager) diff --git a/tests/tt_eager/ops/test_eltwise_unary_op.cpp b/tests/tt_eager/ops/test_eltwise_unary_op.cpp index 39ab11d8fe9..10b8a584f17 100644 --- a/tests/tt_eager/ops/test_eltwise_unary_op.cpp +++ b/tests/tt_eager/ops/test_eltwise_unary_op.cpp @@ -111,7 +111,7 @@ void test_operation_infrastructure() { MemoryConfig{.memory_layout = tt::tt_metal::TensorMemoryLayout::INTERLEAVED}}); auto program_hash = op.compute_program_hash({input_tensor}, {}); - TT_FATAL(program_hash == 8014710183226948494ULL, fmt::format("Actual value is {}", program_hash)); + TT_FATAL(program_hash == 3018574135764717736ULL, fmt::format("Actual value is {}", program_hash)); auto profiler_info = op.create_profiler_info({input_tensor}); TT_FATAL( diff --git a/tests/tt_metal/tt_metal/unit_tests/CMakeLists.txt b/tests/tt_metal/tt_metal/unit_tests/CMakeLists.txt index b46d91c320b..e1fadfaafec 100644 --- a/tests/tt_metal/tt_metal/unit_tests/CMakeLists.txt +++ b/tests/tt_metal/tt_metal/unit_tests/CMakeLists.txt @@ -43,6 +43,5 @@ target_include_directories(unit_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/common ${CMAKE_CURRENT_SOURCE_DIR}/circular_buffer - ${gtest_SOURCE_DIR}/include ) set_target_properties(unit_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/tt_metal) diff --git a/tests/tt_metal/tt_metal/unit_tests_common/CMakeLists.txt b/tests/tt_metal/tt_metal/unit_tests_common/CMakeLists.txt index 2a954cbd57a..a3b2d629fc5 100644 --- a/tests/tt_metal/tt_metal/unit_tests_common/CMakeLists.txt +++ b/tests/tt_metal/tt_metal/unit_tests_common/CMakeLists.txt @@ -27,7 +27,7 @@ set(UNIT_TESTS_COMMON_SRC ${CMAKE_CURRENT_SOURCE_DIR}/watcher/test_waypoint.cpp ) add_library(unit_tests_common_o OBJECT ${UNIT_TESTS_COMMON_SRC}) -target_link_libraries(unit_tests_common_o PUBLIC compiler_flags metal_header_directories) +target_link_libraries(unit_tests_common_o PUBLIC compiler_flags metal_header_directories umd_device gtest gtest_main) target_include_directories(unit_tests_common_o PUBLIC ${UMD_HOME} ${PROJECT_SOURCE_DIR} @@ -36,5 +36,4 @@ target_include_directories(unit_tests_common_o PUBLIC ${PROJECT_SOURCE_DIR}/tt_metal/common ${PROJECT_SOURCE_DIR}/tests ${CMAKE_CURRENT_SOURCE_DIR}/common - ${gtest_SOURCE_DIR}/include ) diff --git a/tests/tt_metal/tt_metal/unit_tests_common/common/test_bit_utils.cpp b/tests/tt_metal/tt_metal/unit_tests_common/common/test_bit_utils.cpp index d2a38145462..99f62def780 100644 --- a/tests/tt_metal/tt_metal/unit_tests_common/common/test_bit_utils.cpp +++ b/tests/tt_metal/tt_metal/unit_tests_common/common/test_bit_utils.cpp @@ -74,16 +74,20 @@ TEST(NoFixture, ExtractPackBitArray) { uint32_t src[4] = { 0x12345678, 0x9abcdef0, 0x13579bdf, 0x2468ace0 }; // Compute the number of 3-bit elements that can be packed into 4 x 32-bit elements - const uint32_t num_3_bit_elements = (4 * 32 + 3 - 1) / 3; + const uint32_t num_3_bit_elements = (4 * 32) / 3; uint32_t dest[num_3_bit_elements]; for (uint num_pack_bits = 3; num_pack_bits <= 31; num_pack_bits++) { - const uint32_t num_dest_elements = (4 * 32 + num_pack_bits - 1) / num_pack_bits; + const uint32_t num_dest_elements = (4 * 32) / num_pack_bits; extract_bit_array(src, num_pack_bits, dest, num_dest_elements); uint32_t packed[4]; pack_bit_array(dest, num_pack_bits, packed, num_dest_elements); - for (int i = 0; i < 4; i++) { + + // If the bit length of src is not evenly divisible by num_pack_bits + // then the last element after packing back won't equal the original. + bool has_partial = (num_pack_bits * num_dest_elements) % 32 != 0; + for (int i = 0; i < 4 - has_partial; i++) { EXPECT_EQ(src[i], packed[i]); } } diff --git a/tests/tt_metal/tt_metal/unit_tests_common/watcher/test_assert.cpp b/tests/tt_metal/tt_metal/unit_tests_common/watcher/test_assert.cpp index cfd5caeb985..c982481c102 100644 --- a/tests/tt_metal/tt_metal/unit_tests_common/watcher/test_assert.cpp +++ b/tests/tt_metal/tt_metal/unit_tests_common/watcher/test_assert.cpp @@ -171,10 +171,10 @@ static void RunTest(WatcherFixture *fixture, Device *device, riscv_id_t riscv_ty log_info(LogTest, "Expected error: {}", expected); std::string exception = ""; do { - exception = watcher_server_get_exception_message(); + exception = get_watcher_exception_message(); } while (exception == ""); log_info(LogTest, "Reported error: {}", exception); - EXPECT_TRUE(expected == watcher_server_get_exception_message()); + EXPECT_TRUE(expected == get_watcher_exception_message()); } TEST_F(WatcherFixture, TestWatcherAssertBrisc) { diff --git a/tests/tt_metal/tt_metal/unit_tests_common/watcher/test_noc_sanitize.cpp b/tests/tt_metal/tt_metal/unit_tests_common/watcher/test_noc_sanitize.cpp index 269014962c1..a173220e6a8 100644 --- a/tests/tt_metal/tt_metal/unit_tests_common/watcher/test_noc_sanitize.cpp +++ b/tests/tt_metal/tt_metal/unit_tests_common/watcher/test_noc_sanitize.cpp @@ -181,10 +181,10 @@ void RunTestOnCore(WatcherFixture* fixture, Device* device, CoreCoord &core, boo log_info(LogTest, "Expected error: {}", expected); std::string exception = ""; do { - exception = watcher_server_get_exception_message(); + exception = get_watcher_exception_message(); } while (exception == ""); log_info(LogTest, "Reported error: {}", exception); - EXPECT_TRUE(watcher_server_get_exception_message() == expected); + EXPECT_TRUE(get_watcher_exception_message() == expected); } static void RunTestEth(WatcherFixture* fixture, Device* device) { diff --git a/tests/tt_metal/tt_metal/unit_tests_fast_dispatch/CMakeLists.txt b/tests/tt_metal/tt_metal/unit_tests_fast_dispatch/CMakeLists.txt index 4b4189739b9..23707d70cd5 100644 --- a/tests/tt_metal/tt_metal/unit_tests_fast_dispatch/CMakeLists.txt +++ b/tests/tt_metal/tt_metal/unit_tests_fast_dispatch/CMakeLists.txt @@ -24,6 +24,5 @@ target_include_directories(unit_tests_fast_dispatch PRIVATE ${PROJECT_SOURCE_DIR}/tests ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/common - ${gtest_SOURCE_DIR}/include ) set_target_properties(unit_tests_fast_dispatch PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/tt_metal) diff --git a/tests/tt_metal/tt_metal/unit_tests_fast_dispatch_single_chip_multi_queue/CMakeLists.txt b/tests/tt_metal/tt_metal/unit_tests_fast_dispatch_single_chip_multi_queue/CMakeLists.txt index 4ed39a15588..3b3578ba3c6 100644 --- a/tests/tt_metal/tt_metal/unit_tests_fast_dispatch_single_chip_multi_queue/CMakeLists.txt +++ b/tests/tt_metal/tt_metal/unit_tests_fast_dispatch_single_chip_multi_queue/CMakeLists.txt @@ -15,6 +15,5 @@ target_include_directories(unit_tests_fast_dispatch_single_chip_multi_queue PRIV ${PROJECT_SOURCE_DIR}/tests ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/common - ${gtest_SOURCE_DIR}/include ) set_target_properties(unit_tests_fast_dispatch_single_chip_multi_queue PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/tt_metal) diff --git a/tests/tt_metal/tt_metal/unit_tests_frequent/CMakeLists.txt b/tests/tt_metal/tt_metal/unit_tests_frequent/CMakeLists.txt index 589f2df86dd..7256f7571b3 100644 --- a/tests/tt_metal/tt_metal/unit_tests_frequent/CMakeLists.txt +++ b/tests/tt_metal/tt_metal/unit_tests_frequent/CMakeLists.txt @@ -5,7 +5,7 @@ set(UNIT_TESTS_FREQUENT_SRCS add_executable(unit_tests_frequent ${UNIT_TESTS_FREQUENT_SRCS}) -target_link_libraries(unit_tests_frequent PUBLIC test_metal_common_libs) +target_link_libraries(unit_tests_frequent PUBLIC test_metal_common_libs gtest gtest_main) target_include_directories(unit_tests_frequent PRIVATE ${UMD_HOME} ${PROJECT_SOURCE_DIR} @@ -13,6 +13,5 @@ target_include_directories(unit_tests_frequent PRIVATE ${PROJECT_SOURCE_DIR}/tests ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/common - ${gtest_SOURCE_DIR}/include ) set_target_properties(unit_tests_frequent PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/tt_metal) diff --git a/tests/ttnn/unit_tests/gtests/CMakeLists.txt b/tests/ttnn/unit_tests/gtests/CMakeLists.txt index 05af1e23e00..2c1f825ab68 100644 --- a/tests/ttnn/unit_tests/gtests/CMakeLists.txt +++ b/tests/ttnn/unit_tests/gtests/CMakeLists.txt @@ -15,6 +15,5 @@ target_include_directories(unit_tests_ttnn PRIVATE ${PROJECT_SOURCE_DIR}/tt_metal ${PROJECT_SOURCE_DIR}/tests ${CMAKE_CURRENT_SOURCE_DIR} - ${gtest_SOURCE_DIR}/include ) set_target_properties(unit_tests_ttnn PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test/ttnn) diff --git a/tt_eager/queue/CMakeLists.txt b/tt_eager/queue/CMakeLists.txt index c6d7ab6ff29..71ab6fa5a9a 100644 --- a/tt_eager/queue/CMakeLists.txt +++ b/tt_eager/queue/CMakeLists.txt @@ -4,7 +4,7 @@ set(QUEUE_SRCS ) add_library(queue OBJECT ${QUEUE_SRCS}) -target_link_libraries(queue PUBLIC metal_header_directories compiler_flags) +target_link_libraries(queue PUBLIC metal_header_directories compiler_flags umd_device) target_include_directories(queue PUBLIC ${UMD_HOME} ${PROJECT_SOURCE_DIR} diff --git a/tt_eager/tensor/CMakeLists.txt b/tt_eager/tensor/CMakeLists.txt index adfbdf2fede..cc1b63dc2e1 100644 --- a/tt_eager/tensor/CMakeLists.txt +++ b/tt_eager/tensor/CMakeLists.txt @@ -9,7 +9,7 @@ set(TENSOR_SRCS add_library(tensor OBJECT ${TENSOR_SRCS}) -target_link_libraries(tensor PUBLIC metal_header_directories compiler_flags) +target_link_libraries(tensor PUBLIC metal_header_directories compiler_flags umd_device) target_include_directories(tensor PUBLIC ${UMD_HOME} ${PROJECT_SOURCE_DIR} diff --git a/tt_eager/tensor/host_buffer/functions.hpp b/tt_eager/tensor/host_buffer/functions.hpp index 17c57b253f0..eb77a76f47d 100644 --- a/tt_eager/tensor/host_buffer/functions.hpp +++ b/tt_eager/tensor/host_buffer/functions.hpp @@ -38,7 +38,7 @@ Buffer get_as(BorrowedBuffer& buffer) { } template -const Buffer get_as(const BorrowedBuffer& buffer) { +Buffer get_as(const BorrowedBuffer& buffer) { return std::get>(buffer); } @@ -58,10 +58,10 @@ Buffer get_as(Tensor& tensor) { } template -const Buffer get_as(const Tensor& tensor) { +Buffer get_as(const Tensor& tensor) { validate_datatype(tensor); return std::visit( - [](auto&& storage) -> const Buffer { + [](auto&& storage) -> Buffer { using StorageType = std::decay_t; if constexpr (std::is_same_v) { return get_as(storage.buffer); @@ -111,7 +111,7 @@ Buffer get_as(OwnedBuffer& buffer) { } template -const Buffer get_as(const OwnedBuffer& buffer) { +Buffer get_as(const OwnedBuffer& buffer) { return std::get>(buffer); } @@ -131,10 +131,10 @@ Buffer get_as(Tensor& tensor) { } template -const Buffer get_as(const Tensor& tensor) { +Buffer get_as(const Tensor& tensor) { validate_datatype(tensor); return std::visit( - [](auto&& storage) -> const Buffer { + [](auto&& storage) -> Buffer { using StorageType = std::decay_t; if constexpr (std::is_same_v) { return get_as(storage.buffer); @@ -156,7 +156,7 @@ borrowed_buffer::Buffer get_as(OwnedBuffer& buffer) { } template -const borrowed_buffer::Buffer get_as(const OwnedBuffer& buffer) { +borrowed_buffer::Buffer get_as(const OwnedBuffer& buffer) { auto owned_buffer = std::get>(buffer); return borrowed_buffer::Buffer(owned_buffer.begin(), owned_buffer.size()); } @@ -172,7 +172,7 @@ borrowed_buffer::Buffer get_as(BorrowedBuffer& buffer) { } template -const borrowed_buffer::Buffer get_as(const BorrowedBuffer& buffer) { +borrowed_buffer::Buffer get_as(const BorrowedBuffer& buffer) { return borrowed_buffer::get_as(buffer); } @@ -193,9 +193,9 @@ borrowed_buffer::Buffer get_as(Tensor& tensor) { } template -const borrowed_buffer::Buffer get_as(const Tensor& tensor) { +borrowed_buffer::Buffer get_as(const Tensor& tensor) { return std::visit( - [](auto&& storage) -> const borrowed_buffer::Buffer { + [](auto&& storage) -> borrowed_buffer::Buffer { using StorageType = std::decay_t; if constexpr (std::is_same_v) { return host_buffer::get_as(storage.buffer); diff --git a/tt_eager/tt_dnn/op_library/CMakeLists.txt b/tt_eager/tt_dnn/op_library/CMakeLists.txt index ad766da0669..78b7a28086b 100644 --- a/tt_eager/tt_dnn/op_library/CMakeLists.txt +++ b/tt_eager/tt_dnn/op_library/CMakeLists.txt @@ -216,7 +216,7 @@ set(TT_DNN_SRCS add_library(tt_dnn OBJECT ${TT_DNN_SRCS}) -target_link_libraries(tt_dnn PUBLIC metal_header_directories compiler_flags) +target_link_libraries(tt_dnn PUBLIC metal_header_directories compiler_flags umd_device) target_include_directories(tt_dnn PUBLIC ${UMD_HOME} ${PROJECT_SOURCE_DIR} diff --git a/tt_eager/tt_dnn/op_library/eltwise_binary/eltwise_binary_op.cpp b/tt_eager/tt_dnn/op_library/eltwise_binary/eltwise_binary_op.cpp index f36ecd4729d..2f2486736a6 100644 --- a/tt_eager/tt_dnn/op_library/eltwise_binary/eltwise_binary_op.cpp +++ b/tt_eager/tt_dnn/op_library/eltwise_binary/eltwise_binary_op.cpp @@ -280,8 +280,7 @@ const operation::Hash EltwiseBinary::compute_program_hash(const std::vector( this->op_type, parallelization_strategy, input_tensor_a.dtype(), diff --git a/tt_eager/tt_dnn/op_library/eltwise_unary/eltwise_unary_op.cpp b/tt_eager/tt_dnn/op_library/eltwise_unary/eltwise_unary_op.cpp index 4c8bf9ea574..a7a28239144 100644 --- a/tt_eager/tt_dnn/op_library/eltwise_unary/eltwise_unary_op.cpp +++ b/tt_eager/tt_dnn/op_library/eltwise_unary/eltwise_unary_op.cpp @@ -414,8 +414,7 @@ const operation::Hash EltwiseUnary::compute_program_hash(const std::vector( compute_volume(input_shape), input_tensor.dtype(), std::get(input_tensor.storage()).memory_config(), diff --git a/tt_eager/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.cpp b/tt_eager/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.cpp index 43ee6b71746..6573cf0f125 100644 --- a/tt_eager/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.cpp +++ b/tt_eager/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.cpp @@ -276,8 +276,7 @@ const operation::Hash MorehMatmul::compute_program_hash( const auto& other = input_tensors.at(1); const auto& bias = optional_input_tensors.at(0); - operation::Hash hash = tt::stl::hash::hash_objects_with_default_seed( - typeid(*this).hash_code(), input, other, bias, this->transpose_input, this->transpose_other); + operation::Hash hash = operation::hash_operation(input, other, bias, this->transpose_input, this->transpose_other); return hash; } diff --git a/tt_eager/tt_dnn/op_library/operation.hpp b/tt_eager/tt_dnn/op_library/operation.hpp index 98cb9195b81..5da9685a866 100644 --- a/tt_eager/tt_dnn/op_library/operation.hpp +++ b/tt_eager/tt_dnn/op_library/operation.hpp @@ -23,7 +23,7 @@ using Hash = tt::stl::hash::hash_t; template static Hash hash_operation(const Types&... objects) { - return stl::hash::hash_objects_with_default_seed(typeid(OperationType).hash_code(), objects...); + return stl::hash::hash_objects_with_default_seed(tt::stl::hash::type_hash, objects...); } using OverrideAddressesCallback = diff --git a/tt_metal/CMakeLists.txt b/tt_metal/CMakeLists.txt index ce44aa00226..c65ac96576f 100644 --- a/tt_metal/CMakeLists.txt +++ b/tt_metal/CMakeLists.txt @@ -17,15 +17,10 @@ set(TT_METAL_OBJECTS ) add_library(tt_metal ${TT_METAL_OBJECTS}) -if(BUILD_SHARED_LIBS) - target_link_libraries(tt_metal PUBLIC device metal_common_libs) - add_dependencies(tt_metal umd_device) -else() - target_link_libraries(tt_metal PUBLIC ${UMD_STATIC_LIB} metal_common_libs) - add_dependencies(tt_metal umd_static_lib_target) -endif() -target_link_libraries(tt_metal PUBLIC compiler_flags linker_flags metal_header_directories yaml-cpp $<$:TracyClient>) # linker_flags = -rdynamic if tracy enabled +target_link_libraries(tt_metal PUBLIC umd_device metal_common_libs) + +target_link_libraries(tt_metal PUBLIC compiler_flags linker_flags metal_header_directories yaml-cpp::yaml-cpp $<$:TracyClient>) # linker_flags = -rdynamic if tracy enabled target_link_directories(tt_metal PUBLIC ${PROJECT_BINARY_DIR}/lib) # required so tt_metal can find device library target_include_directories(tt_metal PUBLIC ${UMD_HOME} diff --git a/tt_metal/common/CMakeLists.txt b/tt_metal/common/CMakeLists.txt index 34ac92c372d..7c9cd8e9860 100644 --- a/tt_metal/common/CMakeLists.txt +++ b/tt_metal/common/CMakeLists.txt @@ -6,7 +6,7 @@ set(COMMON_SRCS ) add_library(common OBJECT ${COMMON_SRCS}) -target_link_libraries(common PUBLIC compiler_flags metal_header_directories) +target_link_libraries(common PUBLIC compiler_flags metal_header_directories umd_device) target_include_directories(common PUBLIC ${UMD_HOME} diff --git a/tt_metal/hw/inc/bit_utils.h b/tt_metal/hw/inc/bit_utils.h index cdbecbba25b..0ebe9a44616 100644 --- a/tt_metal/hw/inc/bit_utils.h +++ b/tt_metal/hw/inc/bit_utils.h @@ -4,7 +4,9 @@ #pragma once +#include #include +#include // Given a source array of 32-bit elements that contains a densely-packed array of elements of another size, // extract the packed elements and store each element in the destination array. @@ -29,7 +31,7 @@ void extract_bit_array(uint32_t *src_array, int src_element_bits, uint32_t *dest int bits_to_take = bits_to_process < bits_available ? bits_to_process : bits_available; // Bits to take from the current src_array element // Extract the bits - uint32_t mask = (1 << bits_to_take) - 1; // Mask to extract_bit_array the bits + uint32_t mask = (1 << bits_to_take) - 1u; // Mask to extract_bit_array the bits current_value |= ((src_array[src_index] >> bits_processed) & mask) << (src_element_bits - bits_to_process); bits_processed += bits_to_take; @@ -52,7 +54,9 @@ void extract_bit_array(uint32_t *src_array, int src_element_bits, uint32_t *dest void pack_bit_array(uint32_t *src_array, int src_element_bits, uint32_t *dest_array, int num_src_elements) { int dest_index = 0; // Index for the current destination array element being filled int bits_filled = 0; // Tracks the number of bits filled in the current dest_array element - dest_array[dest_index] = 0; // Initialize the first destination element + + auto dest_bytes = num_src_elements * src_element_bits / CHAR_BIT; + memset(dest_array, 0, dest_bytes); for (int i = 0; i < num_src_elements; i++) { uint32_t current_value = src_array[i]; // Current source element to pack @@ -71,7 +75,6 @@ void pack_bit_array(uint32_t *src_array, int src_element_bits, uint32_t *dest_ar if (bits_filled == 32) { // If the current dest_array element is full, move to the next dest_index++; - dest_array[dest_index] = 0; // Initialize the next destination element bits_filled = 0; // Reset bits filled counter } } diff --git a/tt_metal/impl/debug/watcher_server.cpp b/tt_metal/impl/debug/watcher_server.cpp index 9b353e30594..a3f71c2e383 100644 --- a/tt_metal/impl/debug/watcher_server.cpp +++ b/tt_metal/impl/debug/watcher_server.cpp @@ -47,8 +47,19 @@ static string kernel_file_name = "kernel_names.txt"; // Flag to signal whether the watcher server has been killed due to a thrown exception. static std::atomic watcher_killed_due_to_error = false; -// Description of thrown exception from watcher server, used for testing purposes. -static string watcher_exception_message = ""; +static std::mutex watcher_exception_message_mutex; + +// Function to get the static string +static std::string& watcher_exception_message() { + static std::string message = ""; + return message; +} + +// Function to set the static string +static void set_watcher_exception_message(const std::string& message) { + std::lock_guard lock(watcher_exception_message_mutex); + watcher_exception_message() = message; +} static double get_elapsed_secs() { std::chrono::time_point now_time = std::chrono::system_clock::now(); @@ -352,7 +363,7 @@ static void dump_noc_sanity_status( log_ring_buffer(device, core); log_running_kernels(launch_msg); // Save the error string for checking later in unit tests. - watcher::watcher_exception_message = fmt::format("{}: {}", core_str, error_msg); + set_watcher_exception_message(fmt::format("{}: {}", core_str, error_msg)); TT_THROW(error_reason); } } @@ -383,7 +394,7 @@ static void dump_assert_status( log_waypoint(core, launch_msg, debug_status); log_ring_buffer(device, core); log_running_kernels(launch_msg); - watcher::watcher_exception_message = error_msg; + set_watcher_exception_message(error_msg); TT_THROW("Watcher detected tripped assert and stopped device."); break; } @@ -1082,7 +1093,7 @@ void watcher_attach(Device *device) { watcher::create_kernel_file(); } watcher::watcher_killed_due_to_error = false; - watcher::watcher_exception_message = ""; + watcher::set_watcher_exception_message(""); watcher::enabled = true; @@ -1153,8 +1164,6 @@ bool watcher_server_killed_due_to_error() { return watcher::watcher_killed_due_t void watcher_server_set_error_flag(bool val) { watcher::watcher_killed_due_to_error = val; } -string watcher_server_get_exception_message() { return watcher::watcher_exception_message; } - void watcher_clear_log() { watcher::create_log_file(); } string watcher_get_log_file_name() { @@ -1187,4 +1196,10 @@ void watcher_read_kernel_ids_from_file() { } } +// Function to get the static string value +std::string get_watcher_exception_message() { + std::lock_guard lock(watcher::watcher_exception_message_mutex); + return watcher::watcher_exception_message(); +} + } // namespace tt diff --git a/tt_metal/impl/debug/watcher_server.hpp b/tt_metal/impl/debug/watcher_server.hpp index a7c3960815f..cd071b3f318 100644 --- a/tt_metal/impl/debug/watcher_server.hpp +++ b/tt_metal/impl/debug/watcher_server.hpp @@ -25,7 +25,9 @@ void watcher_read_kernel_ids_from_file(); // that flag. Used in test mode only. bool watcher_server_killed_due_to_error(); void watcher_server_set_error_flag(bool val); -string watcher_server_get_exception_message(); + +// Description of thrown exception from watcher server, used for testing purposes. +std::string get_watcher_exception_message(); // Helper function to clear the watcher log file void watcher_clear_log(); diff --git a/tt_metal/jit_build/settings.hpp b/tt_metal/jit_build/settings.hpp index 80d6e2e52c3..485d263d2a9 100644 --- a/tt_metal/jit_build/settings.hpp +++ b/tt_metal/jit_build/settings.hpp @@ -4,19 +4,19 @@ #pragma once +#include + #include "common/core_coord.h" #include "common/utils.hpp" -#include "hostdevcommon/kernel_structs.h" #include "hlk_desc.hpp" +#include "hostdevcommon/kernel_structs.h" -namespace tt::tt_metal -{ +namespace tt::tt_metal { class JitBuildEnv; class JitBuildOptions { - public: - + public: // general config const JitBuildEnv& build_env; std::string name; @@ -37,7 +37,7 @@ class JitBuildOptions { // ERISC config std::string erisc_kernel_file_name; - std::map hlk_defines; // preprocessor defines for HLK + std::map hlk_defines; // preprocessor defines for HLK std::map ncrisc_defines; std::map brisc_defines; std::map erisc_defines; @@ -45,14 +45,14 @@ class JitBuildOptions { JitBuildOptions(const JitBuildEnv& env); void set_name(const std::string& name); - void set_hlk_file_name_all_cores(std::string file_name) ; - void set_hlk_math_fidelity_all_cores(MathFidelity math_fidelity) ; + void set_hlk_file_name_all_cores(std::string file_name); + void set_hlk_math_fidelity_all_cores(MathFidelity math_fidelity); void set_hlk_math_approx_mode_all_cores(bool approx_mode); - void set_hlk_args_all_cores(void *args, size_t size) ; + void set_hlk_args_all_cores(void* args, size_t size); void set_cb_dataformat_all_cores(CB cb_id, DataFormat data_format); // old API name void set_hlk_operand_dataformat_all_cores(HlkOperand op_id, DataFormat data_format); }; -} // end namespace tt +} // namespace tt::tt_metal diff --git a/tt_metal/tools/CMakeLists.txt b/tt_metal/tools/CMakeLists.txt index fb09ed6225b..796c7238979 100644 --- a/tt_metal/tools/CMakeLists.txt +++ b/tt_metal/tools/CMakeLists.txt @@ -1,4 +1,3 @@ - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/profiler) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/watcher_dump) diff --git a/tt_metal/tt_stl/reflection.hpp b/tt_metal/tt_stl/reflection.hpp index e610693f313..293e23ffc6b 100644 --- a/tt_metal/tt_stl/reflection.hpp +++ b/tt_metal/tt_stl/reflection.hpp @@ -39,6 +39,11 @@ constexpr bool DEBUG_HASH_OBJECT_FUNCTION = false; using hash_t = std::uint64_t; constexpr hash_t DEFAULT_SEED = 1234; +// stuff this in a header somewhere +inline int type_hash_counter = 0; +template +inline const int type_hash = type_hash_counter++; + namespace detail { template @@ -356,7 +361,7 @@ template std::ostream& operator<<(std::ostream& os, const std::vector& vector) { os << "{"; for (auto index = 0; index < vector.size(); index++) { - const auto& element = vector[index]; + const T& element = vector[index]; os << element; if (index != vector.size() - 1) { os << ", "; diff --git a/ttnn/CMakeLists.txt b/ttnn/CMakeLists.txt index fdf3d9ea6cf..8679b400270 100644 --- a/ttnn/CMakeLists.txt +++ b/ttnn/CMakeLists.txt @@ -9,7 +9,7 @@ set(TTNN_SRCS ) add_library(ttnn_lib OBJECT ${TTNN_SRCS}) target_compile_options(ttnn_lib PUBLIC -MP -Wno-int-to-pointer-cast -fno-var-tracking) -target_link_libraries(ttnn_lib PUBLIC compiler_flags metal_header_directories metal_common_libs) +target_link_libraries(ttnn_lib PUBLIC compiler_flags metal_header_directories metal_common_libs umd_device) target_include_directories(ttnn_lib PUBLIC ${UMD_HOME} ${PROJECT_SOURCE_DIR} diff --git a/ttnn/cpp/ttnn/op_library/binary/binary_op.cpp b/ttnn/cpp/ttnn/op_library/binary/binary_op.cpp index b73c63d819f..280b9d98f5d 100644 --- a/ttnn/cpp/ttnn/op_library/binary/binary_op.cpp +++ b/ttnn/cpp/ttnn/op_library/binary/binary_op.cpp @@ -304,8 +304,7 @@ const operation::Hash Binary::compute_program_hash(const std::vector& in const auto& input_tensor_a = input_tensors.at(0); const auto& input_tensor_b = input_tensors.at(1); auto program_type = get_program_type(*this, input_tensors); - operation::Hash hash = tt::stl::hash::hash_objects_with_default_seed( - typeid(*this).hash_code(), + operation::Hash hash = operation::hash_operation( this->program_config, program_type, input_tensor_a.dtype(),