int main(int argc, char* argv[]) { mpi::environment env(argc, argv); mpi::communicator world; if(world.size() < 2) throw std::runtime_error("Please run with at least 2 MPI processes!"); int group_a_ranks[2] = {0,1}; mpi::group world_group = world.group(); mpi::group group_a = world_group.include(group_a_ranks,group_a_ranks+2); mpi::communicator comm_a(world,group_a); std::string value("Hello world!"); if(comm_a) { if(comm_a.rank() == 0) { value = "Hello group a!"; } mpi::broadcast(comm_a, value, 0); } std::cout << "Process #" << world.rank() << " says " << value << std::endl; return 0; }
static void add_comment(CommentPtr comment, Wt::WTextEdit* edit, ForumCommentWidget* widget) { dbo::Transaction t(tApp->session()); comment.reread(); tApp->user().reread(); Comment::State state = Comment::state_of_new(tApp->user(), Comment::FORUM_COMMENT, comment); if (state == Comment::DELETED) { return; } CommentPtr c = tApp->session().add(new Comment(true)); c.modify()->set_parent(comment); c.modify()->set_type(Comment::FORUM_COMMENT); c.modify()->set_text(patch_text_edit_text(edit->valueText())); c.modify()->set_init(tApp->user()); c.modify()->set_root(comment->root()); c.modify()->set_state(state); int root_id = comment->root().id(); CommentPtr post_text = comment->root(); CommentPtr post = post_text->parent(); post.reread(); post.modify()->post_comment_added(); c.flush(); // private notification Wt::WString notification = "[auto] " + comm_a(c.id()); User::send_message(tApp->user(), post->init(), notification); if (post->init() != comment->init()) { User::send_message(tApp->user(), comment->init(), notification); } t.commit(); t_emit(COMMENT, root_id); if (state == Comment::DRAFT) { widget->clear(); widget->addWidget(new Wt::WText(Wt::WString::tr( "tc.comment.draft_message"))); } else { tApp->path().post()->set_integer_value(post.id()); tApp->path().post()->open(); } }