@@ -472,33 +472,34 @@ static LogicalResult runTuningLoop(ModuleOp source) {
472472 rock::createTunableParamSpace (source, tuningSpaceKind));
473473 for (rock::RockTuningParamAttrInterface tuningAttr :
474474 tuningSpace->tuningRange ) {
475- OwningOpRef<ModuleOp> tuneCopy = cast<ModuleOp>(source->clone ());
475+ OwningOpRef<ModuleOp> applicabilityCopy = cast<ModuleOp>(source->clone ());
476476 // TODO: remove this once perf_config gets parsed earlier
477477 SmallString<64 > perfConfig;
478478 tuningAttr.getPerfConfigStr (perfConfig);
479479 llvm::outs () << perfConfig << " \t " ;
480480 StringAttr perfConfigAttr = StringAttr::get (ctx, perfConfig);
481- tuneCopy ->walk ([&perfConfigAttr](rock::RockGemmWrapperInterface op) {
481+ applicabilityCopy ->walk ([&perfConfigAttr](rock::RockGemmWrapperInterface op) {
482482 op->setAttr (" perf_config" , perfConfigAttr);
483483 });
484- tuneCopy ->walk ([&perfConfigAttr](rock::RockGemmGemmWrapperInterface op) {
484+ applicabilityCopy ->walk ([&perfConfigAttr](rock::RockGemmGemmWrapperInterface op) {
485485 op->setAttr (" perf_config" , perfConfigAttr);
486486 });
487+ OwningOpRef<ModuleOp> compileCopy = cast<ModuleOp>(applicabilityCopy->clone ());
487488
488- if (!rock::isModuleFusible (tuneCopy .get (), perfConfig)) {
489+ if (!rock::isModuleFusible (applicabilityCopy .get (), perfConfig)) {
489490 llvm::outs () << " N/A\n " ;
490491 continue ;
491492 }
492493
493- if (failed (applicability.run (tuneCopy .get ()))) {
494+ if (failed (applicability.run (applicabilityCopy .get ()))) {
494495 llvm::outs () << " N/A\n " ;
495496 continue ;
496497 }
497498
498499 SmallVector<uint32_t > blockSizes;
499500 SmallVector<uint32_t > gridSizes;
500501 for (auto &fnName : kernelFuncNames) {
501- auto tunedFunc = tuneCopy ->lookupSymbol <func::FuncOp>(fnName);
502+ auto tunedFunc = applicabilityCopy ->lookupSymbol <func::FuncOp>(fnName);
502503 if (!tunedFunc) {
503504 llvm::errs () << " Tuned copy somehow missing kernel function\n " ;
504505 return failure ();
@@ -511,7 +512,7 @@ static LogicalResult runTuningLoop(ModuleOp source) {
511512 // We have to get these now, they disappear later. Also, if these attributes
512513 // aren't set the contract of the applicability pipeline changed and that's
513514 // a problem.
514- if (failed (compilation.run (tuneCopy .get ()))) {
515+ if (failed (compilation.run (compileCopy .get ()))) {
515516 llvm::errs () << " Backend pipeline failed for config: " << perfConfig
516517 << " \n " ;
517518 return failure ();
@@ -520,7 +521,7 @@ static LogicalResult runTuningLoop(ModuleOp source) {
520521 // Extract binary and benchmark
521522 SmallVector<std::string> hipModules;
522523 for (const auto &fnName : kernelFuncNames) {
523- auto binary = tuneCopy ->lookupSymbol <gpu::BinaryOp>(fnName + " _module" );
524+ auto binary = compileCopy ->lookupSymbol <gpu::BinaryOp>(fnName + " _module" );
524525 if (!binary) {
525526 llvm::errs () << " could not find the GPU binary\n " ;
526527 }
0 commit comments