1 /* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
3 * SPDX-License-Identifier: Apache-2.0 */
12 # ifdef WITH_HIP_DYNLOAD
20 /* Utility to push/pop HIP context. */
21 class HIPContextScope
{
23 HIPContextScope(HIPDevice
*device
);
30 /* Utility for checking return values of HIP function calls. */
31 # define hip_device_assert(hip_device, stmt) \
33 hipError_t result = stmt; \
34 if (result != hipSuccess) { \
35 const char *name = hipewErrorString(result); \
36 hip_device->set_error( \
37 string_printf("%s in %s (%s:%d)", name, #stmt, __FILE__, __LINE__)); \
42 # define hip_assert(stmt) hip_device_assert(this, stmt)
44 # ifndef WITH_HIP_DYNLOAD
45 /* Transparently implement some functions, so majority of the file does not need
46 * to worry about difference between dynamically loaded and linked HIP at all. */
47 const char *hipewErrorString(hipError_t result
);
48 const char *hipewCompilerPath();
49 int hipewCompilerVersion();
50 # endif /* WITH_HIP_DYNLOAD */
52 static std::string
hipDeviceArch(const int hipDevId
)
54 hipDeviceProp_t props
;
55 hipGetDeviceProperties(&props
, hipDevId
);
56 const char *arch
= strtok(props
.gcnArchName
, ":");
57 return (arch
== nullptr) ? props
.gcnArchName
: arch
;
60 static inline bool hipSupportsDevice(const int hipDevId
)
63 hipDeviceGetAttribute(&major
, hipDeviceAttributeComputeCapabilityMajor
, hipDevId
);
64 hipDeviceGetAttribute(&minor
, hipDeviceAttributeComputeCapabilityMinor
, hipDevId
);
69 static inline bool hipSupportsDeviceOIDN(const int hipDevId
)
71 /* Matches HIPDevice::getArch in HIP. */
72 const std::string arch
= hipDeviceArch(hipDevId
);
73 return (arch
== "gfx1030" || arch
== "gfx1100" || arch
== "gfx1101" || arch
== "gfx1102");