monolish
0.14.2
MONOlithic LIner equation Solvers for Highly-parallel architecture
src
utils
system
gpu_deivce.cpp
Go to the documentation of this file.
1
#include "../../internal/monolish_internal.hpp"
2
3
namespace
monolish
{
4
namespace
util {
5
6
int
get_num_devices
() {
7
#if MONOLISH_USE_NVIDIA_GPU
8
int
devices = 0;
9
cudaGetDeviceCount(&devices);
10
return
devices;
11
#else
12
return
-10;
13
#endif
14
}
15
16
bool
set_default_device
(
size_t
device_num) {
17
#if MONOLISH_USE_NVIDIA_GPU
18
cudaSetDevice((
int
)device_num);
19
omp_set_default_device(device_num);
20
return
true
;
21
#else
22
return
false
;
23
#endif
24
}
25
26
int
get_default_device
() {
27
#if MONOLISH_USE_NVIDIA_GPU
28
int
device = 0;
29
cudaGetDevice(&device);
30
return
device;
31
#else
32
return
-10;
33
#endif
34
}
35
36
}
// namespace util
37
}
// namespace monolish
monolish::util::set_default_device
bool set_default_device(size_t device_num)
set default device number
Definition:
gpu_deivce.cpp:16
monolish
Definition:
monolish_matrix_blas.hpp:10
monolish::util::get_default_device
int get_default_device()
get default device number
Definition:
gpu_deivce.cpp:26
monolish::util::get_num_devices
int get_num_devices()
get the number of devices
Definition:
gpu_deivce.cpp:6
Generated by
1.8.17