Created
March 31, 2022 18:00
-
-
Save yushangdi/8eff332d240d5c50c41bf268bc98bcfe to your computer and use it in GitHub Desktop.
parlayschtest.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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