Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InputTraitsGood.cpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Zoltan2: A package of combinatorial algorithms for scientific computing
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Karen Devine (kddevin@sandia.gov)
39 // Erik Boman (egboman@sandia.gov)
40 // Siva Rajamanickam (srajama@sandia.gov)
41 //
42 // ***********************************************************************
43 //
44 // @HEADER
45 //
46 // Test for Zoltan2::InputTraitsGood
47 
48 #include <Zoltan2_InputTraits.hpp>
49 
51 
52 #define BEGIN_CHECK if( InputTraits<
53 #define END_CHECK >::name() == "unused string" ) \
54  { std::cout << "Unused - Just make sure it compiles." << std::endl; }
55 
56 int main(int argc, char *argv[])
57 {
58  // scalar ordinal (first slot) must be float, double, or int
59  // this validates they all work
64 
65  // local ordinal (second slot) must always be signed
66  // this validates they all work
73 
74  // global ordinal (third slot) must be int, long, long long, ssize_t,
75  // unsigned int, unsigned long, unsigned long long, size_t
88 
89  // we also want to make sure that user typedefs will work just fine
90  // lots of redundancy here to make sure std::is_same is working as we think
91  typedef signed int user_int_t;
92  typedef unsigned int user_unsigned_int_t;
93  typedef float user_float_t;
94  typedef double user_double_t;
95  typedef int32_t user_int32_t;
96  typedef uint32_t user_uint32_t;
97  typedef int64_t user_int64_t;
98  typedef uint64_t user_uint64_t;
99  typedef signed long user_long_t;
100  typedef signed long long user_long_long_t;
101  typedef unsigned long user_unsigned_long_t;
102  typedef unsigned long long user_unsigned_long_long_t;
103  typedef size_t user_size_t;
104  typedef ssize_t user_ssize_t;
105 
106  // scalar ordinal (first slot) must be float, double, or int
111 
112  // local ordinal (second slot) must always be signed
119 
120  // global ordinal (third slot) must be int, long, long long, ssize_t,
121  // unsigned int, unsigned long, unsigned long long, size_t
134 
135  // this section takes each specific type and validates a few combinations
136  // note that some types may pass only two template parameters, not three,
137  // so it can be scalar + local + global or it can be just local + global.
138 
139  // validate Zoltan2::BasicUserTypes
145 
146  // validate Xpetra::CrsMatrix
147  BEGIN_CHECK Xpetra::CrsMatrix<double, signed int, long long> END_CHECK
148  BEGIN_CHECK Xpetra::CrsMatrix<double, int, long long> END_CHECK
149  BEGIN_CHECK Xpetra::CrsMatrix<float, signed long, unsigned int> END_CHECK
150  BEGIN_CHECK Xpetra::CrsMatrix<float, signed long long, long> END_CHECK
151  BEGIN_CHECK Xpetra::CrsMatrix<double, ssize_t, unsigned int> END_CHECK
152 
153  // validate Tpetra::CrsMatrix
154  BEGIN_CHECK Tpetra::CrsMatrix<double, signed int, long long> END_CHECK
155  BEGIN_CHECK Tpetra::CrsMatrix<double, int, long long> END_CHECK
156  BEGIN_CHECK Tpetra::CrsMatrix<float, signed long, unsigned int> END_CHECK
157  BEGIN_CHECK Tpetra::CrsMatrix<float, signed long long, long> END_CHECK
158  BEGIN_CHECK Tpetra::CrsMatrix<double, ssize_t, unsigned int> END_CHECK
159 
160  // validate Xpetra::RowMatrix
161  BEGIN_CHECK Xpetra::RowMatrix<double, signed int, long long> END_CHECK
162  BEGIN_CHECK Xpetra::RowMatrix<double, int, long long> END_CHECK
163  BEGIN_CHECK Xpetra::RowMatrix<float, signed long, unsigned int> END_CHECK
164  BEGIN_CHECK Xpetra::RowMatrix<float, signed long long, long> END_CHECK
165  BEGIN_CHECK Xpetra::RowMatrix<double, ssize_t, unsigned int> END_CHECK
166 
167  // validate Tpetra::RowMatrix
168  BEGIN_CHECK Tpetra::RowMatrix<double, signed int, long long> END_CHECK
169  BEGIN_CHECK Tpetra::RowMatrix<double, int, long long> END_CHECK
170  BEGIN_CHECK Tpetra::RowMatrix<float, signed long, unsigned int> END_CHECK
171  BEGIN_CHECK Tpetra::RowMatrix<float, signed long long, long> END_CHECK
172  BEGIN_CHECK Tpetra::RowMatrix<double, ssize_t, unsigned int> END_CHECK
173 
174  // validate Xpetra::Vector
175  BEGIN_CHECK Xpetra::Vector<double, signed int, long long> END_CHECK
176  BEGIN_CHECK Xpetra::Vector<double, int, long long> END_CHECK
177  BEGIN_CHECK Xpetra::Vector<float, signed long, unsigned int> END_CHECK
178  BEGIN_CHECK Xpetra::Vector<float, signed long long, long> END_CHECK
179  BEGIN_CHECK Xpetra::Vector<double, ssize_t, unsigned int> END_CHECK
180 
181  // validate Tpetra::RowMatrix
182  BEGIN_CHECK Tpetra::RowMatrix<double, signed int, long long> END_CHECK
183  BEGIN_CHECK Tpetra::RowMatrix<double, int, long long> END_CHECK
184  BEGIN_CHECK Tpetra::RowMatrix<float, signed long, unsigned int> END_CHECK
185  BEGIN_CHECK Tpetra::RowMatrix<float, signed long long, long> END_CHECK
186  BEGIN_CHECK Tpetra::RowMatrix<double, ssize_t, unsigned int> END_CHECK
187 
188  // validate Xpetra::MultiVector
189  BEGIN_CHECK Xpetra::MultiVector<double, signed int, long long> END_CHECK
190  BEGIN_CHECK Xpetra::MultiVector<double, int, long long> END_CHECK
191  BEGIN_CHECK Xpetra::MultiVector<float, signed long, unsigned int> END_CHECK
192  BEGIN_CHECK Xpetra::MultiVector<float, signed long long, long> END_CHECK
193  BEGIN_CHECK Xpetra::MultiVector<double, ssize_t, unsigned int> END_CHECK
194 
195  // validate Tpetra::MultiVector
196  BEGIN_CHECK Tpetra::MultiVector<double, signed int, long long> END_CHECK
197  BEGIN_CHECK Tpetra::MultiVector<double, int, long long> END_CHECK
198  BEGIN_CHECK Tpetra::MultiVector<float, signed long, unsigned int> END_CHECK
199  BEGIN_CHECK Tpetra::MultiVector<float, signed long long, long> END_CHECK
200  BEGIN_CHECK Tpetra::MultiVector<double, ssize_t, unsigned int> END_CHECK
201 
202  // validate Xpetra::CrsGraph
203  BEGIN_CHECK Xpetra::CrsGraph<signed int, long long> END_CHECK
204  BEGIN_CHECK Xpetra::CrsGraph<int, long long> END_CHECK
205  BEGIN_CHECK Xpetra::CrsGraph<signed long, unsigned int> END_CHECK
206  BEGIN_CHECK Xpetra::CrsGraph<signed long long, long> END_CHECK
207  BEGIN_CHECK Xpetra::CrsGraph<ssize_t, unsigned int> END_CHECK
208 
209  // validate Tpetra::CrsGraph
210  BEGIN_CHECK Tpetra::CrsGraph<signed int, long long> END_CHECK
211  BEGIN_CHECK Tpetra::CrsGraph<int, long long> END_CHECK
212  BEGIN_CHECK Tpetra::CrsGraph<signed long, unsigned int> END_CHECK
213  BEGIN_CHECK Tpetra::CrsGraph<signed long long, long> END_CHECK
214  BEGIN_CHECK Tpetra::CrsGraph<ssize_t, unsigned int> END_CHECK
215 
216  // set the PASS keyword
217  std::cout << "Validated InputTraits - The test PASSED "
218  "because it compiled" << std::endl;
219  return 0;
220 }
221 
int main(int narg, char *arg[])
A simple class that can be the User template argument for an InputAdapter.
#define BEGIN_CHECK
#define END_CHECK
The traits required of User input classes or structures.
Traits for application input objects.