intel-qs icon indicating copy to clipboard operation
intel-qs copied to clipboard

Add Barrier and Timing to the Python Interface

Open cangumeli opened this issue 5 years ago • 6 comments

cangumeli avatar Sep 09 '20 21:09 cangumeli

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.

giangiac avatar Nov 09 '20 17:11 giangiac

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.

giangiac avatar Nov 09 '20 18:11 giangiac

I will be looking into it to find a better way of timing. Thanks for the response.

cangumeli avatar Nov 18 '20 13:11 cangumeli

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

cangumeli avatar Dec 02 '20 22:12 cangumeli

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?

giangiac avatar Dec 08 '20 06:12 giangiac

Yes that is my idea. I will make the change and comment here when I have time :).

cangumeli avatar Dec 13 '20 00:12 cangumeli