Debian Codegraph @

src/atlas/array/gridtools/GridToolsTraits.h

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #pragma once
12
13 #include <type_traits>
14 #include <utility>
15
16 #include "gridtools/common/generic_metafunctions/accumulate.hpp"
17 #include "gridtools/storage/storage_facility.hpp"
18
19 #include "atlas/array/ArrayViewDefs.h"
20 #include "atlas/library/config.h"
21
22 //------------------------------------------------------------------------------
23
24 namespace atlas {
25 namespace array {
26 namespace gridtools {
27
28 //------------------------------------------------------------------------------
29
30 #if ATLAS_GRIDTOOLS_STORAGE_BACKEND_CUDA
31 using backend_t = ::gridtools::backend::cuda;
32 using storage_traits = ::gridtools::storage_traits<backend_t>;
33 #elif ATLAS_GRIDTOOLS_STORAGE_BACKEND_HOST
34 using backend_t = ::gridtools::backend::x86;
35 using storage_traits = ::gridtools::storage_traits<backend_t>;
36 #else
37 #error ATLAS_GRIDTOOLS_STORAGE_BACKEND_<HOST,CUDA> not set
38 #endif
39
40 //------------------------------------------------------------------------------
41
42 template <typename Value, unsigned int Rank, ::gridtools::access_mode AccessMode = ::gridtools::access_mode::read_write>
43 using data_view_tt =
44 ::gridtools::data_view<gridtools::storage_traits::data_store_t<typename std::remove_const<Value>::type,
45 gridtools::storage_traits::storage_info_t<0, Rank>>,
46 AccessMode>;
47
48 template <typename Value, typename std::enable_if<std::is_const<Value>::value, Value>::type* = nullptr>
49 inline constexpr ::gridtools::access_mode get_access_mode() {
50 return ::gridtools::access_mode::read_only;
51 }
52 template <typename Value, typename std::enable_if<!std::is_const<Value>::value, Value>::type* = nullptr>
53 inline constexpr ::gridtools::access_mode get_access_mode() {
54 return ::gridtools::access_mode::read_write;
55 }
56
57 //------------------------------------------------------------------------------
58
59 } // namespace gridtools
60 } // namespace array
61 } // namespace atlas