Skip to content

Commit

Permalink
add CEM lib
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 d8b4a4f commit 07d939e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions device/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ target_link_libraries(
Boost::interprocess
fmt::fmt-header-only
yaml-cpp::yaml-cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/libcreate_ethernet_map.a
)

install(
Expand Down
Binary file removed device/bin/silicon/aarch64/create-ethernet-map
Binary file not shown.
Binary file removed device/bin/silicon/x86/create-ethernet-map
Binary file not shown.
4 changes: 4 additions & 0 deletions device/libs/create_ethernet_map.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// External function to create the cluster descriptor yaml file.
extern "C" {
int create_ethernet_map(char *file);
}
Binary file added device/libs/libcreate_ethernet_map.a
Binary file not shown.
20 changes: 20 additions & 0 deletions device/tt_cluster_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


#include "tt_cluster_descriptor.h"
#include "libs/create_ethernet_map.h"

#include <fstream>
#include <memory>
Expand Down Expand Up @@ -298,6 +299,25 @@ chip_id_t tt_ClusterDescriptor::get_closest_mmio_capable_chip(const chip_id_t ch
return closest_chip;
}

std::string tt_ClusterDescriptor::get_cluster_descriptor_file_path() {
static std::string yaml_path;
static bool is_initialized = false;
if (!is_initialized){
// Cluster descriptor path will be created in the working directory.
std::filesystem::path cluster_path = std::filesystem::path("cluster_descriptor.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!");
}

int val = create_ethernet_map((char*)cluster_path.string().c_str());
if(val != 0) throw std::runtime_error("Cluster Generation Failed!");
yaml_path = cluster_path.string();
is_initialized = true;
}
return yaml_path;
}

std::unique_ptr<tt_ClusterDescriptor> tt_ClusterDescriptor::create_from_yaml(const std::string &cluster_descriptor_file_path) {
std::unique_ptr<tt_ClusterDescriptor> desc = std::unique_ptr<tt_ClusterDescriptor>(new tt_ClusterDescriptor());

Expand Down
4 changes: 4 additions & 0 deletions device/tt_cluster_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class tt_ClusterDescriptor {
bool is_chip_remote(const chip_id_t chip_id) const;
chip_id_t get_closest_mmio_capable_chip(const chip_id_t chip);
chip_id_t get_shelf_local_physical_chip_coords(chip_id_t virtual_coord);

// TODO: These following functions will be removed, and ClusterDescriptor will be created without any parameters.
// get_cluster_descriptor_file_path will create ethernet map in the background.
static std::string get_cluster_descriptor_file_path();
static std::unique_ptr<tt_ClusterDescriptor> create_from_yaml(const std::string &cluster_descriptor_file_path);
static std::unique_ptr<tt_ClusterDescriptor> create_for_grayskull_cluster(
const std::set<chip_id_t> &logical_mmio_device_ids,
Expand Down

0 comments on commit 07d939e

Please sign in to comment.