RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
TensorNegate.hpp
Go to the documentation of this file.
1 
11 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
12 // Copyright (c) Lawrence Livermore National Security, LLC and other
13 // RAJA Project Developers. See top-level LICENSE and COPYRIGHT
14 // files for dates and other details. No copyright assignment is required
15 // to contribute to RAJA.
16 //
17 // SPDX-License-Identifier: (BSD-3-Clause)
18 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
19 
20 #ifndef RAJA_pattern_tensor_ET_TensorNegate_HPP
21 #define RAJA_pattern_tensor_ET_TensorNegate_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 #include "RAJA/util/macros.hpp"
26 
28 
29 namespace RAJA
30 {
31 namespace internal
32 {
33 namespace expt
34 {
35 
36 
37 namespace ET
38 {
39 
40 template<typename ET_TYPE>
41 class TensorNegate : public TensorExpressionBase<TensorNegate<ET_TYPE>>
42 {
43 public:
45  using rhs_type = ET_TYPE;
46  using tensor_type = typename ET_TYPE::result_type;
47  using element_type = typename tensor_type::element_type;
48  using index_type = typename ET_TYPE::index_type;
49 
51  using tile_type = typename ET_TYPE::tile_type;
52  static constexpr camp::idx_t s_num_dims = ET_TYPE::s_num_dims;
53 
54  RAJA_INLINE
55 
57  TensorNegate(rhs_type const& tensor) : m_tensor {tensor} {}
58 
59  RAJA_INLINE
60 
62  constexpr index_type getDimSize(index_type dim) const
63  {
64  return m_tensor.getDimSize(dim);
65  }
66 
67  template<typename TILE_TYPE>
68  RAJA_INLINE RAJA_HOST_DEVICE result_type eval(TILE_TYPE const& tile) const
69  {
70  return m_tensor.eval(tile).scale(-1);
71  }
72 
73  RAJA_INLINE
74 
76  void print_ast() const
77  {
78  printf("Negate(");
79  m_tensor.print_ast();
80  printf(")");
81  }
82 
83 private:
84  rhs_type m_tensor;
85 };
86 
87 
88 } // namespace ET
89 
90 } // namespace expt
91 } // namespace internal
92 
93 } // namespace RAJA
94 
95 
96 #endif
RAJA header file defining SIMD/SIMT register operations.
Definition: ExpressionTemplateBase.hpp:72
Definition: TensorNegate.hpp:42
typename ET_TYPE::index_type index_type
Definition: TensorNegate.hpp:48
RAJA_INLINE RAJA_HOST_DEVICE void print_ast() const
Definition: TensorNegate.hpp:76
RAJA_INLINE RAJA_HOST_DEVICE result_type eval(TILE_TYPE const &tile) const
Definition: TensorNegate.hpp:68
typename tensor_type::element_type element_type
Definition: TensorNegate.hpp:47
tensor_type result_type
Definition: TensorNegate.hpp:50
ET_TYPE rhs_type
Definition: TensorNegate.hpp:45
RAJA_INLINE RAJA_HOST_DEVICE TensorNegate(rhs_type const &tensor)
Definition: TensorNegate.hpp:57
static constexpr camp::idx_t s_num_dims
Definition: TensorNegate.hpp:52
typename ET_TYPE::result_type tensor_type
Definition: TensorNegate.hpp:46
RAJA_INLINE constexpr RAJA_HOST_DEVICE index_type getDimSize(index_type dim) const
Definition: TensorNegate.hpp:62
typename ET_TYPE::tile_type tile_type
Definition: TensorNegate.hpp:51
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
Definition: AlignedRangeIndexSetBuilders.cpp:35
RAJA_HOST_DEVICE RAJA_INLINE void tile(CONTEXT const &ctx, TILE_T tile_size, SEGMENT const &segment, BODY const &body)
Definition: launch_core.hpp:589