Compadre  1.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Compadre_KokkosParser.hpp
Go to the documentation of this file.
1 #ifndef _COMPADRE_KOKKOSPARSER_HPP_
2 #define _COMPADRE_KOKKOSPARSER_HPP_
3 
4 #include "Compadre_Config.h"
5 #include "Compadre_Typedefs.hpp"
6 
7 namespace Compadre {
8 
9 /*! \class KokkosParser
10  \brief Class handling Kokkos command line arguments and returning parameters.
11 */
12 class KokkosParser {
13 
14 private:
15 
17  int _numa;
18  int _device;
19  int _ngpu;
20 
22 
23  // prevent default constructor
24  KokkosParser();
25 
26 public:
27 
28  // call with command line arguments
29  KokkosParser(int argc, char* args[], bool print_status = false);
30 
31  // call with integer arguments
32  KokkosParser(int num_threads = -1, int numa = -1, int device = -1, int ngpu = -1, bool print_status = false);
33 
34  // destructor
36  // clean-up Kokkos
37  if (_called_initialize) {
38  this->finalize();
39  }
40  };
41 
42  // initialize Kokkos if not already initialized using
43  // arguments provided at object construction
44  int initialize();
45 
46  // finalize Kokkos if this object initialized it
47  // or if hard_finalize is true
48  int finalize(bool hard_finalize = false);
49 
50  // retrieve arguments from a previous initialized Kokkos state
52 
53  // use this object's state to create a Kokkos object used
54  // later for initialization
55  Kokkos::InitArguments createInitArguments() const;
56 
57  int getNumberOfThreads() const { return _num_threads; }
58  int getNuma() const { return _numa; }
59  int getDeviceID() const { return _device; }
60  int getNumberOfGPUs() const { return _ngpu; }
61 
62  // prints status
63  void status() const;
64 
65  // prohibit using the assignment constructor
66  KokkosParser& operator=( const KokkosParser& ) = delete;
67  //KokkosParser( const KokkosParser& ) = delete;
68 
69 };
70 
71 } // Compadre
72 
73 #endif
Class handling Kokkos command line arguments and returning parameters.
Kokkos::InitArguments createInitArguments() const
KokkosParser & operator=(const KokkosParser &)=delete
void retrievePreviouslyInstantiatedKokkosInitArguments()
int finalize(bool hard_finalize=false)