45#include "Kokkos_Core.hpp"
48#include "Teuchos_CommandLineProcessor.hpp"
49#include "Teuchos_StandardCatchMacros.hpp"
50#ifdef KOKKOS_ENABLE_CUDA
51#include "cuda_runtime_api.h"
54template <
typename Scalar,
typename Ordinal,
typename Device>
67 const size_t num_sockets = Kokkos::hwloc::get_available_numa_count();
68 const size_t num_cores_per_socket =
69 Kokkos::hwloc::get_available_cores_per_numa();
76 Teuchos::CommandLineProcessor
CLP;
78 "This test performance of mean-based UQ::PCE multiply routines.\n");
80 CLP.setOption(
"n", &nGrid,
"Number of mesh points in the each direction");
82 CLP.setOption(
"ni", &nIter,
"Number of multiply iterations");
84 CLP.setOption(
"order", &order,
"Polynomial order");
86 CLP.setOption(
"dmin", &dim_min,
"Starting stochastic dimension");
88 CLP.setOption(
"dmax", &dim_max,
"Stopping stochastic dimension");
89 int numa = num_sockets;
90 CLP.setOption(
"numa", &numa,
"Number of numa nodes");
91 int cores = num_cores_per_socket;
92 CLP.setOption(
"cores", &cores,
"Cores per numa node");
93#ifdef KOKKOS_ENABLE_THREADS
95 CLP.setOption(
"threads", &threads,
"Number of threads for Threads device");
97#ifdef KOKKOS_ENABLE_OPENMP
99 CLP.setOption(
"openmp", &openmp,
"Number of threads for OpenMP device");
101#ifdef KOKKOS_ENABLE_CUDA
103 CLP.setOption(
"cuda",
"no-cuda", &cuda,
"Enable Cuda device");
105 CLP.setOption(
"device", &device_id,
"CUDA device ID");
112#ifdef KOKKOS_ENABLE_THREADS
114 typedef Kokkos::Threads Device;
116 Kokkos::InitializationSettings init_args;
117 init_args.set_num_threads(threads);
118 Kokkos::initialize( init_args );
120 std::cout << std::endl
121 <<
"Threads performance with " << threads
122 <<
" threads, " << numa <<
" numas, " << cores
123 <<
" cores/numa:" << std::endl;
125 performance_test_driver<Scalar,Ordinal,Device>(
126 nGrid, nIter, order, dim_min, dim_max);
132#ifdef KOKKOS_ENABLE_OPENMP
134 typedef Kokkos::OpenMP Device;
136 Kokkos::InitializationSettings init_args;
137 init_args.set_num_threads(openmp);
138 Kokkos::initialize( init_args );
140 std::cout << std::endl
141 <<
"OpenMP performance with " << openmp
142 <<
" threads, " << numa <<
" numas, " << cores
143 <<
" cores/numa:" << std::endl;
145 performance_test_driver<Scalar,Ordinal,Device>(
146 nGrid, nIter, order, dim_min, dim_max);
152#ifdef KOKKOS_ENABLE_CUDA
154 typedef Kokkos::Cuda Device;
156 Kokkos::InitializationSettings init_args;
157 init_args.set_device_id(device_id);
158 Kokkos::initialize( init_args );
160 cudaDeviceProp deviceProp;
161 cudaGetDeviceProperties(&deviceProp, device_id);
162 std::cout << std::endl
163 <<
"CUDA performance for device " << device_id <<
" ("
164 << deviceProp.name <<
"):"
167 performance_test_driver<Scalar,Ordinal,Device>(
168 nGrid, nIter, order, dim_min, dim_max);
175 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
int main(int argc, char *argv[])
void performance_test_driver(const Ordinal nGrid, const Ordinal nIter, const Ordinal order, const Ordinal min_var, const Ordinal max_var)