From e9dc0d12fc24aba9196b05e6ba142be475447694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Ro=C5=A1ko?= <156314064+broskoTT@users.noreply.github.com> Date: Fri, 22 Nov 2024 13:33:07 +0100 Subject: [PATCH] create_for_grayskull_cluster -> create_mock_cluster (#310) ### Issue Contributes to #99 , and a continuation of #280 ### Description This function is now only used for creating a cluster descriptor for simulation or mockup environment. Changing accordingly. ### List of the changes - Renamed create_for_grayskull_cluster to create_mock_cluster - Changed arguments and functionality so that this function does not accept physical device ids at all. - Accepting std::vector instead of std::set for logical device ids ### Testing Code builds. ### API Changes This PR has API changes: - [x] tt_metal approved PR pointing to this branch: https://github.com/tenstorrent/tt-metal/pull/15301 - tt_debuda doesn't use this --------- Co-authored-by: Vincent Tang --- .../deprecated/tt_emulation_device.cpp | 4 +- .../deprecated/tt_versim_device.cpp | 3 +- device/tt_cluster_descriptor.cpp | 50 +++++++------------ device/tt_cluster_descriptor.h | 9 ++-- 4 files changed, 25 insertions(+), 41 deletions(-) diff --git a/device/simulation/deprecated/tt_emulation_device.cpp b/device/simulation/deprecated/tt_emulation_device.cpp index e7d66893..8f096e64 100644 --- a/device/simulation/deprecated/tt_emulation_device.cpp +++ b/device/simulation/deprecated/tt_emulation_device.cpp @@ -14,9 +14,7 @@ tt_emulation_device::tt_emulation_device(const std::string& sdesc_path) : tt_device(sdesc_path) { soc_descriptor_per_chip.emplace(0, tt_SocDescriptor(sdesc_path)); - std::set target_devices = {0}; - // create just a default one, we do not have cluster anyway - ndesc = tt_ClusterDescriptor::create_for_grayskull_cluster(target_devices, {}); + ndesc = tt_ClusterDescriptor::create_mock_cluster({0}); tt_zebu_wrapper_inst = new tt_emu_zemi3_wrapper(); log_info(tt::LogEmulationDriver, "Created Emulation Device "); diff --git a/device/simulation/deprecated/tt_versim_device.cpp b/device/simulation/deprecated/tt_versim_device.cpp index 9504d9f6..acbfe13e 100644 --- a/device/simulation/deprecated/tt_versim_device.cpp +++ b/device/simulation/deprecated/tt_versim_device.cpp @@ -67,9 +67,8 @@ void translate_soc_descriptor_to_ca_soc(CA::Soc& soc, const tt_SocDescriptor soc tt_VersimDevice::tt_VersimDevice(const std::string& sdesc_path, const std::string& ndesc_path) : tt_device(sdesc_path) { soc_descriptor_per_chip.emplace(0, tt_SocDescriptor(sdesc_path)); - std::set target_devices = {0}; if (ndesc_path == "") { - ndesc = tt_ClusterDescriptor::create_for_grayskull_cluster(target_devices, {}); + ndesc = tt_ClusterDescriptor::create_mock_cluster({0}); } else { ndesc = tt_ClusterDescriptor::create_from_yaml(ndesc_path); } diff --git a/device/tt_cluster_descriptor.cpp b/device/tt_cluster_descriptor.cpp index b427fc9f..70e18111 100644 --- a/device/tt_cluster_descriptor.cpp +++ b/device/tt_cluster_descriptor.cpp @@ -437,44 +437,32 @@ std::unique_ptr tt_ClusterDescriptor::create_from_yaml( return desc; } -std::unique_ptr tt_ClusterDescriptor::create_for_grayskull_cluster( - const std::set &logical_mmio_device_ids, const std::vector &physical_mmio_device_ids) { +std::unique_ptr tt_ClusterDescriptor::create_mock_cluster( + const std::vector &logical_device_ids, tt::ARCH arch) { std::unique_ptr desc = std::unique_ptr(new tt_ClusterDescriptor()); - // Some users need not care about physical ids, can provide empty set. - auto use_physical_ids = physical_mmio_device_ids.size() ? true : false; - auto largest_workload_logical_device_id = *logical_mmio_device_ids.rbegin(); // Last element in ordered set. - auto num_available_physical_devices = physical_mmio_device_ids.size(); - auto required_physical_devices = largest_workload_logical_device_id + 1; - - log_debug( - tt::LogSiliconDriver, - "{} - use_physical_ids: {} largest_workload_logical_device_id: {} num_available_physical_devices: {} " - "required_physical_devices: {}", - __FUNCTION__, - use_physical_ids, - largest_workload_logical_device_id, - num_available_physical_devices, - required_physical_devices); + BoardType board_type; + switch (arch) { + case tt::ARCH::WORMHOLE_B0: + board_type = BoardType::N150; + break; + case tt::ARCH::BLACKHOLE: + board_type = BoardType::P150A; + break; + default: + log_error("Unsupported architecture for mock cluster"); + break; + } - log_assert( - !use_physical_ids || num_available_physical_devices >= required_physical_devices, - "Insufficient silicon devices. Workload requires device_id: {} (ie. {} devices) but only {} present", - largest_workload_logical_device_id, - required_physical_devices, - num_available_physical_devices); - - // All Grayskull devices are MMIO mapped so physical_mmio_device_ids correspond to all available devices - for (auto &logical_id : logical_mmio_device_ids) { - auto physical_id = use_physical_ids ? physical_mmio_device_ids.at(logical_id) : -1; - desc->chips_with_mmio.insert({logical_id, physical_id}); + for (auto &logical_id : logical_device_ids) { desc->all_chips.insert(logical_id); - eth_coord_t chip_location{logical_id, 0, 0, 0}; + eth_coord_t chip_location{0, logical_id, 0, 0, 0}; desc->chip_locations.insert({logical_id, chip_location}); desc->coords_to_chip_ids[chip_location.rack][chip_location.shelf][chip_location.y][chip_location.x] = logical_id; - log_debug( - tt::LogSiliconDriver, "{} - adding logical: {} => physical: {}", __FUNCTION__, logical_id, physical_id); + log_debug(tt::LogSiliconDriver, "{} - adding logical: {}", __FUNCTION__, logical_id); + desc->chip_board_type.insert({logical_id, board_type}); + desc->chips_with_mmio.insert({logical_id, logical_id}); } desc->enable_all_devices(); diff --git a/device/tt_cluster_descriptor.h b/device/tt_cluster_descriptor.h index 842da6dd..834f8e23 100644 --- a/device/tt_cluster_descriptor.h +++ b/device/tt_cluster_descriptor.h @@ -18,6 +18,7 @@ #include "device/tt_cluster_descriptor_types.h" #include "device/tt_xy_pair.h" +#include "tt_arch_types.h" namespace YAML { class Node; @@ -96,11 +97,9 @@ class tt_ClusterDescriptor { static std::string get_cluster_descriptor_file_path(); static std::unique_ptr create_from_yaml(const std::string &cluster_descriptor_file_path); - // TODO: This function is used to create mock cluster descriptor yaml files, for example for simulation. - // The name of the function is kept to not gate the changes regarding create-ethernet-map. - // It should be renamed to something like create_mock_cluster_descriptor and changed in tt-metal/tt-debuda. - static std::unique_ptr create_for_grayskull_cluster( - const std::set &logical_mmio_device_ids, const std::vector &physical_mmio_device_ids); + // This function is used to create mock cluster descriptor yaml files, for example for simulation. + static std::unique_ptr create_mock_cluster( + const std::vector &logical_device_ids, tt::ARCH arch); const std::unordered_map &get_harvesting_info() const; const std::unordered_map &get_noc_translation_table_en() const;