def parallel_main(NUM_TESTS, NUM_QUBITS):
    COMM = MPI.COMM_WORLD
    NUM_PROC = COMM.Get_size()
    M_RANK = COMM.Get_rank()
    if (M_RANK == MASTER_RANK):
        overlap_probabilities = np.zeros(NUM_TESTS, dtype=np.float64)
        start_time = MPI.Wtime()
    else:
        overlap_probabilities = np.empty(NUM_TESTS, dtype=np.float64)
    M_TESTS = int((NUM_TESTS / NUM_PROC))
    m_overlap_probabilities = np.empty(M_TESTS, dtype=np.float64)
    COMM.Scatter([overlap_probabilities, MPI.DOUBLE], [m_overlap_probabilities, MPI.DOUBLE])
    for i in range(M_TESTS):
        m_overlap_probabilities[i] = test(RAND_COEF, 0, NUM_QUBITS)
    COMM.Barrier()
    COMM.Allgather([m_overlap_probabilities, MPI.DOUBLE], [overlap_probabilities, MPI.DOUBLE])
    COMM.Barrier()
    if (M_RANK == MASTER_RANK):
        stop_time = MPI.Wtime()
        total_time = (stop_time - start_time)
        print(('---------- NUMBER OF QUBITS = %d ----------' % NUM_QUBITS))
        print(('\tNUMBER OF PROCESSES = %d' % NUM_PROC))
        print(('\tNUMBER OF TESTS = %d' % NUM_TESTS))
        print(('\tTOTAL TIME = %f sec' % total_time))
        print('------------------------------------------')
def parallel_main(NUM_TESTS, NUM_QUBITS):
    COMM = MPI.COMM_WORLD
    NUM_PROC = COMM.Get_size()
    M_RANK = COMM.Get_rank()
    if (M_RANK == MASTER_RANK):
        overlap_probabilities = np.zeros(NUM_TESTS, dtype=np.float64)
        start_time = MPI.Wtime()
    else:
        overlap_probabilities = np.empty(NUM_TESTS, dtype=np.float64)
    M_TESTS = int((NUM_TESTS / NUM_PROC))
    m_overlap_probabilities = np.empty(M_TESTS, dtype=np.float64)
    COMM.Scatter([overlap_probabilities, MPI.DOUBLE], [m_overlap_probabilities, MPI.DOUBLE])
    for i in range(M_TESTS):
        m_overlap_probabilities[i] = test(RAND_COEF, 0, NUM_QUBITS)
    COMM.Barrier()
    COMM.Allgather([m_overlap_probabilities, MPI.DOUBLE], [overlap_probabilities, MPI.DOUBLE])
    COMM.Barrier()
    if (M_RANK == MASTER_RANK):
        stop_time = MPI.Wtime()
        total_time = (stop_time - start_time)
        print(('---------- NUMBER OF QUBITS = %d ----------' % NUM_QUBITS))
        print(('\tNUMBER OF PROCESSES = %d' % NUM_PROC))
        print(('\tNUMBER OF TESTS = %d' % NUM_TESTS))
        print(('\tTOTAL TIME = %f sec' % total_time))
        print('------------------------------------------')