Bulk Synchronous Parallel (BSP) - parallel pattern implementation
ComputationFunction comp_body = [catch_args](std::vector<T> input)
{
//do computation with input
}
CommunicationFunction comm_body = [catch_args](std::vector<T> output, int from, int to)
{
//do communication of output using from and to index
}
CommunicationProtocol one_to_one;
for(int i=0; i<nw; i++)
{
std::vector<int> d{i};
one_to_one.push_back(std::make_pair(i,d));
}
/* Superstep use */
SuperStep<int> s1(parallel_degree,data,true);
s1.reset_barrier();
s1.computation(comp_body);
s1.reset_barrier();
s1.communication(comm_body,one_to_one);
/* Get result from superstep */
std::vector<int> output;
output=flatten(s1.get_results(output));
Compile:
g++ src/*.cpp -lpthread -o main
Run:
./main n(int) par_degree(int) verbose(0 or 1, optional with 0 default)
From BSP main folder:
test/test.sh
Save results in data/results.csv. With --verbose flag, print results on standard output without write on csv.