Blender  V3.3
cuda/util.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifdef WITH_CUDA
5 
6 # include "device/cuda/util.h"
8 
10 
11 CUDAContextScope::CUDAContextScope(CUDADevice *device) : device(device)
12 {
13  cuda_device_assert(device, cuCtxPushCurrent(device->cuContext));
14 }
15 
16 CUDAContextScope::~CUDAContextScope()
17 {
18  cuda_device_assert(device, cuCtxPopCurrent(NULL));
19 }
20 
21 # ifndef WITH_CUDA_DYNLOAD
22 const char *cuewErrorString(CUresult result)
23 {
24  /* We can only give error code here without major code duplication, that
25  * should be enough since dynamic loading is only being disabled by folks
26  * who knows what they're doing anyway.
27  *
28  * NOTE: Avoid call from several threads.
29  */
30  static string error;
31  error = string_printf("%d", result);
32  return error.c_str();
33 }
34 
35 const char *cuewCompilerPath()
36 {
37  return CYCLES_CUDA_NVCC_EXECUTABLE;
38 }
39 
40 int cuewCompilerVersion()
41 {
42  return (CUDA_VERSION / 100) + (CUDA_VERSION % 100 / 10);
43 }
44 # endif
45 
47 
48 #endif /* WITH_CUDA */
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
static void error(const char *str)
Definition: meshlaplacian.c:51
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
Definition: string.cpp:22