Blender V4.5
hip/util.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#ifdef WITH_HIP
6
7# include "device/hip/util.h"
9
11
12HIPContextScope::HIPContextScope(HIPDevice *device) : device(device)
13{
14 hip_device_assert(device, hipCtxPushCurrent(device->hipContext));
15}
16
17HIPContextScope::~HIPContextScope()
18{
19 hip_device_assert(device, hipCtxPopCurrent(nullptr));
20}
21
22# ifndef WITH_HIP_DYNLOAD
23const char *hipewErrorString(hipError_t result)
24{
25 /* We can only give error code here without major code duplication, that
26 * should be enough since dynamic loading is only being disabled by folks
27 * who knows what they're doing anyway.
28 *
29 * NOTE: Avoid call from several threads.
30 */
31 static string error;
32 error = string_printf("%d", result);
33 return error.c_str();
34}
35
36const char *hipewCompilerPath()
37{
38 return CYCLES_HIP_HIPCC_EXECUTABLE;
39}
40
41int hipewCompilerVersion()
42{
43 return (HIP_VERSION / 100) + (HIP_VERSION % 100 / 10);
44}
45# endif /* !WITH_HIP_DYNLOAD */
46
47bool hipSupportsDriver()
48{
49# ifdef _WIN32
50# ifndef WITH_HIP_SDK_5
51 /* This check is only necessary if we're using HIP SDK 6 or newer. */
52 int hip_driver_version = 0;
53 hipError_t result = hipDriverGetVersion(&hip_driver_version);
54 if (result != hipSuccess) {
55 VLOG_WARNING << "Error getting driver version: " << hipewErrorString(result);
56 return false;
57 }
58
59 VLOG_DEBUG << "Detected HIP driver version: " << hip_driver_version;
60
61 if (hip_driver_version < 60140252) {
62 /* Cycles crashes during rendering due to issues in older GPU drivers.
63 * 60140252 corresponds to Adrenalin 24.6.1. */
64 return false;
65 }
66# endif
67# endif
68
69 return true;
70}
71
73
74#endif /* WITH_HIP */
#define CCL_NAMESPACE_END
#define VLOG_WARNING
Definition log.h:69
#define VLOG_DEBUG
Definition log.h:80
static void error(const char *str)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
Definition string.cpp:23