################ La ça marche !!!!!!
from MultiThread import multi_process as multi
import time

def test(i,arguments, common_arguments):
    a,b,c = common_arguments
    d = arguments
    output =[]
    for args in d:
        time.sleep(np.random.rand()/a)
        output.append(args**2)
    return(output)

individual_arguments = np.arange(8)
common_arguments = [10,'bb','cc']
out = multi.parallel_for(test, individual_arguments, common_arguments,nprocs=8)
######################


### Tests:
individual_arguments = np.arange(1000)
common_arguments = [100,'bb','cc']
nprocs = arange(16)+1
alltimes=[]
for n in nprocs:
    t = %timeit -o multi.parallel_for(test, individual_arguments, common_arguments,nprocs=n)
    alltimes.append(t)
    
thetimes = [5.47, 2.82, 1.9, 1.44, 1.18, 1.03, 0.896, 0.752, 0.681, 0.616, 0.614, 0.539, 0.545, 0.490, 0.482, 0.451]

plot(nprocs, thetimes, 'ro')
Beispiel #2
0
            acq = QubicAcquisition(instrument_one, sampling, scene, photon_noise=False)
            C = acq.get_convolution_peak_operator()
            coverage = acq.get_coverage()
            observed = coverage > covlim * np.max(coverage)
            acq_restricted = acq[:, :, observed]
            H = acq_restricted.get_operator()
            x0_convolved = C(input_maps)
            pack = PackOperator(observed, broadcast='rightward')
            y_noiseless = H(pack(x0_convolved))
            invntt = acq.get_invntt_operator()
            A = H.T * invntt * H
            preconditioner = DiagonalOperator(1 / coverage[observed], broadcast='rightward')

            # Parallel loop
            sigsmc = mtp.parallel_for(toloop, np.arange(nbmc),nprocs=6)

            allsigs[i,j,incv,:,:]=np.array(sigsmc)


msigs = np.mean(allsigs, axis=3)
errsigs = np.std(allsigs, axis=3)






clf()
errorbar(fknee_vals,msigs[0,:,1]/msigs[0,0,1], yerr=errsigs[0,:,1]/msigs[0,0,1],fmt='o-', label='Q')
errorbar(fknee_vals,msigs[0,:,2]/msigs[0,0,2], yerr=errsigs[0,:,2]/msigs[0,0,2],fmt='o-', label='U')