GithubHelp home page GithubHelp logo

chubbymaggie / agency Goto Github PK

View Code? Open in Web Editor NEW

This project forked from agency-library/agency

0.0 3.0 0.0 1.4 MB

Execution primitives for C++

License: BSD 3-Clause "New" or "Revised" License

Python 0.19% C++ 93.79% Cuda 6.02%

agency's Introduction

Agency

Agency is an experiment exploring how to marry bulk synchronous parallel programming with the components described in the Technical Specification for C++ Extensions for Parallelism. The programming model Agency embodies is intended to be suited to all parallel architectures and is particularly exploitable by wide architectures exposing fine-grained parallelism.

The bulk_invoke function creates groups of execution agents which all invoke a lambda en masse:

template<class Iterator, class T, class BinaryFunction>
T reduce(Iterator first, Iterator last, T init, BinaryFunction binary_op)
{
  using namespace agency;
  auto n = std::distance(first, last);

  // reduce partitions of data into partial sums
  auto partial_sums = bulk_invoke(par, [=](parallel_agent& g)
  {
    auto i = g.index();
    auto partition_size = (n + g.group_size() - 1) / g.group_size();

    auto partition_begin = first + partition_size * i;
    auto partition_end   = std::min(last, partition_begin + partition_size);

    return reduce(seq, partition_begin + 1, partition_end, *partition_begin, binary_op);
  });

  return reduce(seq, partial_sums.begin(), partial_sums.end(), init, binary_op);
}

Design Goals

The design of the library is intended to achieve the following goals:

  • Deliver efficiency by exploiting structured concurrency and sharing

  • Build upon the execution policy approach introduced by the Parallelism TS

  • Interface to the underlying platform via executors

  • Provide a mechanism for controlling the placement of work to be created

Building the Example Programs

Programs with filenames ending in the .cpp extension are compilable with a C++11 compiler, e.g.:

$ g++ -std=c++11 -I. -pthread example.cpp

or

$ clang -std=c++11 -I. -pthread -lstdc++ example.cpp

or

$ icc -std=c++11 -I. -pthread example.cpp

Programs with filenames ending in the .cu extension are compilable with the NVIDIA compiler, e.g.:

$ nvcc -std=c++11 -I. example.cu

These programs are known to compile with g++ v4.8, clang v3.5, nvcc v8.0, and icc 15.0.

agency's People

Contributors

jaredhoberock avatar

Watchers

James Cloos avatar  avatar  avatar

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.