Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TestCuda.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 "TestStochastic.hpp"
11 
12 #include "Kokkos_Core.hpp"
13 
26 
27 namespace unit_test {
28 
29 template<typename Scalar>
30 struct performance_test_driver<Scalar,Kokkos::Cuda> {
31  static void run(bool test_flat, bool test_orig, bool test_lin,
32  bool test_block, bool symmetric) {
33  typedef Kokkos::Cuda Device;
34 
35  int nGrid;
36  int nIter;
37 
38  // All methods compared against flat-original
39  if (test_flat) {
40  nGrid = 5 ;
41  nIter = 1 ;
42  performance_test_driver_all<Scalar,Device>(
43  3 , 1 , 9 , nGrid , nIter , test_block , symmetric );
44  performance_test_driver_all<Scalar,Device>(
45  5 , 1 , 5 , nGrid , nIter , test_block , symmetric );
46  }
47 
48  // Just polynomial methods compared against original
49  if (test_orig) {
50  nGrid = 32 ;
51  nIter = 1 ;
52  performance_test_driver_poly<Scalar,Device,Stokhos::DefaultMultiply>(
53  3 , 1 , 12 , nGrid , nIter , test_block , symmetric );
54  performance_test_driver_poly<Scalar,Device,Stokhos::DefaultMultiply>(
55  5 , 1 , 6 , nGrid , nIter , test_block , symmetric );
56  }
57 
58  // Just polynomial methods compared against original
59  if (test_lin) {
60  nGrid = 32 ;
61  nIter = 10 ;
62  performance_test_driver_linear<Scalar,Device,Stokhos::DefaultMultiply>(
63  31 , 255 , 32 , nGrid , nIter , test_block , symmetric );
64  }
65 
66  }
67 
68 };
69 
70 }
71 
72 template <typename Scalar>
73 int mainCuda(bool test_flat, bool test_orig, bool test_lin, bool test_block,
74  bool symmetric, int device_id)
75 {
76  typedef unsigned long long int IntType ;
77 
78  Kokkos::InitializationSettings init_args;
79  init_args.set_device_id(device_id);
80  Kokkos::initialize( init_args );
81  Kokkos::print_configuration( std::cout );
82 
83  cudaDeviceProp deviceProp;
84  cudaGetDeviceProperties(&deviceProp, device_id);
85  std::cout << std::endl
86  << "Device " << device_id << ": " << deviceProp.name
87  << std::endl;
88 
89  cudaDeviceSetSharedMemConfig(cudaSharedMemBankSizeEightByte);
90 
91  std::cout << std::endl << "\"Cuda Performance\"" << std::endl ;
93  test_flat, test_orig, test_lin, test_block, symmetric);
94 
95  Kokkos::finalize();
96 
97  cudaDeviceReset();
98 
99  return 0 ;
100 }
101 
102 template int mainCuda<float>(bool, bool, bool, bool, bool, int);
103 template int mainCuda<double>(bool, bool, bool, bool, bool, int);
void mainCuda(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
template int mainCuda< double >(bool, bool, bool, bool, bool, int)
static void run(bool test_flat, bool test_orig, bool test_lin, bool test_block, bool symmetric)
Definition: TestCuda.cpp:31
template int mainCuda< float >(bool, bool, bool, bool, bool, int)