Skip to content

Commit

Permalink
alter tests and remove getClusterYaml
Browse files Browse the repository at this point in the history
  • Loading branch information
broskoTT authored and blozano-tt committed Nov 2, 2024
1 parent 07d939e commit 6d4e180
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 95 deletions.
15 changes: 13 additions & 2 deletions tests/api/test_chip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ inline std::unique_ptr<tt_ClusterDescriptor> get_cluster_desc() {
cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path);
} else {
// TODO: remove getting manually cluster descriptor from yaml.
std::string yaml_path = test_utils::GetClusterDescYAML();
std::string yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path);
}

Expand Down Expand Up @@ -91,7 +91,7 @@ inline std::unique_ptr<Cluster> get_cluster() {
yaml_path = test_utils::GetAbsPath("blackhole_1chip_cluster.yaml");
} else {
// TODO: remove getting manually cluster descriptor from yaml.
yaml_path = test_utils::GetClusterDescYAML();
yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
}
// TODO: Remove the need to do this, allow default constructor to construct with all chips.
std::unique_ptr<tt_ClusterDescriptor> cluster_desc = get_cluster_desc();
Expand Down Expand Up @@ -122,6 +122,11 @@ inline std::unique_ptr<Cluster> get_cluster() {
TEST(ApiChipTest, ManualTLBConfiguration) {
std::unique_ptr<Cluster> umd_cluster = get_cluster();

if (umd_cluster == nullptr || umd_cluster->get_all_chips_in_cluster().empty()) {
std::cout << "No chips found. Skipping test." << std::endl;
return;
}

// Expect to throw for remote chip for any worker core
auto remote_chips = umd_cluster->get_target_remote_device_ids();
if (!remote_chips.empty()) {
Expand Down Expand Up @@ -176,6 +181,12 @@ TEST(ApiChipTest, ManualTLBConfiguration) {
// TODO: Move to test_chip
TEST(ApiChipTest, SimpleAPIShowcase) {
std::unique_ptr<Cluster> umd_cluster = get_cluster();

if (umd_cluster == nullptr || umd_cluster->get_all_chips_in_cluster().empty()) {
std::cout << "No chips found. Skipping test." << std::endl;
return;
}

chip_id_t chip_id = *umd_cluster->get_all_chips_in_cluster().begin();

// TODO: In future, will be accessed through tt::umd::Chip api.
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ inline std::unique_ptr<tt_ClusterDescriptor> get_cluster_desc() {
cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path);
} else {
// TODO: remove getting manually cluster descriptor from yaml.
std::string yaml_path = test_utils::GetClusterDescYAML();
std::string yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ inline std::unique_ptr<Cluster> get_cluster() {
yaml_path = test_utils::GetAbsPath("blackhole_1chip_cluster.yaml");
} else {
// TODO: remove getting manually cluster descriptor from yaml.
yaml_path = test_utils::GetClusterDescYAML();
yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
}
// TODO: Remove the need to do this, allow default constructor to construct with all chips.
std::unique_ptr<tt_ClusterDescriptor> cluster_desc = get_cluster_desc();
Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_cluster_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ inline std::unique_ptr<tt_ClusterDescriptor> get_cluster_desc() {
cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path);
} else {
// TODO: remove getting manually cluster descriptor from yaml.
std::string yaml_path = test_utils::GetClusterDescYAML();
std::string yaml_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
cluster_desc = tt_ClusterDescriptor::create_from_yaml(yaml_path);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/blackhole/test_bh_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BlackholeTestFixture : public ::testing::Test {
std::iota(devices.begin(), devices.end(), 0);
std::set<chip_id_t> target_devices = {devices.begin(), devices.end()};
uint32_t num_host_mem_ch_per_mmio_device = 1;
device = std::make_unique<tt_SiliconDevice>(test_utils::GetAbsPath(SOC_DESC_PATH), test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true);
device = std::make_unique<tt_SiliconDevice>(test_utils::GetAbsPath(SOC_DESC_PATH), tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, 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());

Expand Down
12 changes: 6 additions & 6 deletions tests/blackhole/test_silicon_driver_bh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ TEST(SiliconDriverBH, CreateDestroy) {
// std::unordered_map<chip_id_t, uint32_t> simulated_harvesting_masks = {{0, 30}, {1, 60}};

// {
// std::unique_ptr<tt_ClusterDescriptor> cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML());
// std::unique_ptr<tt_ClusterDescriptor> cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path());
// if (cluster_desc_uniq->get_number_of_chips() != target_devices.size()) {
// GTEST_SKIP() << "SiliconDriverWH.Harvesting skipped because it can only be run on a two chip nebula system";
// }
// }

// uint32_t num_host_mem_ch_per_mmio_device = 1;
// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_8x10.yaml", test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks);
// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_8x10.yaml", tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks);
// auto sdesc_per_chip = device.get_virtual_soc_descriptors();

// ASSERT_EQ(device.using_harvested_soc_descriptors(), true) << "Expected Driver to have performed harvesting";
Expand All @@ -120,15 +120,15 @@ TEST(SiliconDriverBH, CreateDestroy) {
// std::set<chip_id_t> target_devices = {0, 1};
// std::unordered_map<chip_id_t, uint32_t> simulated_harvesting_masks = {{0, 30}, {1, 60}};
// {
// std::unique_ptr<tt_ClusterDescriptor> cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML());
// std::unique_ptr<tt_ClusterDescriptor> cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path());
// if (cluster_desc_uniq->get_number_of_chips() != target_devices.size()) {
// GTEST_SKIP() << "SiliconDriverWH.Harvesting skipped because it can only be run on a two chip nebula system";
// }
// }

// 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("./tests/soc_descs/wormhole_b0_1x1.yaml", test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, false, simulated_harvesting_masks);
// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_1x1.yaml", tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, num_host_mem_ch_per_mmio_device, 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";
Expand All @@ -146,15 +146,15 @@ TEST(SiliconDriverBH, CreateDestroy) {
// std::set<chip_id_t> target_devices = {0, 1};
// std::unordered_map<chip_id_t, uint32_t> simulated_harvesting_masks = {{0, 30}, {1, 60}};
// {
// std::unique_ptr<tt_ClusterDescriptor> cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML());
// std::unique_ptr<tt_ClusterDescriptor> cluster_desc_uniq = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path());
// if (cluster_desc_uniq->get_number_of_chips() != target_devices.size()) {
// GTEST_SKIP() << "SiliconDriverWH.Harvesting skipped because it can only be run on a two chip nebula system";
// }
// }

// uint32_t num_host_mem_ch_per_mmio_device = 1;

// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_8x10.yaml", test_utils::GetClusterDescYAML(), target_devices, num_host_mem_ch_per_mmio_device, false, true, true, simulated_harvesting_masks);
// tt_SiliconDevice device = tt_SiliconDevice("./tests/soc_descs/wormhole_b0_8x10.yaml", tt_ClusterDescriptor::get_cluster_descriptor_file_path(), target_devices, 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();

Expand Down
6 changes: 3 additions & 3 deletions tests/galaxy/test_umd_concurrent_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static const std::string SOC_DESC_PATH = "tests/soc_descs/wormhole_b0_8x10.yaml"
TEST(GalaxyConcurrentThreads, WriteToAllChipsL1) {
// Galaxy Setup

std::string cluster_desc_path = test_utils::GetClusterDescYAML();
std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
std::shared_ptr<tt_ClusterDescriptor> cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path);
std::set<chip_id_t> target_devices_th1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
std::set<chip_id_t> target_devices_th2 = {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32};
Expand Down Expand Up @@ -113,7 +113,7 @@ TEST(GalaxyConcurrentThreads, WriteToAllChipsL1) {

TEST(GalaxyConcurrentThreads, WriteToAllChipsDram) {
// Galaxy Setup
std::string cluster_desc_path = test_utils::GetClusterDescYAML();
std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
std::shared_ptr<tt_ClusterDescriptor> cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path);
std::set<chip_id_t> target_devices_th1 = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32};
std::set<chip_id_t> target_devices_th2 = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31};
Expand Down Expand Up @@ -204,7 +204,7 @@ TEST(GalaxyConcurrentThreads, WriteToAllChipsDram) {

TEST(GalaxyConcurrentThreads, PushInputsWhileSignalingCluster) {
// Galaxy Setup
std::string cluster_desc_path = test_utils::GetClusterDescYAML();
std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
std::shared_ptr<tt_ClusterDescriptor> cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path);
std::set<chip_id_t> target_devices = {0, 1, 2, 3, 4, 5, 6, 7, 8};
for (const auto& chip : target_devices) {
Expand Down
6 changes: 3 additions & 3 deletions tests/galaxy/test_umd_remote_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static const std::string SOC_DESC_PATH = "tests/soc_descs/wormhole_b0_8x10.yaml"

void run_remote_read_write_test(uint32_t vector_size, bool dram_write) {
// Galaxy Setup
std::string cluster_desc_path = test_utils::GetClusterDescYAML();
std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
std::shared_ptr<tt_ClusterDescriptor> cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path);
std::set<chip_id_t> target_devices = {};
for (const auto& chip : cluster_desc->get_all_chips()) {
Expand Down Expand Up @@ -126,7 +126,7 @@ TEST(GalaxyBasicReadWrite, LargeRemoteDramBlockReadWrite) { run_remote_read_writ
void run_data_mover_test(
uint32_t vector_size, tt_multichip_core_addr sender_core, tt_multichip_core_addr receiver_core) {
// Galaxy Setup
std::string cluster_desc_path = test_utils::GetClusterDescYAML();
std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
std::shared_ptr<tt_ClusterDescriptor> cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path);
std::set<chip_id_t> target_devices = {};
for (const auto& chip : cluster_desc->get_all_chips()) {
Expand Down Expand Up @@ -240,7 +240,7 @@ TEST(GalaxyDataMovement, TwoChipMoveData4) {
void run_data_broadcast_test(
uint32_t vector_size, tt_multichip_core_addr sender_core, std::vector<tt_multichip_core_addr> receiver_cores) {
// Galaxy Setup
std::string cluster_desc_path = test_utils::GetClusterDescYAML();
std::string cluster_desc_path = tt_ClusterDescriptor::get_cluster_descriptor_file_path();
std::shared_ptr<tt_ClusterDescriptor> cluster_desc = tt_ClusterDescriptor::create_from_yaml(cluster_desc_path);
std::set<chip_id_t> target_devices = {};
for (const auto& chip : cluster_desc->get_all_chips()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/galaxy/test_umd_remote_api_stability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class WormholeGalaxyStabilityTestFixture : public WormholeTestFixture {
static uint32_t scale_number_of_tests;

static void SetUpTestSuite() {
std::unique_ptr<tt_ClusterDescriptor> cluster_desc = tt_ClusterDescriptor::create_from_yaml(test_utils::GetClusterDescYAML());
std::unique_ptr<tt_ClusterDescriptor> cluster_desc = tt_ClusterDescriptor::create_from_yaml(tt_ClusterDescriptor::get_cluster_descriptor_file_path());
detected_num_chips = cluster_desc->get_number_of_chips();
if (detected_num_chips < EXPECTED_MIN_CHIPS) {
skip_tests = true;
Expand Down
36 changes: 0 additions & 36 deletions tests/test_utils/generate_cluster_desc.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions tests/test_utils/generate_cluster_desc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,4 @@ inline std::string GetAbsPath(std::string path_){
std::filesystem::path abs_path = umd_root / path_;
return abs_path.string();
}

inline std::string GetClusterDescYAML(){
static std::string yaml_path;
static bool is_initialized = false;
if (!is_initialized){
std::filesystem::path umd_path = std::filesystem::path(test_utils::GetAbsPath(""));
std::filesystem::path cluster_path = umd_path / ".umd";
std::filesystem::create_directories( cluster_path );

cluster_path /= "cluster_desc.yaml";
if (!std::filesystem::exists(cluster_path)){
auto val = system ( ("touch " + cluster_path.string()).c_str());
if(val != 0) throw std::runtime_error("Cluster Generation Failed!");
}
// Generates the cluster descriptor in the CWD

std::filesystem::path eth_fpath = umd_path / "device/bin/silicon/x86/create-ethernet-map";
std::string cmd = fmt::format("{} {}", eth_fpath.string(), cluster_path.string());
int val = system(cmd.c_str());
if(val != 0) throw std::runtime_error("Cluster Generation Failed!");
yaml_path = cluster_path.string();
is_initialized = true;
}
return yaml_path;
}
} // namespace test_utils
Loading

0 comments on commit 6d4e180

Please sign in to comment.