35 #ifndef SCHWARZ_DEVICE_GUARD_HPP_ 36 #define SCHWARZ_DEVICE_GUARD_HPP_ 41 #include <schwarz/config.hpp> 44 #include <cuda_runtime.h> 48 #include <exception_helpers.hpp> 69 SCHWARZ_ASSERT_NO_CUDA_ERRORS(cudaGetDevice(&original_device_id));
70 SCHWARZ_ASSERT_NO_CUDA_ERRORS(cudaSetDevice(device_id));
85 if (std::uncaught_exception()) {
87 cudaSetDevice(original_device_id);
91 SCHWARZ_ASSERT_NO_CUDA_ERRORS(cudaSetDevice(original_device_id));
97 int original_device_id{};
104 #endif // SCHWARZ_DEVICE_GUARD_HPP_ This class defines a device guard for the cuda functions and the cuda module.
Definition: device_guard.hpp:64
The Schwarz wrappers namespace.
Definition: comm_helpers.hpp:49