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_scan.html below:

parallel_scan - Kokkos documentation

parallel_scan

Header File: <Kokkos_Core.hpp>

Usage
Kokkos::parallel_scan( name, policy, functor, result );
Kokkos::parallel_scan( name, policy, functor );
Kokkos::parallel_scan( policy, functor, result);
Kokkos::parallel_scan( policy, functor );

Dispatches parallel work defined by functor according to the ExecutionPolicy policy and perform a pre (exclusive) or post (inclusive) scan of the contributions provided by the work items. The optional label name is used by profiling and debugging tools. If provided, the final result is placed in result.

Interface
template<class ExecPolicy, class FunctorType>
Kokkos::parallel_scan(const std::string &name, const ExecPolicy &policy, const FunctorType &functor);
template<class ExecPolicy, class FunctorType>
Kokkos::parallel_scan(const ExecPolicy &policy, const FunctorType &functor);
template<class ExecPolicy, class FunctorType, class ReturnType>
Kokkos::parallel_scan(const std::string &name, const ExecPolicy &policy, const FunctorType &functor, ReturnType &return_value);
template<class ExecPolicy, class FunctorType, class ReturnType>
Kokkos::parallel_scan(const ExecPolicy &policy, const FunctorType &functor, ReturnType &return_value);
Parameters: Requirements: Semantics Examples
#include<Kokkos_Core.hpp>
#include<cstdio>

int main(int argc, char* argv[]) {
  Kokkos::initialize(argc,argv);
  {
    int N = argc>1?atoi(argv[1]):100;
    int64_t result;
    Kokkos::View<int64_t*>post("postfix_sum",N);
    Kokkos::View<int64_t*>pre("prefix_sum",N);

    Kokkos::parallel_scan("Loop1", N,
      KOKKOS_LAMBDA(int64_t i, int64_t& partial_sum, bool is_final) {
      if(is_final) pre(i) = partial_sum;
      partial_sum += i;
      if(is_final) post(i) = partial_sum;
    }, result);

    // pre (exclusive): 0,0,1,3,6,10,...
    // post (inclusive): 0,1,3,6,10,...
    // result: N*(N-1)/2
    printf("Result: %i %li\n",N,result);
  }
  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