Code Monkey home page Code Monkey logo

bcl's Introduction

BCL

The Berkeley Container Library is a C++ library of distributed data structures with interfaces similar to those in STL containers.

Example

  BCL::HashMap<std::string, int> map(1000);

  map[std::to_string(BCL::rank())] = BCL::rank();

  BCL::barrier();

  if (BCL::rank() == 0) {
    for (size_t i = 0; i < BCL::nprocs(); i++) {
      int value = *map.find(std::string(i), value);
      printf("Got key, val %s, %lu\n",
             std::to_string(i).c_str(), value);
    }
  }

Design

Global Pointers

BCL data structures are designed to operate using only one-sided operations that can be executed with RDMA. Under the hood, BCL data structures are implemented using the BCL Core, which is a small API based around global pointers, which are C++ objects that can be used like regular pointers, but reference memory that may lie on another process or node.

  BCL::GlobalPtr<int> ptr = nullptr;

  if (BCL::rank() == 0) {
    ptr = BCL::alloc<int>(BCL::nprocs());
  }

  ptr = BCL::broadcast(ptr, 0);

  ptr[BCL::rank()] = BCL::rank();

  if (BCL::rank() == 1) {
    for (size_t i = 0; i < BCL::nprocs(); i++) {
      int local_val = local_ptr[i];
      printf("%lu: %lu\n", i, local_ptr[i]);
    }
  }

Backends

The BCL Core works by calling a small set of backend functions that do things like read or write from remote memory. The interface is designed to make it easy to implement new backend functions, and we have implemented backends for MPI, OpenSHMEM, and GASNet-EX.

Compiling BCL Programs

BCL is a header-only library, so to compile a program with BCL, you only need to include the necessary BCL header files and compile as normal for your backend.

[xiii@shini example-dir]$ vi hello.cpp
[xiii@shini example-dir]$ mpic++ hello.cpp -o hello -std=gnu++17 -O3 -I $HOME/src/BCL
[xiii@shini example-dir]$ mpirun -n 4 ./hello
Hello, BCL! I am rank 1/4.
Hello, BCL! I am rank 0/4.
Hello, BCL! I am rank 2/4.
Hello, BCL! I am rank 3/4.

MPI is the default backend, and you can explicitly select a backend with the compiler directives -DMPI, -DSHMEM, and -DGASNET_EX. See /bcl/bcl.hpp for details.

Example Programs

You can find example BCL programs in the /examples directory. We recommend you start with /examples/simple, which covers basic functions in the BCL Core.

Bugs

Please let us know if you identify any bugs or general usability issues by creating an issue on GitHub or directly contacting the authors.

Academic Papers

[ICPP'19] "BCL: A Cross-Platform Distributed Container Library"

Blog Posts

[1] "Creating Expressive C++ Smart Pointers for Remote Memory"

[2] "Storing C++ Objects in Distributed Memory"

bcl's People

Contributors

benbrock avatar jeffamstutz avatar jiakunyan avatar kenvifire avatar rustielin avatar yuxinxinchen 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  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

bcl's Issues

Backoff does not back off

The method Backoff::backoff() does not increase sleeping time.
I think it should invoke increase_backoff_impl_() in its function body.

void backoff() {
  usleep(sleep_time_);
}

void increase_backoff_impl_() {
  sleep_time_ = backoff_fn_(sleep_time_);
  sleep_time_ = std::max(sleep_time_, max_sleep_);
}

Test CircularQueue03 fails with MPICH

Test CircularQueue03 fails intermittently. It appears that one of the threads blocks upon entering MPI_Win_lock_all. No MPI error codes are returned.

Ensure that separate compilation works

Most of our current BCL workflows only use BCL in a single compilation unit. Ensure that everything works when BCL is used from multiple compilation units.

UPC++ backend not compiling

Compiling a program with UPC++ throws errors, especially in the associated "backend.hpp" file.

This is the code I use in the given example Makefile:

else ifeq ($(BACKEND), UPCXX) BACKEND=UPCXX CXX=$(HOME)/opt/upcxx/bin/upcxx BCLFLAGS = -DUPCXX -I$(BCLROOT) BCL_RUN=$(HOME)/opt/upcxx/bin/upcxx-run

Do we need atomic queue::size()?

Currently the queue::size() method is implemented as below

  size_t size() const {
    return BCL::rget(tail) - BCL::rget(head);
  }

When it is used simultaneously with push&pop, it might get unpredictable results.
Do we need to implement an atomic version?

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.