Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
test
Performance
KokkosSpMM
KokkosSpMM/TestSpMM.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
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#include <iostream>
43
44
// Devices
45
#include "Kokkos_Core.hpp"
46
47
// Utilities
48
#include "Teuchos_CommandLineProcessor.hpp"
49
#include "Teuchos_StandardCatchMacros.hpp"
50
#ifdef KOKKOS_ENABLE_CUDA
51
#include "cuda_runtime_api.h"
52
#endif
53
54
template
<
typename
Scalar,
typename
Ordinal,
typename
Device>
55
void
performance_test_driver
(
const
Ordinal nGrid,
56
const
Ordinal nIter,
57
const
Ordinal ensemble_min,
58
const
Ordinal ensemble_max,
59
const
Ordinal ensemble_step );
60
61
int
main
(
int
argc,
char
*
argv
[])
62
{
63
bool
success =
true
;
64
bool
verbose =
false
;
65
try
{
66
67
#ifdef KOKKOS_ENABLE_THREADS
68
const
size_t
num_sockets = Kokkos::hwloc::get_available_numa_count();
69
const
size_t
num_cores_per_socket =
70
Kokkos::hwloc::get_available_cores_per_numa();
71
const
size_t
num_threads_per_core =
72
Kokkos::hwloc::get_available_threads_per_core();
73
#endif
74
75
// Setup command line options
76
Teuchos::CommandLineProcessor
CLP
;
77
CLP
.setDocString(
78
"This test performance of MP::Vector multiply routines.\n"
);
79
int
nGrid = 32;
80
CLP
.setOption(
"n"
, &nGrid,
"Number of mesh points in the each direction"
);
81
int
nIter = 10;
82
CLP
.setOption(
"ni"
, &nIter,
"Number of multiply iterations"
);
83
int
ensemble_min = 4;
84
CLP
.setOption(
"emin"
, &ensemble_min,
"Staring ensemble size"
);
85
int
ensemble_max = 24;
86
CLP
.setOption(
"emax"
, &ensemble_max,
"Stoping ensemble size"
);
87
int
ensemble_step = 4;
88
CLP
.setOption(
"estep"
, &ensemble_step,
"Ensemble increment"
);
89
#ifdef KOKKOS_ENABLE_THREADS
90
bool
threads =
true
;
91
CLP
.setOption(
"threads"
,
"no-threads"
, &threads,
"Enable Threads device"
);
92
int
num_cores
= num_cores_per_socket * num_sockets;
93
CLP
.setOption(
"cores"
, &
num_cores
,
94
"Number of CPU cores to use (defaults to all)"
);
95
int
num_hyper_threads
= num_threads_per_core;
96
CLP
.setOption(
"hyperthreads"
, &
num_hyper_threads
,
97
"Number of hyper threads per core to use (defaults to all)"
);
98
#endif
99
#ifdef KOKKOS_ENABLE_CUDA
100
bool
cuda =
true
;
101
CLP
.setOption(
"cuda"
,
"no-cuda"
, &cuda,
"Enable Cuda device"
);
102
int
device_id = 0;
103
CLP
.setOption(
"device"
, &device_id,
"CUDA device ID"
);
104
#endif
105
CLP
.parse( argc,
argv
);
106
107
typedef
int
Ordinal;
108
typedef
double
Scalar
;
109
110
#ifdef KOKKOS_ENABLE_THREADS
111
if
(threads) {
112
typedef
Kokkos::Threads Device;
113
114
Kokkos::InitializationSettings init_args;
115
init_args.set_num_threads(
num_cores
*
num_hyper_threads
);
116
Kokkos::initialize( init_args );
117
118
std::cout << std::endl
119
<<
"Threads performance with "
<<
num_cores
*
num_hyper_threads
120
<<
" threads:"
<< std::endl;
121
122
performance_test_driver<Scalar,Ordinal,Device>
(
123
nGrid, nIter, ensemble_min, ensemble_max, ensemble_step);
124
125
Kokkos::finalize();
126
}
127
#endif
128
129
#ifdef KOKKOS_ENABLE_CUDA
130
if
(cuda) {
131
typedef
Kokkos::Cuda Device;
132
133
Kokkos::InitializationSettings init_args;
134
init_args.set_device_id(device_id);
135
Kokkos::initialize( init_args );
136
137
cudaDeviceProp deviceProp;
138
cudaGetDeviceProperties(&deviceProp, device_id);
139
std::cout << std::endl
140
<<
"CUDA performance for device "
<< device_id <<
" ("
141
<< deviceProp.name <<
"):"
142
<< std::endl;
143
144
performance_test_driver<Scalar,Ordinal,Device>
(
145
nGrid, nIter, ensemble_min, ensemble_max, ensemble_step);
146
147
Kokkos::finalize();
148
}
149
#endif
150
151
}
152
TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
153
154
if
(success)
155
return
0;
156
return
-1;
157
}
main
int main(int argc, char *argv[])
Definition
KokkosSpMM/TestSpMM.cpp:61
performance_test_driver
void performance_test_driver(const Ordinal nGrid, const Ordinal nIter, const Ordinal ensemble_min, const Ordinal ensemble_max, const Ordinal ensemble_step)
Definition
TestSpMM.hpp:242
argv
char * argv[]
Definition
Stokhos_HouseTriDiagUnitTest.cpp:286
num_hyper_threads
size_t num_hyper_threads
Definition
Stokhos_KokkosCrsMatrixMPVectorUnitTest_OpenMP.cpp:76
num_cores
size_t num_cores
Definition
Stokhos_KokkosCrsMatrixMPVectorUnitTest_OpenMP.cpp:76
CLP
@ CLP
Definition
gram_schmidt_example3.cpp:87
Scalar
pce_type Scalar
Definition
linear2d_diffusion_scalar_types.hpp:49
Generated by
1.17.0