3
// ************************************************************************
5
// Kokkos: Manycore Performance-Portable Multidimensional Arrays
6
// Copyright (2012) Sandia Corporation
8
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9
// the U.S. Government retains certain rights in this software.
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
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.
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.
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.
38
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
40
// ************************************************************************
44
#ifndef KOKKOS_ANALYZESHAPE_HPP
45
#define KOKKOS_ANALYZESHAPE_HPP
47
#include <impl/Kokkos_Shape.hpp>
49
//----------------------------------------------------------------------------
50
//----------------------------------------------------------------------------
55
//----------------------------------------------------------------------------
57
/** \brief Analyze the array shape defined by a Kokkos::View data type.
59
* It is presumed that the data type can be mapped down to a multidimensional
60
* array of an intrinsic scalar numerical type (double, float, int, ... ).
61
* The 'value_type' of an array may be an embedded aggregate type such
62
* as a fixed length array 'Array<T,N>'.
63
* In this case the 'array_intrinsic_type' represents the
64
* underlying array of intrinsic scalar numerical type.
66
* The embedded aggregate type must have an AnalyzeShape specialization
67
* to map it down to a shape and intrinsic scalar numerical type.
70
struct AnalyzeShape : public Shape< sizeof(T) , 0 >
72
typedef void specialize ;
74
typedef Shape< sizeof(T), 0 > shape ;
76
typedef T array_intrinsic_type ;
77
typedef T value_type ;
80
typedef const T const_array_intrinsic_type ;
81
typedef const T const_value_type ;
82
typedef const T const_type ;
84
typedef T non_const_array_intrinsic_type ;
85
typedef T non_const_value_type ;
86
typedef T non_const_type ;
90
struct AnalyzeShape<void> : public Shape< 0 , 0 >
92
typedef void specialize ;
94
typedef Shape< 0 , 0 > shape ;
96
typedef void array_intrinsic_type ;
97
typedef void value_type ;
99
typedef const void const_array_intrinsic_type ;
100
typedef const void const_value_type ;
101
typedef const void const_type ;
102
typedef void non_const_array_intrinsic_type ;
103
typedef void non_const_value_type ;
104
typedef void non_const_type ;
108
struct AnalyzeShape< const T > : public AnalyzeShape<T>::shape
111
typedef AnalyzeShape<T> nested ;
114
typedef typename nested::specialize specialize ;
116
typedef typename nested::shape shape ;
118
typedef typename nested::const_array_intrinsic_type array_intrinsic_type ;
119
typedef typename nested::const_value_type value_type ;
120
typedef typename nested::const_type type ;
122
typedef typename nested::const_array_intrinsic_type const_array_intrinsic_type ;
123
typedef typename nested::const_value_type const_value_type ;
124
typedef typename nested::const_type const_type ;
126
typedef typename nested::non_const_array_intrinsic_type non_const_array_intrinsic_type ;
127
typedef typename nested::non_const_value_type non_const_value_type ;
128
typedef typename nested::non_const_type non_const_type ;
132
struct AnalyzeShape< T * >
133
: public ShapeInsert< typename AnalyzeShape<T>::shape , 0 >::type
136
typedef AnalyzeShape<T> nested ;
139
typedef typename nested::specialize specialize ;
141
typedef typename ShapeInsert< typename nested::shape , 0 >::type shape ;
143
typedef typename nested::array_intrinsic_type * array_intrinsic_type ;
144
typedef typename nested::value_type value_type ;
145
typedef typename nested::type * type ;
147
typedef typename nested::const_array_intrinsic_type * const_array_intrinsic_type ;
148
typedef typename nested::const_value_type const_value_type ;
149
typedef typename nested::const_type * const_type ;
151
typedef typename nested::non_const_array_intrinsic_type * non_const_array_intrinsic_type ;
152
typedef typename nested::non_const_value_type non_const_value_type ;
153
typedef typename nested::non_const_type * non_const_type ;
157
struct AnalyzeShape< T[] >
158
: public ShapeInsert< typename AnalyzeShape<T>::shape , 0 >::type
161
typedef AnalyzeShape<T> nested ;
164
typedef typename nested::specialize specialize ;
166
typedef typename ShapeInsert< typename nested::shape , 0 >::type shape ;
168
typedef typename nested::array_intrinsic_type array_intrinsic_type [] ;
169
typedef typename nested::value_type value_type ;
170
typedef typename nested::type type [] ;
172
typedef typename nested::const_array_intrinsic_type const_array_intrinsic_type [] ;
173
typedef typename nested::const_value_type const_value_type ;
174
typedef typename nested::const_type const_type [] ;
176
typedef typename nested::non_const_array_intrinsic_type non_const_array_intrinsic_type [] ;
177
typedef typename nested::non_const_value_type non_const_value_type ;
178
typedef typename nested::non_const_type non_const_type [] ;
182
struct AnalyzeShape< const T[] >
183
: public ShapeInsert< typename AnalyzeShape< const T >::shape , 0 >::type
186
typedef AnalyzeShape< const T > nested ;
189
typedef typename nested::specialize specialize ;
191
typedef typename ShapeInsert< typename nested::shape , 0 >::type shape ;
193
typedef typename nested::array_intrinsic_type array_intrinsic_type [] ;
194
typedef typename nested::value_type value_type ;
195
typedef typename nested::type type [] ;
197
typedef typename nested::const_array_intrinsic_type const_array_intrinsic_type [] ;
198
typedef typename nested::const_value_type const_value_type ;
199
typedef typename nested::const_type const_type [] ;
201
typedef typename nested::non_const_array_intrinsic_type non_const_array_intrinsic_type [] ;
202
typedef typename nested::non_const_value_type non_const_value_type ;
203
typedef typename nested::non_const_type non_const_type [] ;
206
template< class T , unsigned N >
207
struct AnalyzeShape< T[N] >
208
: public ShapeInsert< typename AnalyzeShape<T>::shape , N >::type
211
typedef AnalyzeShape<T> nested ;
214
typedef typename nested::specialize specialize ;
216
typedef typename ShapeInsert< typename nested::shape , N >::type shape ;
218
typedef typename nested::array_intrinsic_type array_intrinsic_type [N] ;
219
typedef typename nested::value_type value_type ;
220
typedef typename nested::type type [N] ;
222
typedef typename nested::const_array_intrinsic_type const_array_intrinsic_type [N] ;
223
typedef typename nested::const_value_type const_value_type ;
224
typedef typename nested::const_type const_type [N] ;
226
typedef typename nested::non_const_array_intrinsic_type non_const_array_intrinsic_type [N] ;
227
typedef typename nested::non_const_value_type non_const_value_type ;
228
typedef typename nested::non_const_type non_const_type [N] ;
231
template< class T , unsigned N >
232
struct AnalyzeShape< const T[N] >
233
: public ShapeInsert< typename AnalyzeShape< const T >::shape , N >::type
236
typedef AnalyzeShape< const T > nested ;
239
typedef typename nested::specialize specialize ;
241
typedef typename ShapeInsert< typename nested::shape , N >::type shape ;
243
typedef typename nested::array_intrinsic_type array_intrinsic_type [N] ;
244
typedef typename nested::value_type value_type ;
245
typedef typename nested::type type [N] ;
247
typedef typename nested::const_array_intrinsic_type const_array_intrinsic_type [N] ;
248
typedef typename nested::const_value_type const_value_type ;
249
typedef typename nested::const_type const_type [N] ;
251
typedef typename nested::non_const_array_intrinsic_type non_const_array_intrinsic_type [N] ;
252
typedef typename nested::non_const_value_type non_const_value_type ;
253
typedef typename nested::non_const_type non_const_type [N] ;
257
} // namespace Kokkos
259
#endif /* #ifndef KOKKOS_ANALYZESHAPE_HPP */