Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stokhos_KokkosArrayKernelsUnitTest_Cuda.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// Utilities
30#include "Teuchos_UnitTestHarness.hpp"
31#include "Teuchos_UnitTestRepository.hpp"
32#include "Teuchos_GlobalMPISession.hpp"
33
34// Device
35#include "Kokkos_Core.hpp"
36
37// Kernels
47
48// Tests
50
51using namespace KokkosKernelsUnitTest;
52
53UnitTestSetup<Kokkos::Cuda> setup;
54
55// Test declarations
57
58// Not all of the generic kernels work with Cuda because of the way
59// the Cuda StochasticProductTensor specialization is done
60
61using Kokkos::Cuda;
62
63// The Tiled-Crs kernel seems to fail when OpenMP is the host device
64#ifdef KOKKOS_ENABLE_OPENMP
65#define TILED_CRS_TEST(SCALAR, DEVICE)
66#else
67#define TILED_CRS_TEST(SCALAR, DEVICE) \
68TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, TiledCrsProductTensor, SCALAR, DEVICE )
69#endif
70
71#define UNIT_TEST_GROUP_SCALAR_CUDA( SCALAR ) \
72 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CrsMatrixFree, SCALAR, Cuda ) \
73 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CrsMatrixFreeView, SCALAR, Cuda ) \
74 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CrsMatrixFreeKokkos, SCALAR, Cuda ) \
75 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CrsMatrixFreeSingleCol, SCALAR, Cuda ) \
76 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CrsDenseBlock, SCALAR, Cuda ) \
77 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CrsFlatCommuted, SCALAR, Cuda ) \
78 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CrsFlatOriginal, SCALAR, Cuda ) \
79 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CrsProductTensor, SCALAR, Cuda ) \
80 TILED_CRS_TEST(SCALAR, Cuda ) \
81 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CooProductTensorPacked, SCALAR, Cuda ) \
82 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, CooProductTensorUnpacked, SCALAR, Cuda ) \
83 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, LinearTensorSymmetric, SCALAR, Cuda ) \
84 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, LinearTensorAsymmetric, SCALAR, Cuda )
85
86// Commenting this one out -- it may be generating memory errors
87// TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( Kokkos_SG_SpMv, SimpleTiledCrsProductTensor, SCALAR, Cuda )
88
90
91int main( int argc, char* argv[] ) {
92 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
93
94 // Initialize Cuda
95 Kokkos::InitializationSettings init_args;
96 init_args.set_device_id(0);
97 Kokkos::initialize( init_args );
98 Kokkos::print_configuration( std::cout );
99
100 // Setup (has to happen after initialization)
101 setup.setup();
102
103 // Run tests
104 int ret = Teuchos::UnitTestRepository::runUnitTestsFromMain(argc, argv);
105
106 // Finish up
107 Kokkos::finalize();
108
109 return ret;
110}
UnitTestSetup< Kokkos::Cuda > setup
int main(int argc, char *argv[])
#define UNIT_TEST_GROUP_SCALAR_CUDA(SCALAR)