#include <diy/master.hpp>
#include <diy/reduce-operations.hpp>
#include <diy/decomposition.hpp>
#include <diy/assigner.hpp>
#include <diy/fmt/format.h>
using namespace std;
struct Block
{
Block() {}
static void* create()
{ return new Block; }
static void destroy(void* b)
{ delete static_cast<Block*>(b); }
{
diy::save(bb, *static_cast<const Block*>(b)); }
void generate_data()
{
my_work = 1;
}
int my_work;
int tot_work;
};
void sum(Block* b,
{
b->tot_work = 0;
for (
int i = 0; i < rp.
out_link().size(); ++i)
for (
int i = 0; i < rp.
in_link().size(); ++i)
{
int in_val;
b->tot_work += in_val;
}
}
void get_tot_work(Block* b,
{
fmt::print(stderr,
"[{}] tot_work = {}\n", cp.
gid(), b->tot_work);
}
void set_some_done(Block* b,
{
b->my_work = (cp.gid() % 2 ? 1 : 0);
}
void set_all_done(Block* b,
{
b->my_work = 0;
}
int main(int argc, char* argv[])
{
int nblocks = world.
size();
int mem_blocks = -1;
int threads = 1;
int dim = 3;
threads,
mem_blocks,
&Block::create,
&Block::destroy,
&storage,
Bounds domain;
int k = 2;
if (world.rank() == 0)
fmt::print(stderr, "None of the blocks are done; tot_work will be > 0 for all blocks:\n");
master.foreach(&get_tot_work);
master.foreach(&set_some_done);
if (world.rank() == 0)
fmt::print(stderr, "Some of the blocks are done, but tot_work will still be > 0 for all blocks:\n");
master.foreach(&get_tot_work);
master.foreach(&set_all_done);
if (world.rank() == 0)
fmt::print(stderr, "Only now that every block is done will tot_work be 0 for all blocks:\n");
master.foreach(&get_tot_work);
}