Skip to content

Commit

Permalink
wip, before full rename
Browse files Browse the repository at this point in the history
more fixes, revert some changes

more refactorings

minor

arch to tt

fix after rebase

revert Arch to ARCH
  • Loading branch information
broskoTT committed Dec 8, 2024
1 parent c853fdf commit c422ccc
Show file tree
Hide file tree
Showing 20 changed files with 305 additions and 332 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 @@ -12,9 +12,9 @@
#include <vector>

#include "umd/device/tlb.h"
#include "umd/device/tt_arch_types.h"
#include "umd/device/tt_xy_pair.h"
#include "umd/device/xy_pair.h"
#include "umd/device/types/arch.h"
#include "umd/device/types/xy_pair.h"

struct tt_driver_host_address_params;
struct tt_driver_eth_interface_params;
Expand Down
200 changes: 3 additions & 197 deletions device/api/umd/device/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#include "tt_soc_descriptor.h"
#include "tt_xy_pair.h"
#include "umd/device/tlb.h"
#include "umd/device/tt_cluster_descriptor_types.h"
#include "umd/device/tt_device/tt_device.h"
#include "umd/device/tt_io.hpp"
#include "umd/device/types/arch.h"
#include "umd/device/types/cluster_descriptor_types.h"
#include "umd/device/types/cluster_types.h"

using TLB_DATA = tt::umd::tlb_data;

Expand All @@ -30,191 +32,6 @@ class named_mutex;

class tt_ClusterDescriptor;

enum tt_DevicePowerState { BUSY, SHORT_IDLE, LONG_IDLE };

enum tt_MemBarFlag {
SET = 0xaa,
RESET = 0xbb,
};

inline std::ostream& operator<<(std::ostream& os, const tt_DevicePowerState power_state) {
switch (power_state) {
case tt_DevicePowerState::BUSY:
os << "Busy";
break;
case tt_DevicePowerState::SHORT_IDLE:
os << "SHORT_IDLE";
break;
case tt_DevicePowerState::LONG_IDLE:
os << "LONG_IDLE";
break;
default:
throw("Unknown DevicePowerState");
}
return os;
}

struct tt_device_dram_address_params {
std::uint32_t DRAM_BARRIER_BASE = 0;
};

/**
* Struct encapsulating all L1 Address Map parameters required by UMD.
* These parameters are passed to the constructor.
*/
struct tt_device_l1_address_params {
std::uint32_t tensix_l1_barrier_base = 0;
std::uint32_t eth_l1_barrier_base = 0;
std::uint32_t fw_version_addr = 0;
};

/**
* Struct encapsulating all Host Address Map parameters required by UMD.
* These parameters are passed to the constructor and are needed for non-MMIO transactions.
*/
struct tt_driver_host_address_params {
std::uint32_t eth_routing_block_size = 0;
std::uint32_t eth_routing_buffers_start = 0;
};

struct tt_driver_noc_params {
std::uint32_t noc_addr_local_bits = 0;
std::uint32_t noc_addr_node_id_bits = 0;
};

/**
* Struct encapsulating all ERISC Firmware parameters required by UMD.
* These parameters are passed to the constructor and are needed for non-MMIO transactions.
*/
struct tt_driver_eth_interface_params {
std::uint32_t eth_rack_coord_width = 0;
std::uint32_t cmd_buf_size_mask = 0;
std::uint32_t max_block_size = 0;
std::uint32_t request_cmd_queue_base = 0;
std::uint32_t response_cmd_queue_base = 0;
std::uint32_t cmd_counters_size_bytes = 0;
std::uint32_t remote_update_ptr_size_bytes = 0;
std::uint32_t cmd_data_block = 0;
std::uint32_t cmd_wr_req = 0;
std::uint32_t cmd_wr_ack = 0;
std::uint32_t cmd_rd_req = 0;
std::uint32_t cmd_rd_data = 0;
std::uint32_t cmd_buf_size = 0;
std::uint32_t cmd_data_block_dram = 0;
std::uint32_t eth_routing_data_buffer_addr = 0;
std::uint32_t request_routing_cmd_queue_base = 0;
std::uint32_t response_routing_cmd_queue_base = 0;
std::uint32_t cmd_buf_ptr_mask = 0;
std::uint32_t cmd_ordered = 0;
std::uint32_t cmd_broadcast = 0;
};

struct tt_version {
std::uint16_t major = 0xffff;
std::uint8_t minor = 0xff;
std::uint8_t patch = 0xff;

tt_version() {}

tt_version(std::uint16_t major_, std::uint8_t minor_, std::uint8_t patch_) {
major = major_;
minor = minor_;
patch = patch_;
}

tt_version(std::uint32_t version) {
major = (version >> 16) & 0xff;
minor = (version >> 12) & 0xf;
patch = version & 0xfff;
}

std::string str() const { return fmt::format("{}.{}.{}", major, minor, patch); }
};

struct tt_device_params {
bool register_monitor = false;
bool enable_perf_scoreboard = false;
std::vector<std::string> vcd_dump_cores;
std::vector<std::string> plusargs;
bool init_device = true;
bool early_open_device = false;
int aiclk = 0;

// The command-line input for vcd_dump_cores can have the following format:
// {"*-2", "1-*", "*-*", "1-2"}
// '*' indicates we must dump all the cores in that dimension.
// This function takes the vector above and unrolles the coords with '*' in one or both dimensions.
std::vector<std::string> unroll_vcd_dump_cores(tt_xy_pair grid_size) const {
std::vector<std::string> unrolled_dump_core;
for (auto& dump_core : vcd_dump_cores) {
// If the input is a single *, then dump all cores.
if (dump_core == "*") {
for (size_t x = 0; x < grid_size.x; x++) {
for (size_t y = 0; y < grid_size.y; y++) {
std::string current_core_coord = fmt::format("{}-{}", x, y);
if (std::find(
std::begin(unrolled_dump_core), std::end(unrolled_dump_core), current_core_coord) ==
std::end(unrolled_dump_core)) {
unrolled_dump_core.push_back(current_core_coord);
}
}
}
continue;
}
// Each core coordinate must contain three characters: "core.x-core.y".
assert(dump_core.size() <= 5);
size_t delimiter_pos = dump_core.find('-');
assert(delimiter_pos != std::string::npos); // y-dim should exist in core coord.

std::string core_dim_x = dump_core.substr(0, delimiter_pos);
size_t core_dim_y_start = delimiter_pos + 1;
std::string core_dim_y = dump_core.substr(core_dim_y_start, dump_core.length() - core_dim_y_start);

if (core_dim_x == "*" && core_dim_y == "*") {
for (size_t x = 0; x < grid_size.x; x++) {
for (size_t y = 0; y < grid_size.y; y++) {
std::string current_core_coord = fmt::format("{}-{}", x, y);
if (std::find(
std::begin(unrolled_dump_core), std::end(unrolled_dump_core), current_core_coord) ==
std::end(unrolled_dump_core)) {
unrolled_dump_core.push_back(current_core_coord);
}
}
}
} else if (core_dim_x == "*") {
for (size_t x = 0; x < grid_size.x; x++) {
std::string current_core_coord = fmt::format("{}-{}", x, core_dim_y);
if (std::find(std::begin(unrolled_dump_core), std::end(unrolled_dump_core), current_core_coord) ==
std::end(unrolled_dump_core)) {
unrolled_dump_core.push_back(current_core_coord);
}
}
} else if (core_dim_y == "*") {
for (size_t y = 0; y < grid_size.y; y++) {
std::string current_core_coord = fmt::format("{}-{}", core_dim_x, y);
if (std::find(std::begin(unrolled_dump_core), std::end(unrolled_dump_core), current_core_coord) ==
std::end(unrolled_dump_core)) {
unrolled_dump_core.push_back(current_core_coord);
}
}
} else {
unrolled_dump_core.push_back(dump_core);
}
}
return unrolled_dump_core;
}

std::vector<std::string> expand_plusargs() const {
std::vector<std::string> all_plusargs{
fmt::format("+enable_perf_scoreboard={}", enable_perf_scoreboard),
fmt::format("+register_monitor={}", register_monitor)};

all_plusargs.insert(all_plusargs.end(), plusargs.begin(), plusargs.end());

return all_plusargs;
}
};

// TODO: This class is to be removed once we move Simulation and Mockup devices to be Chips instead of Clusters.
/**
* Parent class for Cluster (Silicon Driver).
Expand Down Expand Up @@ -1026,14 +843,3 @@ class Cluster : public tt_device {
};

} // namespace tt::umd

constexpr inline bool operator==(const tt_version& a, const tt_version& b) {
return a.major == b.major && a.minor == b.minor && a.patch == b.patch;
}

constexpr inline bool operator>=(const tt_version& a, const tt_version& b) {
bool fw_major_greater = a.major > b.major;
bool fw_minor_greater = (a.major == b.major) && (a.minor > b.minor);
bool patch_greater_or_equal = (a.major == b.major) && (a.minor == b.minor) && (a.patch >= b.patch);
return fw_major_greater || fw_minor_greater || patch_greater_or_equal;
}
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 @@ -10,9 +10,9 @@
#include <set>
#include <vector>

#include "umd/device/tt_arch_types.h"
#include "umd/device/tt_core_coordinates.h"
#include "umd/device/tt_xy_pair.h"
#include "umd/device/types/arch.h"

class CoordinateManager {
public:
Expand Down
2 changes: 1 addition & 1 deletion device/api/umd/device/hugepage.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <cstdint>
#include <string>

#include "umd/device/tt_cluster_descriptor_types.h"
#include "umd/device/types/cluster_descriptor_types.h"

namespace tt::umd {

Expand Down
3 changes: 1 addition & 2 deletions device/api/umd/device/pci_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
#include "fmt/format.h"
#include "umd/device/semver.hpp"
#include "umd/device/tlb.h"
#include "umd/device/tt_arch_types.h"
#include "umd/device/tt_cluster_descriptor_types.h"
#include "umd/device/tt_xy_pair.h"
#include "umd/device/types/arch.h"

namespace tt::umd {
struct semver_t;
Expand Down
20 changes: 0 additions & 20 deletions device/api/umd/device/tt_arch_types.h

This file was deleted.

5 changes: 2 additions & 3 deletions device/api/umd/device/tt_cluster_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#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"
#include "umd/device/types/arch.h"
#include "umd/device/types/cluster_descriptor_types.h"

namespace YAML {
class Node;
Expand Down Expand Up @@ -78,7 +78,6 @@ class tt_ClusterDescriptor {
static void load_harvesting_information(YAML::Node &yaml, tt_ClusterDescriptor &desc);

void fill_chips_grouped_by_closest_mmio();
static tt::ARCH arch_from_string(std::string arch_str);

public:
/*
Expand Down
39 changes: 1 addition & 38 deletions device/api/umd/device/tt_soc_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,14 @@
#include "fmt/core.h"
#include "tt_xy_pair.h"
#include "umd/device/coordinate_manager.h"
#include "umd/device/tt_arch_types.h"
#include "umd/device/tt_core_coordinates.h"
#include "umd/device/tt_xy_pair.h"
#include "umd/device/types/arch.h"

namespace YAML {
class Node;
}

std::ostream &operator<<(std::ostream &out, const tt::ARCH &arch_name);

static inline std::string get_arch_str(const tt::ARCH arch_name) {
std::string arch_name_str;

if (arch_name == tt::ARCH::GRAYSKULL) {
arch_name_str = "grayskull";
} else if (arch_name == tt::ARCH::WORMHOLE_B0) {
arch_name_str = "wormhole_b0";
} else if (arch_name == tt::ARCH::BLACKHOLE) {
arch_name_str = "blackhole";
} else {
throw std::runtime_error("Invalid arch_name");
}

return arch_name_str;
}

static inline tt::ARCH get_arch_name(const std::string &arch_str) {
tt::ARCH arch;

if ((arch_str == "grayskull") || (arch_str == "GRAYSKULL")) {
arch = tt::ARCH::GRAYSKULL;
} else if (
(arch_str == "wormhole") || (arch_str == "WORMHOLE") || (arch_str == "wormhole_b0") ||
(arch_str == "WORMHOLE_B0")) {
arch = tt::ARCH::WORMHOLE_B0;
} else if ((arch_str == "blackhole") || (arch_str == "BLACKHOLE")) {
arch = tt::ARCH::BLACKHOLE;
} else {
throw std::runtime_error(
fmt::format("At LoadSocDescriptorFromYaml: \"{}\" is not recognized as tt::ARCH.", arch_str));
}

return arch;
}

std::string format_node(tt_xy_pair xy);

tt_xy_pair format_node(std::string str);
Expand Down
3 changes: 2 additions & 1 deletion device/api/umd/device/tt_xy_pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

#include <regex>

#include "umd/device/xy_pair.h"
#include "umd/device/types/xy_pair.h"

// TODO: These usings and this whole file are to be removed.
using tt_xy_pair = tt::umd::xy_pair;
using tt_cxy_pair = tt::umd::cxy_pair;
Loading

0 comments on commit c422ccc

Please sign in to comment.