How to check difference between parallel and non parallel programming using mpi - parallel-processing

How to confirm that parallel program written by me using MPI is faster than the program written in non parallel method.

You may use MPI_Wtime() to time you program. Here is an example. Profiling tools may provide you with a more detailed result. Take a loop at this question : Good profiler for Fortran and MPI

Related

How does random_number() work in parallel?

How does random_number() works in parallel with OpenMP?
If I run my program without parallelization I always get the same result, but with parallelization I get different (but similar) results every time.
There is no guarantee about thread safety or threading performance about random_number in general. The Fortran standard does not know OpenMP at all.
Individual compilers may offer you some guarantees, but they will be only valid for the version present in the particular compiler. For example, the current gfortran version supplies a thread-safe random number generator and "Note that in a multi-threaded program (e.g. using OpenMP directives), each thread will have its own random number state." Other compilers may differ. Notably, the compiler your user may want to use may differ and you may not know about that.
There are dedicated parallel random number generators available. For example, I use a modified version of the library that uses the Ziggurat method for several random number distributions, was parallelized by Gib Bogle and I added the implementation of xoroshiro128+ as the underlying algorithm, similar to the one used by Gfortran. There are other implementations of similar algorithms available and standard C++ contains some new generators which are actually defined to use a specific algorithm, so you could call them.
If your goal is to have a reproducible random numbers, take a look at this answer: https://stackoverflow.com/a/52884455/12845922
It's in C, but gives you an effective way to get reproducible results for any number of threads that could easily be converted to Fortan.

MPI and message passing in Julia

I never used MPI before and now for my project in Julia I need to learn how to write my code in MPI and have several codes with different parameters run in parallel and from time to time send some data from each calculation to the other ones.
And I am absolutely blank how to do this in Julia and I never did it in any language before. I installed library MPI but didn't find good tutorial or documentation or an available example for that.
There are different ways to do parallel programming with Julia.
If your problem is very simply, then it might sufficient to use parallel for loops and shared arrays:
https://docs.julialang.org/en/v1/manual/parallel-computing/
Note however, you cannot use multiple computing nodes (such as a cluster) in this case.
To me, the other native constructs in Julia are difficult to work with for more complex programs and in my case, I needed to restructure (significantly) my serial code to use them.
The advantage of MPI is that you will find a lot of documentation of doing MPI-style (single-program, multiple-data) programming in general (but not necessarily documentation specific to julia). You might find the MPI style also more obvious.
On a large cluster it is also possible that you will find optimized MPI libraries.
A good starting points are the examples distributed with MPI.jl:
https://github.com/JuliaParallel/MPI.jl/tree/master/examples

How to use EPCC's OpenMP Microbenchmark suite for my program

I have implemented an application using OpenMP that I compiled with GCC on Ubuntu 16.04 for which I would like to calculate overheads in my application. (The binary file of my application is for e.g. xyz.exe.)
For that I'm trying to use EPCC OpenMP micro-benchmark suite. After makeing the suite, I tried to run one of the benchmarks called syncbench (./syncbench) on the terminal. But I would like to know as to how can I use the benchmark on my OpenMP implementation (xyz.exe). I tried to search the EPCC's official webpage for the suite (https://www.epcc.ed.ac.uk/research/computing/performance-characterisation-and-benchmarking/epcc-openmp-micro-benchmark-suite) and also the README available with the install code, but couldn't find how exactly can I do this.
If anyone has used this suite for their own implementation, please let me know how you have merged the benchmark with your implementation.
I'm new to parallel computing and benchmarking, so please excuse me if my query sounds trivial.
I think you are confusing a microbenchmark and a profiler. A microbenchmark (like EPCC) measures the performance of a specific set of small code fragments (in the case of the EPCC OpenMP benchmark, the performance of OpenMP constructs). A profiler measures the performance of any code and shows you where time is spent.
Therefore, to measure the behaviour of your code, you need a profiler (such as Intel Vtune, HPC toolkit, Tau, ...) not a microbenchmark.
[FWIW I work for Intel, but not directly on Vtune]

Serial Fortran code with openMPI

I'm a newbie to parallel computing.
I have to run a legacy fluid dynamics Fortran 77 code. The program is serial and runs slowly, so I was wondering about the possibility to make it run parallel (e.g. by using open MPI), without deepening into the code. Is it possible?
You will have to deepen into the code. Some stuff can be calculated in parallel, some stuff needs synchronization. Parallelizing compilers and frameworks help identifying what depends on what, what can be parallelized, and what needs to be serialized, but as they can only read your code, and don't know about what you're modeling, it's still you who has to do the hard part of the work.

What do we need to define while using parallel optimization flag?

I have a program with more than 100 subroutines and I am trying to make this code to run faster and I am trying to compile these subroutines using parallel flag. I was wondering what variable or parameters do I need to define in the program if I want to use the parallel flag. Just using the parallel optimization flag increased the run time for my program compared to the one without parallel flag.
Any suggestions is highly appreciated. Thanks a lot.
Best Regards,
Jdbaba
I can give you some general guidelines, but without knowing your specific compiler and platform/OS I won't be able to help you specifically. As far as I know, all of the autoparallelization schemes that are used in Fortran compilers end up using either OpenMP or MPI commands to split the loops out into either threads or processes. The issue is that there is a certain amount of overhead associated with those schemes. For instance, in one case I had a program that used an optimization library which was provided by a vendor as a compiled library without optimization within it. As all of my subroutines and functions were either outside or inside the large loop of the optimizer, and since there was only object data, the autoparallelizer wasn't able to perform ipo and as such it failed to use more than the one core. The run times in this case, due to the DLL that was loaded for OpenMP, the /qparallel actually added ~10% to the run time.
As a note, autoparallelizers aren't magic. Essentially all they are doing is the same type of thing that the autovectorization techniques do, which is to look for loops that have no data that are dependent upon the previous iteration. If it detects that variables are changed between iterations or if the compiler can't tell, then it will not attempt to parallelize the loop.
If you are using the Intel Fortran compiler, you can turn on a diagnostic switch "/qpar-report3" or "-par-report3" to give you information as to the dependency tree of loops to see why they failed to optimize. If you don't have access to large sections of the code you are using, in particular parts with major loops, there is a good chance that there won't be much opportunity in your code to use the auto-parallelizer.
In any case, you can always attempt to reduce dependencies and reformulate your code such that it is more friendly to autoparallelization.

Resources