Skip to content

Commit

Permalink
Merge branch 'joelsmith/joelsmith/fix-address-type' of github.com:ten…
Browse files Browse the repository at this point in the history
…storrent/tt-umd into joelsmith/joelsmith/fix-address-type
  • Loading branch information
joelsmithTT committed Nov 26, 2024
2 parents 74990bb + 48d8541 commit a200cee
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion device/pcie/pci_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ static T read_sysfs(const PciDeviceInfo &device_info, const std::string &attribu
return value;
}

template <typename T>
T read_sysfs(const PciDeviceInfo &device_info, const std::string &attribute_name, const T &default_value) {
try {
return read_sysfs<T>(device_info, attribute_name);
} catch (...) {
return default_value;
}
}

static PciDeviceInfo read_device_info(int fd) {
tenstorrent_get_device_info info{};
info.in.output_size_bytes = sizeof(info.out);
Expand Down Expand Up @@ -255,7 +264,7 @@ PCIDevice::PCIDevice(int pci_device_number, int logical_device_id) :
logical_id(logical_device_id),
pci_device_file_desc(open(device_path.c_str(), O_RDWR | O_CLOEXEC)),
info(read_device_info(pci_device_file_desc)),
numa_node(read_sysfs<int>(info, "numa_node")),
numa_node(read_sysfs<int>(info, "numa_node", -1)), // default to -1 if not found
revision(read_sysfs<int>(info, "revision")),
arch(detect_arch(info.device_id, revision)),
architecture_implementation(tt::umd::architecture_implementation::create(arch)),
Expand Down

0 comments on commit a200cee

Please sign in to comment.