Git Product home page Git Product logo

executors-impl's Introduction

executors-impl

A prototype implementation of the executors proposal, which is published as P0443.

Status

Implements most of P0443R5, plus specification "bug" fixes.

executors-impl's People

Contributors

chriskohlhoff avatar ericniebler avatar jaredhoberock avatar leehowes avatar marehr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

executors-impl's Issues

Which proposal?

Consider adding in the Readme which proposal number this code is tracking (and maybe which revision it is currently implementing).

Update properties to R7 form

It looks like the implementation still uses the pre-R7 form of properties like blocking, bulk_guarantee, etc. There's a fair amount of complexity in the new form of properties, and it's probably worth coding them up sooner rather than later.

How to generically implement transform_reduce

Hi

we are looking into putting together a std::executors backend for Kokkos https://github.com/kokkos/kokkos/tree/std-executors-backend
and I am puzzling over how to best implement a parallel_reduce (or in stl terms a transform_reduce).

One straight forward way seems to be to use the bulk_twoway_execute and use the ResultFactory to provide a handle to a std::atomic. While that probably would work no matter what the executor type is (as long as it supports bulk_twoway_execute) it is also an exceptionally slow way of implementing a reduction.

// Insert this into the for_each example
template<class ExecutionPolicy, class RandomAccessIterator, class T, class Function>
T transform_reduce(ExecutionPolicy&& policy, RandomAccessIterator first, RandomAccessIterator last, T init, std::plus<> , Function f)
{
  auto n = last - first;

  std::atomic<T> result = init;
  auto twoway_bulk_exec = execution::require(policy.executor(), execution::bulk, execution::twoway);

  twoway_bulk_exec.bulk_twoway_execute([=](size_t idx,  std::atomic<T>* result, impl::ignored&)
  {
    T val = init;
    *result += f(first[idx]);
  },
  n,
  [&]()-> std::atomic<T>* {return &result;},
  []{ return impl::ignore; }
  ).get();
  return result;
}

void foo() {
  std::vector<int> vec(10);
  for(int i=0; i<10; i++) vec[i] = i;
  int result = transform_reduce(par,vec.begin(),vec.end(),0,std::plus<>(),[&] (int& ptr) -> int {
    return ptr;
  });
  assert(result == 45);
}

Now if I know that the executor is mapping to std::thread I could probably do something with a map to get from the thread id to a scratch space location in the range of 0 to concurrency, so that I can store each threads contribution and then do some serial reduction later (or the last thread done does its stuff or something like that). But that requires the knowledge of executor mapping to std::thread. Is there something I am overlooking? Is the possibility of implementing this in a general way just outside of what executors are supposed to address for now?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.