Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 32 characters in body
Source Link

Your whole program is run on both of the two processors you set with the -np 2. A common way to prevent duplicates of printouts, final results, etc., is have one thread do those things just by checking the thread id first. Like:

int id; MPI_Comm_rank(MPI_COMM_WORLD, &id); if (id == 0) { printf("only process %d does this one\n", id); } printf("everybody"hello doesfrom thisprocess one\n"%d\n", id); // all processes do this one 

When starting out in MPI I found it helpful to print out those id numbers along with whatever partial results or data each thread was dealing with. Helped me make more sense out of what was happening.

Your whole program is run on both of the two processors you set with the -np 2. A common way to prevent duplicates of printouts, final results, etc., is have one thread do those things just by checking the thread id first. Like:

int id; MPI_Comm_rank(MPI_COMM_WORLD, &id); if (id == 0) { printf("only process %d does this one\n", id); } printf("everybody does this one\n"); 

When starting out in MPI I found it helpful to print out those id numbers along with whatever partial results or data each thread was dealing with. Helped me make more sense out of what was happening.

Your whole program is run on both of the two processors you set with the -np 2. A common way to prevent duplicates of printouts, final results, etc., is have one thread do those things just by checking the thread id first. Like:

int id; MPI_Comm_rank(MPI_COMM_WORLD, &id); if (id == 0) { printf("only process %d does this one\n", id); } printf("hello from process %d\n", id); // all processes do this one 

When starting out in MPI I found it helpful to print out those id numbers along with whatever partial results or data each thread was dealing with. Helped me make more sense out of what was happening.

Source Link

Your whole program is run on both of the two processors you set with the -np 2. A common way to prevent duplicates of printouts, final results, etc., is have one thread do those things just by checking the thread id first. Like:

int id; MPI_Comm_rank(MPI_COMM_WORLD, &id); if (id == 0) { printf("only process %d does this one\n", id); } printf("everybody does this one\n"); 

When starting out in MPI I found it helpful to print out those id numbers along with whatever partial results or data each thread was dealing with. Helped me make more sense out of what was happening.