diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..21dc1a35 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +device/libs/**/*.a filter=lfs diff=lfs merge=lfs -text diff --git a/.github/docker_install_common.sh b/.github/docker_install_common.sh index c5a8d93a..7a98fe15 100644 --- a/.github/docker_install_common.sh +++ b/.github/docker_install_common.sh @@ -7,6 +7,7 @@ apt-get update && apt-get install -y \ cmake \ ninja-build \ git \ + git-lfs \ libhwloc-dev \ libgtest-dev \ libyaml-cpp-dev \ diff --git a/.github/workflows/build-device.yml b/.github/workflows/build-device.yml index 0175724c..5a8c0648 100644 --- a/.github/workflows/build-device.yml +++ b/.github/workflows/build-device.yml @@ -44,6 +44,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive + lfs: 'true' - name: Build ${{ env.BUILD_TARGET }} run: | diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 54b534b7..3c21f65d 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -28,6 +28,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + with: + submodules: recursive + lfs: 'true' - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/.github/workflows/build-tests.yml b/.github/workflows/build-tests.yml index 149db6ec..5edd35eb 100644 --- a/.github/workflows/build-tests.yml +++ b/.github/workflows/build-tests.yml @@ -33,7 +33,6 @@ env: LIB_OUTPUT_DIR: ./build/lib DEPS_OUTPUT_DIR: ./build/_deps TEST_OUTPUT_DIR: ./build/test - CREATE_MAP_BINARIES_DIR: ./device/bin/silicon jobs: build: @@ -59,6 +58,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive + lfs: 'true' - name: Build ${{ env.BUILD_TARGET }} run: | @@ -74,8 +74,7 @@ jobs: run: | tar cvf artifact.tar ${{ env.TEST_OUTPUT_DIR }} \ ${{ env.LIB_OUTPUT_DIR }} \ - ${{ env.DEPS_OUTPUT_DIR }} \ - ${{ env.CREATE_MAP_BINARIES_DIR }} + ${{ env.DEPS_OUTPUT_DIR }} - name: Upload build artifacts archive uses: actions/upload-artifact@v4 diff --git a/device/CMakeLists.txt b/device/CMakeLists.txt index 5065f746..40a09728 100644 --- a/device/CMakeLists.txt +++ b/device/CMakeLists.txt @@ -54,6 +54,7 @@ target_link_libraries( Boost::interprocess fmt::fmt-header-only yaml-cpp::yaml-cpp + ${CMAKE_CURRENT_SOURCE_DIR}/libs/${CMAKE_SYSTEM_PROCESSOR}/libcreate_ethernet_map.a ) install( diff --git a/device/bin/silicon/aarch64/create-ethernet-map b/device/bin/silicon/aarch64/create-ethernet-map deleted file mode 100755 index 8e76fa09..00000000 Binary files a/device/bin/silicon/aarch64/create-ethernet-map and /dev/null differ diff --git a/device/bin/silicon/x86/create-ethernet-map b/device/bin/silicon/x86/create-ethernet-map deleted file mode 100755 index c4e3e731..00000000 Binary files a/device/bin/silicon/x86/create-ethernet-map and /dev/null differ diff --git a/device/libs/README.md b/device/libs/README.md new file mode 100644 index 00000000..ef69c138 --- /dev/null +++ b/device/libs/README.md @@ -0,0 +1,9 @@ +## Building lib from source + +The source can be found in the repository: https://github.com/tenstorrent/luwen + +To build static lib, use the following commands: +``` +cargo build -p create-ethernet-map --release --lib +cross build --target aarch64-unknown-linux-gnu --release --lib -p create-ethernet-map +``` diff --git a/device/libs/aarch64/libcreate_ethernet_map.a b/device/libs/aarch64/libcreate_ethernet_map.a new file mode 100644 index 00000000..8811946f --- /dev/null +++ b/device/libs/aarch64/libcreate_ethernet_map.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff4aeeb92fdccaadb1e973b654ae59c7861c95ca40527efe31e8c323b7ae2f08 +size 25186398 diff --git a/device/libs/create_ethernet_map.h b/device/libs/create_ethernet_map.h new file mode 100644 index 00000000..84164085 --- /dev/null +++ b/device/libs/create_ethernet_map.h @@ -0,0 +1,4 @@ +// External function to create the cluster descriptor yaml file. +extern "C" { +int create_ethernet_map(char *file); +} diff --git a/device/libs/x86_64/libcreate_ethernet_map.a b/device/libs/x86_64/libcreate_ethernet_map.a new file mode 100644 index 00000000..51da88bf --- /dev/null +++ b/device/libs/x86_64/libcreate_ethernet_map.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97839a9fc3277505dbbf877df522c4909ea1237a0d86886b38a81bfd287b1bcc +size 23634360 diff --git a/device/tt_cluster_descriptor.cpp b/device/tt_cluster_descriptor.cpp index 558fb0ab..0c4576d1 100644 --- a/device/tt_cluster_descriptor.cpp +++ b/device/tt_cluster_descriptor.cpp @@ -4,6 +4,7 @@ #include "tt_cluster_descriptor.h" +#include "libs/create_ethernet_map.h" #include #include @@ -298,6 +299,25 @@ chip_id_t tt_ClusterDescriptor::get_closest_mmio_capable_chip(const chip_id_t ch return closest_chip; } +std::string tt_ClusterDescriptor::get_cluster_descriptor_file_path() { + static std::string yaml_path; + static bool is_initialized = false; + if (!is_initialized){ + // Cluster descriptor path will be created in the working directory. + std::filesystem::path cluster_path = std::filesystem::path("cluster_descriptor.yaml"); + if (!std::filesystem::exists(cluster_path)){ + auto val = system ( ("touch " + cluster_path.string()).c_str()); + if(val != 0) throw std::runtime_error("Cluster Generation Failed!"); + } + + int val = create_ethernet_map((char*)cluster_path.string().c_str()); + if(val != 0) throw std::runtime_error("Cluster Generation Failed!"); + yaml_path = cluster_path.string(); + is_initialized = true; + } + return yaml_path; +} + std::unique_ptr tt_ClusterDescriptor::create_from_yaml(const std::string &cluster_descriptor_file_path) { std::unique_ptr desc = std::unique_ptr(new tt_ClusterDescriptor()); diff --git a/device/tt_cluster_descriptor.h b/device/tt_cluster_descriptor.h index ea8d0f52..ad2926b9 100644 --- a/device/tt_cluster_descriptor.h +++ b/device/tt_cluster_descriptor.h @@ -83,6 +83,10 @@ class tt_ClusterDescriptor { bool is_chip_remote(const chip_id_t chip_id) const; chip_id_t get_closest_mmio_capable_chip(const chip_id_t chip); chip_id_t get_shelf_local_physical_chip_coords(chip_id_t virtual_coord); + + // TODO: These following functions will be removed, and ClusterDescriptor will be created without any parameters. + // get_cluster_descriptor_file_path will create ethernet map in the background. + static std::string get_cluster_descriptor_file_path(); static std::unique_ptr create_from_yaml(const std::string &cluster_descriptor_file_path); static std::unique_ptr create_for_grayskull_cluster( const std::set &logical_mmio_device_ids, diff --git a/tests/api/test_chip.cpp b/tests/api/test_chip.cpp index bbecf97f..308bc9e0 100644 --- a/tests/api/test_chip.cpp +++ b/tests/api/test_chip.cpp @@ -54,7 +54,7 @@ inline std::unique_ptr get_cluster_desc() { cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path); } else { // TODO: remove getting manually cluster descriptor from yaml. - std::string yaml_path = test_utils::GetClusterDescYAML(); + std::string yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path); } @@ -92,7 +92,7 @@ inline std::unique_ptr get_cluster() { yaml_path = test_utils::GetAbsPath("blackhole_1chip_cluster.yaml"); } else { // TODO: remove getting manually cluster descriptor from yaml. - yaml_path = test_utils::GetClusterDescYAML(); + yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); } // TODO: Remove the need to do this, allow default constructor to construct with all chips. std::unique_ptr cluster_desc = get_cluster_desc(); @@ -123,6 +123,11 @@ inline std::unique_ptr get_cluster() { TEST(ApiChipTest, ManualTLBConfiguration) { std::unique_ptr umd_cluster = get_cluster(); + if (umd_cluster == nullptr || umd_cluster->get_all_chips_in_cluster().empty()) { + std::cout << "No chips found. Skipping test." << std::endl; + return; + } + // Expect to throw for remote chip for any worker core auto remote_chips = umd_cluster->get_target_remote_device_ids(); if (!remote_chips.empty()) { @@ -177,6 +182,12 @@ TEST(ApiChipTest, ManualTLBConfiguration) { // TODO: Move to test_chip TEST(ApiChipTest, SimpleAPIShowcase) { std::unique_ptr umd_cluster = get_cluster(); + + if (umd_cluster == nullptr || umd_cluster->get_all_chips_in_cluster().empty()) { + std::cout << "No chips found. Skipping test." << std::endl; + return; + } + chip_id_t chip_id = umd_cluster->get_cluster_description()->get_chips_with_mmio().begin()->first; // TODO: In future, will be accessed through tt::umd::Chip api. diff --git a/tests/api/test_cluster.cpp b/tests/api/test_cluster.cpp index 9dca1fa5..258598dc 100644 --- a/tests/api/test_cluster.cpp +++ b/tests/api/test_cluster.cpp @@ -66,7 +66,7 @@ inline std::unique_ptr get_cluster_desc() { cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path); } else { // TODO: remove getting manually cluster descriptor from yaml. - std::string yaml_path = test_utils::GetClusterDescYAML(); + std::string yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path); } @@ -104,7 +104,7 @@ inline std::unique_ptr get_cluster() { yaml_path = test_utils::GetAbsPath("blackhole_1chip_cluster.yaml"); } else { // TODO: remove getting manually cluster descriptor from yaml. - yaml_path = test_utils::GetClusterDescYAML(); + yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); } // TODO: Remove the need to do this, allow default constructor to construct with all chips. std::unique_ptr cluster_desc = get_cluster_desc(); diff --git a/tests/api/test_cluster_descriptor.cpp b/tests/api/test_cluster_descriptor.cpp index dd38b285..1441a991 100644 --- a/tests/api/test_cluster_descriptor.cpp +++ b/tests/api/test_cluster_descriptor.cpp @@ -45,7 +45,7 @@ inline std::unique_ptr get_cluster_desc() { cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path); } else { // TODO: remove getting manually cluster descriptor from yaml. - std::string yaml_path = test_utils::GetClusterDescYAML(); + std::string yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path); } diff --git a/tests/blackhole/test_bh_common.h b/tests/blackhole/test_bh_common.h index 781418ef..3002eb93 100644 --- a/tests/blackhole/test_bh_common.h +++ b/tests/blackhole/test_bh_common.h @@ -61,7 +61,7 @@ class BlackholeTestFixture : public ::testing::Test { std::iota(devices.begin(), devices.end(), 0); std::set target_devices = {devices.begin(), devices.end()}; uint32_t num_host_mem_ch_per_mmio_device = 1; - device = std::make_unique(test_utils::GetAbsPath(SOC_DESC_PATH), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + device = std::make_unique(test_utils::GetAbsPath(SOC_DESC_PATH), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); assert(device != nullptr); assert(device->get_cluster_description()->get_number_of_chips() == get_detected_num_chips()); diff --git a/tests/blackhole/test_silicon_driver_bh.cpp b/tests/blackhole/test_silicon_driver_bh.cpp index 2302400f..b7fa45ac 100644 --- a/tests/blackhole/test_silicon_driver_bh.cpp +++ b/tests/blackhole/test_silicon_driver_bh.cpp @@ -97,14 +97,14 @@ TEST(SiliconDriverBH, CreateDestroy) { // std::unordered_map simulated_harvesting_masks = {{0, 30}, {1, 60}}; // { -// std::unique_ptr cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML()); +// std::unique_ptr cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path()); // if (cluster_desc_uniq->get_number_of_chips() != target_devices.size()) { // GTEST_SKIP() << "SiliconDriverWH.Harvesting skipped because it can only be run on a two chip nebula system"; // } // } // uint32_t num_host_mem_ch_per_mmio_device = 1; -// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_8x10.yaml", test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); +// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_8x10.yaml", tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); // auto sdesc_per_chip = device.get_virtual_soc_descriptors(); // ASSERT_EQ(device.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; @@ -120,7 +120,7 @@ TEST(SiliconDriverBH, CreateDestroy) { // std::set target_devices = {0, 1}; // std::unordered_map simulated_harvesting_masks = {{0, 30}, {1, 60}}; // { -// std::unique_ptr cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML()); +// std::unique_ptr cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path()); // if (cluster_desc_uniq->get_number_of_chips() != target_devices.size()) { // GTEST_SKIP() << "SiliconDriverWH.Harvesting skipped because it can only be run on a two chip nebula system"; // } @@ -128,7 +128,7 @@ TEST(SiliconDriverBH, CreateDestroy) { // uint32_t num_host_mem_ch_per_mmio_device = 1; // // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting -// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_1x1.yaml", test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, false, simulated_harvesting_masks); +// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_1x1.yaml", tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, false, simulated_harvesting_masks); // auto sdesc_per_chip = device.get_virtual_soc_descriptors(); // ASSERT_EQ(device.using_harvested_soc_descriptors(), false) << "SOC descriptors should not be modified when harvesting is disabled"; @@ -146,7 +146,7 @@ TEST(SiliconDriverBH, CreateDestroy) { // std::set target_devices = {0, 1}; // std::unordered_map simulated_harvesting_masks = {{0, 30}, {1, 60}}; // { -// std::unique_ptr cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML()); +// std::unique_ptr cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path()); // if (cluster_desc_uniq->get_number_of_chips() != target_devices.size()) { // GTEST_SKIP() << "SiliconDriverWH.Harvesting skipped because it can only be run on a two chip nebula system"; // } @@ -154,7 +154,7 @@ TEST(SiliconDriverBH, CreateDestroy) { // uint32_t num_host_mem_ch_per_mmio_device = 1; -// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_8x10.yaml", test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); +// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_8x10.yaml", tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); // set_params_for_remote_txn(device); // auto mmio_devices = device.get_target_mmio_device_ids(); diff --git a/tests/galaxy/test_umd_concurrent_threads.cpp b/tests/galaxy/test_umd_concurrent_threads.cpp index b11ff929..8d604305 100644 --- a/tests/galaxy/test_umd_concurrent_threads.cpp +++ b/tests/galaxy/test_umd_concurrent_threads.cpp @@ -25,7 +25,7 @@ static const std::string SOC_DESC_PATH = "tests/soc_descs/wormhole_b0_8x10.yaml" TEST(GalaxyConcurrentThreads, WriteToAllChipsL1) { // Galaxy Setup - std::string cluster_desc_path = test_utils::GetClusterDescYAML(); + std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); std::shared_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path); std::set target_devices_th1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; std::set target_devices_th2 = {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}; @@ -113,7 +113,7 @@ TEST(GalaxyConcurrentThreads, WriteToAllChipsL1) { TEST(GalaxyConcurrentThreads, WriteToAllChipsDram) { // Galaxy Setup - std::string cluster_desc_path = test_utils::GetClusterDescYAML(); + std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); std::shared_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path); std::set target_devices_th1 = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32}; std::set target_devices_th2 = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}; @@ -204,7 +204,7 @@ TEST(GalaxyConcurrentThreads, WriteToAllChipsDram) { TEST(GalaxyConcurrentThreads, PushInputsWhileSignalingCluster) { // Galaxy Setup - std::string cluster_desc_path = test_utils::GetClusterDescYAML(); + std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); std::shared_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path); std::set target_devices = {0, 1, 2, 3, 4, 5, 6, 7, 8}; for (const auto& chip : target_devices) { diff --git a/tests/galaxy/test_umd_remote_api.cpp b/tests/galaxy/test_umd_remote_api.cpp index 8e7b7c11..dbc5f6ff 100644 --- a/tests/galaxy/test_umd_remote_api.cpp +++ b/tests/galaxy/test_umd_remote_api.cpp @@ -22,7 +22,7 @@ static const std::string SOC_DESC_PATH = "tests/soc_descs/wormhole_b0_8x10.yaml" void run_remote_read_write_test(uint32_t vector_size, bool dram_write) { // Galaxy Setup - std::string cluster_desc_path = test_utils::GetClusterDescYAML(); + std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); std::shared_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path); std::set target_devices = {}; for (const auto& chip : cluster_desc->get_all_chips()) { @@ -126,7 +126,7 @@ TEST(GalaxyBasicReadWrite, LargeRemoteDramBlockReadWrite) { run_remote_read_writ void run_data_mover_test( uint32_t vector_size, tt_multichip_core_addr sender_core, tt_multichip_core_addr receiver_core) { // Galaxy Setup - std::string cluster_desc_path = test_utils::GetClusterDescYAML(); + std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); std::shared_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path); std::set target_devices = {}; for (const auto& chip : cluster_desc->get_all_chips()) { @@ -240,7 +240,7 @@ TEST(GalaxyDataMovement, TwoChipMoveData4) { void run_data_broadcast_test( uint32_t vector_size, tt_multichip_core_addr sender_core, std::vector receiver_cores) { // Galaxy Setup - std::string cluster_desc_path = test_utils::GetClusterDescYAML(); + std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path(); std::shared_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path); std::set target_devices = {}; for (const auto& chip : cluster_desc->get_all_chips()) { diff --git a/tests/galaxy/test_umd_remote_api_stability.cpp b/tests/galaxy/test_umd_remote_api_stability.cpp index 9dac7ce7..3d148528 100644 --- a/tests/galaxy/test_umd_remote_api_stability.cpp +++ b/tests/galaxy/test_umd_remote_api_stability.cpp @@ -37,7 +37,7 @@ class WormholeGalaxyStabilityTestFixture : public WormholeTestFixture { static uint32_t scale_number_of_tests; static void SetUpTestSuite() { - std::unique_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML()); + std::unique_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path()); detected_num_chips = cluster_desc->get_number_of_chips(); if (detected_num_chips < EXPECTED_MIN_CHIPS) { skip_tests = true; diff --git a/tests/test_utils/generate_cluster_desc.cpp b/tests/test_utils/generate_cluster_desc.cpp deleted file mode 100644 index 6ac9bd3d..00000000 --- a/tests/test_utils/generate_cluster_desc.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "tests/test_utils/generate_cluster_desc.hpp" -#include "device/tt_device.h" - -namespace test_utils { -fs::path generate_cluster_desc_yaml() { - fs::path umd_path = fs::path ( __FILE__ ).parent_path().parent_path() / ".umd"; - fs::create_directory( umd_path ); - umd_path /= "cluster_desc.yaml"; - if (!fs::exists(umd_path)){ - auto val = system ( ("touch " + umd_path.string()).c_str()); - if(val != 0) throw std::runtime_error("Cluster Generation Failed!"); - } - // Generates the cluster descriptor in the CWD - - fs::path eth_fpath = fs::path ( __FILE__ ).parent_path().parent_path().parent_path(); - eth_fpath /= "device/bin/silicon/x86/create-ethernet-map"; - std::string cmd = fmt::format("{} {}", eth_fpath.string(), umd_path.string()); - int val = system(cmd.c_str()); - if(val != 0) throw std::runtime_error("Cluster Generation Failed!"); - - return fs::absolute(umd_path); -} -} - -fs::path GetClusterDescYAML() -{ - static fs::path yaml_path{test_utils::generate_cluster_desc_yaml()}; - return yaml_path; -} - diff --git a/tests/test_utils/generate_cluster_desc.hpp b/tests/test_utils/generate_cluster_desc.hpp index d96ed091..145f011a 100644 --- a/tests/test_utils/generate_cluster_desc.hpp +++ b/tests/test_utils/generate_cluster_desc.hpp @@ -27,29 +27,4 @@ inline std::string GetAbsPath(std::string path_){ std::filesystem::path abs_path = umd_root / path_; return abs_path.string(); } - -inline std::string GetClusterDescYAML(){ - static std::string yaml_path; - static bool is_initialized = false; - if (!is_initialized){ - std::filesystem::path umd_path = std::filesystem::path(test_utils::GetAbsPath("")); - std::filesystem::path cluster_path = umd_path / ".umd"; - std::filesystem::create_directories( cluster_path ); - - cluster_path /= "cluster_desc.yaml"; - if (!std::filesystem::exists(cluster_path)){ - auto val = system ( ("touch " + cluster_path.string()).c_str()); - if(val != 0) throw std::runtime_error("Cluster Generation Failed!"); - } - // Generates the cluster descriptor in the CWD - - std::filesystem::path eth_fpath = umd_path / "device/bin/silicon/x86/create-ethernet-map"; - std::string cmd = fmt::format("{} {}", eth_fpath.string(), cluster_path.string()); - int val = system(cmd.c_str()); - if(val != 0) throw std::runtime_error("Cluster Generation Failed!"); - yaml_path = cluster_path.string(); - is_initialized = true; - } - return yaml_path; -} } // namespace test_utils diff --git a/tests/wormhole/test_silicon_driver_wh.cpp b/tests/wormhole/test_silicon_driver_wh.cpp index 722be47b..a0c74775 100644 --- a/tests/wormhole/test_silicon_driver_wh.cpp +++ b/tests/wormhole/test_silicon_driver_wh.cpp @@ -84,7 +84,7 @@ std::int32_t get_static_tlb_index(tt_xy_pair target) { std::set get_target_devices() { std::set target_devices; - std::unique_ptr cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML()); + std::unique_ptr cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path()); for (int i = 0; i < cluster_desc_uniq->get_number_of_chips(); i++) { target_devices.insert(i); } @@ -97,7 +97,7 @@ TEST(SiliconDriverWH, CreateDestroy) { tt_device_params default_params; // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting for(int i = 0; i < 50; i++) { - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_1x1.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, false); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_1x1.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, false); set_params_for_remote_txn(device); device.start_device(default_params); device.deassert_risc_reset(); @@ -111,7 +111,7 @@ TEST(SiliconDriverWH, Harvesting) { std::unordered_map simulated_harvesting_masks = {{0, 30}, {1, 60}}; uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); auto sdesc_per_chip = device.get_virtual_soc_descriptors(); ASSERT_EQ(device.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; @@ -130,7 +130,7 @@ TEST(SiliconDriverWH, CustomSocDesc) { uint32_t num_host_mem_ch_per_mmio_device = 1; // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_1x1.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, false, simulated_harvesting_masks); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_1x1.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, false, simulated_harvesting_masks); auto sdesc_per_chip = device.get_virtual_soc_descriptors(); ASSERT_EQ(device.using_harvested_soc_descriptors(), false) << "SOC descriptors should not be modified when harvesting is disabled"; @@ -153,7 +153,7 @@ TEST(SiliconDriverWH, HarvestingRuntime) { uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); set_params_for_remote_txn(device); auto mmio_devices = device.get_target_mmio_device_ids(); @@ -218,7 +218,7 @@ TEST(SiliconDriverWH, UnalignedStaticTLB_RW) { uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); set_params_for_remote_txn(device); auto mmio_devices = device.get_target_mmio_device_ids(); @@ -277,7 +277,7 @@ TEST(SiliconDriverWH, StaticTLB_RW) { uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); set_params_for_remote_txn(device); auto mmio_devices = device.get_target_mmio_device_ids(); @@ -326,7 +326,7 @@ TEST(SiliconDriverWH, DynamicTLB_RW) { std::set target_devices = get_target_devices(); uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); set_params_for_remote_txn(device); @@ -364,7 +364,7 @@ TEST(SiliconDriverWH, MultiThreadedDevice) { std::set target_devices = get_target_devices(); uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); set_params_for_remote_txn(device); @@ -423,7 +423,7 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { uint32_t base_addr = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); set_params_for_remote_txn(device); auto mmio_devices = device.get_target_mmio_device_ids(); @@ -530,7 +530,7 @@ TEST(SiliconDriverWH, BroadcastWrite) { uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); set_params_for_remote_txn(device); auto mmio_devices = device.get_target_mmio_device_ids(); @@ -586,7 +586,7 @@ TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { uint32_t num_host_mem_ch_per_mmio_device = 1; - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); set_params_for_remote_txn(device); auto mmio_devices = device.get_target_mmio_device_ids(); @@ -669,7 +669,7 @@ TEST(SiliconDriverWH, SysmemTestWithPcie) { auto target_devices = get_target_devices(); tt_SiliconDevice device(test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_8x10.yaml"), - test_utils::GetClusterDescYAML(), + tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, 1, // one "host memory channel", currently a 1G huge page false, // skip driver allocs - no (don't skip) diff --git a/tests/wormhole/test_umd_remote_api_stability.cpp b/tests/wormhole/test_umd_remote_api_stability.cpp index 96fef09a..0850b71b 100644 --- a/tests/wormhole/test_umd_remote_api_stability.cpp +++ b/tests/wormhole/test_umd_remote_api_stability.cpp @@ -37,7 +37,7 @@ class WormholeNebulaX2TestFixture : public WormholeTestFixture { static uint32_t scale_number_of_tests; static void SetUpTestSuite() { - std::unique_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML()); + std::unique_ptr cluster_desc = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path()); detected_num_chips = cluster_desc->get_number_of_chips(); if (detected_num_chips != EXPECTED_NUM_CHIPS) { skip_tests = true; diff --git a/tests/wormhole/test_wh_common.h b/tests/wormhole/test_wh_common.h index d54ce16f..288d0ff6 100644 --- a/tests/wormhole/test_wh_common.h +++ b/tests/wormhole/test_wh_common.h @@ -59,7 +59,7 @@ class WormholeTestFixture : public ::testing::Test { std::iota(devices.begin(), devices.end(), 0); std::set target_devices = {devices.begin(), devices.end()}; uint32_t num_host_mem_ch_per_mmio_device = 1; - device = std::make_unique(test_utils::GetAbsPath(SOC_DESC_PATH), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); + device = std::make_unique(test_utils::GetAbsPath(SOC_DESC_PATH), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true); assert(device != nullptr); assert(device->get_cluster_description()->get_number_of_chips() == get_detected_num_chips());