RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
forall.hpp
Go to the documentation of this file.
1 
16 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
17 // Copyright (c) Lawrence Livermore National Security, LLC and other
18 // RAJA Project Developers. See top-level LICENSE and COPYRIGHT
19 // files for dates and other details. No copyright assignment is required
20 // to contribute to RAJA.
21 //
22 // SPDX-License-Identifier: (BSD-3-Clause)
23 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
24 
25 #ifndef RAJA_forall_sequential_HPP
26 #define RAJA_forall_sequential_HPP
27 
28 #include "RAJA/config.hpp"
29 
30 #include "RAJA/util/types.hpp"
31 
33 
35 
36 #include "RAJA/util/resource.hpp"
37 
39 
40 namespace RAJA
41 {
42 namespace policy
43 {
44 namespace sequential
45 {
46 
47 
48 //
50 //
51 // The following function templates iterate over index set segments
52 // sequentially. Segment execution is defined by segment
53 // execution policy template parameter.
54 //
56 //
57 
58 template<typename Iterable, typename Func, typename ForallParam>
59 RAJA_INLINE concepts::enable_if_t<
60  resources::EventProxy<resources::Host>,
62 forall_impl(resources::Host host_res,
63  const seq_exec& pol,
64  Iterable&& iter,
65  Func&& body,
66  ForallParam f_params)
67 {
68  constexpr bool has_reducers =
71 
73 
74  for (decltype(distance_it) i = 0; i < distance_it; ++i)
75  {
76  if constexpr (has_reducers)
77  {
78  expt::invoke_body(f_params, body, *(begin_it + i));
79  }
80  else
81  {
82  body(*(begin_it + i));
83  }
84  }
85 
86 
88 
89  return resources::EventProxy<resources::Host>(host_res);
90 }
91 
92 } // namespace sequential
93 
94 } // namespace policy
95 
96 } // namespace RAJA
97 
98 #endif // closing endif for header file include guard
value_type::device_call &[i_loop] iter
Definition: WorkRunner.hpp:216
constexpr RAJA_HOST_DEVICE auto invoke_body(Params &&params, Fn &&f, Ts &&... extra)
Definition: forall.hpp:598
RAJA_INLINE concepts::enable_if_t< resources::EventProxy< resources::Host >, expt::type_traits::is_ForallParamPack< ForallParam > > forall_impl(resources::Host host_res, const seq_exec &pol, Iterable &&iter, Func &&body, ForallParam f_params)
Definition: forall.hpp:62
Definition: AlignedRangeIndexSetBuilders.cpp:35
auto & body
Definition: launch.hpp:177
Internal header for RAJA forall "BED" macros (i.e., loop bounds 'BED' --> begin, end,...
#define RAJA_EXTRACT_BED_IT(CONTAINER)
Definition: forall.hpp:32
Header file for RAJA resource definitions.
Header file containing RAJA sequential policy definitions.
static constexpr void parampack_resolve(EXEC_POL const &pol, ForallParamPack< Params... > &f_params, Args &&... args)
Definition: forall.hpp:304
static constexpr void parampack_init(EXEC_POL const &pol, ForallParamPack< Params... > &f_params, Args &&... args)
Definition: forall.hpp:269
Definition: TypeTraits.hpp:59
Definition: policy.hpp:78
Header file for RAJA type definitions.