RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
Sync.hpp
Go to the documentation of this file.
1 
12 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
13 // Copyright (c) Lawrence Livermore National Security, LLC and other
14 // RAJA Project Developers. See top-level LICENSE and COPYRIGHT
15 // files for dates and other details. No copyright assignment is required
16 // to contribute to RAJA.
17 //
18 // SPDX-License-Identifier: (BSD-3-Clause)
19 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
20 
21 
22 #ifndef RAJA_policy_cuda_kernel_Sync_HPP
23 #define RAJA_policy_cuda_kernel_Sync_HPP
24 
25 #include "RAJA/config.hpp"
26 
27 #if defined(RAJA_ENABLE_CUDA)
28 
29 #include <cassert>
30 #include <climits>
31 
32 #include "camp/camp.hpp"
33 
34 #include "RAJA/pattern/kernel.hpp"
35 
36 #include "RAJA/util/macros.hpp"
37 #include "RAJA/util/types.hpp"
38 
39 namespace RAJA
40 {
41 namespace statement
42 {
43 
47 struct CudaSyncThreads : public internal::Statement<camp::nil>
48 {};
49 
53 struct CudaSyncWarp : public internal::Statement<camp::nil>
54 {};
55 
56 } // namespace statement
57 
58 namespace internal
59 {
60 
61 template<typename Data, typename Types>
62 struct CudaStatementExecutor<Data, statement::CudaSyncThreads, Types>
63 {
64 
65  static inline RAJA_DEVICE void exec(Data&, bool) { __syncthreads(); }
66 
67  static inline LaunchDims calculateDimensions(
68  Data const& RAJA_UNUSED_ARG(data))
69  {
70  return LaunchDims();
71  }
72 };
73 
74 template<typename Data, typename Types>
75 struct CudaStatementExecutor<Data, statement::CudaSyncWarp, Types>
76 {
77 
78  static inline RAJA_DEVICE
79 #if CUDART_VERSION >= 9000
80  void
81  exec(Data&, bool)
82  {
83  __syncwarp();
84  }
85 #else
86  void
87  exec(Data&, bool)
88  {
89  }
90 #endif
91 
92  static inline LaunchDims calculateDimensions(
93  Data const& RAJA_UNUSED_ARG(data))
94  {
95  return LaunchDims();
96  }
97 };
98 
99 
100 } // namespace internal
101 } // namespace RAJA
102 
103 #endif // closing endif for RAJA_ENABLE_CUDA guard
104 
105 #endif // closing endif for header file include guard
Header file for common RAJA internal macro definitions.
#define RAJA_UNUSED_ARG(x)
Definition: macros.hpp:97
#define RAJA_DEVICE
Definition: macros.hpp:66
Definition: AlignedRangeIndexSetBuilders.cpp:35
RAJA header file containing user interface for RAJA::kernel.
Header file for RAJA type definitions.