Skip to content

Commit

Permalink
[Chip] Move TTDevice to local chip (#396)
Browse files Browse the repository at this point in the history
### Issue
Related to #351 

### Description
Another PR in a push to define Chip class properly.
This PR moves tt_device under Chip, specifically under LocalChips.

### List of the changes
- Add TTDevice to LocalChip
- Renamed all_chips, target_chips and remote_chips to have more
consistent naming.
- MockChip disabled at the moment, it will start working by itself at
some point, when enough stuff is moved to Chip class.

### Testing
Existing tests

### API Changes
There are no API changes in this PR.
  • Loading branch information
broskoTT authored Dec 17, 2024
1 parent cfadca1 commit 4ed53ca
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 150 deletions.
4 changes: 4 additions & 0 deletions device/api/umd/device/chip/chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace tt::umd {

class TTDevice;

// An abstract class that represents a chip.
class Chip {
public:
Expand All @@ -20,6 +22,8 @@ class Chip {

tt_SocDescriptor& get_soc_descriptor();

virtual TTDevice* get_tt_device();

virtual bool is_mmio_capable() const = 0;

private:
Expand Down
8 changes: 7 additions & 1 deletion device/api/umd/device/chip/local_chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
namespace tt::umd {
class LocalChip : public Chip {
public:
LocalChip(tt_SocDescriptor soc_descriptor);
LocalChip(tt_SocDescriptor soc_descriptor, int pci_device_id);

TTDevice* get_tt_device() override;

bool is_mmio_capable() const override;

private:
std::unique_ptr<TTDevice> tt_device_;
};
} // namespace tt::umd
25 changes: 4 additions & 21 deletions device/api/umd/device/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,20 +311,6 @@ class tt_device {
throw std::runtime_error("---- tt_device::translate_to_noc_table_coords is not implemented\n");
}

/**
* Get the total number of chips in the cluster based on the network descriptor.
*/
virtual int get_number_of_chips_in_cluster() {
throw std::runtime_error("---- tt_device::get_number_of_chips_in_cluster is not implemented\n");
}

/**
* Get the logical ids for all chips in the cluster
*/
virtual std::unordered_set<chip_id_t> get_all_chips_in_cluster() {
throw std::runtime_error("---- tt_device::get_all_chips_in_cluster is not implemented\n");
}

/**
* Get cluster descriptor object being used in UMD instance.
*/
Expand Down Expand Up @@ -621,13 +607,12 @@ class Cluster : public tt_device {
virtual bool using_harvested_soc_descriptors();
virtual std::unordered_map<chip_id_t, uint32_t> get_harvesting_masks_for_soc_descriptors();
virtual void translate_to_noc_table_coords(chip_id_t device_id, std::size_t& r, std::size_t& c);
virtual int get_number_of_chips_in_cluster();
virtual std::unordered_set<chip_id_t> get_all_chips_in_cluster();
virtual tt_ClusterDescriptor* get_cluster_description();
static int detect_number_of_chips();
static std::vector<chip_id_t> detect_available_device_ids();
virtual std::set<chip_id_t> get_target_mmio_device_ids();
virtual std::set<chip_id_t> get_target_remote_device_ids();
virtual std::set<chip_id_t> get_target_device_ids();
virtual std::map<int, int> get_clocks();
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;
Expand Down Expand Up @@ -803,14 +788,12 @@ class Cluster : public tt_device {
tt_driver_noc_params noc_params;
tt_driver_eth_interface_params eth_interface_params;
std::vector<tt::ARCH> archs_in_cluster = {};
std::set<chip_id_t> target_devices_in_cluster = {};
std::set<chip_id_t> target_remote_chips = {};
std::set<chip_id_t> all_target_mmio_devices = {};
std::set<chip_id_t> all_chip_ids_ = {};
std::set<chip_id_t> remote_chip_ids_ = {};
std::set<chip_id_t> local_chip_ids_ = {};
std::unordered_map<chip_id_t, std::unique_ptr<Chip>> chips_;
tt::ARCH arch_name;

// Map of enabled tt devices
std::unordered_map<chip_id_t, std::unique_ptr<TTDevice>> m_tt_device_map;
std::shared_ptr<tt_ClusterDescriptor> cluster_desc;

// remote eth transfer setup
Expand Down
2 changes: 2 additions & 0 deletions device/chip/chip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ Chip::Chip(tt_SocDescriptor soc_descriptor) : soc_descriptor_(soc_descriptor) {}

tt_SocDescriptor& Chip::get_soc_descriptor() { return soc_descriptor_; }

TTDevice* Chip::get_tt_device() { return nullptr; }

} // namespace tt::umd
7 changes: 6 additions & 1 deletion device/chip/local_chip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@

#include "umd/device/chip/local_chip.h"

#include "umd/device/tt_device/tt_device.h"

namespace tt::umd {

LocalChip::LocalChip(tt_SocDescriptor soc_descriptor) : Chip(soc_descriptor) {}
LocalChip::LocalChip(tt_SocDescriptor soc_descriptor, int pci_device_id) :
Chip(soc_descriptor), tt_device_(TTDevice::create(pci_device_id)) {}

TTDevice* LocalChip::get_tt_device() { return tt_device_.get(); }

bool LocalChip::is_mmio_capable() const { return true; }
} // namespace tt::umd
2 changes: 1 addition & 1 deletion device/chip/mock_chip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ namespace tt::umd {

MockChip::MockChip(tt_SocDescriptor soc_descriptor) : Chip(soc_descriptor) {}

bool MockChip::is_mmio_capable() const { return true; }
bool MockChip::is_mmio_capable() const { return false; }
} // namespace tt::umd
Loading

0 comments on commit 4ed53ca

Please sign in to comment.