From f4da414eade2a90a1287f182b18b1c2a532a8c6e Mon Sep 17 00:00:00 2001 From: pjanevski Date: Mon, 9 Dec 2024 13:57:40 +0000 Subject: [PATCH] Rename device to cluster in tests --- tests/blackhole/CMakeLists.txt | 2 +- tests/blackhole/test_bh_common.h | 22 +- ...icon_driver_bh.cpp => test_cluster_bh.cpp} | 262 +++++++++--------- .../galaxy/test_umd_remote_api_stability.cpp | 14 +- tests/grayskull/CMakeLists.txt | 2 +- ...silicon_driver.cpp => test_cluster_gs.cpp} | 172 ++++++------ tests/test_utils/stimulus_generators.hpp | 36 +-- tests/wormhole/CMakeLists.txt | 2 +- ...icon_driver_wh.cpp => test_cluster_wh.cpp} | 244 ++++++++-------- .../test_umd_remote_api_stability.cpp | 56 ++-- tests/wormhole/test_wh_common.h | 22 +- 11 files changed, 417 insertions(+), 417 deletions(-) rename tests/blackhole/{test_silicon_driver_bh.cpp => test_cluster_bh.cpp} (83%) rename tests/grayskull/{test_silicon_driver.cpp => test_cluster_gs.cpp} (79%) rename tests/wormhole/{test_silicon_driver_wh.cpp => test_cluster_wh.cpp} (83%) diff --git a/tests/blackhole/CMakeLists.txt b/tests/blackhole/CMakeLists.txt index d153cdda..e47a5655 100644 --- a/tests/blackhole/CMakeLists.txt +++ b/tests/blackhole/CMakeLists.txt @@ -1,4 +1,4 @@ -set(UNIT_TESTS_BH_SRCS test_silicon_driver_bh.cpp) +set(UNIT_TESTS_BH_SRCS test_cluster_bh.cpp) add_executable(unit_tests_blackhole ${UNIT_TESTS_BH_SRCS}) target_link_libraries(unit_tests_blackhole PRIVATE test_common) diff --git a/tests/blackhole/test_bh_common.h b/tests/blackhole/test_bh_common.h index 0297b191..af9902ae 100644 --- a/tests/blackhole/test_bh_common.h +++ b/tests/blackhole/test_bh_common.h @@ -13,9 +13,9 @@ using namespace tt::umd; namespace tt::umd::test::utils { -static void set_params_for_remote_txn(Cluster& device) { +static void set_params_for_remote_txn(Cluster& cluster) { // Populate address map and NOC parameters that the driver needs for remote transactions - device.set_device_l1_address_params( + cluster.set_device_l1_address_params( {l1_mem::address_map::L1_BARRIER_BASE, eth_l1_mem::address_map::ERISC_BARRIER_BASE, eth_l1_mem::address_map::FW_VERSION_ADDR}); @@ -26,7 +26,7 @@ class BlackholeTestFixture : public ::testing::Test { // You can remove any or all of the following functions if their bodies would // be empty. - std::unique_ptr device; + std::unique_ptr cluster; BlackholeTestFixture() {} @@ -54,18 +54,18 @@ class BlackholeTestFixture : public ::testing::Test { std::iota(devices.begin(), devices.end(), 0); std::set target_devices = {devices.begin(), devices.end()}; uint32_t num_host_mem_ch_per_mmio_device = 1; - device = std::make_unique(num_host_mem_ch_per_mmio_device, false, true, true); - assert(device != nullptr); - assert(device->get_cluster_description()->get_number_of_chips() == get_detected_num_chips()); + cluster = std::make_unique(num_host_mem_ch_per_mmio_device, false, true, true); + assert(cluster != nullptr); + assert(cluster->get_cluster_description()->get_number_of_chips() == get_detected_num_chips()); - set_params_for_remote_txn(*device); + set_params_for_remote_txn(*cluster); tt_device_params default_params; - device->start_device(default_params); + cluster->start_device(default_params); - device->deassert_risc_reset(); + cluster->deassert_risc_reset(); - device->wait_for_non_mmio_flush(); + cluster->wait_for_non_mmio_flush(); } void TearDown() override { @@ -74,7 +74,7 @@ class BlackholeTestFixture : public ::testing::Test { if (!is_test_skipped()) { // std::cout << "Tearing Down Test." << std::endl; - device->close_device(); + cluster->close_device(); } } }; diff --git a/tests/blackhole/test_silicon_driver_bh.cpp b/tests/blackhole/test_cluster_bh.cpp similarity index 83% rename from tests/blackhole/test_silicon_driver_bh.cpp rename to tests/blackhole/test_cluster_bh.cpp index 5b653d4d..5f7b86c7 100644 --- a/tests/blackhole/test_silicon_driver_bh.cpp +++ b/tests/blackhole/test_cluster_bh.cpp @@ -18,9 +18,9 @@ using namespace tt::umd; -void set_params_for_remote_txn(Cluster& device) { +void set_params_for_remote_txn(Cluster& cluster) { // Populate address map and NOC parameters that the driver needs for remote transactions - device.set_device_l1_address_params( + cluster.set_device_l1_address_params( {l1_mem::address_map::L1_BARRIER_BASE, eth_l1_mem::address_map::ERISC_BARRIER_BASE, eth_l1_mem::address_map::FW_VERSION_ADDR}); @@ -85,17 +85,17 @@ TEST(SiliconDriverBH, CreateDestroy) { tt_device_params default_params; // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting for (int i = 0; i < 50; i++) { - Cluster device = Cluster( + Cluster cluster = Cluster( test_utils::GetAbsPath("tests/soc_descs/blackhole_140_arch_no_eth.yaml"), target_devices, num_host_mem_ch_per_mmio_device, false, true, false); - set_params_for_remote_txn(device); - device.start_device(default_params); - device.deassert_risc_reset(); - device.close_device(); + set_params_for_remote_txn(cluster); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); + cluster.close_device(); } } @@ -113,7 +113,7 @@ TEST(SiliconDriverBH, CreateDestroy) { // } // uint32_t num_host_mem_ch_per_mmio_device = 1; -// Cluster device = Cluster( +// Cluster cluster = Cluster( // "./tests/soc_descs/wormhole_b0_8x10.yaml", // target_devices, // num_host_mem_ch_per_mmio_device, @@ -121,17 +121,17 @@ TEST(SiliconDriverBH, CreateDestroy) { // true, // true, // simulated_harvesting_masks); -// auto sdesc_per_chip = device.get_virtual_soc_descriptors(); +// auto sdesc_per_chip = cluster.get_virtual_soc_descriptors(); -// ASSERT_EQ(device.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; +// ASSERT_EQ(cluster.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; // for (const auto& chip : sdesc_per_chip) { // ASSERT_EQ(chip.second.workers.size(), 48) // << "Expected SOC descriptor with harvesting to have 48 workers for chip" << chip.first; // } -// ASSERT_EQ(device.get_harvesting_masks_for_soc_descriptors().at(0), 30) +// ASSERT_EQ(cluster.get_harvesting_masks_for_soc_descriptors().at(0), 30) // << "Expected first chip to have harvesting mask of 30"; -// ASSERT_EQ(device.get_harvesting_masks_for_soc_descriptors().at(1), 60) +// ASSERT_EQ(cluster.get_harvesting_masks_for_soc_descriptors().at(1), 60) // << "Expected second chip to have harvesting mask of 60"; // } @@ -149,7 +149,7 @@ TEST(SiliconDriverBH, CreateDestroy) { // uint32_t num_host_mem_ch_per_mmio_device = 1; // // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting -// Cluster device = Cluster( +// Cluster cluster = Cluster( // "./tests/soc_descs/wormhole_b0_1x1.yaml", // target_devices, // num_host_mem_ch_per_mmio_device, @@ -157,9 +157,9 @@ TEST(SiliconDriverBH, CreateDestroy) { // true, // false, // simulated_harvesting_masks); -// auto sdesc_per_chip = device.get_virtual_soc_descriptors(); +// auto sdesc_per_chip = cluster.get_virtual_soc_descriptors(); -// ASSERT_EQ(device.using_harvested_soc_descriptors(), false) +// ASSERT_EQ(cluster.using_harvested_soc_descriptors(), false) // << "SOC descriptors should not be modified when harvesting is disabled"; // for (const auto& chip : sdesc_per_chip) { // ASSERT_EQ(chip.second.workers.size(), 1) << "Expected 1x1 SOC descriptor to be unmodified by driver"; @@ -182,7 +182,7 @@ TEST(SiliconDriverBH, CreateDestroy) { // uint32_t num_host_mem_ch_per_mmio_device = 1; -// Cluster device = Cluster( +// Cluster cluster = Cluster( // "./tests/soc_descs/wormhole_b0_8x10.yaml", // target_devices, // num_host_mem_ch_per_mmio_device, @@ -190,8 +190,8 @@ TEST(SiliconDriverBH, CreateDestroy) { // true, // true, // simulated_harvesting_masks); -// set_params_for_remote_txn(device); -// auto mmio_devices = device.get_target_mmio_device_ids(); +// set_params_for_remote_txn(cluster); +// auto mmio_devices = cluster.get_target_mmio_device_ids(); // for (int i = 0; i < target_devices.size(); i++) { // // Iterate over MMIO devices and only setup static TLBs for worker cores @@ -199,16 +199,16 @@ TEST(SiliconDriverBH, CreateDestroy) { // auto& sdesc = device.get_soc_descriptor(i); // for (auto& core : sdesc.workers) { // // Statically mapping a 1MB TLB to this core, starting from address NCRISC_FIRMWARE_BASE. -// device.configure_tlb( +// cluster.configure_tlb( // i, core, get_static_tlb_index_callback(core), l1_mem::address_map::NCRISC_FIRMWARE_BASE); // } // } // } -// device.setup_core_to_tlb_map(get_static_tlb_index_callback); +// cluster.setup_core_to_tlb_map(get_static_tlb_index_callback); // tt_device_params default_params; -// device.start_device(default_params); -// device.deassert_risc_reset(); +// cluster.start_device(default_params); +// cluster.deassert_risc_reset(); // std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; // std::vector dynamic_readback_vec = {}; @@ -227,17 +227,17 @@ TEST(SiliconDriverBH, CreateDestroy) { // tt_cxy_pair(i, core), // address, // ""); -// device.write_to_device( +// cluster.write_to_device( // vector_to_write.data(), // vector_to_write.size() * sizeof(std::uint32_t), // tt_cxy_pair(i, core), // dynamic_write_address, // "SMALL_READ_WRITE_TLB"); -// device.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited +// cluster.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited -// test_utils::read_data_from_device(device, readback_vec, tt_cxy_pair(i, core), address, 40, ""); +// test_utils::read_data_from_device(cluster, readback_vec, tt_cxy_pair(i, core), address, 40, ""); // test_utils::read_data_from_device( -// device, +// cluster, // dynamic_readback_vec, // tt_cxy_pair(i, core), // dynamic_write_address, @@ -247,21 +247,21 @@ TEST(SiliconDriverBH, CreateDestroy) { // << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; // ASSERT_EQ(vector_to_write, dynamic_readback_vec) // << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; -// device.wait_for_non_mmio_flush(); +// cluster.wait_for_non_mmio_flush(); -// device.write_to_device( +// cluster.write_to_device( // zeros.data(), // zeros.size() * sizeof(std::uint32_t), // tt_cxy_pair(i, core), // dynamic_write_address, // "SMALL_READ_WRITE_TLB"); // Clear any written data -// device.write_to_device( +// cluster.write_to_device( // zeros.data(), // zeros.size() * sizeof(std::uint32_t), // tt_cxy_pair(i, core), // address, // ""); // Clear any written data -// device.wait_for_non_mmio_flush(); +// cluster.wait_for_non_mmio_flush(); // readback_vec = {}; // dynamic_readback_vec = {}; // } @@ -269,7 +269,7 @@ TEST(SiliconDriverBH, CreateDestroy) { // dynamic_write_address += 0x20; // } // } -// device.close_device(); +// cluster.close_device(); // } TEST(SiliconDriverBH, UnalignedStaticTLB_RW) { @@ -279,9 +279,9 @@ TEST(SiliconDriverBH, UnalignedStaticTLB_RW) { uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); for (int i = 0; i < target_devices.size(); i++) { // Iterate over MMIO devices and only setup static TLBs for worker cores @@ -289,16 +289,16 @@ TEST(SiliconDriverBH, UnalignedStaticTLB_RW) { auto& sdesc = device.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address NCRISC_FIRMWARE_BASE. - device.configure_tlb( + cluster.configure_tlb( i, core, get_static_tlb_index_callback(core), l1_mem::address_map::NCRISC_FIRMWARE_BASE); } - device.setup_core_to_tlb_map(i, get_static_tlb_index_callback); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index_callback); } } tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector unaligned_sizes = {3, 14, 21, 255, 362, 430, 1022, 1023, 1025}; for (int i = 0; i < target_devices.size(); i++) { @@ -316,17 +316,17 @@ TEST(SiliconDriverBH, UnalignedStaticTLB_RW) { device.read_from_device(readback_vec.data(), tt_cxy_pair(i, core), address, size, ""); ASSERT_EQ(readback_vec, write_vec); readback_vec = std::vector(size, 0); - device.write_to_sysmem(write_vec.data(), size, 0, 0, 0); - device.read_from_sysmem(readback_vec.data(), 0, 0, size, 0); + cluster.write_to_sysmem(write_vec.data(), size, 0, 0, 0); + cluster.read_from_sysmem(readback_vec.data(), 0, 0, size, 0); ASSERT_EQ(readback_vec, write_vec); readback_vec = std::vector(size, 0); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); } address += 0x20; } } } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverBH, StaticTLB_RW) { @@ -336,9 +336,9 @@ TEST(SiliconDriverBH, StaticTLB_RW) { uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); for (int i = 0; i < target_devices.size(); i++) { // Iterate over MMIO devices and only setup static TLBs for worker cores @@ -346,18 +346,18 @@ TEST(SiliconDriverBH, StaticTLB_RW) { auto& sdesc = device.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 2MB TLB to this core, starting from address NCRISC_FIRMWARE_BASE. - device.configure_tlb( + cluster.configure_tlb( i, core, get_static_tlb_index_callback(core), l1_mem::address_map::NCRISC_FIRMWARE_BASE); } - device.setup_core_to_tlb_map(i, get_static_tlb_index_callback); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index_callback); } } printf("MT: Static TLBs set\n"); tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector readback_vec = {}; @@ -374,24 +374,24 @@ TEST(SiliconDriverBH, StaticTLB_RW) { tt_cxy_pair(i, core), address, ""); - device.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited - test_utils::read_data_from_device(device, readback_vec, tt_cxy_pair(i, core), address, 40, ""); + cluster.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited + test_utils::read_data_from_device(cluster, readback_vec, tt_cxy_pair(i, core), address, 40, ""); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; - device.wait_for_non_mmio_flush(); - device.write_to_device( + cluster.wait_for_non_mmio_flush(); + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), address, "SMALL_READ_WRITE_TLB"); // Clear any written data - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); readback_vec = {}; } address += 0x20; // Increment by uint32_t size for each write } } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverBH, DynamicTLB_RW) { @@ -400,14 +400,14 @@ TEST(SiliconDriverBH, DynamicTLB_RW) { std::set target_devices = get_target_devices(); uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); + set_params_for_remote_txn(cluster); tt_device_params default_params; - device.start_device(default_params); + cluster.start_device(default_params); // MT: Don't deassert risc resets since there's no loaded FW - // device.deassert_risc_reset(); + // cluster.deassert_risc_reset(); std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector zeros = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -424,19 +424,19 @@ TEST(SiliconDriverBH, DynamicTLB_RW) { tt_cxy_pair(i, core), address, "SMALL_READ_WRITE_TLB"); - device.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited + cluster.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, 40, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; - device.wait_for_non_mmio_flush(); - device.write_to_device( + cluster.wait_for_non_mmio_flush(); + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), address, "SMALL_READ_WRITE_TLB"); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); readback_vec = {}; } address += 0x20; // Increment by uint32_t size for each write @@ -454,25 +454,25 @@ TEST(SiliconDriverBH, DynamicTLB_RW) { for (int ch = 0; ch < NUM_CHANNELS; ch++) { std::vector chan = device.get_soc_descriptor(i).dram_cores.at(ch); tt_xy_pair subchan = chan.at(0); - device.write_to_device( + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(i, subchan), address, "SMALL_READ_WRITE_TLB"); - device.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited + cluster.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, subchan), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(i, subchan), address, 40, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << subchan.x << "-" << subchan.y << "does not match what was written"; - device.wait_for_non_mmio_flush(); - device.write_to_device( + cluster.wait_for_non_mmio_flush(); + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, subchan), address, "SMALL_READ_WRITE_TLB"); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); readback_vec = {}; address += 0x20; // Increment by uint32_t size for each write } @@ -480,7 +480,7 @@ TEST(SiliconDriverBH, DynamicTLB_RW) { } printf("Target DRAM completed\n"); - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverBH, MultiThreadedDevice) { @@ -490,13 +490,13 @@ TEST(SiliconDriverBH, MultiThreadedDevice) { std::set target_devices = get_target_devices(); uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); + set_params_for_remote_txn(cluster); tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::thread th1 = std::thread([&] { std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; @@ -511,7 +511,7 @@ TEST(SiliconDriverBH, MultiThreadedDevice) { address, "SMALL_READ_WRITE_TLB"); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; readback_vec = {}; @@ -527,14 +527,14 @@ TEST(SiliconDriverBH, MultiThreadedDevice) { for (auto& core_ls : device.get_soc_descriptor(0).dram_cores) { for (int loop = 0; loop < 100; loop++) { for (auto& core : core_ls) { - device.write_to_device( + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, "SMALL_READ_WRITE_TLB"); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; readback_vec = {}; @@ -546,7 +546,7 @@ TEST(SiliconDriverBH, MultiThreadedDevice) { th1.join(); th2.join(); - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverBH, MultiThreadedMemBar) { @@ -561,26 +561,26 @@ TEST(SiliconDriverBH, MultiThreadedMemBar) { uint32_t base_addr = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); for (int i = 0; i < target_devices.size(); i++) { // Iterate over devices and only setup static TLBs for functional worker cores auto& sdesc = device.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address DATA_BUFFER_SPACE_BASE. - device.configure_tlb(i, core, get_static_tlb_index_callback(core), base_addr); + cluster.configure_tlb(i, core, get_static_tlb_index_callback(core), base_addr); } - device.setup_core_to_tlb_map(i, get_static_tlb_index_callback); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index_callback); } tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector readback_membar_vec = {}; for (auto& core : device.get_soc_descriptor(0).workers) { test_utils::read_data_from_device( - device, + cluster, readback_membar_vec, tt_cxy_pair(0, core), l1_mem::address_map::L1_BARRIER_BASE, @@ -594,7 +594,7 @@ TEST(SiliconDriverBH, MultiThreadedMemBar) { for (int chan = 0; chan < device.get_soc_descriptor(0).get_num_dram_channels(); chan++) { auto core = device.get_soc_descriptor(0).get_core_for_dram_channel(chan, 0); test_utils::read_data_from_device( - device, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); + cluster, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); ASSERT_EQ( readback_membar_vec.at(0), 187); // Ensure that memory barriers were correctly initialized on all DRAM readback_membar_vec = {}; @@ -602,7 +602,7 @@ TEST(SiliconDriverBH, MultiThreadedMemBar) { for (auto& core : device.get_soc_descriptor(0).ethernet_cores) { test_utils::read_data_from_device( - device, + cluster, readback_membar_vec, tt_cxy_pair(0, core), eth_l1_mem::address_map::ERISC_BARRIER_BASE, @@ -631,13 +631,13 @@ TEST(SiliconDriverBH, MultiThreadedMemBar) { for (int loop = 0; loop < 50; loop++) { for (auto& core : device.get_soc_descriptor(0).workers) { std::vector readback_vec = {}; - device.write_to_device( + cluster.write_to_device( vec1.data(), vec1.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); - device.l1_membar(0, "SMALL_READ_WRITE_TLB", {core}); + cluster.l1_membar(0, "SMALL_READ_WRITE_TLB", {core}); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 4 * vec1.size(), ""); + cluster, readback_vec, tt_cxy_pair(0, core), address, 4 * vec1.size(), ""); ASSERT_EQ(readback_vec, vec1); - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); readback_vec = {}; } @@ -649,13 +649,13 @@ TEST(SiliconDriverBH, MultiThreadedMemBar) { for (int loop = 0; loop < 50; loop++) { for (auto& core : device.get_soc_descriptor(0).workers) { std::vector readback_vec = {}; - device.write_to_device( + cluster.write_to_device( vec2.data(), vec2.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); - device.l1_membar(0, "SMALL_READ_WRITE_TLB", {core}); + cluster.l1_membar(0, "SMALL_READ_WRITE_TLB", {core}); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 4 * vec2.size(), ""); + cluster, readback_vec, tt_cxy_pair(0, core), address, 4 * vec2.size(), ""); ASSERT_EQ(readback_vec, vec2); - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); readback_vec = {}; } @@ -667,7 +667,7 @@ TEST(SiliconDriverBH, MultiThreadedMemBar) { for (auto& core : device.get_soc_descriptor(0).workers) { test_utils::read_data_from_device( - device, + cluster, readback_membar_vec, tt_cxy_pair(0, core), l1_mem::address_map::L1_BARRIER_BASE, @@ -680,7 +680,7 @@ TEST(SiliconDriverBH, MultiThreadedMemBar) { for (auto& core : device.get_soc_descriptor(0).ethernet_cores) { test_utils::read_data_from_device( - device, + cluster, readback_membar_vec, tt_cxy_pair(0, core), eth_l1_mem::address_map::ERISC_BARRIER_BASE, @@ -691,7 +691,7 @@ TEST(SiliconDriverBH, MultiThreadedMemBar) { 187); // Ensure that memory barriers end up in the correct sate for ethernet cores readback_membar_vec = {}; } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverBH, DISABLED_BroadcastWrite) { // Cannot broadcast to tensix/ethernet and DRAM simultaneously on @@ -701,13 +701,13 @@ TEST(SiliconDriverBH, DISABLED_BroadcastWrite) { // Cannot broadcast to tensix/ uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector broadcast_sizes = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}; uint32_t address = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; std::set rows_to_exclude = {0, 6}; @@ -724,7 +724,7 @@ TEST(SiliconDriverBH, DISABLED_BroadcastWrite) { // Cannot broadcast to tensix/ zeros[i] = 0; } // Broadcast to Tensix - device.broadcast_write_to_cluster( + cluster.broadcast_write_to_cluster( vector_to_write.data(), vector_to_write.size() * 4, address, @@ -732,9 +732,9 @@ TEST(SiliconDriverBH, DISABLED_BroadcastWrite) { // Cannot broadcast to tensix/ rows_to_exclude, cols_to_exclude, "LARGE_WRITE_TLB"); - device.wait_for_non_mmio_flush(); // flush here so we don't simultaneously broadcast to DRAM? + cluster.wait_for_non_mmio_flush(); // flush here so we don't simultaneously broadcast to DRAM? // Broadcast to DRAM - device.broadcast_write_to_cluster( + cluster.broadcast_write_to_cluster( vector_to_write.data(), vector_to_write.size() * 4, address, @@ -742,7 +742,7 @@ TEST(SiliconDriverBH, DISABLED_BroadcastWrite) { // Cannot broadcast to tensix/ rows_to_exclude_for_dram_broadcast, cols_to_exclude_for_dram_broadcast, "LARGE_WRITE_TLB"); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); for (const auto i : target_devices) { for (const auto& core : device.get_soc_descriptor(i).workers) { @@ -750,10 +750,10 @@ TEST(SiliconDriverBH, DISABLED_BroadcastWrite) { // Cannot broadcast to tensix/ continue; } test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was broadcasted"; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -764,11 +764,11 @@ TEST(SiliconDriverBH, DISABLED_BroadcastWrite) { // Cannot broadcast to tensix/ for (int chan = 0; chan < device.get_soc_descriptor(i).get_num_dram_channels(); chan++) { const auto& core = device.get_soc_descriptor(i).get_core_for_dram_channel(chan, 0); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from DRAM core " << i << " " << core.x << "-" << core.y << " does not match what was broadcasted " << size; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -778,9 +778,9 @@ TEST(SiliconDriverBH, DISABLED_BroadcastWrite) { // Cannot broadcast to tensix/ } } // Wait for data to be cleared before writing next block - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverBH, DISABLED_VirtualCoordinateBroadcast) { // same problem as above.. @@ -789,22 +789,22 @@ TEST(SiliconDriverBH, DISABLED_VirtualCoordinateBroadcast) { // same problem as uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); tt_device_params default_params; - device.start_device(default_params); - auto eth_version = device.get_ethernet_fw_version(); + cluster.start_device(default_params); + auto eth_version = cluster.get_ethernet_fw_version(); bool virtual_bcast_supported = - (eth_version >= tt_version(6, 8, 0) || eth_version == tt_version(6, 7, 241)) && device.translation_tables_en; + (eth_version >= tt_version(6, 8, 0) || eth_version == tt_version(6, 7, 241)) && cluster.translation_tables_en; if (!virtual_bcast_supported) { - device.close_device(); + cluster.close_device(); GTEST_SKIP() << "SiliconDriverWH.VirtualCoordinateBroadcast skipped since ethernet version does not support " "Virtual Coordinate Broadcast or NOC translation is not enabled"; } - device.deassert_risc_reset(); + cluster.deassert_risc_reset(); std::vector broadcast_sizes = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}; uint32_t address = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; std::set rows_to_exclude = {0, 3, 5, 6, 8, 9}; @@ -821,7 +821,7 @@ TEST(SiliconDriverBH, DISABLED_VirtualCoordinateBroadcast) { // same problem as zeros[i] = 0; } // Broadcast to Tensix - device.broadcast_write_to_cluster( + cluster.broadcast_write_to_cluster( vector_to_write.data(), vector_to_write.size() * 4, address, @@ -830,7 +830,7 @@ TEST(SiliconDriverBH, DISABLED_VirtualCoordinateBroadcast) { // same problem as cols_to_exclude, "LARGE_WRITE_TLB"); // Broadcast to DRAM - device.broadcast_write_to_cluster( + cluster.broadcast_write_to_cluster( vector_to_write.data(), vector_to_write.size() * 4, address, @@ -838,7 +838,7 @@ TEST(SiliconDriverBH, DISABLED_VirtualCoordinateBroadcast) { // same problem as rows_to_exclude_for_dram_broadcast, cols_to_exclude_for_dram_broadcast, "LARGE_WRITE_TLB"); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); for (const auto i : target_devices) { for (const auto& core : device.get_soc_descriptor(i).workers) { @@ -846,10 +846,10 @@ TEST(SiliconDriverBH, DISABLED_VirtualCoordinateBroadcast) { // same problem as continue; } test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was broadcasted"; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -860,11 +860,11 @@ TEST(SiliconDriverBH, DISABLED_VirtualCoordinateBroadcast) { // same problem as for (int chan = 0; chan < device.get_soc_descriptor(i).get_num_dram_channels(); chan++) { const auto& core = device.get_soc_descriptor(i).get_core_for_dram_channel(chan, 0); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from DRAM core " << i << " " << core.x << "-" << core.y << " does not match what was broadcasted " << size; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -874,9 +874,9 @@ TEST(SiliconDriverBH, DISABLED_VirtualCoordinateBroadcast) { // same problem as } } // Wait for data to be cleared before writing next block - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); } - device.close_device(); + cluster.close_device(); } /** diff --git a/tests/galaxy/test_umd_remote_api_stability.cpp b/tests/galaxy/test_umd_remote_api_stability.cpp index 0204f245..9da5a0d3 100644 --- a/tests/galaxy/test_umd_remote_api_stability.cpp +++ b/tests/galaxy/test_umd_remote_api_stability.cpp @@ -55,12 +55,12 @@ uint32_t WormholeGalaxyStabilityTestFixture::scale_number_of_tests = 1; TEST_F(WormholeGalaxyStabilityTestFixture, MixedRemoteTransfers) { int seed = 0; - assert(device != nullptr); + assert(cluster != nullptr); log_info(LogSiliconDriver, "Started MixedRemoteTransfers"); std::vector command_history; try { RunMixedTransfersUniformDistributions( - *this->device, + *this->cluster, 100000 * scale_number_of_tests, seed, transfer_type_weights_t{.write = 0.40, .read = 0.4}, @@ -87,10 +87,10 @@ TEST_F(WormholeGalaxyStabilityTestFixture, DISABLED_MultithreadedMixedRemoteTran log_info(LogSiliconDriver, "Started MultithreadedMixedRemoteTransfersMediumSmall"); - assert(device != nullptr); + assert(cluster != nullptr); std::thread t1([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 50000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 0.50, .read = 0.50}, @@ -110,7 +110,7 @@ TEST_F(WormholeGalaxyStabilityTestFixture, DISABLED_MultithreadedMixedRemoteTran }); std::thread t2([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 50000 * scale_number_of_tests, 100, transfer_type_weights_t{.write = 0.25, .read = 0.50}, @@ -130,7 +130,7 @@ TEST_F(WormholeGalaxyStabilityTestFixture, DISABLED_MultithreadedMixedRemoteTran }); std::thread t3([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 50000 * scale_number_of_tests, 23, transfer_type_weights_t{.write = 0.5, .read = 0.25}, @@ -150,7 +150,7 @@ TEST_F(WormholeGalaxyStabilityTestFixture, DISABLED_MultithreadedMixedRemoteTran }); std::thread t4([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 99, transfer_type_weights_t{.write = 0.1, .read = 0.1}, diff --git a/tests/grayskull/CMakeLists.txt b/tests/grayskull/CMakeLists.txt index 9bd6ff74..5231b27d 100644 --- a/tests/grayskull/CMakeLists.txt +++ b/tests/grayskull/CMakeLists.txt @@ -1,4 +1,4 @@ -set(UNIT_TESTS_GS_SRCS test_silicon_driver.cpp) +set(UNIT_TESTS_GS_SRCS test_cluster_gs.cpp) add_executable(unit_tests_grayskull ${UNIT_TESTS_GS_SRCS}) target_link_libraries(unit_tests_grayskull PRIVATE test_common) diff --git a/tests/grayskull/test_silicon_driver.cpp b/tests/grayskull/test_cluster_gs.cpp similarity index 79% rename from tests/grayskull/test_silicon_driver.cpp rename to tests/grayskull/test_cluster_gs.cpp index 4a7cd97c..b86378f7 100644 --- a/tests/grayskull/test_silicon_driver.cpp +++ b/tests/grayskull/test_cluster_gs.cpp @@ -20,10 +20,10 @@ TEST(SiliconDriverGS, CreateDestroySequential) { uint32_t num_host_mem_ch_per_mmio_device = 1; tt_device_params default_params; for (int i = 0; i < 100; i++) { - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true); - device.start_device(default_params); - device.deassert_risc_reset(); - device.close_device(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); + cluster.close_device(); } } @@ -38,9 +38,9 @@ TEST(SiliconDriverGS, CreateMultipleInstance) { concurrent_devices.at(i)->start_device(default_params); } - for (auto& device : concurrent_devices) { - device.second->close_device(); - delete device.second; + for (auto& cluster : concurrent_devices) { + cluster.second->close_device(); + delete cluster.second; } } @@ -48,20 +48,20 @@ TEST(SiliconDriverGS, Harvesting) { std::set target_devices = {0}; std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); - auto sdesc_per_chip = device.get_virtual_soc_descriptors(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); + auto sdesc_per_chip = cluster.get_virtual_soc_descriptors(); - ASSERT_EQ(device.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; + ASSERT_EQ(cluster.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; for (const auto& chip : sdesc_per_chip) { ASSERT_LE(chip.second.workers.size(), 96) << "Expected SOC descriptor with harvesting to have less than or equal to 96 workers for chip " << chip.first; } - ASSERT_EQ(device.get_harvesting_masks_for_soc_descriptors().at(0) & simulated_harvesting_masks[0], 6) + ASSERT_EQ(cluster.get_harvesting_masks_for_soc_descriptors().at(0) & simulated_harvesting_masks[0], 6) << "Expected first chip to include simulated harvesting mask of 6"; - // ASSERT_EQ(device.get_harvesting_masks_for_soc_descriptors().at(1), 12) << "Expected second chip to have + // ASSERT_EQ(cluster.get_harvesting_masks_for_soc_descriptors().at(1), 12) << "Expected second chip to have // harvesting mask of 12"; - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverGS, CustomSocDesc) { @@ -69,7 +69,7 @@ TEST(SiliconDriverGS, CustomSocDesc) { std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; uint32_t num_host_mem_ch_per_mmio_device = 1; // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting - Cluster device = Cluster( + Cluster cluster = Cluster( test_utils::GetAbsPath("./tests/soc_descs/grayskull_1x1_arch.yaml"), target_devices, num_host_mem_ch_per_mmio_device, @@ -77,8 +77,8 @@ TEST(SiliconDriverGS, CustomSocDesc) { true, false, simulated_harvesting_masks); - auto sdesc_per_chip = device.get_virtual_soc_descriptors(); - ASSERT_EQ(device.using_harvested_soc_descriptors(), false) + auto sdesc_per_chip = cluster.get_virtual_soc_descriptors(); + ASSERT_EQ(cluster.using_harvested_soc_descriptors(), false) << "SOC descriptors should not be modified when harvesting is disabled"; for (const auto& chip : sdesc_per_chip) { ASSERT_EQ(chip.second.workers.size(), 1) << "Expected 1x1 SOC descriptor to be unmodified by driver"; @@ -97,21 +97,21 @@ TEST(SiliconDriverGS, HarvestingRuntime) { std::set target_devices = {0}; std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); for (int i = 0; i < target_devices.size(); i++) { // Iterate over devices and only setup static TLBs for functional worker cores - auto& sdesc = device.get_soc_descriptor(i); + auto& sdesc = cluster.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address DATA_BUFFER_SPACE_BASE. - device.configure_tlb(i, core, get_static_tlb_index(core), l1_mem::address_map::DATA_BUFFER_SPACE_BASE); + cluster.configure_tlb(i, core, get_static_tlb_index(core), l1_mem::address_map::DATA_BUFFER_SPACE_BASE); } - device.setup_core_to_tlb_map(i, get_static_tlb_index); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index); } tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector dynamic_tlb_vector_to_write = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; @@ -125,14 +125,14 @@ TEST(SiliconDriverGS, HarvestingRuntime) { std::uint32_t dynamic_write_address = 0x30000000; for (int loop = 0; loop < 100; loop++) { // Write to each core a 100 times at different statically mapped addresses - for (auto& core : device.get_soc_descriptor(i).workers) { - device.write_to_device( + for (auto& core : cluster.get_soc_descriptor(i).workers) { + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), address, ""); - device.write_to_device( + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -146,9 +146,9 @@ TEST(SiliconDriverGS, HarvestingRuntime) { if (wait_duration > timeout_in_seconds) { break; } - test_utils::read_data_from_device(device, readback_vec, tt_cxy_pair(i, core), address, 40, ""); + test_utils::read_data_from_device(cluster, readback_vec, tt_cxy_pair(i, core), address, 40, ""); test_utils::read_data_from_device( - device, + cluster, dynamic_readback_vec, tt_cxy_pair(i, core), dynamic_write_address, @@ -157,13 +157,13 @@ TEST(SiliconDriverGS, HarvestingRuntime) { } ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), address, "SMALL_READ_WRITE_TLB"); // Clear any written data - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -176,7 +176,7 @@ TEST(SiliconDriverGS, HarvestingRuntime) { dynamic_write_address += 0x20; } } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverGS, StaticTLB_RW) { @@ -190,21 +190,21 @@ TEST(SiliconDriverGS, StaticTLB_RW) { std::set target_devices = {0}; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true); for (int i = 0; i < target_devices.size(); i++) { // Iterate over devices and only setup static TLBs for worker cores - auto& sdesc = device.get_soc_descriptor(i); + auto& sdesc = cluster.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address DATA_BUFFER_SPACE_BASE. - device.configure_tlb( + cluster.configure_tlb( i, core, get_static_tlb_index(core), l1_mem::address_map::DATA_BUFFER_SPACE_BASE, TLB_DATA::Posted); } - device.setup_core_to_tlb_map(i, get_static_tlb_index); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index); } tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector readback_vec = {}; @@ -215,8 +215,8 @@ TEST(SiliconDriverGS, StaticTLB_RW) { std::uint32_t address = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; for (int loop = 0; loop < 100; loop++) { // Write to each core a 100 times at different statically mapped addresses - for (auto& core : device.get_soc_descriptor(i).workers) { - device.write_to_device( + for (auto& core : cluster.get_soc_descriptor(i).workers) { + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -230,11 +230,11 @@ TEST(SiliconDriverGS, StaticTLB_RW) { if (wait_duration > timeout_in_seconds) { break; } - test_utils::read_data_from_device(device, readback_vec, tt_cxy_pair(i, core), address, 40, ""); + test_utils::read_data_from_device(cluster, readback_vec, tt_cxy_pair(i, core), address, 40, ""); } ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -245,7 +245,7 @@ TEST(SiliconDriverGS, StaticTLB_RW) { address += 0x20; // Increment by uint32_t size for each write } } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverGS, DynamicTLB_RW) { @@ -254,12 +254,12 @@ TEST(SiliconDriverGS, DynamicTLB_RW) { std::set target_devices = {0}; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true); - device.set_fallback_tlb_ordering_mode( + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true); + cluster.set_fallback_tlb_ordering_mode( "SMALL_READ_WRITE_TLB", TLB_DATA::Posted); // Explicitly test API to set fallback tlb ordering mode tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector zeros = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -270,8 +270,8 @@ TEST(SiliconDriverGS, DynamicTLB_RW) { std::uint32_t address = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; for (int loop = 0; loop < 100; loop++) { // Write to each core a 100 times at different statically mapped addresses - for (auto& core : device.get_soc_descriptor(i).workers) { - device.write_to_device( + for (auto& core : cluster.get_soc_descriptor(i).workers) { + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -286,12 +286,12 @@ TEST(SiliconDriverGS, DynamicTLB_RW) { break; } test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, 40, "SMALL_READ_WRITE_TLB"); } ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -302,7 +302,7 @@ TEST(SiliconDriverGS, DynamicTLB_RW) { address += 0x20; // Increment by uint32_t size for each write } } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverGS, MultiThreadedDevice) { @@ -312,11 +312,11 @@ TEST(SiliconDriverGS, MultiThreadedDevice) { std::set target_devices = {0}; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true); tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::thread th1 = std::thread([&] { std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; @@ -324,8 +324,8 @@ TEST(SiliconDriverGS, MultiThreadedDevice) { float timeout_in_seconds = 10; std::uint32_t address = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; for (int loop = 0; loop < 100; loop++) { - for (auto& core : device.get_soc_descriptor(0).workers) { - device.write_to_device( + for (auto& core : cluster.get_soc_descriptor(0).workers) { + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), @@ -340,7 +340,7 @@ TEST(SiliconDriverGS, MultiThreadedDevice) { break; } test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); } ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; @@ -355,10 +355,10 @@ TEST(SiliconDriverGS, MultiThreadedDevice) { std::vector readback_vec = {}; float timeout_in_seconds = 10; std::uint32_t address = 0x30000000; - for (auto& core_ls : device.get_soc_descriptor(0).dram_cores) { + for (auto& core_ls : cluster.get_soc_descriptor(0).dram_cores) { for (int loop = 0; loop < 100; loop++) { for (auto& core : core_ls) { - device.write_to_device( + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), @@ -373,7 +373,7 @@ TEST(SiliconDriverGS, MultiThreadedDevice) { break; } test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); } ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; @@ -386,7 +386,7 @@ TEST(SiliconDriverGS, MultiThreadedDevice) { th1.join(); th2.join(); - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverGS, MultiThreadedMemBar) { // this tests takes ~5 mins to run @@ -408,42 +408,42 @@ TEST(SiliconDriverGS, MultiThreadedMemBar) { // this tests takes ~5 mins to run uint32_t base_addr = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true); for (int i = 0; i < target_devices.size(); i++) { // Iterate over devices and only setup static TLBs for functional worker cores - auto& sdesc = device.get_soc_descriptor(i); + auto& sdesc = cluster.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address DATA_BUFFER_SPACE_BASE. - device.configure_tlb(i, core, get_static_tlb_index(core), base_addr); + cluster.configure_tlb(i, core, get_static_tlb_index(core), base_addr); } - device.setup_core_to_tlb_map(i, get_static_tlb_index); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index); } tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector readback_membar_vec = {}; - for (auto& core : device.get_soc_descriptor(0).workers) { + for (auto& core : cluster.get_soc_descriptor(0).workers) { test_utils::read_data_from_device( - device, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); + cluster, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); ASSERT_EQ( readback_membar_vec.at(0), 187); // Ensure that memory barriers were correctly initialized on all workers readback_membar_vec = {}; } - for (auto& core : device.get_soc_descriptor(0).workers) { + for (auto& core : cluster.get_soc_descriptor(0).workers) { test_utils::read_data_from_device( - device, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); + cluster, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); ASSERT_EQ( readback_membar_vec.at(0), 187); // Ensure that memory barriers were correctly initialized on all workers readback_membar_vec = {}; } - for (int chan = 0; chan < device.get_soc_descriptor(0).get_num_dram_channels(); chan++) { - auto core = device.get_soc_descriptor(0).get_core_for_dram_channel(chan, 0); + for (int chan = 0; chan < cluster.get_soc_descriptor(0).get_num_dram_channels(); chan++) { + auto core = cluster.get_soc_descriptor(0).get_core_for_dram_channel(chan, 0); test_utils::read_data_from_device( - device, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); + cluster, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); ASSERT_EQ( readback_membar_vec.at(0), 187); // Ensure that memory barriers were correctly initialized on all DRAM readback_membar_vec = {}; @@ -464,15 +464,15 @@ TEST(SiliconDriverGS, MultiThreadedMemBar) { // this tests takes ~5 mins to run std::thread th1 = std::thread([&] { std::uint32_t address = base_addr; for (int loop = 0; loop < 100; loop++) { - for (auto& core : device.get_soc_descriptor(0).workers) { + for (auto& core : cluster.get_soc_descriptor(0).workers) { std::vector readback_vec = {}; - device.write_to_device( + cluster.write_to_device( vec1.data(), vec1.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); - device.l1_membar(0, "", {core}); + cluster.l1_membar(0, "", {core}); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 4 * vec1.size(), ""); + cluster, readback_vec, tt_cxy_pair(0, core), address, 4 * vec1.size(), ""); ASSERT_EQ(readback_vec, vec1); - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); readback_vec = {}; } @@ -482,15 +482,15 @@ TEST(SiliconDriverGS, MultiThreadedMemBar) { // this tests takes ~5 mins to run std::thread th2 = std::thread([&] { std::uint32_t address = base_addr + vec1.size() * 4; for (int loop = 0; loop < 100; loop++) { - for (auto& core : device.get_soc_descriptor(0).workers) { + for (auto& core : cluster.get_soc_descriptor(0).workers) { std::vector readback_vec = {}; - device.write_to_device( + cluster.write_to_device( vec2.data(), vec2.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); - device.l1_membar(0, "", {core}); + cluster.l1_membar(0, "", {core}); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 4 * vec2.size(), ""); + cluster, readback_vec, tt_cxy_pair(0, core), address, 4 * vec2.size(), ""); ASSERT_EQ(readback_vec, vec2); - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); readback_vec = {}; } @@ -500,14 +500,14 @@ TEST(SiliconDriverGS, MultiThreadedMemBar) { // this tests takes ~5 mins to run th1.join(); th2.join(); - for (auto& core : device.get_soc_descriptor(0).workers) { + for (auto& core : cluster.get_soc_descriptor(0).workers) { test_utils::read_data_from_device( - device, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); + cluster, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(readback_membar_vec.at(0), 187); // Ensure that memory barriers end up in correct sate workers readback_membar_vec = {}; } - device.close_device(); + cluster.close_device(); } /** diff --git a/tests/test_utils/stimulus_generators.hpp b/tests/test_utils/stimulus_generators.hpp index 995b2da8..99351ad7 100644 --- a/tests/test_utils/stimulus_generators.hpp +++ b/tests/test_utils/stimulus_generators.hpp @@ -451,7 +451,7 @@ static void print_command_executable_code(remote_transfer_sample_t const& comman std::cout << "assert(" << command_args.size_in_bytes << " >= sizeof(uint32_t));" << std::endl; emit_bytes_to_words_len_string("len", command_args.size_in_bytes, sizeof(uint32_t)); emit_payload_resize_string(command_args.size_in_bytes, sizeof(uint32_t)); - std::cout << "device->write_to_device(payload.data(), len, destination, " << command_args.address << ", \"" + std::cout << "cluster->write_to_device(payload.data(), len, destination, " << command_args.address << ", \"" << command_args.tlb_to_use << "\");" << std::endl; // driver.write_to_device(payload.data(), command_args.size, command_args.destination, command_args.address, // command_args.tlb_to_use, false, false); @@ -461,7 +461,7 @@ static void print_command_executable_code(remote_transfer_sample_t const& comman std::cout << "tt_cxy_pair const& destination = tt_cxy_pair(" << command_args.destination.chip << ", " << command_args.destination.x << ", " << command_args.destination.y << ");" << std::endl; emit_payload_resize_string(command_args.size_in_bytes, sizeof(uint32_t)); - std::cout << "device->read_from_device(payload.data(), destination, " << command_args.address << ", " + std::cout << "cluster->read_from_device(payload.data(), destination, " << command_args.address << ", " << command_args.size_in_bytes << ", \"" << command_args.tlb_to_use << "\");" << std::endl; // driver.read_from_device(payload.data(), command_args.destination, command_args.address, // command_args.size, command_args.tlb_to_use); @@ -498,7 +498,7 @@ template < template class READ_SIZE_DISTR_T> void RunMixedTransfers( - Cluster& device, + Cluster& cluster, int num_samples, int seed, @@ -544,7 +544,7 @@ void RunMixedTransfers( if (i != 0 && num_samples > 100 && i % (num_samples / 100) == 0) { // std::cout << "Completed " << i / (num_samples / 100) << "% of samples" << std::endl; } - dispatch_remote_transfer_command(device, sample, payload); + dispatch_remote_transfer_command(cluster, sample, payload); } } @@ -556,10 +556,10 @@ get_default_address_generator(int seed, address_t start, address_t end) { } static ConstrainedTemplateTemplateGenerator -get_default_full_dram_dest_generator(int seed, Cluster* device) { - assert(device != nullptr); - tt_ClusterDescriptor* cluster_desc = device->get_cluster_description(); - tt_SocDescriptor const& soc_desc = device->get_soc_descriptor(0); +get_default_full_dram_dest_generator(int seed, Cluster* cluster) { + assert(cluster != nullptr); + tt_ClusterDescriptor* cluster_desc = cluster->get_cluster_description(); + tt_SocDescriptor const& soc_desc = cluster->get_soc_descriptor(0); std::vector core_index_to_location = generate_core_index_locations(*cluster_desc, soc_desc); return ConstrainedTemplateTemplateGenerator( @@ -573,9 +573,9 @@ static WriteCommandGenerator< std::uniform_int_distribution, transfer_size_t, std::uniform_int_distribution> -build_dummy_write_command_generator(Cluster& device) { - tt_ClusterDescriptor* cluster_desc = device.get_cluster_description(); - tt_SocDescriptor const& soc_desc = device.get_soc_descriptor(0); +build_dummy_write_command_generator(Cluster& cluster) { + tt_ClusterDescriptor* cluster_desc = cluster.get_cluster_description(); + tt_SocDescriptor const& soc_desc = cluster.get_soc_descriptor(0); std::vector core_index_to_location = generate_core_index_locations(*cluster_desc, soc_desc); auto dest_generator = ConstrainedTemplateTemplateGenerator( 0, @@ -598,9 +598,9 @@ static ReadCommandGenerator< std::uniform_int_distribution, transfer_size_t, std::uniform_int_distribution> -build_dummy_read_command_generator(Cluster& device) { - tt_ClusterDescriptor* cluster_desc = device.get_cluster_description(); - tt_SocDescriptor const& soc_desc = device.get_soc_descriptor(0); +build_dummy_read_command_generator(Cluster& cluster) { + tt_ClusterDescriptor* cluster_desc = cluster.get_cluster_description(); + tt_SocDescriptor const& soc_desc = cluster.get_soc_descriptor(0); std::vector core_index_to_location = generate_core_index_locations(*cluster_desc, soc_desc); auto dest_generator = ConstrainedTemplateTemplateGenerator( 0, @@ -626,7 +626,7 @@ template < template class UNROLL_COUNT_GENERATOR_T> void RunMixedTransfersUniformDistributions( - Cluster& device, + Cluster& cluster, int num_samples, int seed, @@ -640,8 +640,8 @@ void RunMixedTransfersUniformDistributions( bool record_command_history = false, std::vector* command_history = nullptr) { - tt_ClusterDescriptor* cluster_desc = device.get_cluster_description(); - tt_SocDescriptor const& soc_desc = device.get_soc_descriptor(0); + tt_ClusterDescriptor* cluster_desc = cluster.get_cluster_description(); + tt_SocDescriptor const& soc_desc = cluster.get_soc_descriptor(0); std::vector core_index_to_location = generate_core_index_locations(*cluster_desc, soc_desc); auto dest_generator = ConstrainedTemplateTemplateGenerator( @@ -671,7 +671,7 @@ void RunMixedTransfersUniformDistributions( seed + 4, unroll_count_distribution, [](int unroll_count) -> int { return unroll_count; }); RunMixedTransfers( - device, + cluster, num_samples, seed, diff --git a/tests/wormhole/CMakeLists.txt b/tests/wormhole/CMakeLists.txt index b6886ffa..5602a558 100644 --- a/tests/wormhole/CMakeLists.txt +++ b/tests/wormhole/CMakeLists.txt @@ -1,5 +1,5 @@ set(UNIT_TESTS_WH_SRCS - test_silicon_driver_wh.cpp + test_cluster_wh.cpp test_umd_remote_api_stability.cpp ) diff --git a/tests/wormhole/test_silicon_driver_wh.cpp b/tests/wormhole/test_cluster_wh.cpp similarity index 83% rename from tests/wormhole/test_silicon_driver_wh.cpp rename to tests/wormhole/test_cluster_wh.cpp index c0ce3664..215b8299 100644 --- a/tests/wormhole/test_silicon_driver_wh.cpp +++ b/tests/wormhole/test_cluster_wh.cpp @@ -16,9 +16,9 @@ using namespace tt::umd; -void set_params_for_remote_txn(Cluster& device) { +void set_params_for_remote_txn(Cluster& cluster) { // Populate address map and NOC parameters that the driver needs for remote transactions - device.set_device_l1_address_params( + cluster.set_device_l1_address_params( {l1_mem::address_map::L1_BARRIER_BASE, eth_l1_mem::address_map::ERISC_BARRIER_BASE, eth_l1_mem::address_map::FW_VERSION_ADDR}); @@ -86,17 +86,17 @@ TEST(SiliconDriverWH, CreateDestroy) { tt_device_params default_params; // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting for (int i = 0; i < 50; i++) { - Cluster device = Cluster( + Cluster cluster = Cluster( test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_1x1.yaml"), target_devices, num_host_mem_ch_per_mmio_device, false, true, false); - set_params_for_remote_txn(device); - device.start_device(default_params); - device.deassert_risc_reset(); - device.close_device(); + set_params_for_remote_txn(cluster); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); + cluster.close_device(); } } @@ -106,17 +106,17 @@ TEST(SiliconDriverWH, Harvesting) { std::unordered_map simulated_harvesting_masks = {{0, 30}, {1, 60}}; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); - auto sdesc_per_chip = device.get_virtual_soc_descriptors(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); + auto sdesc_per_chip = cluster.get_virtual_soc_descriptors(); - ASSERT_EQ(device.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; + ASSERT_EQ(cluster.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; for (const auto& chip : sdesc_per_chip) { ASSERT_EQ(chip.second.workers.size(), 48) << "Expected SOC descriptor with harvesting to have 48 workers for chip" << chip.first; } for (int i = 0; i < num_devices; i++) { - ASSERT_EQ(device.get_harvesting_masks_for_soc_descriptors().at(i), simulated_harvesting_masks.at(i)) + ASSERT_EQ(cluster.get_harvesting_masks_for_soc_descriptors().at(i), simulated_harvesting_masks.at(i)) << "Expecting chip " << i << " to have harvesting mask of " << simulated_harvesting_masks.at(i); } } @@ -127,7 +127,7 @@ TEST(SiliconDriverWH, CustomSocDesc) { uint32_t num_host_mem_ch_per_mmio_device = 1; // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting - Cluster device = Cluster( + Cluster cluster = Cluster( test_utils::GetAbsPath("tests/soc_descs/wormhole_b0_1x1.yaml"), target_devices, num_host_mem_ch_per_mmio_device, @@ -135,9 +135,9 @@ TEST(SiliconDriverWH, CustomSocDesc) { true, false, simulated_harvesting_masks); - auto sdesc_per_chip = device.get_virtual_soc_descriptors(); + auto sdesc_per_chip = cluster.get_virtual_soc_descriptors(); - ASSERT_EQ(device.using_harvested_soc_descriptors(), false) + ASSERT_EQ(cluster.using_harvested_soc_descriptors(), false) << "SOC descriptors should not be modified when harvesting is disabled"; for (const auto& chip : sdesc_per_chip) { ASSERT_EQ(chip.second.workers.size(), 1) << "Expected 1x1 SOC descriptor to be unmodified by driver"; @@ -158,9 +158,9 @@ TEST(SiliconDriverWH, HarvestingRuntime) { uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); for(int i = 0; i < target_devices.size(); i++) { // Iterate over MMIO devices and only setup static TLBs for worker cores @@ -168,15 +168,15 @@ TEST(SiliconDriverWH, HarvestingRuntime) { auto& sdesc = device.get_soc_descriptor(i); for(auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address NCRISC_FIRMWARE_BASE. - device.configure_tlb(i, core, get_static_tlb_index_callback(core), l1_mem::address_map::NCRISC_FIRMWARE_BASE); + cluster.configure_tlb(i, core, get_static_tlb_index_callback(core), l1_mem::address_map::NCRISC_FIRMWARE_BASE); } } } - device.setup_core_to_tlb_map(get_static_tlb_index_callback); + cluster.setup_core_to_tlb_map(get_static_tlb_index_callback); tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector dynamic_readback_vec = {}; @@ -193,15 +193,15 @@ TEST(SiliconDriverWH, HarvestingRuntime) { device.write_to_device(vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), dynamic_write_address, "SMALL_READ_WRITE_TLB"); device.wait_for_non_mmio_flush(); // Barrier to ensure that all writes over ethernet were commited - test_utils::read_data_from_device(device, readback_vec, tt_cxy_pair(i, core), address, 40, ""); - test_utils::read_data_from_device(device, dynamic_readback_vec, tt_cxy_pair(i, core), dynamic_write_address, 40, "SMALL_READ_WRITE_TLB"); + test_utils::read_data_from_device(cluster, readback_vec, tt_cxy_pair(i, core), address, 40, ""); + test_utils::read_data_from_device(cluster, dynamic_readback_vec, tt_cxy_pair(i, core), dynamic_write_address, 40, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; ASSERT_EQ(vector_to_write, dynamic_readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); - device.write_to_device(zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), dynamic_write_address, "SMALL_READ_WRITE_TLB"); // Clear any written data - device.write_to_device(zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), address, ""); // Clear any written data - device.wait_for_non_mmio_flush(); + cluster.write_to_device(zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), dynamic_write_address, "SMALL_READ_WRITE_TLB"); // Clear any written data + cluster.write_to_device(zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), address, ""); // Clear any written data + cluster.wait_for_non_mmio_flush(); readback_vec = {}; dynamic_readback_vec = {}; } @@ -209,7 +209,7 @@ TEST(SiliconDriverWH, HarvestingRuntime) { dynamic_write_address += 0x20; } } - device.close_device(); + cluster.close_device(); } #endif @@ -220,9 +220,9 @@ TEST(SiliconDriverWH, UnalignedStaticTLB_RW) { int num_devices = target_devices.size(); uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); for (int i = 0; i < target_devices.size(); i++) { // Iterate over MMIO devices and only setup static TLBs for worker cores @@ -230,16 +230,16 @@ TEST(SiliconDriverWH, UnalignedStaticTLB_RW) { auto& sdesc = device.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address NCRISC_FIRMWARE_BASE. - device.configure_tlb( + cluster.configure_tlb( i, core, get_static_tlb_index_callback(core), l1_mem::address_map::NCRISC_FIRMWARE_BASE); } - device.setup_core_to_tlb_map(i, get_static_tlb_index_callback); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index_callback); } } tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector unaligned_sizes = {3, 14, 21, 255, 362, 430, 1022, 1023, 1025}; for (int i = 0; i < num_devices; i++) { @@ -257,17 +257,17 @@ TEST(SiliconDriverWH, UnalignedStaticTLB_RW) { device.read_from_device(readback_vec.data(), tt_cxy_pair(i, core), address, size, ""); ASSERT_EQ(readback_vec, write_vec); readback_vec = std::vector(size, 0); - device.write_to_sysmem(write_vec.data(), size, 0, 0, 0); - device.read_from_sysmem(readback_vec.data(), 0, 0, size, 0); + cluster.write_to_sysmem(write_vec.data(), size, 0, 0, 0); + cluster.read_from_sysmem(readback_vec.data(), 0, 0, size, 0); ASSERT_EQ(readback_vec, write_vec); readback_vec = std::vector(size, 0); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); } address += 0x20; } } } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverWH, StaticTLB_RW) { @@ -276,9 +276,9 @@ TEST(SiliconDriverWH, StaticTLB_RW) { std::set target_devices = get_target_devices(); uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); for (int i = 0; i < target_devices.size(); i++) { // Iterate over MMIO devices and only setup static TLBs for worker cores @@ -286,16 +286,16 @@ TEST(SiliconDriverWH, StaticTLB_RW) { auto& sdesc = device.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address NCRISC_FIRMWARE_BASE. - device.configure_tlb( + cluster.configure_tlb( i, core, get_static_tlb_index_callback(core), l1_mem::address_map::NCRISC_FIRMWARE_BASE); } - device.setup_core_to_tlb_map(i, get_static_tlb_index_callback); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index_callback); } } tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector readback_vec = {}; @@ -313,24 +313,24 @@ TEST(SiliconDriverWH, StaticTLB_RW) { address, ""); // Barrier to ensure that all writes over ethernet were commited - device.wait_for_non_mmio_flush(); - test_utils::read_data_from_device(device, readback_vec, tt_cxy_pair(i, core), address, 40, ""); + cluster.wait_for_non_mmio_flush(); + test_utils::read_data_from_device(cluster, readback_vec, tt_cxy_pair(i, core), address, 40, ""); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; - device.wait_for_non_mmio_flush(); - device.write_to_device( + cluster.wait_for_non_mmio_flush(); + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), address, "SMALL_READ_WRITE_TLB"); // Clear any written data - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); readback_vec = {}; } address += 0x20; // Increment by uint32_t size for each write } } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverWH, DynamicTLB_RW) { @@ -339,13 +339,13 @@ TEST(SiliconDriverWH, DynamicTLB_RW) { std::set target_devices = get_target_devices(); uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); + set_params_for_remote_txn(cluster); tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector zeros = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -363,25 +363,25 @@ TEST(SiliconDriverWH, DynamicTLB_RW) { address, "SMALL_READ_WRITE_TLB"); // Barrier to ensure that all writes over ethernet were commited - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, 40, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; - device.wait_for_non_mmio_flush(); - device.write_to_device( + cluster.wait_for_non_mmio_flush(); + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), address, "SMALL_READ_WRITE_TLB"); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); readback_vec = {}; } address += 0x20; // Increment by uint32_t size for each write } } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverWH, MultiThreadedDevice) { @@ -391,13 +391,13 @@ TEST(SiliconDriverWH, MultiThreadedDevice) { std::set target_devices = get_target_devices(); uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); + set_params_for_remote_txn(cluster); tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::thread th1 = std::thread([&] { std::vector vector_to_write = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; @@ -412,7 +412,7 @@ TEST(SiliconDriverWH, MultiThreadedDevice) { address, "SMALL_READ_WRITE_TLB"); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; readback_vec = {}; @@ -428,14 +428,14 @@ TEST(SiliconDriverWH, MultiThreadedDevice) { for (auto& core_ls : device.get_soc_descriptor(0).dram_cores) { for (int loop = 0; loop < 100; loop++) { for (auto& core : core_ls) { - device.write_to_device( + cluster.write_to_device( vector_to_write.data(), vector_to_write.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, "SMALL_READ_WRITE_TLB"); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); + cluster, readback_vec, tt_cxy_pair(0, core), address, 40, "SMALL_READ_WRITE_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was written"; readback_vec = {}; @@ -447,7 +447,7 @@ TEST(SiliconDriverWH, MultiThreadedDevice) { th1.join(); th2.join(); - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverWH, MultiThreadedMemBar) { @@ -462,9 +462,9 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { uint32_t base_addr = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); for (int i = 0; i < target_devices.size(); i++) { // Iterate over devices and only setup static TLBs for functional worker cores @@ -472,20 +472,20 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { auto& sdesc = device.get_soc_descriptor(i); for (auto& core : sdesc.workers) { // Statically mapping a 1MB TLB to this core, starting from address DATA_BUFFER_SPACE_BASE. - device.configure_tlb(i, core, get_static_tlb_index_callback(core), base_addr); + cluster.configure_tlb(i, core, get_static_tlb_index_callback(core), base_addr); } - device.setup_core_to_tlb_map(i, get_static_tlb_index_callback); + cluster.setup_core_to_tlb_map(i, get_static_tlb_index_callback); } } tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector readback_membar_vec = {}; for (auto& core : device.get_soc_descriptor(0).workers) { test_utils::read_data_from_device( - device, + cluster, readback_membar_vec, tt_cxy_pair(0, core), l1_mem::address_map::L1_BARRIER_BASE, @@ -499,7 +499,7 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { for (int chan = 0; chan < device.get_soc_descriptor(0).get_num_dram_channels(); chan++) { auto core = device.get_soc_descriptor(0).get_core_for_dram_channel(chan, 0); test_utils::read_data_from_device( - device, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); + cluster, readback_membar_vec, tt_cxy_pair(0, core), 0, 4, "SMALL_READ_WRITE_TLB"); ASSERT_EQ( readback_membar_vec.at(0), 187); // Ensure that memory barriers were correctly initialized on all DRAM readback_membar_vec = {}; @@ -507,7 +507,7 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { for (auto& core : device.get_soc_descriptor(0).ethernet_cores) { test_utils::read_data_from_device( - device, + cluster, readback_membar_vec, tt_cxy_pair(0, core), eth_l1_mem::address_map::ERISC_BARRIER_BASE, @@ -536,13 +536,13 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { for (int loop = 0; loop < 50; loop++) { for (auto& core : device.get_soc_descriptor(0).workers) { std::vector readback_vec = {}; - device.write_to_device( + cluster.write_to_device( vec1.data(), vec1.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); - device.l1_membar(0, "SMALL_READ_WRITE_TLB", {core}); + cluster.l1_membar(0, "SMALL_READ_WRITE_TLB", {core}); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 4 * vec1.size(), ""); + cluster, readback_vec, tt_cxy_pair(0, core), address, 4 * vec1.size(), ""); ASSERT_EQ(readback_vec, vec1); - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); readback_vec = {}; } @@ -554,13 +554,13 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { for (int loop = 0; loop < 50; loop++) { for (auto& core : device.get_soc_descriptor(0).workers) { std::vector readback_vec = {}; - device.write_to_device( + cluster.write_to_device( vec2.data(), vec2.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); - device.l1_membar(0, "SMALL_READ_WRITE_TLB", {core}); + cluster.l1_membar(0, "SMALL_READ_WRITE_TLB", {core}); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(0, core), address, 4 * vec2.size(), ""); + cluster, readback_vec, tt_cxy_pair(0, core), address, 4 * vec2.size(), ""); ASSERT_EQ(readback_vec, vec2); - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(0, core), address, ""); readback_vec = {}; } @@ -572,7 +572,7 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { for (auto& core : device.get_soc_descriptor(0).workers) { test_utils::read_data_from_device( - device, + cluster, readback_membar_vec, tt_cxy_pair(0, core), l1_mem::address_map::L1_BARRIER_BASE, @@ -585,7 +585,7 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { for (auto& core : device.get_soc_descriptor(0).ethernet_cores) { test_utils::read_data_from_device( - device, + cluster, readback_membar_vec, tt_cxy_pair(0, core), eth_l1_mem::address_map::ERISC_BARRIER_BASE, @@ -596,7 +596,7 @@ TEST(SiliconDriverWH, MultiThreadedMemBar) { 187); // Ensure that memory barriers end up in the correct sate for ethernet cores readback_membar_vec = {}; } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverWH, BroadcastWrite) { @@ -605,13 +605,13 @@ TEST(SiliconDriverWH, BroadcastWrite) { uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); tt_device_params default_params; - device.start_device(default_params); - device.deassert_risc_reset(); + cluster.start_device(default_params); + cluster.deassert_risc_reset(); std::vector broadcast_sizes = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}; uint32_t address = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; std::set rows_to_exclude = {0, 6}; @@ -628,7 +628,7 @@ TEST(SiliconDriverWH, BroadcastWrite) { zeros[i] = 0; } // Broadcast to Tensix - device.broadcast_write_to_cluster( + cluster.broadcast_write_to_cluster( vector_to_write.data(), vector_to_write.size() * 4, address, @@ -637,7 +637,7 @@ TEST(SiliconDriverWH, BroadcastWrite) { cols_to_exclude, "LARGE_WRITE_TLB"); // Broadcast to DRAM - device.broadcast_write_to_cluster( + cluster.broadcast_write_to_cluster( vector_to_write.data(), vector_to_write.size() * 4, address, @@ -645,7 +645,7 @@ TEST(SiliconDriverWH, BroadcastWrite) { rows_to_exclude_for_dram_broadcast, cols_to_exclude_for_dram_broadcast, "LARGE_WRITE_TLB"); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); for (const auto i : target_devices) { for (const auto& core : device.get_soc_descriptor(i).workers) { @@ -653,10 +653,10 @@ TEST(SiliconDriverWH, BroadcastWrite) { continue; } test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was broadcasted"; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -667,11 +667,11 @@ TEST(SiliconDriverWH, BroadcastWrite) { for (int chan = 0; chan < device.get_soc_descriptor(i).get_num_dram_channels(); chan++) { const auto& core = device.get_soc_descriptor(i).get_core_for_dram_channel(chan, 0); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from DRAM core " << i << " " << core.x << "-" << core.y << " does not match what was broadcasted " << size; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -681,9 +681,9 @@ TEST(SiliconDriverWH, BroadcastWrite) { } } // Wait for data to be cleared before writing next block - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); } - device.close_device(); + cluster.close_device(); } TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { @@ -692,22 +692,22 @@ TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { uint32_t num_host_mem_ch_per_mmio_device = 1; - Cluster device = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); - set_params_for_remote_txn(device); - auto mmio_devices = device.get_target_mmio_device_ids(); + Cluster cluster = Cluster(num_host_mem_ch_per_mmio_device, false, true, true); + set_params_for_remote_txn(cluster); + auto mmio_devices = cluster.get_target_mmio_device_ids(); tt_device_params default_params; - device.start_device(default_params); - auto eth_version = device.get_ethernet_fw_version(); + cluster.start_device(default_params); + auto eth_version = cluster.get_ethernet_fw_version(); bool virtual_bcast_supported = - (eth_version >= tt_version(6, 8, 0) || eth_version == tt_version(6, 7, 241)) && device.translation_tables_en; + (eth_version >= tt_version(6, 8, 0) || eth_version == tt_version(6, 7, 241)) && cluster.translation_tables_en; if (!virtual_bcast_supported) { - device.close_device(); + cluster.close_device(); GTEST_SKIP() << "SiliconDriverWH.VirtualCoordinateBroadcast skipped since ethernet version does not support " "Virtual Coordinate Broadcast or NOC translation is not enabled"; } - device.deassert_risc_reset(); + cluster.deassert_risc_reset(); std::vector broadcast_sizes = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}; uint32_t address = l1_mem::address_map::DATA_BUFFER_SPACE_BASE; std::set rows_to_exclude = {0, 3, 5, 6, 8, 9}; @@ -724,7 +724,7 @@ TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { zeros[i] = 0; } // Broadcast to Tensix - device.broadcast_write_to_cluster( + cluster.broadcast_write_to_cluster( vector_to_write.data(), vector_to_write.size() * 4, address, @@ -733,7 +733,7 @@ TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { cols_to_exclude, "LARGE_WRITE_TLB"); // Broadcast to DRAM - device.broadcast_write_to_cluster( + cluster.broadcast_write_to_cluster( vector_to_write.data(), vector_to_write.size() * 4, address, @@ -741,7 +741,7 @@ TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { rows_to_exclude_for_dram_broadcast, cols_to_exclude_for_dram_broadcast, "LARGE_WRITE_TLB"); - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); for (const auto i : target_devices) { for (const auto& core : device.get_soc_descriptor(i).workers) { @@ -749,10 +749,10 @@ TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { continue; } test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from core " << core.x << "-" << core.y << "does not match what was broadcasted"; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -763,11 +763,11 @@ TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { for (int chan = 0; chan < device.get_soc_descriptor(i).get_num_dram_channels(); chan++) { const auto& core = device.get_soc_descriptor(i).get_core_for_dram_channel(chan, 0); test_utils::read_data_from_device( - device, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); + cluster, readback_vec, tt_cxy_pair(i, core), address, vector_to_write.size() * 4, "LARGE_READ_TLB"); ASSERT_EQ(vector_to_write, readback_vec) << "Vector read back from DRAM core " << i << " " << core.x << "-" << core.y << " does not match what was broadcasted " << size; - device.write_to_device( + cluster.write_to_device( zeros.data(), zeros.size() * sizeof(std::uint32_t), tt_cxy_pair(i, core), @@ -777,9 +777,9 @@ TEST(SiliconDriverWH, VirtualCoordinateBroadcast) { } } // Wait for data to be cleared before writing next block - device.wait_for_non_mmio_flush(); + cluster.wait_for_non_mmio_flush(); } - device.close_device(); + cluster.close_device(); } /** diff --git a/tests/wormhole/test_umd_remote_api_stability.cpp b/tests/wormhole/test_umd_remote_api_stability.cpp index ae41d137..18fe7cbc 100644 --- a/tests/wormhole/test_umd_remote_api_stability.cpp +++ b/tests/wormhole/test_umd_remote_api_stability.cpp @@ -59,9 +59,9 @@ TEST_F(WormholeNebulaX2TestFixture, MixedRemoteTransfersMediumSmall) { std::vector command_history; try { - assert(device != nullptr); + assert(cluster != nullptr); RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 0.25, .read = 0.25}, @@ -88,14 +88,14 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersMediumSmall log_info(LogSiliconDriver, "Started MultithreadedMixedRemoteTransfersMediumSmall"); - assert(device != nullptr); + assert(cluster != nullptr); std::vector command_history0; std::vector command_history1; std::vector command_history2; std::vector command_history3; std::thread t1([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 0.50, .read = 0.50}, @@ -115,7 +115,7 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersMediumSmall }); std::thread t2([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 100, transfer_type_weights_t{.write = 0.25, .read = 0.50}, @@ -135,7 +135,7 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersMediumSmall }); std::thread t3([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 23, transfer_type_weights_t{.write = 0.5, .read = 0.25}, @@ -155,7 +155,7 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersMediumSmall }); std::thread t4([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 99, transfer_type_weights_t{.write = 1.0, .read = 0.0}, @@ -185,11 +185,11 @@ TEST_F(WormholeNebulaX2TestFixture, MixedRemoteTransfersLarge) { log_info(LogSiliconDriver, "Started MixedRemoteTransfersLarge"); - assert(device != nullptr); + assert(cluster != nullptr); std::vector command_history; try { RunMixedTransfersUniformDistributions( - *device, + *cluster, 10000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 0.15, .read = 0.15}, @@ -216,7 +216,7 @@ TEST_F(WormholeNebulaX2TestFixture, WritesOnlyNormalDistributionMean10kStd3kMinS log_info(LogSiliconDriver, "Started WritesOnlyNormalDistributionMean10kStd3kMinSizeTruncate4"); - assert(device != nullptr); + assert(cluster != nullptr); std::vector command_history; auto write_size_generator = ConstrainedTemplateTemplateGenerator( @@ -224,17 +224,17 @@ TEST_F(WormholeNebulaX2TestFixture, WritesOnlyNormalDistributionMean10kStd3kMinS return size_aligner_32B(static_cast((x >= 4) ? x : 4)); }); - auto dest_generator = get_default_full_dram_dest_generator(seed, device.get()); + auto dest_generator = get_default_full_dram_dest_generator(seed, cluster.get()); auto address_generator = get_default_address_generator(seed, 0x100000, 0x5000000); try { RunMixedTransfers( - *device, + *cluster, 10000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 1., .read = 0.}, WriteCommandGenerator(dest_generator, address_generator, write_size_generator), - build_dummy_read_command_generator(*device), + build_dummy_read_command_generator(*cluster), // Set to true if you want to emit the command history code to command line false, &command_history); @@ -248,14 +248,14 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersLMS) { log_info(LogSiliconDriver, "Started MultithreadedMixedRemoteTransfersLMS"); - assert(device != nullptr); + assert(cluster != nullptr); std::vector command_history0; std::vector command_history1; std::vector command_history2; std::vector command_history3; std::thread t1([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 0.50, .read = 0.50}, @@ -275,7 +275,7 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersLMS) { }); std::thread t2([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 100, transfer_type_weights_t{.write = 0.25, .read = 0.50}, @@ -295,7 +295,7 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersLMS) { }); std::thread t3([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 23, transfer_type_weights_t{.write = 0.5, .read = 0.25}, @@ -315,7 +315,7 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersLMS) { }); std::thread t4([&]() { RunMixedTransfersUniformDistributions( - *device, + *cluster, 100000 * scale_number_of_tests, 99, transfer_type_weights_t{.write = 1.0, .read = 0.0}, @@ -345,7 +345,7 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersLargeWrites log_info(LogSiliconDriver, "Started MultithreadedMixedRemoteTransfersLargeWritesSmallReads"); - assert(device != nullptr); + assert(cluster != nullptr); std::vector command_history0; std::vector command_history1; @@ -362,40 +362,40 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersLargeWrites return size_aligner_32B(static_cast((x >= 4) ? x : 4)); }); - auto dest_generator = get_default_full_dram_dest_generator(seed, device.get()); + auto dest_generator = get_default_full_dram_dest_generator(seed, cluster.get()); auto address_generator = get_default_address_generator(seed, 0x100000, 0x5000000); std::thread write_cmds_thread1([&]() { RunMixedTransfers( - *device, + *cluster, 10000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 1., .read = 0.}, WriteCommandGenerator(dest_generator, address_generator, write_size_generator), - build_dummy_read_command_generator(*device), + build_dummy_read_command_generator(*cluster), // Set to true if you want to emit the command history code to command line false, &command_history0); }); std::thread write_cmds_thread2([&]() { RunMixedTransfers( - *device, + *cluster, 10000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 1., .read = 0.}, WriteCommandGenerator(dest_generator, address_generator, write_size_generator), - build_dummy_read_command_generator(*device), + build_dummy_read_command_generator(*cluster), // Set to true if you want to emit the command history code to command line false, &command_history0); }); std::thread read_cmd_threads1([&]() { RunMixedTransfers( - *device, + *cluster, 10000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 0, .read = 1.}, - build_dummy_write_command_generator(*device), + build_dummy_write_command_generator(*cluster), ReadCommandGenerator(dest_generator, address_generator, read_size_generator), // Set to true if you want to emit the command history code to command line false, @@ -403,11 +403,11 @@ TEST_F(WormholeNebulaX2TestFixture, MultithreadedMixedRemoteTransfersLargeWrites }); std::thread read_cmd_threads2([&]() { RunMixedTransfers( - *device, + *cluster, 10000 * scale_number_of_tests, 0, transfer_type_weights_t{.write = 0, .read = 1.}, - build_dummy_write_command_generator(*device), + build_dummy_write_command_generator(*cluster), ReadCommandGenerator(dest_generator, address_generator, read_size_generator), // Set to true if you want to emit the command history code to command line false, diff --git a/tests/wormhole/test_wh_common.h b/tests/wormhole/test_wh_common.h index fe76e3c2..fb7555ec 100644 --- a/tests/wormhole/test_wh_common.h +++ b/tests/wormhole/test_wh_common.h @@ -14,9 +14,9 @@ namespace tt::umd::test::utils { -static void set_params_for_remote_txn(Cluster& device) { +static void set_params_for_remote_txn(Cluster& cluster) { // Populate address map and NOC parameters that the driver needs for remote transactions - device.set_device_l1_address_params( + cluster.set_device_l1_address_params( {l1_mem::address_map::L1_BARRIER_BASE, eth_l1_mem::address_map::ERISC_BARRIER_BASE, eth_l1_mem::address_map::FW_VERSION_ADDR}); @@ -27,7 +27,7 @@ class WormholeTestFixture : public ::testing::Test { // You can remove any or all of the following functions if their bodies would // be empty. - std::unique_ptr device; + std::unique_ptr cluster; WormholeTestFixture() {} @@ -54,18 +54,18 @@ class WormholeTestFixture : public ::testing::Test { std::iota(devices.begin(), devices.end(), 0); std::set target_devices = {devices.begin(), devices.end()}; uint32_t num_host_mem_ch_per_mmio_device = 1; - device = std::make_unique(num_host_mem_ch_per_mmio_device, false, true, true); - assert(device != nullptr); - assert(device->get_cluster_description()->get_number_of_chips() == get_detected_num_chips()); + cluster = std::make_unique(num_host_mem_ch_per_mmio_device, false, true, true); + assert(cluster != nullptr); + assert(cluster->get_cluster_description()->get_number_of_chips() == get_detected_num_chips()); - set_params_for_remote_txn(*device); + set_params_for_remote_txn(*cluster); tt_device_params default_params; - device->start_device(default_params); + cluster->start_device(default_params); - device->deassert_risc_reset(); + cluster->deassert_risc_reset(); - device->wait_for_non_mmio_flush(); + cluster->wait_for_non_mmio_flush(); } void TearDown() override { @@ -73,7 +73,7 @@ class WormholeTestFixture : public ::testing::Test { // before the destructor). if (!is_test_skipped()) { - device->close_device(); + cluster->close_device(); } } };