RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
Dispatcher.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_openmp_target_WorkGroup_Dispatcher_HPP
21 #define RAJA_openmp_target_WorkGroup_Dispatcher_HPP
22 
23 #include "RAJA/config.hpp"
24 
26 
28 
29 namespace RAJA
30 {
31 
32 namespace detail
33 {
34 
35 namespace omp_target
36 {
37 
38 // create the value in a target region using the factory, map the value
39 // back, and return the value created in the target region
40 template<typename Factory>
41 inline auto get_value(Factory factory)
42 {
43  typename std::decay_t<Factory>::value_type value;
44 
45 #pragma omp target map(tofrom : value) map(to : factory)
46  {
47  value = factory();
48  }
49 
50  return value;
51 }
52 
53 // get the device value and store it so it can be used
54 // multiple times
55 template<typename Factory>
56 inline auto get_cached_value(Factory&& factory)
57 {
58  static auto value = get_value(std::forward<Factory>(factory));
59  return value;
60 }
61 
62 } // namespace omp_target
63 
68 template<typename T, typename Dispatcher_T>
69 inline const Dispatcher_T* get_Dispatcher(omp_target_work const&)
70 {
71  static Dispatcher_T dispatcher {
72  Dispatcher_T::template makeDispatcher<T>([](auto&& factory) {
74  std::forward<decltype(factory)>(factory));
75  })};
76  return &dispatcher;
77 }
78 
79 } // namespace detail
80 
81 } // namespace RAJA
82 
83 #endif // closing endif for header file include guard
auto get_value(Factory factory)
Definition: Dispatcher.hpp:41
auto get_cached_value(Factory &&factory)
Definition: Dispatcher.hpp:56
const Dispatcher_T * get_Dispatcher(cuda_work_explicit< BLOCK_SIZE, BLOCKS_PER_SM, Async > const &)
Definition: Dispatcher.hpp:115
Definition: AlignedRangeIndexSetBuilders.cpp:35
Header file providing RAJA Dispatcher for workgroup.