Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into afuller/clarify-api
Browse files Browse the repository at this point in the history
  • Loading branch information
afuller-TT committed Nov 22, 2024
2 parents 6bdc44f + e9dc0d1 commit 1c60c36
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 41 deletions.
9 changes: 4 additions & 5 deletions device/api/umd/device/tt_cluster_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <unordered_set>
#include <vector>

#include "umd/device/tt_arch_types.h"
#include "umd/device/tt_cluster_descriptor_types.h"
#include "umd/device/tt_xy_pair.h"

Expand Down Expand Up @@ -96,11 +97,9 @@ class tt_ClusterDescriptor {
static std::string get_cluster_descriptor_file_path();
static std::unique_ptr<tt_ClusterDescriptor> 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<tt_ClusterDescriptor> create_for_grayskull_cluster(
const std::set<chip_id_t> &logical_mmio_device_ids, const std::vector<chip_id_t> &physical_mmio_device_ids);
// This function is used to create mock cluster descriptor yaml files, for example for simulation.
static std::unique_ptr<tt_ClusterDescriptor> create_mock_cluster(
const std::vector<chip_id_t> &logical_device_ids, tt::ARCH arch);

const std::unordered_map<chip_id_t, std::uint32_t> &get_harvesting_info() const;
const std::unordered_map<chip_id_t, bool> &get_noc_translation_table_en() const;
Expand Down
4 changes: 1 addition & 3 deletions device/simulation/deprecated/tt_emulation_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<chip_id_t> 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 ");
Expand Down
3 changes: 1 addition & 2 deletions device/simulation/deprecated/tt_versim_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<chip_id_t> 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);
}
Expand Down
50 changes: 19 additions & 31 deletions device/tt_cluster_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,44 +437,32 @@ std::unique_ptr<tt_ClusterDescriptor> tt_ClusterDescriptor::create_from_yaml(
return desc;
}

std::unique_ptr<tt_ClusterDescriptor> tt_ClusterDescriptor::create_for_grayskull_cluster(
const std::set<chip_id_t> &logical_mmio_device_ids, const std::vector<chip_id_t> &physical_mmio_device_ids) {
std::unique_ptr<tt_ClusterDescriptor> tt_ClusterDescriptor::create_mock_cluster(
const std::vector<chip_id_t> &logical_device_ids, tt::ARCH arch) {
std::unique_ptr<tt_ClusterDescriptor> desc = std::unique_ptr<tt_ClusterDescriptor>(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();
Expand Down

0 comments on commit 1c60c36

Please sign in to comment.