@@ -235,11 +235,23 @@ def run(self, healpix_ids=None):
235
235
236
236
def write_results (self ):
237
237
if self .config ['compute' ].getboolean ('compute-correlation' , False ):
238
- for healpix_id , result in self .xi_output .items ():
239
- self .output .write_cf_healpix (result , healpix_id , self .config , self .settings )
238
+ if self .num_cpu > 1 :
239
+ with multiprocessing .Pool (processes = self .num_cpu ) as pool :
240
+ arguments = [(result , healpix_id , self .config , self .settings )
241
+ for healpix_id , result in self .xi_output .items ()]
242
+ _ = pool .starmap (self .output .write_cf_healpix , arguments )
243
+ else :
244
+ for healpix_id , result in self .xi_output .items ():
245
+ self .output .write_cf_healpix (result , healpix_id , self .config , self .settings )
240
246
241
247
if self .config ['compute' ].getboolean ('compute-distortion-matrix' , False ):
242
- for healpix_id , result in self .dmat_output .items ():
243
- self .output .write_dmat_healpix (result , healpix_id , self .config , self .settings )
248
+ if self .num_cpu > 1 :
249
+ with multiprocessing .Pool (processes = self .num_cpu ) as pool :
250
+ arguments = [(result , healpix_id , self .config , self .settings )
251
+ for healpix_id , result in self .dmat_output .items ()]
252
+ _ = pool .starmap (self .output .write_dmat_healpix , arguments )
253
+ else :
254
+ for healpix_id , result in self .dmat_output .items ():
255
+ self .output .write_dmat_healpix (result , healpix_id , self .config , self .settings )
244
256
245
257
# TODO: add other modes
0 commit comments