Blender
V5.0
intern
cycles
device
cuda
cycles/device/cuda/util.h
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
#pragma once
6
7
#ifdef WITH_CUDA
8
9
# ifdef WITH_CUDA_DYNLOAD
10
# include <cuew.h>
11
# else
12
# include <cuda.h>
13
# endif
14
15
CCL_NAMESPACE_BEGIN
16
17
class
CUDADevice;
18
19
/* Utility to push/pop CUDA context. */
20
class
CUDAContextScope {
21
public
:
22
CUDAContextScope(CUDADevice *device);
23
~CUDAContextScope();
24
25
private
:
26
CUDADevice *device;
27
};
28
29
/* Utility for checking return values of CUDA function calls. */
30
# define cuda_device_assert(cuda_device, stmt) \
31
{ \
32
CUresult result = stmt; \
33
if (result != CUDA_SUCCESS) { \
34
const char *name = cuewErrorString(result); \
35
cuda_device->set_error( \
36
string_printf("%s in %s (%s:%d)", name, #stmt, __FILE__, __LINE__)); \
37
} \
38
} \
39
(void)0
40
41
# define cuda_assert(stmt) cuda_device_assert(this, stmt)
42
43
# ifndef WITH_CUDA_DYNLOAD
44
/* Transparently implement some functions, so majority of the file does not need
45
* to worry about difference between dynamically loaded and linked CUDA at all. */
46
const
char
*cuewErrorString(CUresult
result
);
47
const
char
*cuewCompilerPath();
48
int
cuewCompilerVersion();
49
# endif
/* WITH_CUDA_DYNLOAD */
50
51
static
inline
bool
cudaSupportsDevice(
const
int
cudaDevID)
52
{
53
int
major;
54
cuDeviceGetAttribute(&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cudaDevID);
55
if
(major >= 5) {
56
return
true
;
57
}
58
return
false
;
59
}
60
61
CCL_NAMESPACE_END
62
63
#endif
/* WITH_CUDA */
result
double result
Definition
BLI_expr_pylike_eval_test.cc:351
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
CCL_NAMESPACE_BEGIN
Definition
python.cpp:37
Generated on
for Blender by
doxygen
1.16.1