A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://kokkos.github.io/kokkos-core-wiki/API/algorithms/std-algorithms/all/StdForEach.html below:

for_each - Kokkos documentation

Toggle table of contents sidebar

for_each

Header File: Kokkos_StdAlgorithms.hpp

namespace Kokkos{
namespace Experimental{

template <class ExecutionSpace, class InputIterator, class UnaryFunctorType>
void for_each(const ExecutionSpace& exespace,                            (1)
              InputIterator first, InputIterator last,
              UnaryFunctorType functor);

template <class ExecutionSpace, class InputIterator, class UnaryFunctorType>
void for_each(const std::string& label, const ExecutionSpace& exespace,  (2)
              InputIterator first, InputIterator last,
              UnaryFunctorType functor);

template <class ExecutionSpace, class DataType, class... Properties, class UnaryFunctorType>
void for_each(const ExecutionSpace& exespace,
              const Kokkos::View<DataType, Properties...>& view,                      (3)
              UnaryFunctorType functor);

template <class ExecutionSpace, class DataType, class... Properties, class PredicateType>
void for_each(const std::string& label, const ExecutionSpace& exespace,
              const Kokkos::View<DataType, Properties...>& view,                      (4)
              UnaryFunctorType func);

} //end namespace Experimental
} //end namespace Kokkos
Description

Applies the UnaryFunctorType func to the result of dereferencing each iterator in [first,last) for (1,2) and to the view elements in (3,4).

Parameters and Requirements Return

(nothing)

Example
namespace KE = Kokkos::Experimental;

template<class ValueType>
struct IncrementValsFunctor
{
  const ValueType m_value;
  IncrementValsFunctor(ValueType value) : m_value(value){}

  KOKKOS_INLINE_FUNCTION
  void operator()(const ValueType & operand) const {
    operand += m_value;
  }
};

auto exespace = Kokkos::DefaultExecutionSpace;
using view_type = Kokkos::View<exespace, int*>;
view_type a("a", 15);
// fill "a" somehow

// create functor
IncrementValsFunctor<int> p(5);

// Increment each element in "a" by 5.
KE::for_each(exespace, KE::begin(a), KE::end(a), p);

// assuming OpenMP is enabled, then you can also explicitly call
KE::for_each(Kokkos::OpenMP(), KE::begin(a), KE::end(a), p);

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4