@@ -89,24 +89,28 @@ void TuningHarness<Backend>::doCompile(SearchStrategy& searchStrategy) {
8989 }
9090 std::unique_ptr<typename Backend::ExecutorType> pExecutor (nullptr );
9191 auto pConf = searchStrategy.population .at (current).get ();
92- auto options = makeOptions<Backend>(baseMapping_, *pConf);
93- try {
94- if (FLAGS_debug_tuner) {
95- std::stringstream ssInfo;
96- typename Backend::MappingOptionsCppPrinter infoPrinter (ssInfo);
97- infoPrinter << options;
98- LOG (INFO) << " [COMPILE] Start compilation @:" << current;
99- LOG_LINE_BY_LINE (INFO, ssInfo);
92+ if (not stopRequested_) {
93+ auto options = makeOptions<Backend>(baseMapping_, *pConf);
94+ try {
95+ if (FLAGS_debug_tuner) {
96+ std::stringstream ssInfo;
97+ typename Backend::MappingOptionsCppPrinter infoPrinter (ssInfo);
98+ infoPrinter << options;
99+ LOG (INFO) << " [COMPILE] Start compilation @:" << current;
100+ LOG_LINE_BY_LINE (INFO, ssInfo);
101+ }
102+ pExecutor =
103+ tc::compile<Backend>(tcTree_, inputs_.begin ()->second , options);
104+ LOG_IF (INFO, FLAGS_debug_tuner) << " [COMPILE] Done compilation" ;
105+ } catch (const std::exception& e) {
106+ LOG (WARNING) << " [TUNER][COMPILE] failed compilation: " << e.what ();
107+ std::stringstream ssWarning;
108+ typename Backend::MappingOptionsCppPrinter warningPrinter (ssWarning);
109+ warningPrinter << options;
110+ LOG_LINE_BY_LINE (WARNING, ssWarning);
111+ pConf->invalid = true ;
100112 }
101- pExecutor =
102- tc::compile<Backend>(tcTree_, inputs_.begin ()->second , options);
103- LOG_IF (INFO, FLAGS_debug_tuner) << " [COMPILE] Done compilation" ;
104- } catch (const std::exception& e) {
105- LOG (WARNING) << " [TUNER][COMPILE] failed compilation: " << e.what ();
106- std::stringstream ssWarning;
107- typename Backend::MappingOptionsCppPrinter warningPrinter (ssWarning);
108- warningPrinter << options;
109- LOG_LINE_BY_LINE (WARNING, ssWarning);
113+ } else {
110114 pConf->invalid = true ;
111115 }
112116
@@ -158,6 +162,11 @@ void TuningHarness<Backend>::doEvaluate(
158162 continue ;
159163 }
160164
165+ if (stopRequested_) {
166+ pConf->invalid = true ;
167+ continue ;
168+ }
169+
161170 auto options = makeOptions<Backend>(baseMapping_, *pConf);
162171 if (FLAGS_debug_tuner) {
163172 // Always log option to INFO so we can correlate to timing offline
@@ -497,8 +506,7 @@ Autotuner<Backend, SearchStrategy>::tune(
497506 } catch (const std::exception& e) {
498507 std::cerr << " Exception during autotuning: " << e.what ()
499508 << " \n dumping cache to "
500- << tc::makeOptionsFilename (cacheFileName) << " /"
501- << Backend::makeDeviceFilename (cacheFileName) << std::endl;
509+ << tc::makeOptionsFilename (cacheFileName) << std::endl;
502510 storeTopKInCache<Backend>(optionsCache_, cacheFileName);
503511 tuningHarnessThreadEx = std::current_exception ();
504512 }
@@ -507,11 +515,7 @@ Autotuner<Backend, SearchStrategy>::tune(
507515 while (not tuningHarnessFinished) {
508516 std::this_thread::sleep_for (std::chrono::milliseconds (100 ));
509517 if (sigint_) {
510- std::cerr
511- << " Autotuning will stop after the current iteration has finished."
512- << std::endl;
513518 tuningHarness.stopAfterCurrentIteration ();
514- tuningHarnessThread.join ();
515519 storeTopKInCache<Backend>(optionsCache_, cacheFileName);
516520 }
517521 if (sigterm_) {
0 commit comments