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/core/parallel-dispatch/parallel_for.html below:

parallel_for - Kokkos documentation

Toggle table of contents sidebar

parallel_for

Header File: <Kokkos_Core.hpp>

Usage:

Kokkos::parallel_for(name, policy, functor);
Kokkos::parallel_for(policy, functor);

Dispatches parallel work defined by functor according to the ExecutionPolicy policy. The optional label name is used by profiling and debugging tools. This call may be asynchronous and return to the callee immediately.

Interface
template<class ExecPolicy, class FunctorType>
Kokkos::parallel_for(const std::string &name, const ExecPolicy &policy, const FunctorType &functor);
template<class ExecPolicy, class FunctorType>
Kokkos::parallel_for(const ExecPolicy &policy, const FunctorType &functor);
Parameters: Requirements Semantics Examples

More Detailed Examples are provided in the ExecutionPolicy documentation.

#include<Kokkos_Core.hpp>
#include<cstdio>

int main(int argc, char* argv[]) {
    Kokkos::initialize(argc,argv);

    int N = atoi(argv[1]);

    Kokkos::parallel_for("Loop1", N, KOKKOS_LAMBDA (const int i) {
        printf("Greeting from iteration %i\n",i);
    });

    Kokkos::finalize();
}
#include<Kokkos_Core.hpp>
#include<cstdio>

struct TagA {};
struct TagB {};

struct Foo {
    KOKKOS_INLINE_FUNCTION
    void operator() (const TagA, const Kokkos::TeamPolicy<>::member_type& team) const {
        printf("Greetings from thread %i of team %i with TagA\n",
                team.thread_rank(),team.league_rank());
    }
    KOKKOS_INLINE_FUNCTION
    void operator() (const TagB, const Kokkos::TeamPolicy<>::member_type& team) const {
        printf("Greetings from thread %i of team %i with TagB\n",
                team.thread_rank(),team.league_rank());
    }
};

int main(int argc, char* argv[]) {
    Kokkos::initialize(argc,argv);

    int N = atoi(argv[1]);

    Foo foo;

    Kokkos::parallel_for(Kokkos::TeamPolicy<TagA>(N,Kokkos::AUTO), foo);
    Kokkos::parallel_for("Loop2", Kokkos::TeamPolicy<TagB>(N,Kokkos::AUTO), foo);

    Kokkos::finalize();
}

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