Skip to content

Commit

Permalink
arch to tt
Browse files Browse the repository at this point in the history
  • Loading branch information
broskoTT committed Dec 4, 2024
1 parent 7bfae2b commit 36a9f13
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 150 deletions.
4 changes: 2 additions & 2 deletions device/api/umd/device/architecture_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class architecture_implementation {
public:
virtual ~architecture_implementation() = default;

virtual tt::umd::Arch get_architecture() const = 0;
virtual tt::Arch get_architecture() const = 0;
virtual uint32_t get_arc_message_arc_get_harvesting() const = 0;
virtual uint32_t get_arc_message_arc_go_busy() const = 0;
virtual uint32_t get_arc_message_arc_go_long_idle() const = 0;
Expand Down Expand Up @@ -72,7 +72,7 @@ class architecture_implementation {
virtual tt_driver_eth_interface_params get_eth_interface_params() const = 0;
virtual tt_driver_noc_params get_noc_params() const = 0;

static std::unique_ptr<architecture_implementation> create(tt::umd::Arch architecture);
static std::unique_ptr<architecture_implementation> create(tt::Arch architecture);
};

} // namespace tt::umd
2 changes: 1 addition & 1 deletion device/api/umd/device/blackhole_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static constexpr uint32_t MSG_TYPE_SETUP_IATU_FOR_PEER_TO_PEER = 0x97;

class blackhole_implementation : public architecture_implementation {
public:
tt::umd::Arch get_architecture() const override { return tt::umd::Arch::BLACKHOLE; }
tt::Arch get_architecture() const override { return tt::Arch::BLACKHOLE; }

uint32_t get_arc_message_arc_get_harvesting() const override {
return static_cast<uint32_t>(blackhole::arc_message_type::ARC_GET_HARVESTING);
Expand Down
14 changes: 7 additions & 7 deletions device/api/umd/device/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ using TLB_DATA = tt::umd::tlb_data;

// TODO: Remove this - it's here for Metal backwards compatibility.
// Implementation is in cluster.cpp.
tt::umd::Arch detect_arch(int pci_device_num);
tt::umd::Arch detect_arch();
tt::Arch detect_arch(int pci_device_num);
tt::Arch detect_arch();

namespace boost::interprocess {
class named_mutex;
Expand Down Expand Up @@ -627,12 +627,12 @@ class Cluster : public tt_device {
virtual void* host_dma_address(std::uint64_t offset, chip_id_t src_device_id, uint16_t channel) const;
virtual std::uint64_t get_pcie_base_addr_from_device(const chip_id_t chip_id) const;
static std::vector<int> extract_rows_to_remove(
const tt::umd::Arch& arch, const int worker_grid_rows, const int harvested_rows);
const tt::Arch& arch, const int worker_grid_rows, const int harvested_rows);
static void remove_worker_row_from_descriptor(
tt_SocDescriptor& full_soc_descriptor, const std::vector<int>& row_coordinates_to_remove);
static void harvest_rows_in_soc_descriptor(tt::umd::Arch arch, tt_SocDescriptor& sdesc, uint32_t harvested_rows);
static void harvest_rows_in_soc_descriptor(tt::Arch arch, tt_SocDescriptor& sdesc, uint32_t harvested_rows);
static std::unordered_map<tt_xy_pair, tt_xy_pair> create_harvested_coord_translation(
const tt::umd::Arch arch, bool identity_map);
const tt::Arch arch, bool identity_map);
std::unordered_map<tt_xy_pair, tt_xy_pair> get_harvested_coord_translation_map(chip_id_t logical_device_id);
virtual std::uint32_t get_num_dram_channels(std::uint32_t device_id);
virtual std::uint64_t get_dram_channel_size(std::uint32_t device_id, std::uint32_t channel);
Expand Down Expand Up @@ -791,10 +791,10 @@ class Cluster : public tt_device {
tt_driver_host_address_params host_address_params;
tt_driver_noc_params noc_params;
tt_driver_eth_interface_params eth_interface_params;
std::vector<tt::umd::Arch> archs_in_cluster = {};
std::vector<tt::Arch> archs_in_cluster = {};
std::set<chip_id_t> target_devices_in_cluster = {};
std::set<chip_id_t> target_remote_chips = {};
tt::umd::Arch arch_name;
tt::Arch arch_name;
std::unordered_map<chip_id_t, std::unique_ptr<PCIDevice>> m_pci_device_map; // Map of enabled pci devices
int m_num_pci_devices; // Number of pci devices in system (enabled or disabled)
std::shared_ptr<tt_ClusterDescriptor> cluster_desc;
Expand Down
2 changes: 1 addition & 1 deletion device/api/umd/device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CoordinateManager {
virtual tt_virtual_coords to_virtual_coords(tt_translated_coords translated_coords);

static std::unique_ptr<CoordinateManager> get_coordinate_manager(
tt::umd::Arch arch,
tt::Arch arch,
const tt_xy_pair& worker_grid_size,
const std::vector<tt_xy_pair>& workers,
std::size_t harvesting_mask);
Expand Down
2 changes: 1 addition & 1 deletion device/api/umd/device/grayskull_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static constexpr uint32_t TENSIX_SOFT_RESET_ADDR = 0xFFB121B0;

class grayskull_implementation : public architecture_implementation {
public:
tt::umd::Arch get_architecture() const override { return tt::umd::Arch::GRAYSKULL; }
tt::Arch get_architecture() const override { return tt::Arch::GRAYSKULL; }

uint32_t get_arc_message_arc_get_harvesting() const override {
return static_cast<uint32_t>(grayskull::arc_message_type::ARC_GET_HARVESTING);
Expand Down
6 changes: 3 additions & 3 deletions device/api/umd/device/pci_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct PciDeviceInfo {
uint16_t pci_device;
uint16_t pci_function;

tt::umd::Arch get_arch() const;
tt::Arch get_arch() const;
// TODO: does it make sense to move attributes that we can read from sysfs
// onto this struct as methods? e.g. current_link_width etc.
};
Expand All @@ -69,7 +69,7 @@ class PCIDevice {
const PciDeviceInfo info; // PCI device info
const int numa_node; // -1 if non-NUMA
const int revision; // PCI revision value from sysfs
const tt::umd::Arch arch; // e.g. Grayskull, Wormhole, Blackhole
const tt::Arch arch; // e.g. Grayskull, Wormhole, Blackhole
const semver_t kmd_version; // KMD version
std::unique_ptr<tt::umd::architecture_implementation> architecture_implementation;

Expand Down Expand Up @@ -140,7 +140,7 @@ class PCIDevice {
/**
* @return what architecture this device is (e.g. Wormhole, Blackhole, etc.)
*/
tt::umd::Arch get_arch() const { return arch; }
tt::Arch get_arch() const { return arch; }

// Note: byte_addr is (mostly but not always) offset into BAR0. This
// interface assumes the caller knows what they are doing - but it's unclear
Expand Down
2 changes: 1 addition & 1 deletion device/api/umd/device/tt_cluster_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class tt_ClusterDescriptor {

// 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::umd::Arch arch);
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: 2 additions & 2 deletions device/api/umd/device/tt_simulation_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ class tt_SimulationDevice : public tt_device {
tt_driver_host_address_params host_address_params;
tt_driver_noc_params noc_params;
tt_driver_eth_interface_params eth_interface_params;
std::vector<tt::umd::Arch> archs_in_cluster = {};
std::vector<tt::Arch> archs_in_cluster = {};
std::set<chip_id_t> target_devices_in_cluster = {};
std::set<chip_id_t> target_remote_chips = {};
tt::umd::Arch arch_name;
tt::Arch arch_name;
std::shared_ptr<tt_ClusterDescriptor> cluster_descriptor;
};
4 changes: 2 additions & 2 deletions device/api/umd/device/tt_soc_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct CoreDescriptor {
*/
class tt_SocDescriptor {
public:
tt::umd::Arch arch;
tt::Arch arch;
tt_xy_pair grid_size;
tt_xy_pair physical_grid_size;
tt_xy_pair worker_grid_size;
Expand Down Expand Up @@ -152,7 +152,7 @@ class tt_SocDescriptor {

void perform_harvesting(std::size_t harvesting_mask);

static std::string get_soc_descriptor_path(tt::umd::Arch arch);
static std::string get_soc_descriptor_path(tt::Arch arch);

private:
void create_coordinate_manager(std::size_t harvesting_mask);
Expand Down
30 changes: 15 additions & 15 deletions device/api/umd/device/types/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <algorithm>
#include <ostream>

namespace tt::umd {
// Arch is common to everything related in TT, and not just UMD. It might move to some common folder someday.
// So we decided to put it in tt namespace instead of tt::umd.
namespace tt {

static inline std::string to_lower(const std::string &str) {
std::string res = str;
Expand All @@ -27,36 +29,34 @@ enum class Arch {
Invalid = 0xFF,
};

static inline tt::umd::Arch arch_from_str(const std::string &arch_str) {
static inline tt::Arch arch_from_str(const std::string &arch_str) {
std::string arch_str_lower = to_lower(arch_str);

if (arch_str_lower == "grayskull") {
return tt::umd::Arch::GRAYSKULL;
return tt::Arch::GRAYSKULL;
} else if ((arch_str_lower == "wormhole") || (arch_str_lower == "wormhole_b0")) {
return tt::umd::Arch::WORMHOLE_B0;
return tt::Arch::WORMHOLE_B0;
} else if (arch_str_lower == "blackhole") {
return tt::umd::Arch::BLACKHOLE;
return tt::Arch::BLACKHOLE;
} else {
return tt::umd::Arch::Invalid;
return tt::Arch::Invalid;
}
}

static inline std::string arch_to_str(const tt::umd::Arch arch) {
static inline std::string arch_to_str(const tt::Arch arch) {
switch (arch) {
case tt::umd::Arch::GRAYSKULL:
case tt::Arch::GRAYSKULL:
return "grayskull";
case tt::umd::Arch::WORMHOLE_B0:
case tt::Arch::WORMHOLE_B0:
return "wormhole_b0";
case tt::umd::Arch::BLACKHOLE:
case tt::Arch::BLACKHOLE:
return "blackhole";
case tt::umd::Arch::Invalid:
case tt::Arch::Invalid:
default:
return "Invalid";
}
}

} // namespace tt::umd
} // namespace tt

static inline std::ostream &operator<<(std::ostream &out, const tt::umd::Arch &arch) {
return out << arch_to_str(arch);
}
static inline std::ostream &operator<<(std::ostream &out, const tt::Arch &arch) { return out << arch_to_str(arch); }
2 changes: 1 addition & 1 deletion device/api/umd/device/wormhole_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static constexpr uint32_t TENSIX_SOFT_RESET_ADDR = 0xFFB121B0;

class wormhole_implementation : public architecture_implementation {
public:
tt::umd::Arch get_architecture() const override { return tt::umd::Arch::WORMHOLE_B0; }
tt::Arch get_architecture() const override { return tt::Arch::WORMHOLE_B0; }

uint32_t get_arc_message_arc_get_harvesting() const override {
return static_cast<uint32_t>(wormhole::arc_message_type::ARC_GET_HARVESTING);
Expand Down
8 changes: 4 additions & 4 deletions device/architecture_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

namespace tt::umd {

std::unique_ptr<architecture_implementation> architecture_implementation::create(tt::umd::Arch architecture) {
std::unique_ptr<architecture_implementation> architecture_implementation::create(tt::Arch architecture) {
switch (architecture) {
case tt::umd::Arch::BLACKHOLE:
case tt::Arch::BLACKHOLE:
return std::make_unique<blackhole_implementation>();
case tt::umd::Arch::GRAYSKULL:
case tt::Arch::GRAYSKULL:
return std::make_unique<grayskull_implementation>();
case tt::umd::Arch::WORMHOLE_B0:
case tt::Arch::WORMHOLE_B0:
return std::make_unique<wormhole_implementation>();
default:
return nullptr;
Expand Down
Loading

0 comments on commit 36a9f13

Please sign in to comment.