~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to lib/kokkos/core/src/impl/Kokkos_AnalyzeShape.hpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-04-29 23:44:49 UTC
  • mfrom: (5.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20150429234449-mbhy9utku6hp6oq8
Tags: 0~20150313.gitfa668e1-1
Upload into unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
//@HEADER
 
3
// ************************************************************************
 
4
// 
 
5
//   Kokkos: Manycore Performance-Portable Multidimensional Arrays
 
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  H. Carter Edwards (hcedwar@sandia.gov) 
 
39
// 
 
40
// ************************************************************************
 
41
//@HEADER
 
42
*/
 
43
 
 
44
#ifndef KOKKOS_ANALYZESHAPE_HPP
 
45
#define KOKKOS_ANALYZESHAPE_HPP
 
46
 
 
47
#include <impl/Kokkos_Shape.hpp>
 
48
 
 
49
//----------------------------------------------------------------------------
 
50
//----------------------------------------------------------------------------
 
51
 
 
52
namespace Kokkos {
 
53
namespace Impl {
 
54
 
 
55
//----------------------------------------------------------------------------
 
56
 
 
57
/** \brief  Analyze the array shape defined by a Kokkos::View data type.
 
58
 *
 
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.
 
65
 *
 
66
 *  The embedded aggregate type must have an AnalyzeShape specialization
 
67
 *  to map it down to a shape and intrinsic scalar numerical type.
 
68
 */
 
69
template< class T >
 
70
struct AnalyzeShape : public Shape< sizeof(T) , 0 >
 
71
{
 
72
  typedef void specialize ;
 
73
 
 
74
  typedef Shape< sizeof(T), 0 >  shape ;
 
75
 
 
76
  typedef       T  array_intrinsic_type ;
 
77
  typedef       T  value_type ;
 
78
  typedef       T  type ;
 
79
 
 
80
  typedef const T  const_array_intrinsic_type ;
 
81
  typedef const T  const_value_type ;
 
82
  typedef const T  const_type ;
 
83
 
 
84
  typedef       T  non_const_array_intrinsic_type ;
 
85
  typedef       T  non_const_value_type ;
 
86
  typedef       T  non_const_type ;
 
87
};
 
88
 
 
89
template<>
 
90
struct AnalyzeShape<void> : public Shape< 0 , 0 >
 
91
{
 
92
  typedef void specialize ;
 
93
 
 
94
  typedef Shape< 0 , 0 >  shape ;
 
95
 
 
96
  typedef       void  array_intrinsic_type ;
 
97
  typedef       void  value_type ;
 
98
  typedef       void  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 ;
 
105
};
 
106
 
 
107
template< class T >
 
108
struct AnalyzeShape< const T > : public AnalyzeShape<T>::shape
 
109
{
 
110
private:
 
111
  typedef AnalyzeShape<T> nested ;
 
112
public:
 
113
 
 
114
  typedef typename nested::specialize specialize ;
 
115
 
 
116
  typedef typename nested::shape shape ;
 
117
 
 
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 ;
 
121
 
 
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 ;
 
125
 
 
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 ;
 
129
};
 
130
 
 
131
template< class T >
 
132
struct AnalyzeShape< T * >
 
133
  : public ShapeInsert< typename AnalyzeShape<T>::shape , 0 >::type
 
134
{
 
135
private:
 
136
  typedef AnalyzeShape<T> nested ;
 
137
public:
 
138
 
 
139
  typedef typename nested::specialize specialize ;
 
140
 
 
141
  typedef typename ShapeInsert< typename nested::shape , 0 >::type shape ;
 
142
 
 
143
  typedef typename nested::array_intrinsic_type * array_intrinsic_type ;
 
144
  typedef typename nested::value_type             value_type ;
 
145
  typedef typename nested::type                 * type ;
 
146
 
 
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 ;
 
150
 
 
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 ;
 
154
};
 
155
 
 
156
template< class T >
 
157
struct AnalyzeShape< T[] >
 
158
  : public ShapeInsert< typename AnalyzeShape<T>::shape , 0 >::type
 
159
{
 
160
private:
 
161
  typedef AnalyzeShape<T> nested ;
 
162
public:
 
163
 
 
164
  typedef typename nested::specialize specialize ;
 
165
 
 
166
  typedef typename ShapeInsert< typename nested::shape , 0 >::type shape ;
 
167
 
 
168
  typedef typename nested::array_intrinsic_type  array_intrinsic_type [] ;
 
169
  typedef typename nested::value_type            value_type ;
 
170
  typedef typename nested::type                  type [] ;
 
171
 
 
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 [] ;
 
175
 
 
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 [] ;
 
179
};
 
180
 
 
181
template< class T >
 
182
struct AnalyzeShape< const T[] >
 
183
  : public ShapeInsert< typename AnalyzeShape< const T >::shape , 0 >::type
 
184
{
 
185
private:
 
186
  typedef AnalyzeShape< const T > nested ;
 
187
public:
 
188
 
 
189
  typedef typename nested::specialize specialize ;
 
190
 
 
191
  typedef typename ShapeInsert< typename nested::shape , 0 >::type shape ;
 
192
 
 
193
  typedef typename nested::array_intrinsic_type  array_intrinsic_type [] ;
 
194
  typedef typename nested::value_type            value_type ;
 
195
  typedef typename nested::type                  type [] ;
 
196
 
 
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 [] ;
 
200
 
 
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 [] ;
 
204
};
 
205
 
 
206
template< class T , unsigned N >
 
207
struct AnalyzeShape< T[N] >
 
208
  : public ShapeInsert< typename AnalyzeShape<T>::shape , N >::type
 
209
{
 
210
private:
 
211
  typedef AnalyzeShape<T> nested ;
 
212
public:
 
213
 
 
214
  typedef typename nested::specialize specialize ;
 
215
 
 
216
  typedef typename ShapeInsert< typename nested::shape , N >::type shape ;
 
217
 
 
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] ;
 
221
 
 
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] ;
 
225
 
 
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] ;
 
229
};
 
230
 
 
231
template< class T , unsigned N >
 
232
struct AnalyzeShape< const T[N] >
 
233
  : public ShapeInsert< typename AnalyzeShape< const T >::shape , N >::type
 
234
{
 
235
private:
 
236
  typedef AnalyzeShape< const T > nested ;
 
237
public:
 
238
 
 
239
  typedef typename nested::specialize specialize ;
 
240
 
 
241
  typedef typename ShapeInsert< typename nested::shape , N >::type shape ;
 
242
 
 
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] ;
 
246
 
 
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] ;
 
250
 
 
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] ;
 
254
};
 
255
 
 
256
} // namespace Impl
 
257
} // namespace Kokkos
 
258
 
 
259
#endif /* #ifndef KOKKOS_ANALYZESHAPE_HPP */
 
260