Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ChipInfo struct #494

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions device/api/umd/device/tt_device/blackhole_tt_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <set>

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

namespace tt::umd {
Expand All @@ -18,8 +19,11 @@ class BlackholeTTDevice : public TTDevice {

void configure_iatu_region(size_t region, uint64_t base, uint64_t target, size_t size) override;

ChipInfo get_chip_info() override;

private:
static constexpr uint64_t ATU_OFFSET_IN_BH_BAR2 = 0x1200;
std::set<size_t> iatu_regions_;
std::unique_ptr<blackhole::BlackholeArcTelemetryReader> telemetry = nullptr;
};
} // namespace tt::umd
2 changes: 2 additions & 0 deletions device/api/umd/device/tt_device/grayskull_tt_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ namespace tt::umd {
class GrayskullTTDevice : public TTDevice {
public:
GrayskullTTDevice(std::unique_ptr<PCIDevice> pci_device);

ChipInfo get_chip_info() override;
};
} // namespace tt::umd
5 changes: 5 additions & 0 deletions device/api/umd/device/tt_device/tt_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "umd/device/architecture_implementation.h"
#include "umd/device/pci_device.hpp"
#include "umd/device/tt_device/tlb_manager.h"
#include "umd/device/types/cluster_descriptor_types.h"

// TODO: Should be moved to blackhole_architecture_implementation.h
// See /vendor_ip/synopsys/052021/bh_pcie_ctl_gen5/export/configuration/DWC_pcie_ctl.h
Expand Down Expand Up @@ -127,6 +128,8 @@ class TTDevice {
*/
virtual void configure_iatu_region(size_t region, uint64_t base, uint64_t target, size_t size);

virtual ChipInfo get_chip_info() = 0;

protected:
std::unique_ptr<PCIDevice> pci_device_;
std::unique_ptr<architecture_implementation> architecture_impl_;
Expand All @@ -151,5 +154,7 @@ class TTDevice {
void create_read_write_mutex();

std::shared_ptr<boost::interprocess::named_mutex> read_write_mutex = nullptr;

ChipInfo chip_info;
};
} // namespace tt::umd
2 changes: 2 additions & 0 deletions device/api/umd/device/tt_device/wormhole_tt_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ namespace tt::umd {
class WormholeTTDevice : public TTDevice {
public:
WormholeTTDevice(std::unique_ptr<PCIDevice> pci_device);

ChipInfo get_chip_info() override;
};
} // namespace tt::umd
14 changes: 14 additions & 0 deletions device/api/umd/device/types/cluster_descriptor_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <cstdint>
#include <functional>

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

// Small performant hash combiner taken from boost library.
// Not using boost::hash_combine due to dependency complications.
inline void boost_hash_combine(std::size_t &seed, const int value) {
Expand Down Expand Up @@ -64,6 +66,18 @@ inline BoardType get_board_type_from_board_id(const uint64_t board_id) {
throw std::runtime_error(fmt::format("No existing board type for board id {}", board_id));
}

struct ChipUID {
uint64_t board_id;
uint8_t asic_location;
};

struct ChipInfo {
tt::umd::HarvestingMasks harvesting_masks;
BoardType board_type;
ChipUID chip_uid;
bool noc_translation_enabled;
};

namespace std {
template <>
struct hash<eth_coord_t> {
Expand Down
33 changes: 32 additions & 1 deletion device/tt_device/blackhole_tt_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@

#include "logger.hpp"
#include "umd/device/blackhole_implementation.h"
#include "umd/device/types/blackhole_telemetry.h"

namespace tt::umd {

BlackholeTTDevice::BlackholeTTDevice(std::unique_ptr<PCIDevice> pci_device) :
TTDevice(std::move(pci_device), std::make_unique<blackhole_implementation>()) {}
TTDevice(std::move(pci_device), std::make_unique<blackhole_implementation>()) {
telemetry = std::make_unique<blackhole::BlackholeArcTelemetryReader>(this);
}

BlackholeTTDevice::~BlackholeTTDevice() {
// Turn off iATU for the regions we programmed. This won't happen if the
Expand Down Expand Up @@ -80,4 +83,32 @@ void BlackholeTTDevice::configure_iatu_region(size_t region, uint64_t base, uint
target);
}

ChipInfo BlackholeTTDevice::get_chip_info() {
chip_info.harvesting_masks.tensix_harvesting_mask =
pjanevskiTT marked this conversation as resolved.
Show resolved Hide resolved
telemetry->is_entry_available(blackhole::TAG_ENABLED_TENSIX_COL)
? (~telemetry->read_entry(blackhole::TAG_ENABLED_TENSIX_COL) & 0x3FFF)
: 0;
chip_info.harvesting_masks.dram_harvesting_mask = telemetry->is_entry_available(blackhole::TAG_ENABLED_GDDR)
? (~telemetry->read_entry(blackhole::TAG_ENABLED_GDDR) & 0xFF)
: 0;
chip_info.harvesting_masks.eth_harvesting_mask = telemetry->is_entry_available(blackhole::TAG_ENABLED_ETH)
? (~telemetry->read_entry(blackhole::TAG_ENABLED_ETH) & 0x3FFF)
: 0;

// It is expected that this entry is always available.
chip_info.chip_uid.asic_location = telemetry->read_entry(blackhole::TAG_ASIC_ID);

// For now, NOC translation is disabled on all Blackhole boards.
// TODO: read this information when it becomes available.
chip_info.noc_translation_enabled = false;

// It is expected that these entries are always available.
chip_info.chip_uid.board_id = ((uint64_t)telemetry->read_entry(blackhole::TAG_BOARD_ID_HIGH) << 32) |
(telemetry->read_entry(blackhole::TAG_BOARD_ID_LOW));

chip_info.board_type = get_board_type_from_board_id(chip_info.chip_uid.board_id);

return chip_info;
}

} // namespace tt::umd
5 changes: 5 additions & 0 deletions device/tt_device/grayskull_tt_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ namespace tt::umd {

GrayskullTTDevice::GrayskullTTDevice(std::unique_ptr<PCIDevice> pci_device) :
TTDevice(std::move(pci_device), std::make_unique<grayskull_implementation>()) {}

ChipInfo GrayskullTTDevice::get_chip_info() {
throw std::runtime_error("Reading ChipInfo is not supported for Grayskull.");
}

} // namespace tt::umd
5 changes: 5 additions & 0 deletions device/tt_device/wormhole_tt_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ namespace tt::umd {

WormholeTTDevice::WormholeTTDevice(std::unique_ptr<PCIDevice> pci_device) :
TTDevice(std::move(pci_device), std::make_unique<wormhole_implementation>()) {}

ChipInfo WormholeTTDevice::get_chip_info() {
throw std::runtime_error("Reading ChipInfo is not supported for Wormhole.");
}

} // namespace tt::umd
1 change: 1 addition & 0 deletions tests/blackhole/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set(UNIT_TESTS_BH_SRCS
test_cluster_bh.cpp
test_arc_messages_bh.cpp
test_arc_telemetry_bh.cpp
test_chip_info_bh.cpp
pjanevskiTT marked this conversation as resolved.
Show resolved Hide resolved
)

add_executable(unit_tests_blackhole ${UNIT_TESTS_BH_SRCS})
Expand Down
21 changes: 21 additions & 0 deletions tests/blackhole/test_chip_info_bh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-FileCopyrightText: (c) 2025 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0
#include "gtest/gtest.h"
#include "umd/device/tt_device/tt_device.h"

using namespace tt::umd;

TEST(BlackholeChipInfo, BasicChipInfo) {
std::vector<int> pci_device_ids = PCIDevice::enumerate_devices();

for (int pci_device_id : pci_device_ids) {
std::unique_ptr<TTDevice> tt_device = TTDevice::create(pci_device_id);

const ChipInfo chip_info = tt_device->get_chip_info();

EXPECT_TRUE(chip_info.board_type == BoardType::P100 || chip_info.board_type == BoardType::P150A);

EXPECT_TRUE(chip_info.chip_uid.asic_location == 0 || chip_info.chip_uid.asic_location == 1);
}
}