Alsvinn  0.5.3
The fast FVM simulator with UQ support
get_current_gpu_id.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "alsutils/config.hpp"
3 #ifdef ALSVINN_HAVE_CUDA
4  #include <cuda.h>
5  #include <cuda_runtime.h>
7 
8 #endif
9 namespace alsutils {
10 namespace cuda {
12 inline int getCurrentGPUId() {
13  int deviceID = -1;
14 #ifdef ALSVINN_HAVE_CUDA
15  CUDA_SAFE_CALL(cudaGetDevice(&deviceID));
16 #endif
17 
18  return deviceID;
19 }
20 }
21 }
#define CUDA_SAFE_CALL(x)
Executes the given code and checks for cuda error.
Definition: cuda_safe_call.hpp:20
int getCurrentGPUId()
Returns the current active GPU id, or -1 if cuda is disabled.
Definition: get_current_gpu_id.hpp:12
Various utilities for mpi and cuda.
Definition: Factory.hpp:3