Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_Details_Random_decl.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TPETRA_DETAILS_RANDOM_DECL_HPP
11 #define TPETRA_DETAILS_RANDOM_DECL_HPP
12 
13 #include "TpetraCore_config.h"
14 #include "Kokkos_Random.hpp"
15 
16 namespace Tpetra {
17 namespace Details {
18 
19 template<class ExecutionSpace>
20 class Static_Random_XorShift64_Pool {
21 public:
22  // The resetPool function will re-initialize the pool based on the system RNG and the MPI rank.
23  // On GPU architectures, this will likely involve non-trivial host-to-device transfers.
24  static void resetPool(int mpi_rank);
25 
26  // The isSet function returns true if resetPool has been callled.
27  static bool isSet();
28  // The getPool function will return the existing pool.
29  static Kokkos::Random_XorShift64_Pool<ExecutionSpace> & getPool();
30 
31  // Do not access this directly. This is public only for deallocation purposes
32  static Kokkos::Random_XorShift64_Pool<ExecutionSpace>* pool_;
33 private:
34  static unsigned int getSeedFromRank(int mpi_rank);
35 
36 };
37 
38 
39 } // namespace Details
40 } // namespace Tpetra
41 
42 #endif // TPETRA_DETAILS_RANDOM_DECL_HPP