Skip to content

Commit

Permalink
Put harvesting masks into a struct
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanevskiTT committed Jan 27, 2025
1 parent a3eb877 commit c4a6d79
Show file tree
Hide file tree
Showing 19 changed files with 206 additions and 247 deletions.
5 changes: 2 additions & 3 deletions device/api/umd/device/blackhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ class BlackholeCoordinateManager : public CoordinateManager {
public:
BlackholeCoordinateManager(
const bool noc_translation_enabled,

tt::umd::HarvestingMasks harvesting_masks,
const tt_xy_pair& tensix_grid_size,
const std::vector<tt_xy_pair>& tensix_cores,
const size_t tensix_harvesting_mask,
const tt_xy_pair& dram_grid_size,
const std::vector<tt_xy_pair>& dram_cores,
const size_t dram_harvesting_mask,
const std::vector<tt_xy_pair>& eth_cores,
const size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
const std::vector<tt_xy_pair>& arc_cores,
const tt_xy_pair& pcie_grid_size,
Expand Down
28 changes: 15 additions & 13 deletions device/api/umd/device/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@

#include "fmt/core.h"
#include "tt_silicon_driver_common.hpp"
#include "tt_soc_descriptor.h"
#include "tt_xy_pair.h"
#include "umd/device/blackhole_arc_message_queue.h"
#include "umd/device/chip/chip.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"
#include "umd/device/types/harvesting.h"
#include "umd/device/types/tlb.h"

using TLB_DATA = tt::umd::tlb_data;
Expand Down Expand Up @@ -500,7 +497,7 @@ class Cluster : public tt_device {
const bool skip_driver_allocs = false,
const bool clean_system_resources = false,
bool perform_harvesting = true,
std::unordered_map<chip_id_t, SoftwareHarvesting> simulated_harvesting_masks = {});
std::unordered_map<chip_id_t, HarvestingMasks> simulated_harvesting_masks = {});

/**
* Cluster constructor.
Expand All @@ -520,7 +517,7 @@ class Cluster : public tt_device {
const bool skip_driver_allocs = false,
const bool clean_system_resources = false,
bool perform_harvesting = true,
std::unordered_map<chip_id_t, SoftwareHarvesting> simulated_harvesting_masks = {});
std::unordered_map<chip_id_t, HarvestingMasks> simulated_harvesting_masks = {});

/**
* Cluster constructor.
Expand All @@ -544,7 +541,7 @@ class Cluster : public tt_device {
const bool skip_driver_allocs = false,
const bool clean_system_resources = false,
bool perform_harvesting = true,
std::unordered_map<chip_id_t, SoftwareHarvesting> simulated_harvesting_masks = {});
std::unordered_map<chip_id_t, HarvestingMasks> simulated_harvesting_masks = {});

/**
* Cluster constructor.
Expand All @@ -566,7 +563,7 @@ class Cluster : public tt_device {
const bool skip_driver_allocs = false,
const bool clean_system_resources = false,
bool perform_harvesting = true,
std::unordered_map<chip_id_t, SoftwareHarvesting> simulated_harvesting_masks = {});
std::unordered_map<chip_id_t, HarvestingMasks> simulated_harvesting_masks = {});

/**
* Cluster constructor which creates a cluster with Mock chips.
Expand Down Expand Up @@ -878,36 +875,41 @@ class Cluster : public tt_device {
chip_id_t chip_id,
tt_ClusterDescriptor* cluster_desc,
bool perform_harvesting,
std::unordered_map<chip_id_t, SoftwareHarvesting>& simulated_harvesting_masks);
std::unordered_map<chip_id_t, HarvestingMasks>& simulated_harvesting_masks);
std::unique_ptr<Chip> construct_chip_from_cluster(
chip_id_t logical_device_id,
tt_ClusterDescriptor* cluster_desc,
bool perform_harvesting,
std::unordered_map<chip_id_t, SoftwareHarvesting>& simulated_harvesting_masks);
std::unordered_map<chip_id_t, HarvestingMasks>& simulated_harvesting_masks);
void add_chip(chip_id_t chip_id, std::unique_ptr<Chip> chip);
HarvestingMasks get_harvesting_masks(
chip_id_t chip_id,
tt_ClusterDescriptor* cluster_desc,
bool perfrom_harvesting,
std::unordered_map<chip_id_t, HarvestingMasks>& simulated_harvesting_masks);
uint32_t get_tensix_harvesting_mask(
chip_id_t chip_id,
tt_ClusterDescriptor* cluster_desc,
bool perform_harvesting,
std::unordered_map<chip_id_t, SoftwareHarvesting>& simulated_harvesting_masks);
std::unordered_map<chip_id_t, HarvestingMasks>& simulated_harvesting_masks);
// TODO: this function returns only software harvesting mask for DRAM.
// Combine this with silicon harvesting mask once gathering silicon harvesting mask is implemented.
uint32_t get_dram_harvesting_mask(
chip_id_t chip_id,
bool perform_harvesting,
std::unordered_map<chip_id_t, SoftwareHarvesting>& simulated_harvesting_masks);
std::unordered_map<chip_id_t, HarvestingMasks>& simulated_harvesting_masks);
// TODO: this function returns only software harvesting mask for ETH.
// Combine this with silicon harvesting mask once gathering silicon harvesting mask is implemented.
uint32_t get_eth_harvesting_mask(
chip_id_t chip_id,
bool perform_harvesting,
std::unordered_map<chip_id_t, SoftwareHarvesting>& simulated_harvesting_masks);
std::unordered_map<chip_id_t, HarvestingMasks>& simulated_harvesting_masks);
void construct_cluster(
const uint32_t& num_host_mem_ch_per_mmio_device,
const bool skip_driver_allocs,
const bool clean_system_resources,
bool perform_harvesting,
std::unordered_map<chip_id_t, SoftwareHarvesting> simulated_harvesting_masks);
std::unordered_map<chip_id_t, HarvestingMasks> simulated_harvesting_masks);
// Helper function for translating chip coordinates.
tt_xy_pair translate_to_api_coords(const chip_id_t chip, const tt::umd::CoreCoord core_coord) const;

Expand Down
22 changes: 6 additions & 16 deletions device/api/umd/device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "umd/device/tt_xy_pair.h"
#include "umd/device/types/arch.h"
#include "umd/device/types/cluster_descriptor_types.h"
#include "umd/device/types/harvesting.h"

class CoordinateManager {
public:
Expand All @@ -28,14 +29,12 @@ class CoordinateManager {
static std::shared_ptr<CoordinateManager> create_coordinate_manager(
tt::ARCH arch,
const bool noc_translation_enabled,
tt::umd::HarvestingMasks harvesting_masks,
const tt_xy_pair& tensix_grid_size,
const std::vector<tt_xy_pair>& tensix_cores,
const size_t tensix_harvesting_mask,
const tt_xy_pair& dram_grid_size,
const std::vector<tt_xy_pair>& dram_cores,
const size_t dram_harvesting_mask,
const std::vector<tt_xy_pair>& eth_cores,
const size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
const std::vector<tt_xy_pair>& arc_cores,
const tt_xy_pair& pcie_grid_size,
Expand All @@ -45,9 +44,7 @@ class CoordinateManager {
static std::shared_ptr<CoordinateManager> create_coordinate_manager(
tt::ARCH arch,
const bool noc_translation_enabled,
const size_t tensix_harvesting_mask = 0,
const size_t dram_harvesting_mask = 0,
const size_t eth_harvesting_mask = 0,
const tt::umd::HarvestingMasks harvesting_masks = {0, 0, 0},
const BoardType board_type = BoardType::UNKNOWN,
const bool is_chip_remote = false);

Expand All @@ -72,9 +69,7 @@ class CoordinateManager {
std::vector<tt::umd::CoreCoord> get_harvested_cores(const CoreType core_type) const;
tt_xy_pair get_harvested_grid_size(const CoreType core_type) const;

size_t get_tensix_harvesting_mask() const;
size_t get_dram_harvesting_mask() const;
size_t get_eth_harvesting_mask() const;
tt::umd::HarvestingMasks get_harvesting_masks() const;

uint32_t get_num_eth_channels() const;

Expand All @@ -95,14 +90,12 @@ class CoordinateManager {
*/
CoordinateManager(
const bool noc_translation_enabled,
const tt::umd::HarvestingMasks harvesting_masks,
const tt_xy_pair& tensix_grid_size,
const std::vector<tt_xy_pair>& tensix_cores,
const size_t tensix_harvesting_mask,
const tt_xy_pair& dram_grid_size,
const std::vector<tt_xy_pair>& dram_cores,
const size_t dram_harvesting_mask,
const std::vector<tt_xy_pair>& eth_cores,
const size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
const std::vector<tt_xy_pair>& arc_cores,
const tt_xy_pair& pcie_grid_size,
Expand Down Expand Up @@ -201,19 +194,16 @@ class CoordinateManager {
// interface it with a coordinate system which abstracts away harvested cores. If it is not enabled, then we need to
// interface it with noc0 coordinates.
bool noc_translation_enabled;
tt::umd::HarvestingMasks harvesting_masks;

tt_xy_pair tensix_grid_size;
const std::vector<tt_xy_pair> tensix_cores;
size_t tensix_harvesting_mask;
const size_t physical_layout_tensix_harvesting_mask;

tt_xy_pair dram_grid_size;
const std::vector<tt_xy_pair> dram_cores;
size_t dram_harvesting_mask;

const size_t num_eth_channels;
const std::vector<tt_xy_pair> eth_cores;
const size_t eth_harvesting_mask;

tt_xy_pair arc_grid_size;
const std::vector<tt_xy_pair> arc_cores;
Expand Down
4 changes: 1 addition & 3 deletions device/api/umd/device/grayskull_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
class GrayskullCoordinateManager : public CoordinateManager {
public:
GrayskullCoordinateManager(
tt::umd::HarvestingMasks harvesting_masks,
const tt_xy_pair& tensix_grid_size,
const std::vector<tt_xy_pair>& tensix_cores,
const size_t tensix_harvesting_mask,
const tt_xy_pair& dram_grid_size,
const std::vector<tt_xy_pair>& dram_cores,
const size_t dram_harvesting_mask,
const std::vector<tt_xy_pair>& eth_cores,
const size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
const std::vector<tt_xy_pair>& arc_cores,
const tt_xy_pair& pcie_grid_size,
Expand Down
12 changes: 3 additions & 9 deletions device/api/umd/device/tt_soc_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class tt_SocDescriptor {
tt_SocDescriptor(
std::string device_descriptor_path,
const bool noc_translation_enabled,
const size_t tensix_harvesting_mask = 0,
const size_t dram_harvesting_mask = 0,
const size_t eth_harvesting_mask = 0);
const tt::umd::HarvestingMasks harvesting_masks = {0, 0, 0});

// CoreCoord conversions.
tt::umd::CoreCoord translate_coord_to(const tt::umd::CoreCoord core_coord, const CoordSystem coord_system) const;
Expand Down Expand Up @@ -124,14 +122,10 @@ class tt_SocDescriptor {
int eth_l1_size;
bool noc_translation_id_enabled;
uint64_t dram_bank_size;
uint32_t tensix_harvesting_mask;
tt::umd::HarvestingMasks harvesting_masks;

private:
void create_coordinate_manager(
const bool noc_translation_enabled,
const size_t tensix_harvesting_mask,
const size_t dram_harvesting_mask,
const size_t eth_harvesting_mask);
void create_coordinate_manager(const bool noc_translation_enabled, const tt::umd::HarvestingMasks harvesting_masks);
void load_core_descriptors_from_device_descriptor(YAML::Node &device_descriptor_yaml);
void load_soc_features_from_device_descriptor(YAML::Node &device_descriptor_yaml);
void get_cores_and_grid_size_from_coordinate_manager();
Expand Down
8 changes: 4 additions & 4 deletions device/api/umd/device/types/harvesting.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace tt::umd {

struct SoftwareHarvesting {
uint32_t tensix_harvesting_mask;
uint32_t eth_harvesting_mask;
uint32_t dram_harvesting_mask;
struct HarvestingMasks {
size_t tensix_harvesting_mask = 0;
size_t dram_harvesting_mask = 0;
size_t eth_harvesting_mask = 0;
};

} // namespace tt::umd
4 changes: 1 addition & 3 deletions device/api/umd/device/wormhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ class WormholeCoordinateManager : public CoordinateManager {
public:
WormholeCoordinateManager(
const bool noc_translation_enabled,
tt::umd::HarvestingMasks harvesting_masks,
const tt_xy_pair& tensix_grid_size,
const std::vector<tt_xy_pair>& tensix_cores,
const size_t tensix_harvesting_mask,
const tt_xy_pair& dram_grid_size,
const std::vector<tt_xy_pair>& dram_cores,
const size_t dram_harvesting_mask,
const std::vector<tt_xy_pair>& eth_cores,
const size_t eth_harvesting_mask,
const tt_xy_pair& arc_grid_size,
const std::vector<tt_xy_pair>& arc_cores,
const tt_xy_pair& pcie_grid_size,
Expand Down
Loading

0 comments on commit c4a6d79

Please sign in to comment.