Commit 3e829627 authored by Gaurav Kukreja's avatar Gaurav Kukreja

Reduction Code updated

 * checks if the number of threads is a power of 2 - Viktor
Signed-off-by: 's avatarGaurav Kukreja <mailme.gaurav@gmail.com>
parent cf295448
#include "mpi.h" #include <mpi.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
main (int argc,char *argv[]) main (int argc,char *argv[])
{ {
int myid, np, ierr; int myid, np, ierr;
int a, tmp, i,tag; int a, tmp, i, tag;
MPI_Status status; MPI_Status status;
ierr = MPI_Init (&argc, &argv); ierr = MPI_Init (&argc, &argv);
...@@ -19,7 +19,16 @@ main (int argc,char *argv[]) ...@@ -19,7 +19,16 @@ main (int argc,char *argv[])
MPI_Comm_size(MPI_COMM_WORLD, &np); MPI_Comm_size(MPI_COMM_WORLD, &np);
MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Comm_rank(MPI_COMM_WORLD, &myid);
// ToDo: Check if np is a power of 2 // Check if np is not a power of 2
if ((np & (np - 1)) != 0)
{
if (myid == 0)
{
printf("Number of Processes is not a power of 2!\n");
}
MPI_Finalize();
exit(0);
}
a = myid; a = myid;
i = 1; i = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment