GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - MultithreadCorner/bulk: Launching collective tasks in bulk

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

515 Commits
515 Commits

Folders and files

NameName
Last commit message
Last commit date
bulk
bulk
 
 
README.md
README.md
 
 
async_reduce.cu
async_reduce.cu
 
 
decomposition.hpp
decomposition.hpp
 
 
for_each.cu
for_each.cu
 
 
futures.cu
futures.cu
 
 
head_flags.hpp
head_flags.hpp
 
 
hello_world.cu
hello_world.cu
 
 
join_iterator.hpp
join_iterator.hpp
 
 
merge.cu
merge.cu
 
 
merge_sort_by_key.cu
merge_sort_by_key.cu
 
 
ping_pong.cu
ping_pong.cu
 
 
reduce.cu
reduce.cu
 
 
reduce_by_key.cu
reduce_by_key.cu
 
 
reduce_intervals.hpp
reduce_intervals.hpp
 
 
saxpy.cu
saxpy.cu
 
 
scan.cu
scan.cu
 
 
sum.cu
sum.cu
 
 
tail_flags.hpp
tail_flags.hpp
 
 
time_invocation_cuda.hpp
time_invocation_cuda.hpp
 
 

Repository files navigation

bulk

We have a lot parallel work to do, but all we have are these puny threads. Let's Bulk up!

Bulk lets you describe a parallel task as a hierarchical grouping of execution agents. Individually, these agents are like tiny, lightweight threads, but when grouped together pack some serious muscle.

We can launch parallel groups of agents with bulk::async:

hello_world.cu:

#include <iostream>
#include <cstdio>
#include <bulk/bulk.hpp>

struct hello
{
  __host__ __device__
  void operator()()
  {
    printf("Hello world!\n");
  }

  __host__ __device__
  void operator()(bulk::parallel_group<> &g)
  {
    printf("Hello world from thread %d\n", g.this_exec.index());
  }
};

int main()
{
  // just launch one agent to say hello
  bulk::async(bulk::par(1), hello());

  // launch 32 agents in parallel
  // bulk::root stands in for the root of the agent hierarchy
  // the hello functor uses this to identify each agent within its group
  bulk::async(bulk::par(32), hello(), bulk::root);

  cudaDeviceSynchronize();

  return 0;
}

From here it's a trivial exercise to get to SAXPY:

#include <iostream>
#include <cassert>
#include <bulk/bulk.hpp>
#include <thrust/device_vector.h>

struct saxpy
{
  __host__ __device__
  void operator()(bulk::agent<> &self, float a, float *x, float *y)
  {
    int i = self.index();
    y[i] = a * x[i] + y[i];
  }
};

int main()
{
  size_t n = 1 << 24;
  thrust::device_vector<float> x(n, 1);
  thrust::device_vector<float> y(n, 1);

  float a = 13;

  // pass bulk::root.this_exec so the saxpy functor receives
  // the current execution agent directly
  bulk::async(bulk::par(n), saxpy(), bulk::root.this_exec, a, thrust::raw_pointer_cast(x.data()), thrust::raw_pointer_cast(y.data()));

  assert(y == thrust::device_vector<float>(n, 14));

  std::cout << "Nice SAXPY. Do you work out?" << std::endl;

  return 0;
}

Algorithms built with Bulk are fast.

reduce Performance

inclusive_scan Performance

merge Performance

reduce_by_key Performance

About

Launching collective tasks in bulk

Resources

Readme
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.