I am trying to display the Hello World message by ascending and descending order of it rank
I read about the bitonic sort but couldn't understand how to implement it,
int[] datalist = new int[8];
MPI.Init(args);
int rank = MPI.COMM_WORLD.Rank();
int size = MPI.COMM_WORLD.Size();
System.out.println("Hello World from <"+rank+"> of total "+size+" processes");
MPI.Finalize();
I get the output from this coding but didn't how to output it by sorting it, I really need help cause I am still new with the mpi stuff
The question is not very clear. It may be interpreted in two ways:
You would like to see the printed rank in ascending or descending order. Any MPI library, including MPJ Express, follows the Single Program Multiple Data (SPMD) model. This essentially means that multiple copies of your program will be executed. The number of copies depend upon how many parallel processes you specified while executing the program with mpjrun switch (using -np switch). It is not possible for MPJ Express to print this line in any particular order since it has no control over execution order of parallel copies of this program. So the output will always be non-deterministic.
You would like to see the data in datalist array to be sorted in an ascending or descending order. Again, for that you will need Gather() or Reduce() operation. Currently your program is making N copies of datalist array (assuming that you started N parallel processes).
Hope this helps.