@@ -187,6 +187,9 @@ flagcxResult_t flagcxTunerInit(size_t nRanks, size_t nNodes,
187187 }
188188 }
189189
190+ // initialize profilingResults pointer
191+ FLAGCXCHECK (
192+ flagcxCalloc (&internalTuner.profilingResults , internalTuner.nranks ));
190193 // start timer
191194 ctx->timer .start ();
192195 return flagcxSuccess;
@@ -281,20 +284,19 @@ static flagcxResult_t findBestComm(struct flagcxTunerContext *ctx,
281284
282285 INFO (FLAGCX_TUNING , " before allgather, duration for rank %d is %.3fms" ,
283286 internalTuner.rank , duration);
284- float *durationResults = NULL ;
285- FLAGCXCHECK (flagcxCalloc (&durationResults, internalTuner.nranks ));
286- memcpy (durationResults + internalTuner.rank , &duration, sizeof (float ));
287+ memcpy (internalTuner.profilingResults + internalTuner.rank , &duration,
288+ sizeof (float ));
287289 // get average duration across all ranks
288- FLAGCXCHECK (bootstrapAllGather (internalTuner.commState ,
289- (void *)durationResults, sizeof (float )));
290- FLAGCXCHECK (bootstrapBarrier (internalTuner.commState , internalTuner.rank ,
290+ FLAGCXCHECK (bootstrapAllGather (internalTuner.bootstrap ,
291+ (void *)internalTuner.profilingResults ,
292+ sizeof (float )));
293+ FLAGCXCHECK (bootstrapBarrier (internalTuner.bootstrap , internalTuner.rank ,
291294 internalTuner.nranks , 0 ));
292295 duration = 0 .0f ;
293296 for (int i = 0 ; i < internalTuner.nranks ; ++i) {
294- duration += durationResults [i];
297+ duration += internalTuner. profilingResults [i];
295298 }
296299 duration /= internalTuner.nranks ;
297- free (durationResults);
298300 INFO (FLAGCX_TUNING , " after allgather, duration for rank %d is %.3fms" ,
299301 internalTuner.rank , duration);
300302
@@ -468,14 +470,16 @@ flagcxResult_t flagcxTunerDestroy(void *context) {
468470
469471 // stop timer
470472 ctx->timer .stop ();
473+ free (internalTuner.profilingResults );
471474 delete ctx;
472475 return flagcxSuccess;
473476}
474477
475478flagcxTuner_t internalTuner = {" internal tuner" ,
476479 NULL , // assigned during flagcxCommInit
477- 0 ,
478- 0 ,
480+ 0 , // assigned during flagcxCommInit
481+ 0 , // assigned during flagcxCommInit
482+ NULL , // initialized during tunerInit
479483 flagcxTunerInit,
480484 flagcxTunerGetCandidateNumber,
481485 flagcxTunerSetCandidate,
0 commit comments