RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
TypeConvert.hpp
Go to the documentation of this file.
1 
15 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
16 // Copyright (c) Lawrence Livermore National Security, LLC and other
17 // RAJA Project Developers. See top-level LICENSE and COPYRIGHT
18 // files for dates and other details. No copyright assignment is required
19 // to contribute to RAJA.
20 //
21 // SPDX-License-Identifier: (BSD-3-Clause)
22 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
23 
24 #ifndef RAJA_util_TypeConvert_HPP
25 #define RAJA_util_TypeConvert_HPP
26 
27 #include "RAJA/config.hpp"
28 
29 #include "RAJA/util/macros.hpp"
30 
31 #include <string.h>
32 
33 namespace RAJA
34 {
35 namespace util
36 {
37 
38 
42 template<typename A, typename B>
43 RAJA_INLINE RAJA_HOST_DEVICE constexpr B reinterp_A_as_B(A const& a)
44 {
45  static_assert(sizeof(A) == sizeof(B), "A and B must be the same size");
46 
47  B b;
48  memcpy(&b, &a, sizeof(A));
49  return b;
50 }
51 
52 
53 } // namespace util
54 } // namespace RAJA
55 
56 #endif // closing endif for header file include guard
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
RAJA_INLINE constexpr RAJA_HOST_DEVICE B reinterp_A_as_B(A const &a)
Definition: TypeConvert.hpp:43
Definition: AlignedRangeIndexSetBuilders.cpp:35