Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
accelerator.cpp
1 // Copyright (c) 2019-2024, Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
8 
9 #include <memory>
10 
11 #include "mfem.hpp"
12 
14 
15 namespace serac {
16 
17 namespace accelerator {
18 
19 // Restrict global to this file only
20 namespace {
21 std::unique_ptr<mfem::Device> device;
22 } // namespace
23 
25 {
26  SLIC_ERROR_ROOT_IF(device, "serac::accelerator::initializeDevice cannot be called more than once");
27  device = std::make_unique<mfem::Device>();
28 #ifdef MFEM_USE_CUDA
29  device->Configure("cuda");
30 #endif
31 }
32 
34 {
35  // Idempotent, no adverse affects if called multiple times
36  device.reset();
37 }
38 
39 } // namespace accelerator
40 
41 } // namespace serac
This file contains the interface used for initializing/terminating any hardware accelerator-related f...
This file contains the all the necessary functions and macros required for logging as well as a helpe...
void initializeDevice()
Initializes the device (GPU)
Definition: accelerator.cpp:24
void terminateDevice()
Cleans up the device, if applicable.
Definition: accelerator.cpp:33
Accelerator functionality.
Definition: serac.cpp:38