From cd4b4898c7438e8b433fb11a7894d88c1effd7cd Mon Sep 17 00:00:00 2001 From: Bojan Rosko Date: Wed, 9 Oct 2024 20:47:16 +0200 Subject: [PATCH 1/3] tryfix_1 --- tests/grayskull/test_silicon_driver.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/grayskull/test_silicon_driver.cpp b/tests/grayskull/test_silicon_driver.cpp index 1798b0e1..9febc77f 100644 --- a/tests/grayskull/test_silicon_driver.cpp +++ b/tests/grayskull/test_silicon_driver.cpp @@ -11,6 +11,7 @@ #include "l1_address_map.h" #include "tests/test_utils/generate_cluster_desc.hpp" #include "tests/test_utils/device_test_utils.hpp" +#include "device/tt_cluster_descriptor.h" TEST(SiliconDriverGS, CreateDestroySequential) { std::set target_devices = {0}; @@ -45,7 +46,10 @@ TEST(SiliconDriverGS, CreateMultipleInstance) { TEST(SiliconDriverGS, Harvesting) { std::set target_devices = {0}; - std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; + std::vector available_devices = {0}; + std::shared_ptr ndesc = tt_ClusterDescriptor::create_for_grayskull_cluster(target_devices, available_devices); + std::unordered_map harvesting_masks = ndesc -> get_harvesting_info(); + std::unordered_map simulated_harvesting_masks = {{0, 6 & harvesting_masks[0]}, {1, 12 & harvesting_masks[1]}}; // Simulated masks have to include the actual masks. std::unordered_map dynamic_tlb_config = {}; // Don't set any dynamic TLBs in this test uint32_t num_host_mem_ch_per_mmio_device = 1; tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/grayskull_10x12.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, true, simulated_harvesting_masks); @@ -62,11 +66,10 @@ TEST(SiliconDriverGS, Harvesting) { TEST(SiliconDriverGS, CustomSocDesc) { std::set target_devices = {0}; - std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; std::unordered_map dynamic_tlb_config = {}; // Don't set any dynamic TLBs in this test uint32_t num_host_mem_ch_per_mmio_device = 1; // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("./tests/soc_descs/grayskull_1x1_arch.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, false, simulated_harvesting_masks); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("./tests/soc_descs/grayskull_1x1_arch.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, false); auto sdesc_per_chip = device.get_virtual_soc_descriptors(); ASSERT_EQ(device.using_harvested_soc_descriptors(), false) << "SOC descriptors should not be modified when harvesting is disabled"; for(const auto& chip : sdesc_per_chip) { @@ -84,7 +87,10 @@ TEST(SiliconDriverGS, HarvestingRuntime) { }; std::set target_devices = {0}; - std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; + std::vector available_devices = {0}; + std::shared_ptr ndesc = tt_ClusterDescriptor::create_for_grayskull_cluster(target_devices, available_devices); + std::unordered_map harvesting_masks = ndesc -> get_harvesting_info(); + std::unordered_map simulated_harvesting_masks = {{0, 6 & harvesting_masks[0]}, {1, 12 & harvesting_masks[1]}}; // Simulated masks have to include the actual masks. std::unordered_map dynamic_tlb_config = {{"SMALL_READ_WRITE_TLB", 157}}; // Use both static and dynamic TLBs here uint32_t num_host_mem_ch_per_mmio_device = 1; tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/grayskull_10x12.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, true, simulated_harvesting_masks); From 8b1d89f5ef67c514a5403c82f7a01d8ee298b1cf Mon Sep 17 00:00:00 2001 From: Bojan Rosko Date: Wed, 9 Oct 2024 21:04:53 +0200 Subject: [PATCH 2/3] another try 2 --- tests/grayskull/test_silicon_driver.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/grayskull/test_silicon_driver.cpp b/tests/grayskull/test_silicon_driver.cpp index 9febc77f..286126a8 100644 --- a/tests/grayskull/test_silicon_driver.cpp +++ b/tests/grayskull/test_silicon_driver.cpp @@ -49,7 +49,7 @@ TEST(SiliconDriverGS, Harvesting) { std::vector available_devices = {0}; std::shared_ptr ndesc = tt_ClusterDescriptor::create_for_grayskull_cluster(target_devices, available_devices); std::unordered_map harvesting_masks = ndesc -> get_harvesting_info(); - std::unordered_map simulated_harvesting_masks = {{0, 6 & harvesting_masks[0]}, {1, 12 & harvesting_masks[1]}}; // Simulated masks have to include the actual masks. + std::unordered_map simulated_harvesting_masks = {{0, 6 | harvesting_masks[0]}, {1, 12 | harvesting_masks[1]}}; // Simulated masks have to include the actual masks. std::unordered_map dynamic_tlb_config = {}; // Don't set any dynamic TLBs in this test uint32_t num_host_mem_ch_per_mmio_device = 1; tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/grayskull_10x12.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, true, simulated_harvesting_masks); @@ -57,9 +57,11 @@ TEST(SiliconDriverGS, Harvesting) { ASSERT_EQ(device.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; for(const auto& chip : sdesc_per_chip) { - ASSERT_EQ(chip.second.workers.size(), 96) << "Expected SOC descriptor with harvesting to have 96 workers for chip " << chip.first; + int harvested_rows = std::bitset<32>(simulated_harvesting_masks[0]).count(); + int expected_workers = 120 - 12 * harvested_rows; + ASSERT_EQ(chip.second.workers.size(), expected_workers) << "Expected SOC descriptor with harvesting to have " << expected_workers << " workers for chip " << chip.first; } - ASSERT_EQ(device.get_harvesting_masks_for_soc_descriptors().at(0), 6) << "Expected first chip to have harvesting mask of 6"; + ASSERT_EQ(device.get_harvesting_masks_for_soc_descriptors().at(0), simulated_harvesting_masks[0]) << "Expected first chip to have harvesting mask of " << simulated_harvesting_masks[0]; // ASSERT_EQ(device.get_harvesting_masks_for_soc_descriptors().at(1), 12) << "Expected second chip to have harvesting mask of 12"; device.close_device(); } @@ -90,7 +92,7 @@ TEST(SiliconDriverGS, HarvestingRuntime) { std::vector available_devices = {0}; std::shared_ptr ndesc = tt_ClusterDescriptor::create_for_grayskull_cluster(target_devices, available_devices); std::unordered_map harvesting_masks = ndesc -> get_harvesting_info(); - std::unordered_map simulated_harvesting_masks = {{0, 6 & harvesting_masks[0]}, {1, 12 & harvesting_masks[1]}}; // Simulated masks have to include the actual masks. + std::unordered_map simulated_harvesting_masks = {{0, 6 | harvesting_masks[0]}, {1, 12 | harvesting_masks[1]}}; // Simulated masks have to include the actual masks. std::unordered_map dynamic_tlb_config = {{"SMALL_READ_WRITE_TLB", 157}}; // Use both static and dynamic TLBs here uint32_t num_host_mem_ch_per_mmio_device = 1; tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/grayskull_10x12.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, true, simulated_harvesting_masks); From 50bed4cd57282eccdcf5de03b10a4c64e6c5cc41 Mon Sep 17 00:00:00 2001 From: Bojan Rosko Date: Wed, 9 Oct 2024 21:24:25 +0200 Subject: [PATCH 3/3] try another way --- device/tt_silicon_driver.cpp | 14 +++++++------- tests/grayskull/test_silicon_driver.cpp | 20 ++++++-------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/device/tt_silicon_driver.cpp b/device/tt_silicon_driver.cpp index 113623f7..ad7332a3 100644 --- a/device/tt_silicon_driver.cpp +++ b/device/tt_silicon_driver.cpp @@ -686,21 +686,21 @@ tt_SiliconDevice::tt_SiliconDevice(const std::string &sdesc_path, const std::str for (auto device_id = target_devices.begin(); device_id != target_devices.end(); device_id++) { log_assert(simulated_harvesting_masks.find(*device_id) != simulated_harvesting_masks.end(), "Could not find harvesting mask for device_id {}", *device_id); if(arch_name == tt::ARCH::GRAYSKULL) { - log_assert((simulated_harvesting_masks.at(*device_id) & harvested_rows_per_target[*device_id]) == harvested_rows_per_target[*device_id], - "Simulated harvesting config for device {} does not include the actual harvesting config (real config must be contained in simulated config when running on device). Actual Harvested Rows : {} Simulated Harvested Rows : {}", - *device_id, harvested_rows_per_target[*device_id], simulated_harvesting_masks.at(*device_id)); - + if ((simulated_harvesting_masks.at(*device_id) & harvested_rows_per_target[*device_id]) != harvested_rows_per_target[*device_id]) { + log_warning(LogSiliconDriver, + "Simulated harvesting config for device {} does not include the actual harvesting config. Simulated harvesting mask will be added to the real harvesting mask. Actual Harvested Rows : {} Simulated Harvested Rows : {}", + *device_id, harvested_rows_per_target[*device_id], simulated_harvesting_masks.at(*device_id)); + } + simulated_harvesting_masks.at(*device_id) |= harvested_rows_per_target[*device_id]; } else if(arch_name == tt::ARCH::WORMHOLE_B0 || arch_name == tt::ARCH::WORMHOLE) { log_assert(std::bitset<32>(simulated_harvesting_masks.at(*device_id)).count() >= std::bitset<32>(harvested_rows_per_target[*device_id]).count(), "Simulated Harvesting for WH must contain at least as many rows as the actual harvesting config. Actual Harvested Rows : {} Simulated Harvested Rows : {}", harvested_rows_per_target[*device_id], simulated_harvesting_masks.at(*device_id)); num_rows_harvested.at(*device_id) = std::bitset<32>(simulated_harvesting_masks.at(*device_id)).count(); - } - harvested_rows_per_target[*device_id] = simulated_harvesting_masks.at(*device_id); - if(arch_name == tt::ARCH::WORMHOLE or arch_name == tt::ARCH::WORMHOLE_B0) { log_assert(performed_harvesting ? translation_tables_en : true, "Using a harvested WH cluster with NOC translation disabled."); } + harvested_rows_per_target[*device_id] = simulated_harvesting_masks.at(*device_id); } } diff --git a/tests/grayskull/test_silicon_driver.cpp b/tests/grayskull/test_silicon_driver.cpp index 286126a8..1f172573 100644 --- a/tests/grayskull/test_silicon_driver.cpp +++ b/tests/grayskull/test_silicon_driver.cpp @@ -11,7 +11,6 @@ #include "l1_address_map.h" #include "tests/test_utils/generate_cluster_desc.hpp" #include "tests/test_utils/device_test_utils.hpp" -#include "device/tt_cluster_descriptor.h" TEST(SiliconDriverGS, CreateDestroySequential) { std::set target_devices = {0}; @@ -46,10 +45,7 @@ TEST(SiliconDriverGS, CreateMultipleInstance) { TEST(SiliconDriverGS, Harvesting) { std::set target_devices = {0}; - std::vector available_devices = {0}; - std::shared_ptr ndesc = tt_ClusterDescriptor::create_for_grayskull_cluster(target_devices, available_devices); - std::unordered_map harvesting_masks = ndesc -> get_harvesting_info(); - std::unordered_map simulated_harvesting_masks = {{0, 6 | harvesting_masks[0]}, {1, 12 | harvesting_masks[1]}}; // Simulated masks have to include the actual masks. + std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; std::unordered_map dynamic_tlb_config = {}; // Don't set any dynamic TLBs in this test uint32_t num_host_mem_ch_per_mmio_device = 1; tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/grayskull_10x12.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, true, simulated_harvesting_masks); @@ -57,21 +53,20 @@ TEST(SiliconDriverGS, Harvesting) { ASSERT_EQ(device.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting"; for(const auto& chip : sdesc_per_chip) { - int harvested_rows = std::bitset<32>(simulated_harvesting_masks[0]).count(); - int expected_workers = 120 - 12 * harvested_rows; - ASSERT_EQ(chip.second.workers.size(), expected_workers) << "Expected SOC descriptor with harvesting to have " << expected_workers << " workers for chip " << chip.first; + 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]) << "Expected first chip to have harvesting mask of " << simulated_harvesting_masks[0]; + ASSERT_EQ(device.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 harvesting mask of 12"; device.close_device(); } TEST(SiliconDriverGS, CustomSocDesc) { std::set target_devices = {0}; + std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; std::unordered_map dynamic_tlb_config = {}; // Don't set any dynamic TLBs in this test uint32_t num_host_mem_ch_per_mmio_device = 1; // Initialize the driver with a 1x1 descriptor and explictly do not perform harvesting - tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("./tests/soc_descs/grayskull_1x1_arch.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, false); + tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("./tests/soc_descs/grayskull_1x1_arch.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, false, simulated_harvesting_masks); auto sdesc_per_chip = device.get_virtual_soc_descriptors(); ASSERT_EQ(device.using_harvested_soc_descriptors(), false) << "SOC descriptors should not be modified when harvesting is disabled"; for(const auto& chip : sdesc_per_chip) { @@ -89,10 +84,7 @@ TEST(SiliconDriverGS, HarvestingRuntime) { }; std::set target_devices = {0}; - std::vector available_devices = {0}; - std::shared_ptr ndesc = tt_ClusterDescriptor::create_for_grayskull_cluster(target_devices, available_devices); - std::unordered_map harvesting_masks = ndesc -> get_harvesting_info(); - std::unordered_map simulated_harvesting_masks = {{0, 6 | harvesting_masks[0]}, {1, 12 | harvesting_masks[1]}}; // Simulated masks have to include the actual masks. + std::unordered_map simulated_harvesting_masks = {{0, 6}, {1, 12}}; std::unordered_map dynamic_tlb_config = {{"SMALL_READ_WRITE_TLB", 157}}; // Use both static and dynamic TLBs here uint32_t num_host_mem_ch_per_mmio_device = 1; tt_SiliconDevice device = tt_SiliconDevice(test_utils::GetAbsPath("tests/soc_descs/grayskull_10x12.yaml"), "", target_devices, num_host_mem_ch_per_mmio_device, dynamic_tlb_config, false, true, true, simulated_harvesting_masks);