18 lines
452 B
C
18 lines
452 B
C
#pragma once
|
|
|
|
#include "spdlog/spdlog.h"
|
|
#include <stdint.h>
|
|
|
|
#include "xpu/runtime.h"
|
|
|
|
static inline uint32_t get_device_pci_addr(int device_id) {
|
|
uint64_t v;
|
|
int ret = xpu_device_get_attr(&v, XPUATTR_PCI_ADDRESS, device_id);
|
|
if (ret != XPU_SUCCESS) {
|
|
spdlog::error("Failed to get PCI address for device {}: {}", device_id,
|
|
xpu_strerror(ret));
|
|
return static_cast<uint32_t>(-1);
|
|
}
|
|
return static_cast<uint32_t>(v);
|
|
}
|