|
48 | 48 | #include <unistd.h> |
49 | 49 |
|
50 | 50 | #include <array> |
51 | | -#include <filesystem> |
52 | 51 | #include <fstream> |
53 | 52 | #include <map> |
54 | 53 | #include <memory> |
@@ -87,12 +86,11 @@ static const std::map<XDNADeviceId, XDNADeviceType> supported_xdna_devices = { |
87 | 86 | {{0x17f0}, XDNADeviceType::Stx}, // Strix Halo / Krackan |
88 | 87 | }; |
89 | 88 |
|
90 | | -namespace fs = std::filesystem; |
91 | | - |
| 89 | +/// Returns the path as a string to avoid C++ ABI issues with std::filesystem::path. |
92 | 90 | /// @brief Devnode path for XDNA devices. |
93 | | -static const fs::path devnodes_path = "/dev/accel"; |
| 91 | +static const std::string devnodes_path = "/dev/accel"; |
94 | 92 | /// @brief Sysfs path for XDNA devices. |
95 | | -static const fs::path sysfs_path = "/sys/class/accel"; |
| 93 | +static const std::string sysfs_path = "/sys/class/accel"; |
96 | 94 | /// @brief Devnode prefix for XDNA devices. |
97 | 95 | static const std::string devnode_prefix = "accel"; |
98 | 96 | /// @brief Maximum devnode minor number for XDNA devices. |
@@ -180,7 +178,7 @@ hsa_status_t XdnaDriver::QueryKernelModeDriver(core::DriverQuery query) { |
180 | 178 | } |
181 | 179 |
|
182 | 180 | hsa_status_t XdnaDriver::Open() { |
183 | | - const auto devnode_path = devnodes_path / devnode_name_; |
| 181 | + const std::string devnode_path = devnodes_path + "/" + devnode_name_; |
184 | 182 | fd_ = open(devnode_path.c_str(), O_RDWR | O_CLOEXEC); |
185 | 183 | if (fd_ < 0) { |
186 | 184 | return HSA_STATUS_ERROR_OUT_OF_RESOURCES; |
@@ -216,19 +214,19 @@ hsa_status_t XdnaDriver::GetNodeProperties(HsaNodeProperties& node_props, uint32 |
216 | 214 | return HSA_STATUS_ERROR; |
217 | 215 | } |
218 | 216 |
|
219 | | - const auto sysfs_device_path = sysfs_path / devnode_name_ / "device"; |
| 217 | + const std::string sysfs_device_path = sysfs_path + "/" + devnode_name_ + "/device"; |
220 | 218 |
|
221 | 219 | // Find device type. |
222 | 220 | XDNADeviceType device_type = XDNADeviceType::Unknown; |
223 | 221 | { |
224 | | - const auto device_id_file = sysfs_device_path / "device"; |
225 | | - if (!fs::exists(device_id_file)) { |
| 222 | + const std::string device_id_file = sysfs_device_path + "/device"; |
| 223 | + std::ifstream is(device_id_file); |
| 224 | + if (!is.good()) { |
226 | 225 | assert(false && "Device file not found in sysfs."); |
227 | 226 | return HSA_STATUS_ERROR; |
228 | 227 | } |
229 | 228 |
|
230 | 229 | XDNADeviceId device_id = {}; |
231 | | - std::ifstream is(device_id_file); |
232 | 230 | // Device ID is in hex. |
233 | 231 | if (!(is >> std::hex >> device_id.device)) { |
234 | 232 | assert(false && "Failed to read device ID from sysfs."); |
@@ -268,13 +266,13 @@ hsa_status_t XdnaDriver::GetNodeProperties(HsaNodeProperties& node_props, uint32 |
268 | 266 |
|
269 | 267 | // Read device name from sysfs. |
270 | 268 | { |
271 | | - const auto device_name_file = sysfs_device_path / "vbnv"; |
272 | | - if (!fs::exists(device_name_file)) { |
| 269 | + const std::string device_name_file = sysfs_device_path + "/vbnv"; |
| 270 | + std::array<char, HSA_PUBLIC_NAME_SIZE> device_name = {}; |
| 271 | + std::ifstream is(device_name_file); |
| 272 | + if (!is.good()) { |
273 | 273 | assert(false && "Device file name not found in sysfs."); |
274 | 274 | return HSA_STATUS_ERROR; |
275 | 275 | } |
276 | | - std::array<char, HSA_PUBLIC_NAME_SIZE> device_name = {}; |
277 | | - std::ifstream is(device_name_file); |
278 | 276 | if (!is.getline(device_name.data(), device_name.size() - 1)) { |
279 | 277 | assert(false && "Failed to read device name from sysfs."); |
280 | 278 | return HSA_STATUS_ERROR; |
|
0 commit comments