29 if (r_meets_driver_requirement) {
30 *r_meets_driver_requirement =
true;
34#elif defined(WITH_HIP_DYNLOAD)
35 static bool initialized =
false;
36 static bool result =
false;
43 int hipew_result = hipewInit(HIPEW_INIT_HIP);
45 if (hipew_result == HIPEW_SUCCESS) {
46 LOG_INFO <<
"HIPEW initialization succeeded";
47 if (!hipSupportsDriver()) {
49 if (r_meets_driver_requirement) {
50 *r_meets_driver_requirement =
false;
57 else if (HIPDevice::have_precompiled_kernels()) {
58 LOG_INFO <<
"HIP: Found precompiled kernels";
61 else if (hipewCompilerPath() !=
nullptr) {
62 LOG_INFO <<
"Found HIPCC " << hipewCompilerPath();
66 LOG_INFO <<
"Neither precompiled kernels nor HIPCC was found,"
67 <<
" unable to use HIP";
71 if (hipew_result == HIPEW_ERROR_ATEXIT_FAILED) {
72 LOG_WARNING <<
"HIPEW initialization failed: Error setting up atexit() handler";
74 else if (hipew_result == HIPEW_ERROR_OLD_DRIVER) {
75 LOG_WARNING <<
"HIPEW initialization failed: Driver version too old, requires AMD Adrenalin "
76 "driver 24.9.1 or newer, or AMD Radeon Pro driver 24.Q4 or newer";
77 if (r_meets_driver_requirement) {
78 *r_meets_driver_requirement =
false;
82 LOG_WARNING <<
"HIPEW initialization failed: Error opening HIP dynamic library";
99 return make_unique<HIPRTDevice>(info, stats, profiler, headless);
101 return make_unique<HIPDevice>(info, stats, profiler, headless);
102#elif defined(WITH_HIP)
103 return make_unique<HIPDevice>(info, stats, profiler, headless);
110 LOG_FATAL <<
"Request to create HIP device without compiled-in support. Should never happen.";
139 hipError_t result = device_hip_safe_init();
140 if (result != hipSuccess) {
141 if (result != hipErrorNoDevice) {
142 LOG_ERROR <<
"HIP hipInit: " << hipewErrorString(result);
148 result = hipGetDeviceCount(&count);
149 if (result != hipSuccess) {
150 LOG_ERROR <<
"HIP hipGetDeviceCount: " << hipewErrorString(result);
155 const bool has_hardware_raytracing = HIPRTDevice::is_supported();
157 const bool has_hardware_raytracing =
false;
162 for (
int num = 0; num < count; num++) {
165 result = hipDeviceGetName(name, 256, num);
166 if (result != hipSuccess) {
167 LOG_ERROR <<
"HIP hipDeviceGetName: " << hipewErrorString(result);
171 if (!hipSupportsDevice(num)) {
185 for (
int peer_num = 0; peer_num < count && !info.
has_peer_memory; peer_num++) {
186 if (num != peer_num) {
187 if (hipSupportsDevice(peer_num)) {
189 hipDeviceCanAccessPeer(&can_access, num, peer_num);
198 int pci_location[3] = {0, 0, 0};
199 hipDeviceGetAttribute(&pci_location[0], hipDeviceAttributePciDomainID, num);
200 hipDeviceGetAttribute(&pci_location[1], hipDeviceAttributePciBusId, num);
201 hipDeviceGetAttribute(&pci_location[2], hipDeviceAttributePciDeviceId, num);
204 (
unsigned int)pci_location[0],
205 (
unsigned int)pci_location[1],
206 (
unsigned int)pci_location[2]);
209# if defined(WITH_OPENIMAGEDENOISE)
212# if OIDN_VERSION >= 20300
213 if (hipSupportsDeviceOIDN(num) && oidnIsHIPDeviceSupported(num)) {
215 if (hipSupportsDeviceOIDN(num) && OIDNDenoiserGPU::is_device_supported(info)) {
224 int timeout_attr = 0;
225 hipDeviceGetAttribute(&timeout_attr, hipDeviceAttributeKernelExecTimeout, num);
228 LOG_INFO <<
"Device is recognized as display.";
231 display_devices.push_back(info);
234 LOG_INFO <<
"Device has compute preemption or is not used for display.";
235 devices.push_back(info);
241 LOG_INFO <<
"Device with id \"" << info.
id <<
"\" supports "
246 if (!display_devices.empty()) {
247 devices.insert(devices.end(), display_devices.begin(), display_devices.end());
257 hipError_t result = device_hip_safe_init();
258 if (result != hipSuccess) {
259 if (result != hipErrorNoDevice) {
260 return string(
"Error initializing HIP: ") + hipewErrorString(result);
262 return "No HIP device found\n";
266 result = hipGetDeviceCount(&count);
267 if (result != hipSuccess) {
268 return string(
"Error getting devices: ") + hipewErrorString(result);
272 for (
int num = 0; num < count; num++) {
274 if (hipDeviceGetName(name, 256, num) != hipSuccess) {
277 capabilities += string(
"\t") + name +
"\n";
279# define GET_ATTR(attr) \
281 if (hipDeviceGetAttribute(&value, hipDeviceAttribute##attr, num) == hipSuccess) { \
282 capabilities += string_printf("\t\thipDeviceAttribute" #attr "\t\t\t%d\n", value); \
289 GET_ATTR(MaxThreadsPerBlock);
290 GET_ATTR(MaxBlockDimX);
291 GET_ATTR(MaxBlockDimY);
292 GET_ATTR(MaxBlockDimZ);
293 GET_ATTR(MaxGridDimX);
294 GET_ATTR(MaxGridDimY);
295 GET_ATTR(MaxGridDimZ);
296 GET_ATTR(MaxSharedMemoryPerBlock);
297 GET_ATTR(TotalConstantMemory);
300 GET_ATTR(MaxRegistersPerBlock);
302 GET_ATTR(TextureAlignment);
303 GET_ATTR(MultiprocessorCount);
304 GET_ATTR(KernelExecTimeout);
305 GET_ATTR(Integrated);
306 GET_ATTR(CanMapHostMemory);
307 GET_ATTR(ComputeMode);
308 GET_ATTR(MaxTexture1DWidth);
309 GET_ATTR(MaxTexture2DWidth);
310 GET_ATTR(MaxTexture2DHeight);
311 GET_ATTR(MaxTexture3DWidth);
312 GET_ATTR(MaxTexture3DHeight);
313 GET_ATTR(MaxTexture3DDepth);
314 GET_ATTR(ConcurrentKernels);
315 GET_ATTR(EccEnabled);
316 GET_ATTR(MemoryClockRate);
317 GET_ATTR(MemoryBusWidth);
318 GET_ATTR(L2CacheSize);
319 GET_ATTR(MaxThreadsPerMultiProcessor);
320 GET_ATTR(ComputeCapabilityMajor);
321 GET_ATTR(ComputeCapabilityMinor);
322 GET_ATTR(MaxSharedMemoryPerMultiprocessor);
323 GET_ATTR(ManagedMemory);
324 GET_ATTR(IsMultiGpuBoard);
326 capabilities +=
"\n";