Compadre  1.6.0
Compadre_KokkosParser.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Compadre: COMpatible PArticle Discretization and REmap Toolkit
4 //
5 // Copyright 2018 NTESS and the Compadre contributors.
6 // SPDX-License-Identifier: BSD-2-Clause
7 // *****************************************************************************
8 // @HEADER
10 
11 using namespace Compadre;
12 
13 // for InitArguments, pass them directly in to Kokkos
15  this->ksg = !Kokkos::is_initialized()
16  && !Kokkos::is_finalized()
17  ?
18  new Kokkos::ScopeGuard(args) : nullptr;
19  if (print_status) this->status();
20 }
21 
22 // for command line arguments, pass them directly in to Kokkos
23 KokkosParser::KokkosParser(int narg, char* args[], bool print_status) {
24  this->ksg = !Kokkos::is_initialized()
25  && !Kokkos::is_finalized()
26  ?
27  new Kokkos::ScopeGuard(narg, args) : nullptr;
28  if (print_status) this->status();
29 }
30 
31 KokkosParser::KokkosParser(std::vector<std::string> stdvec_args, bool print_status) {
32  std::vector<char*> char_args;
33  for (const auto& arg : stdvec_args) {
34  char_args.push_back((char*)arg.data());
35  }
36  char_args.push_back(nullptr);
37  int narg = (int)stdvec_args.size();
38 
39  this->ksg = !Kokkos::is_initialized()
40  && !Kokkos::is_finalized()
41  ?
42  new Kokkos::ScopeGuard(narg, char_args.data()) : nullptr;
43  if (print_status) this->status();
44 }
45 
46 KokkosParser::KokkosParser(bool print_status) : KokkosParser(KokkosInitArguments(), print_status) {}
47 
48 std::string KokkosParser::status() {
49  std::stringstream stream;
50  Kokkos::print_configuration(stream, true);
51  std::string status = stream.str();
52  return status;
53 }
Kokkos::InitializationSettings KokkosInitArguments
Class handling Kokkos command line arguments and returning parameters.
static std::string status()