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 //
4 // Stokhos Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
25 //
26 // ***********************************************************************
27 // @HEADER
28 
29 #include "TestStochastic.hpp"
30 
31 #include "Kokkos_Core.hpp"
32 
45 
46 namespace unit_test {
47 
48 template<typename Scalar>
49 struct performance_test_driver<Scalar,Kokkos::Cuda> {
50  static void run(bool test_flat, bool test_orig, bool test_lin,
51  bool test_block, bool symmetric) {
52  typedef Kokkos::Cuda Device;
53 
54  int nGrid;
55  int nIter;
56 
57  // All methods compared against flat-original
58  if (test_flat) {
59  nGrid = 5 ;
60  nIter = 1 ;
61  performance_test_driver_all<Scalar,Device>(
62  3 , 1 , 9 , nGrid , nIter , test_block , symmetric );
63  performance_test_driver_all<Scalar,Device>(
64  5 , 1 , 5 , nGrid , nIter , test_block , symmetric );
65  }
66 
67  // Just polynomial methods compared against original
68  if (test_orig) {
69  nGrid = 32 ;
70  nIter = 1 ;
71  performance_test_driver_poly<Scalar,Device,Stokhos::DefaultMultiply>(
72  3 , 1 , 12 , nGrid , nIter , test_block , symmetric );
73  performance_test_driver_poly<Scalar,Device,Stokhos::DefaultMultiply>(
74  5 , 1 , 6 , nGrid , nIter , test_block , symmetric );
75  }
76 
77  // Just polynomial methods compared against original
78  if (test_lin) {
79  nGrid = 32 ;
80  nIter = 10 ;
81  performance_test_driver_linear<Scalar,Device,Stokhos::DefaultMultiply>(
82  31 , 255 , 32 , nGrid , nIter , test_block , symmetric );
83  }
84 
85  }
86 
87 };
88 
89 }
90 
91 template <typename Scalar>
92 int mainCuda(bool test_flat, bool test_orig, bool test_lin, bool test_block,
93  bool symmetric, int device_id)
94 {
95  typedef unsigned long long int IntType ;
96 
97  Kokkos::InitArguments init_args;
98  init_args.device_id = device_id;
99  Kokkos::initialize( init_args );
100  Kokkos::print_configuration( std::cout );
101 
102  cudaDeviceProp deviceProp;
103  cudaGetDeviceProperties(&deviceProp, device_id);
104  std::cout << std::endl
105  << "Device " << device_id << ": " << deviceProp.name
106  << std::endl;
107 
108  cudaDeviceSetSharedMemConfig(cudaSharedMemBankSizeEightByte);
109 
110  std::cout << std::endl << "\"Cuda Performance\"" << std::endl ;
112  test_flat, test_orig, test_lin, test_block, symmetric);
113 
114  Kokkos::finalize();
115 
116  cudaDeviceReset();
117 
118  return 0 ;
119 }
120 
121 template int mainCuda<float>(bool, bool, bool, bool, bool, int);
122 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:60
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:50
template int mainCuda< float >(bool, bool, bool, bool, bool, int)