Compadre 1.5.5
Loading...
Searching...
No Matches
Compadre_KokkosParser.cpp
Go to the documentation of this file.
2
3using namespace Compadre;
4
5// for InitArguments, pass them directly in to Kokkos
7 this->ksg = !Kokkos::is_initialized()
8#ifdef COMPADRE_KOKKOS_GREATEREQUAL_3_7
9 && !Kokkos::is_finalized()
10#endif
11 ?
12 new Kokkos::ScopeGuard(args) : nullptr;
13 if (print_status) this->status();
14}
15
16// for command line arguments, pass them directly in to Kokkos
17KokkosParser::KokkosParser(int narg, char* args[], bool print_status) {
18 this->ksg = !Kokkos::is_initialized()
19#ifdef COMPADRE_KOKKOS_GREATEREQUAL_3_7
20 && !Kokkos::is_finalized()
21#endif
22 ?
23 new Kokkos::ScopeGuard(narg, args) : nullptr;
24 if (print_status) this->status();
25}
26
27KokkosParser::KokkosParser(std::vector<std::string> stdvec_args, bool print_status) {
28 std::vector<char*> char_args;
29 for (const auto& arg : stdvec_args) {
30 char_args.push_back((char*)arg.data());
31 }
32 char_args.push_back(nullptr);
33 int narg = (int)stdvec_args.size();
34
35 this->ksg = !Kokkos::is_initialized()
36#ifdef COMPADRE_KOKKOS_GREATEREQUAL_3_7
37 && !Kokkos::is_finalized()
38#endif
39 ?
40 new Kokkos::ScopeGuard(narg, char_args.data()) : nullptr;
41 if (print_status) this->status();
42}
43
44KokkosParser::KokkosParser(bool print_status) : KokkosParser(KokkosInitArguments(), print_status) {}
45
46std::string KokkosParser::status() {
47 std::stringstream stream;
48 Kokkos::print_configuration(stream, true);
49 std::string status = stream.str();
50 return status;
51}
Kokkos::InitArguments KokkosInitArguments
Class handling Kokkos command line arguments and returning parameters.