Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TestHost.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include <iostream>
11 
12 #include "Kokkos_Core.hpp"
13 
14 #ifdef KOKKOS_ENABLE_THREADS
16 #endif
17 #ifdef KOKKOS_ENABLE_OPENMP
19 #endif
20 
21 #include "TestStochastic.hpp"
22 
23 namespace unit_test {
24 
25 template<typename Scalar, typename Device>
27 
28  static void run(bool test_flat, bool test_orig, bool test_deg, bool test_lin,
29  bool test_block, bool symmetric, bool mkl) {
30 
31  int nGrid;
32  int nIter;
33 
34  // All methods compared against flat-original
35  if (test_flat) {
36  nGrid = 12 ;
37  nIter = 1 ;
38  performance_test_driver_all<Scalar,Device>(
39  3 , 1 , 9 , nGrid , nIter , test_block , symmetric );
40  performance_test_driver_all<Scalar,Device>(
41  5 , 1 , 5 , nGrid , nIter , test_block , symmetric );
42  }
43 
44  // Just polynomial methods compared against original
45  if (test_orig) {
46 #ifdef __MIC__
47  nGrid = 32 ;
48 #else
49  nGrid = 32 ;
50 #endif
51  nIter = 1 ;
52  // Something funny happens when we go to larger problem sizes on the
53  // MIC where it appears to slow down subsequent calculations (i.e.,
54  // the degree 5 cases will run slower). Maybe it is getting too hot?
55 #ifdef __MIC__
56  performance_test_driver_poly<Scalar,Device,Stokhos::DefaultMultiply>(
57  3 , 1 , 9 , nGrid , nIter , test_block , symmetric );
58 #else
59  performance_test_driver_poly<Scalar,Device,Stokhos::DefaultMultiply>(
60  3 , 1 , 12 , nGrid , nIter , test_block , symmetric );
61 #endif
62  performance_test_driver_poly<Scalar,Device,Stokhos::DefaultMultiply>(
63  5 , 1, 6 , nGrid , nIter , test_block , symmetric );
64  }
65 
66  // Just polynomial methods compared against original
67  if (test_deg) {
68  #ifdef __MIC__
69  nGrid = 32 ;
70 #else
71  nGrid = 64 ;
72 #endif
73  nIter = 1 ;
74  performance_test_driver_poly_deg<Scalar,Device,Stokhos::DefaultMultiply>(
75  3 , 1 , 12 , nGrid , nIter , test_block , symmetric );
76  }
77 
78  // Just polynomial methods compared against original
79  if (test_lin) {
80 #ifdef __MIC__
81  nGrid = 32 ;
82 #else
83  nGrid = 64 ;
84 #endif
85  nIter = 10 ;
86  performance_test_driver_linear<Scalar,Device,Stokhos::DefaultMultiply>(
87  31 , 255 , 32 , nGrid , nIter , test_block , symmetric );
88  }
89 
90  //------------------------------
91  }
92 
93 };
94 
95 }
96 
97 template <typename Scalar, typename Device>
98 int mainHost(bool test_flat, bool test_orig, bool test_deg, bool test_lin,
99  bool test_block, bool symmetric, bool mkl)
100 {
101  const size_t team_count =
102  Kokkos::hwloc::get_available_numa_count() *
103  Kokkos::hwloc::get_available_cores_per_numa();
104  const size_t threads_per_team =
105  Kokkos::hwloc::get_available_threads_per_core();
106 
107  Kokkos::InitializationSettings init_args;
108  init_args.set_num_threads(team_count*threads_per_team);
109  Kokkos::initialize( init_args );
110 
111  std::string name = "Host";
112 #ifdef KOKKOS_ENABLE_THREADS
113  Kokkos::Threads().print_configuration( std::cout );
114  if (std::is_same<Device,Kokkos::Threads>::value)
115  name = "Threads";
116 #endif
117 #ifdef KOKKOS_ENABLE_OPENMP
118  Kokkos::OpenMP().print_configuration( std::cout );
119  if (std::is_same<Device,Kokkos::OpenMP>::value)
120  name = "OpenMP";
121 #endif
122  std::cout << std::endl << "\"" << name << " Performance with "
123  << team_count * threads_per_team << " threads\"" << std::endl ;
124 
126  test_flat, test_orig, test_deg, test_lin, test_block, symmetric, mkl);
127 
128  Kokkos::finalize();
129 
130  return 0 ;
131 }
132 
133 #ifdef KOKKOS_ENABLE_SERIAL
134 template int mainHost<float,Kokkos::Serial>(bool, bool, bool, bool, bool, bool, bool);
135 template int mainHost<double,Kokkos::Serial>(bool, bool, bool, bool, bool, bool, bool);
136 #endif
137 
138 #ifdef KOKKOS_ENABLE_THREADS
139 template int mainHost<float,Kokkos::Threads>(bool, bool, bool, bool, bool, bool, bool);
140 template int mainHost<double,Kokkos::Threads>(bool, bool, bool, bool, bool, bool, bool);
141 #endif
142 
143 #ifdef KOKKOS_ENABLE_OPENMP
144 template int mainHost<float,Kokkos::OpenMP>(bool, bool, bool, bool, bool, bool, bool);
145 template int mainHost<double,Kokkos::OpenMP>(bool, bool, bool, bool, bool, bool, bool);
146 #endif
void mainHost(const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const int use_print, const int use_trials, const int use_nodes[], const bool check, Kokkos::Example::FENL::DeviceConfig dev_config)
static void run(bool test_flat, bool test_orig, bool test_deg, bool test_lin, bool test_block, bool symmetric, bool mkl)
Definition: TestHost.cpp:28