Skip to content

Instantly share code, notes, and snippets.

@yushangdi
Created March 31, 2022 18:00
Show Gist options
  • Select an option

  • Save yushangdi/8eff332d240d5c50c41bf268bc98bcfe to your computer and use it in GitHub Desktop.

Select an option

Save yushangdi/8eff332d240d5c50c41bf268bc98bcfe to your computer and use it in GitHub Desktop.
parlayschtest.cpp
#include "parlay/scheduler.h"
#include "parlay/parallel.h"
#include <unistd.h>
//to compile: g++ -Iexternal/parlaylib/include -DPARLAY_OPENMP -std=c++17 -pthread parlayschtest.cpp
using namespace std;
int main(int argc, char* argv[]) {
parlay::fork_join_scheduler fj;
parlay::par_do([&] () {
cout << 1 << endl;
sleep(1);
cout << 2 << endl;
;},
[&] () {
cout << 3 << endl;
sleep(1);
cout << 4 << endl;
});
fj.pardo([&] () {
cout << 5 << endl;
sleep(1);
cout << 6 << endl;
;},
[&] () {
cout << 7 << endl;
sleep(1);
cout << 8 << endl;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment