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 5, 2024
1 parent 1feb6f6 commit cc3c180
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 133 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 @@ -26,7 +26,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 @@ -73,7 +73,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 @@ -187,7 +187,7 @@ static const size_t dram_translated_coordinate_start_y = 12;

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
10 changes: 5 additions & 5 deletions device/api/umd/device/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,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 @@ -786,10 +786,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/grayskull_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,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 @@ -55,7 +55,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 @@ -70,7 +70,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
const bool iommu_enabled; // Whether the system is protected from this device by an IOMMU
std::unique_ptr<tt::umd::architecture_implementation> architecture_implementation;
Expand Down Expand Up @@ -142,7 +142,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; }

/**
* @return whether the system is protected from this device by an IOMMU
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 @@ -102,7 +102,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 @@ -46,7 +46,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 @@ -124,7 +124,7 @@ class tt_SocDescriptor {
// CoreCoord conversions.
tt::umd::CoreCoord to(const tt::umd::CoreCoord core_coord, const CoordSystem coord_system);

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(const std::size_t tensix_harvesting_mask, const std::size_t dram_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 @@ -240,7 +240,7 @@ static const size_t eth_translated_coordinate_start_y = 16;

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 cc3c180

Please sign in to comment.