Giter Site home page Giter Site logo

gcc-pstl's Introduction

C++17 开始并行 STL 就是标准库的一部分了,但是到目前为止,三大编译器中只有 MSVC 实现了并行 STLGCC 配合因特尔的 TBB 也是可以工作的。为了方便集成与测试,我这里做了个 pstldocker 镜像。

1. Build the pstl docker image

$ git clone https://github.com/jtcheng/gcc-pstl.git
$ make

# cleanup the docker image
$ make clean

2. Start a pstl docker container

$ cat pstl.sh
#!/bin/bash
# startup gcc container with pstl support
set -e

LOCAL_SRC_ROOT=`pwd`
CPSTL_SRC_ROOT=/root/src
IMAGE=jtcheng/pstl:v0.1

docker run -it --rm -h pstl -v $LOCAL_SRC_ROOT:$CPSTL_SRC_ROOT -w $CPSTL_SRC_ROOT $IMAGE /bin/bash

$ ./pstl.sh

3. Test gcc with tbb to support pstl

root@pstl:~/src# cat pstl_test.cpp
#include <algorithm>
#include <execution>
#include <vector>
#include <iterator>
#include <iostream>

int main(){
  std::vector<int> vi{3, 2, 1, 5, 4, 0};
  std::sort(std::execution::par, vi.begin(), vi.end());
  std::copy(vi.begin(), vi.end(), std::ostream_iterator<int>(std::cout, " "));
  std::cout << std::endl;

  return 0;
}

root@pstl:~/src# g++ pstl_test.cpp -std=c++17 -ltbb
root@pstl:~/src# ./a.out
0 1 2 3 4 5
root@pstl:~/src#

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.