@@ -23,8 +23,8 @@ auto convert_negative_axis(ViewType, int _axis = -1) {
2323 " convert_negative_axis: ViewType must be a Kokkos::View." );
2424 int rank = static_cast <int >(ViewType::rank ());
2525
26- KOKKOSFFT_EXPECTS (_axis >= -rank && _axis < rank,
27- " Axis must be in [-rank, rank-1]" );
26+ KOKKOSFFT_THROW_IF (_axis < -rank || _axis >= rank,
27+ " Axis must be in [-rank, rank-1]" );
2828
2929 int axis = _axis < 0 ? rank + _axis : _axis;
3030 return axis;
@@ -130,7 +130,7 @@ std::size_t get_index(ContainerType& values, const ValueType& value) {
130130 static_assert (std::is_same_v<value_type, ValueType>,
131131 " get_index: Container value type must match ValueType" );
132132 auto it = std::find (values.begin (), values.end (), value);
133- KOKKOSFFT_EXPECTS (it ! = values.end (), " value is not included in values" );
133+ KOKKOSFFT_THROW_IF (it = = values.end (), " value is not included in values" );
134134 return it - values.begin ();
135135}
136136
@@ -256,44 +256,44 @@ void create_view(ViewType& out, const Label& label,
256256
257257template <typename ViewType>
258258void reshape_view (ViewType& out, const std::array<int , 1 >& extents) {
259- KOKKOSFFT_EXPECTS (ViewType::required_allocation_size (out.layout ()) >=
260- ViewType::required_allocation_size (extents[0 ]),
261- " reshape_view: insufficient memory" );
259+ KOKKOSFFT_THROW_IF (ViewType::required_allocation_size (out.layout ()) <
260+ ViewType::required_allocation_size (extents[0 ]),
261+ " reshape_view: insufficient memory" );
262262 out = ViewType (out.data (), extents[0 ]);
263263}
264264
265265template <typename ViewType>
266266void reshape_view (ViewType& out, const std::array<int , 2 >& extents) {
267- KOKKOSFFT_EXPECTS (
268- ViewType::required_allocation_size (out.layout ()) >=
267+ KOKKOSFFT_THROW_IF (
268+ ViewType::required_allocation_size (out.layout ()) <
269269 ViewType::required_allocation_size (extents[0 ], extents[1 ]),
270270 " reshape_view: insufficient memory" );
271271 out = ViewType (out.data (), extents[0 ], extents[1 ]);
272272}
273273
274274template <typename ViewType>
275275void reshape_view (ViewType& out, const std::array<int , 3 >& extents) {
276- KOKKOSFFT_EXPECTS (ViewType::required_allocation_size (out.layout ()) >=
277- ViewType::required_allocation_size (
278- extents[0 ], extents[1 ], extents[2 ]),
279- " reshape_view: insufficient memory" );
276+ KOKKOSFFT_THROW_IF (ViewType::required_allocation_size (out.layout ()) <
277+ ViewType::required_allocation_size (
278+ extents[0 ], extents[1 ], extents[2 ]),
279+ " reshape_view: insufficient memory" );
280280 out = ViewType (out.data (), extents[0 ], extents[1 ], extents[2 ]);
281281}
282282
283283template <typename ViewType>
284284void reshape_view (ViewType& out, const std::array<int , 4 >& extents) {
285- KOKKOSFFT_EXPECTS (ViewType::required_allocation_size (out.layout ()) >=
286- ViewType::required_allocation_size (
287- extents[0 ], extents[1 ], extents[2 ], extents[3 ]),
288- " reshape_view: insufficient memory" );
285+ KOKKOSFFT_THROW_IF (ViewType::required_allocation_size (out.layout ()) <
286+ ViewType::required_allocation_size (
287+ extents[0 ], extents[1 ], extents[2 ], extents[3 ]),
288+ " reshape_view: insufficient memory" );
289289
290290 out = ViewType (out.data (), extents[0 ], extents[1 ], extents[2 ], extents[3 ]);
291291}
292292
293293template <typename ViewType>
294294void reshape_view (ViewType& out, const std::array<int , 5 >& extents) {
295- KOKKOSFFT_EXPECTS (
296- ViewType::required_allocation_size (out.layout ()) >=
295+ KOKKOSFFT_THROW_IF (
296+ ViewType::required_allocation_size (out.layout ()) <
297297 ViewType::required_allocation_size (extents[0 ], extents[1 ], extents[2 ],
298298 extents[3 ], extents[4 ]),
299299 " reshape_view: insufficient memory" );
@@ -303,33 +303,33 @@ void reshape_view(ViewType& out, const std::array<int, 5>& extents) {
303303
304304template <typename ViewType>
305305void reshape_view (ViewType& out, const std::array<int , 6 >& extents) {
306- KOKKOSFFT_EXPECTS (ViewType::required_allocation_size (out.layout ()) >=
307- ViewType::required_allocation_size (
308- extents[0 ], extents[1 ], extents[2 ], extents[3 ],
309- extents[4 ], extents[5 ]),
310- " reshape_view: insufficient memory" );
306+ KOKKOSFFT_THROW_IF (ViewType::required_allocation_size (out.layout ()) <
307+ ViewType::required_allocation_size (
308+ extents[0 ], extents[1 ], extents[2 ], extents[3 ],
309+ extents[4 ], extents[5 ]),
310+ " reshape_view: insufficient memory" );
311311 out = ViewType (out.data (), extents[0 ], extents[1 ], extents[2 ], extents[3 ],
312312 extents[4 ], extents[5 ]);
313313}
314314
315315template <typename ViewType>
316316void reshape_view (ViewType& out, const std::array<int , 7 >& extents) {
317- KOKKOSFFT_EXPECTS (ViewType::required_allocation_size (out.layout ()) >=
318- ViewType::required_allocation_size (
319- extents[0 ], extents[1 ], extents[2 ], extents[3 ],
320- extents[4 ], extents[5 ], extents[6 ]),
321- " reshape_view: insufficient memory" );
317+ KOKKOSFFT_THROW_IF (ViewType::required_allocation_size (out.layout ()) <
318+ ViewType::required_allocation_size (
319+ extents[0 ], extents[1 ], extents[2 ], extents[3 ],
320+ extents[4 ], extents[5 ], extents[6 ]),
321+ " reshape_view: insufficient memory" );
322322 out = ViewType (out.data (), extents[0 ], extents[1 ], extents[2 ], extents[3 ],
323323 extents[4 ], extents[5 ], extents[6 ]);
324324}
325325
326326template <typename ViewType>
327327void reshape_view (ViewType& out, const std::array<int , 8 >& extents) {
328- KOKKOSFFT_EXPECTS (ViewType::required_allocation_size (out.layout ()) >=
329- ViewType::required_allocation_size (
330- extents[0 ], extents[1 ], extents[2 ], extents[3 ],
331- extents[4 ], extents[5 ], extents[6 ], extents[7 ]),
332- " reshape_view: insufficient memory" );
328+ KOKKOSFFT_THROW_IF (ViewType::required_allocation_size (out.layout ()) <
329+ ViewType::required_allocation_size (
330+ extents[0 ], extents[1 ], extents[2 ], extents[3 ],
331+ extents[4 ], extents[5 ], extents[6 ], extents[7 ]),
332+ " reshape_view: insufficient memory" );
333333 out = ViewType (out.data (), extents[0 ], extents[1 ], extents[2 ], extents[3 ],
334334 extents[4 ], extents[5 ], extents[6 ], extents[7 ]);
335335}
0 commit comments