generate#

Header: <Kokkos_StdAlgorithms.hpp>

Description#

Assigns the value generated by the functor g to each elements in the range [first, last) (overloads 1,2,5) or in the view (overloads 3,4,6).

Interface#

Warning

This is currently inside the Kokkos::Experimental namespace.

Overload set accepting execution space#

template <class ExecutionSpace, class IteratorType, class GeneratorType>
void generate(const ExecutionSpace& exespace,                                (1)
              IteratorType first, IteratorType last,
              GeneratorType g);

template <class ExecutionSpace, class IteratorType, class GeneratorType>
void generate(const std::string& label, const ExecutionSpace& exespace,      (2)
              IteratorType first, IteratorType last,
              GeneratorType g);

template <class ExecutionSpace, class DataType, class... Properties, class GeneratorType>
void generate(const ExecutionSpace& exespace,                                (3)
              const Kokkos::View<DataType, Properties...>& view,
              GeneratorType g);

template <class ExecutionSpace, class DataType, class... Properties, class GeneratorType>
void generate(const std::string& label, const ExecutionSpace& exespace,      (4)
              const Kokkos::View<DataType, Properties...>& view,
              GeneratorType g);

Overload set accepting a team handle#

New in version 4.2.

template <class TeamHandleType, class IteratorType, class GeneratorType>
KOKKOS_FUNCTION
void generate(const TeamHandleType& teamHandle,                              (5)
              IteratorType first, IteratorType last,
              GeneratorType g);

template <class TeamHandleType, class DataType, class... Properties, class GeneratorType>
KOKKOS_FUNCTION
void generate(const TeamHandleType& teamHandle,                              (6)
              const Kokkos::View<DataType, Properties...>& view,
              GeneratorType g);

Parameters and Requirements#

  • exespace: execution space instance

  • teamHandle: team handle instance given inside a parallel region when using a TeamPolicy

  • label: used to name the implementation kernels for debugging purposes

    • for 1, the default string is: “Kokkos::generate_iterator_api_default”

    • for 3, the default string is: “Kokkos::generate_view_api_default”

    • NOTE: overloads accepting a team handle do not use a label internally

  • first, last: range of elements to modify

    • must be random access iterators

    • must represent a valid range, i.e., last >= first (checked in debug mode)

    • must be accessible from exespace or from the execution space associated with the team handle

  • view: view to modify

    • must be rank-1, and have LayoutLeft, LayoutRight, or LayoutStride

    • must be accessible from exespace or from the execution space associated with the team handle

  • g:

    • functor of the following form, where return_type must be assignable to value_type, with value_type being the value type of IteratorType or of view:

    struct Generate
    {
        KOKKOS_INLINE_FUNCTION
        return_type operator()() const{ return /* ... */; }
    };
    

Return Value#

None