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

Allow optional soft reset option to be passed into deassert_risc_reset_at_core #292

Merged
merged 2 commits into from
Nov 13, 2024
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
2 changes: 1 addition & 1 deletion device/mockup/tt_mockup_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class tt_MockupDevice : public tt_device {
void start_device(const tt_device_params& device_params) override {}
void assert_risc_reset() override {}
void deassert_risc_reset() override {}
void deassert_risc_reset_at_core(tt_cxy_pair core) override {}
void deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets = TENSIX_DEASSERT_SOFT_RESET) override {}
void assert_risc_reset_at_core(tt_cxy_pair core) override {}
void close_device() override {}

Expand Down
2 changes: 1 addition & 1 deletion device/simulation/deprecated/tt_emulation_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void tt_emulation_device::assert_risc_reset() {
log_info(tt::LogEmulationDriver, "Asserted all tensix RISC Reset ");
}

void tt_emulation_device::deassert_risc_reset_at_core(tt_cxy_pair core) {
void tt_emulation_device::deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets) {
tt_zebu_wrapper_inst->tensix_reset_deassert(core.x, core.y);
}

Expand Down
2 changes: 1 addition & 1 deletion device/simulation/deprecated/tt_emulation_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class tt_emulation_device : public tt_device {
virtual void start_device(const tt_device_params& device_params);
virtual void close_device();
virtual void deassert_risc_reset();
virtual void deassert_risc_reset_at_core(tt_cxy_pair core);
virtual void deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets = TENSIX_DEASSERT_SOFT_RESET);
virtual void assert_risc_reset();
virtual void assert_risc_reset_at_core(tt_cxy_pair core);
virtual void write_to_device(std::vector<uint32_t>& vec, tt_cxy_pair core, uint64_t addr, const std::string& tlb_to_use, bool send_epoch_cmd = false, bool last_send_epoch_cmd = true, bool ordered_with_prev_remote_write = false);
Expand Down
2 changes: 1 addition & 1 deletion device/simulation/deprecated/tt_emulation_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void tt_emulation_device::deassert_risc_reset() {}

void tt_emulation_device::assert_risc_reset() {}

void tt_emulation_device::deassert_risc_reset_at_core(tt_cxy_pair core) {}
void tt_emulation_device::deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets) {}

void tt_emulation_device::assert_risc_reset_at_core(tt_cxy_pair core) {}

Expand Down
2 changes: 1 addition & 1 deletion device/simulation/deprecated/tt_versim_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void tt_VersimDevice::deassert_risc_reset() {
versim::startup_versim_main_loop(*versim);
}

void tt_VersimDevice::deassert_risc_reset_at_core(tt_cxy_pair core) {
void tt_VersimDevice::deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets) {
// This function deasserts reset on the full versim device (don't need core level granularity for versim)
deassert_risc_reset();
}
Expand Down
2 changes: 1 addition & 1 deletion device/simulation/deprecated/tt_versim_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class tt_VersimDevice: public tt_device
virtual void start_device(const tt_device_params &device_params);
virtual void close_device();
virtual void deassert_risc_reset();
virtual void deassert_risc_reset_at_core(tt_cxy_pair core);
virtual void deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets = TENSIX_DEASSERT_SOFT_RESET);
virtual void assert_risc_reset();
virtual void assert_risc_reset_at_core(tt_cxy_pair core);
virtual void write_to_device(std::vector<uint32_t> &vec, tt_cxy_pair core, uint64_t addr, const std::string& tlb_to_use, bool send_epoch_cmd = false, bool last_send_epoch_cmd = true, bool ordered_with_prev_remote_write = false);
Expand Down
2 changes: 1 addition & 1 deletion device/simulation/deprecated/tt_versim_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void tt_VersimDevice::start(
) {}

void tt_VersimDevice::deassert_risc_reset() {}
void tt_VersimDevice::deassert_risc_reset_at_core(tt_cxy_pair core) {}
void tt_VersimDevice::deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets) {}
void tt_VersimDevice::assert_risc_reset() {}
void tt_VersimDevice::assert_risc_reset_at_core(tt_cxy_pair core) {}

Expand Down
2 changes: 1 addition & 1 deletion device/simulation/tt_simulation_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void tt_SimulationDevice::deassert_risc_reset() {
host.send_to_device(wr_buffer_ptr, wr_buffer_size);
}

void tt_SimulationDevice::deassert_risc_reset_at_core(tt_cxy_pair core) {
void tt_SimulationDevice::deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets) {
log_info(tt::LogEmulationDriver, "Sending 'deassert_risc_reset_at_core'.. (Not implemented, defaulting to 'deassert_risc_reset' instead)");
deassert_risc_reset();
}
Expand Down
2 changes: 1 addition & 1 deletion device/simulation/tt_simulation_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class tt_SimulationDevice: public tt_device {
virtual void start_device(const tt_device_params &device_params);
virtual void assert_risc_reset();
virtual void deassert_risc_reset();
virtual void deassert_risc_reset_at_core(tt_cxy_pair core);
virtual void deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets = TENSIX_DEASSERT_SOFT_RESET);
virtual void assert_risc_reset_at_core(tt_cxy_pair core);
virtual void close_device();

Expand Down
4 changes: 2 additions & 2 deletions device/tt_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class tt_device
*
* @param core Chip and core being targeted.
*/
virtual void deassert_risc_reset_at_core(tt_cxy_pair core) {
virtual void deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets = TENSIX_DEASSERT_SOFT_RESET) {
throw std::runtime_error("---- tt_device::deassert_risc_reset_at_core is not implemented\n");
}

Expand Down Expand Up @@ -634,7 +634,7 @@ class tt_SiliconDevice: public tt_device
virtual void start_device(const tt_device_params &device_params);
virtual void assert_risc_reset();
virtual void deassert_risc_reset();
virtual void deassert_risc_reset_at_core(tt_cxy_pair core);
virtual void deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets = TENSIX_DEASSERT_SOFT_RESET);
virtual void assert_risc_reset_at_core(tt_cxy_pair core);
virtual void close_device();

Expand Down
6 changes: 3 additions & 3 deletions device/tt_silicon_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,19 +741,19 @@ void tt_SiliconDevice::deassert_risc_reset() {
broadcast_tensix_risc_reset_to_cluster(TENSIX_DEASSERT_SOFT_RESET);
}

void tt_SiliconDevice::deassert_risc_reset_at_core(tt_cxy_pair core) {
void tt_SiliconDevice::deassert_risc_reset_at_core(tt_cxy_pair core, const TensixSoftResetOptions &soft_resets) {
std::uint32_t target_device = core.chip; // Get Target Device to query soc descriptor and determine location in cluster
log_assert(std::find(get_soc_descriptor(target_device).workers.begin(), get_soc_descriptor(target_device).workers.end(), core) != get_soc_descriptor(target_device).workers.end() ||
std::find(get_soc_descriptor(target_device).ethernet_cores.begin(), get_soc_descriptor(target_device).ethernet_cores.end(), core) != get_soc_descriptor(target_device).ethernet_cores.end(),
"Cannot deassert reset on a non-tensix or harvested core");
bool target_is_mmio_capable = ndesc -> is_chip_mmio_capable(target_device);
if(target_is_mmio_capable) {
log_assert(m_pci_device_map.find(target_device) != m_pci_device_map.end(), "Could not find MMIO mapped device in devices connected over PCIe");
send_tensix_risc_reset_to_core(core, TENSIX_DEASSERT_SOFT_RESET);
send_tensix_risc_reset_to_core(core, soft_resets);
}
else {
log_assert(arch_name != tt::ARCH::BLACKHOLE, "Can't issue access to remote core in BH");
send_remote_tensix_risc_reset_to_core(core, TENSIX_DEASSERT_SOFT_RESET);
send_remote_tensix_risc_reset_to_core(core, soft_resets);
}
}

Expand Down
64 changes: 64 additions & 0 deletions tests/api/test_chip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ inline std::unique_ptr<tt_ClusterDescriptor> get_cluster_desc() {
return cluster_desc;
}

inline tt_cxy_pair get_tensix_chip_core_coord(const std::unique_ptr<Cluster> &umd_cluster) {
chip_id_t any_mmio_chip = *umd_cluster->get_target_mmio_device_ids().begin();
const tt_SocDescriptor& soc_desc = umd_cluster->get_soc_descriptor(any_mmio_chip);
tt_xy_pair core = soc_desc.workers[0];
return tt_cxy_pair(any_mmio_chip, core);
}

inline std::unique_ptr<Cluster> get_cluster() {

// TODO: This should not be needed. And could be part of the cluster descriptor probably.
Expand Down Expand Up @@ -187,3 +194,60 @@ TEST(ApiChipTest, SimpleAPIShowcase) {
umd_cluster->get_pcie_base_addr_from_device(chip_id);
umd_cluster->get_num_host_channels(chip_id);
}

// This tests puts a specific core into reset and then deasserts it using default deassert value
// It reads back the risc reset reg to validate
TEST(ApiChipTest, DeassertRiscResetOnCore) {
std::unique_ptr<Cluster> umd_cluster = get_cluster();

tt_cxy_pair chip_core_coord = get_tensix_chip_core_coord(umd_cluster);

umd_cluster->assert_risc_reset_at_core(chip_core_coord);
umd_cluster->l1_membar(chip_core_coord.chip, "LARGE_WRITE_TLB");
umd_cluster->deassert_risc_reset_at_core(chip_core_coord);
umd_cluster->l1_membar(chip_core_coord.chip, "LARGE_WRITE_TLB");

uint32_t soft_reset_reg_addr = 0xFFB121B0;
uint32_t expected_risc_reset_val = static_cast<uint32_t>(TENSIX_DEASSERT_SOFT_RESET);
uint32_t risc_reset_val;
umd_cluster->read_from_device(&risc_reset_val, chip_core_coord, soft_reset_reg_addr, sizeof(uint32_t), "REG_TLB");
EXPECT_EQ(expected_risc_reset_val, risc_reset_val);
}

// This tests puts a specific core into reset and then specifies a legal deassert value
// It reads back the risc reset reg to validate
TEST(ApiChipTest, SpecifyLegalDeassertRiscResetOnCore) {
std::unique_ptr<Cluster> umd_cluster = get_cluster();

tt_cxy_pair chip_core_coord = get_tensix_chip_core_coord(umd_cluster);

umd_cluster->assert_risc_reset_at_core(chip_core_coord);
TensixSoftResetOptions deassert_val = ALL_TRISC_SOFT_RESET | TensixSoftResetOptions::STAGGERED_START;
umd_cluster->deassert_risc_reset_at_core(chip_core_coord, deassert_val);
umd_cluster->l1_membar(chip_core_coord.chip, "LARGE_WRITE_TLB");

uint32_t soft_reset_reg_addr = 0xFFB121B0;
uint32_t risc_reset_val;
umd_cluster->read_from_device(&risc_reset_val, chip_core_coord, soft_reset_reg_addr, sizeof(uint32_t), "REG_TLB");
EXPECT_EQ(static_cast<uint32_t>(deassert_val), risc_reset_val);
}

// // This tests puts a specific core into reset and then specifies an illegal deassert value
// // It reads back the risc reset reg to validate that reset reg is in a legal state
TEST(ApiChipTest, SpecifyIllegalDeassertRiscResetOnCore) {
std::unique_ptr<Cluster> umd_cluster = get_cluster();

tt_cxy_pair chip_core_coord = get_tensix_chip_core_coord(umd_cluster);

umd_cluster->assert_risc_reset_at_core(chip_core_coord);

TensixSoftResetOptions deassert_val = static_cast<TensixSoftResetOptions>(0xDEADBEEF);
umd_cluster->deassert_risc_reset_at_core(chip_core_coord, deassert_val);
umd_cluster->l1_membar(chip_core_coord.chip, "LARGE_WRITE_TLB");

uint32_t soft_reset_reg_addr = 0xFFB121B0;
uint32_t risc_reset_val;
umd_cluster->read_from_device(&risc_reset_val, chip_core_coord, soft_reset_reg_addr, sizeof(uint32_t), "REG_TLB");
uint32_t expected_deassert_val = static_cast<uint32_t>(deassert_val & ALL_TENSIX_SOFT_RESET);
EXPECT_EQ(risc_reset_val, expected_deassert_val);
}
Loading