Add Barrier and Timing to the Python Interface
Hi @cangumeli, it seems to me that "MPI_Wtime()" returns the number of seconds elapsed from a specific point in the past. This point is guaranteed not to change during the life of the process, but there is no requirement that different nodes return the "same" time.
The value of "MPI_Wtime()" cannot therefore be directly compared between processes.
The barrier-related contribution works fine.
The min/max time approach may not be the best for timing the code in Python.
One simple alternative is: min time --> time-of-day and then barrier max time --> barrier and then time-of-day but this is approximate.
Another approach requires that, at the point of the initialization of the MPI environment, we store the "MPI_Wtime()" separately for every process. When min/ax time is called, we return the time difference with the fixed "initialization time" of the process. However, one must be able to assume that the initialization of every process happens at the same time and this may not be the case.
I will be looking into it to find a better way of timing. Thanks for the response.
When I added min/max time, I actually thought barriers in Python don't work. However, with this contribution, they should work. So I am not sure max and min time are really necessary anymore, maybe we can just do something like this in Python:
begin = time()
run_circuit()
barrier()
end = time()
print time in the process 0
That is what I was thinking too: Providing the barrier command should suffice for most applications. Do you want to eliminate the min/max time and simply keep the barrier?
Yes that is my idea. I will make the change and comment here when I have time :).