GithubHelp home page GithubHelp logo

wuwenbin2006 / omp_hash_map Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jl2922/omp_hash_map

0.0 1.0 0.0 1.05 MB

A high performance C++ concurrent hash map based on OpenMP.

License: MIT License

Makefile 4.04% C++ 95.36% Shell 0.60%

omp_hash_map's Introduction

omp hash map

A high performance and thread-safe implementation of C++ hash maps and hash sets.

Build Status Coverage Status

Features

  • Thread-safe access and modification.
  • Parallel rehashing and clearing.
  • Parallel Map-reduce.
  • Get and set in one shot.

Usage

Omp hash map is pure template library defined in headers. To use this library, include the corresponding header files, compile with the OpenMP support of the compiler enabled, and set the c++ standard to c++14 or newer.

Example

#include "omp_hash_map.h"
#include "reducer.h"
#include <string>

int main() {
  omp_hash_map<std::string, int> m;

  // Set and get.
  m.set("a", 0);
  m.set("b", 1);
  m.set("c", 2);
  m.get_copy_or_default("b", 0);  // 1.
  const auto& complicated_function = [&](auto& value) { value++; };
  m.set("b", complicated_function);  // Only perform one hash node look up.
  m.get_copy_or_default("b", 0);  // 2.

  // Parallel Map reduce.
  const auto& square = [&](const int key, const int value) {
    return value * value;
  };
  const int sum = m.map_reduce<int>(square, reducer::sum<int>, 0);  // 8.

  return 0;

  // Automatic parallel clearing.
}

For more examples, check the test files in the source folder.

omp_hash_map's People

Contributors

streaver91 avatar jl2922 avatar

Watchers

James Cloos 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.