Skip to content

Commit a5c718b

Browse files
committed
add parallel example
1 parent 07c0493 commit a5c718b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

examples/parallel.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// include the nanobdd header file
2+
#include <assert.h>
3+
#include <nanobdd/nanobdd.h>
4+
#include <algorithm>
5+
#include <execution>
6+
7+
int
8+
main(int argc, char** argv) {
9+
// init nanobdd with node table size, cache size, and the number of variables
10+
nanobdd::init(1000, 1000, 3);
11+
12+
// get the three variables
13+
auto x = nanobdd::getVar(0);
14+
auto y = nanobdd::getVar(1);
15+
auto z = nanobdd::getVar(2);
16+
17+
std::vector<nanobdd::Bdd> bdds = {x, y, z};
18+
19+
auto xy = x & y;
20+
21+
std::for_each(std::execution::par, bdds.begin(), bdds.end(), [&](auto bdd) {
22+
bdd | xy;
23+
});
24+
25+
return 0;
26+
}

0 commit comments

Comments
 (0)