@@ -374,13 +374,13 @@ void
374374SyncManager::handleShutdown () {
375375
376376 // ic_barrier_.wait(); // SKK This one may not be necessary...
377- if (num_ranks_.thread > 1 ) {
378377#if 0
379378 // Check for shutdown
380379 Output& out = sim_->getSimulationOutput();
381- out.output("skk:syncmgr:execute: T%d:endSim=%d, shutdown_mode=%d\n", rank_.thread, sim_->endSim, sim_->shutdown_mode_);
380+ out.output("skk:syncmgr:handleShutdown:Before T%d:endSim=%d, shutdown_mode=%d, enter_shutdown=%d, \n",
381+ rank_.thread, sim_->endSim, sim_->shutdown_mode_, sim_->enter_shutdown_);
382382#endif
383- // if (sim_->endSim == true) {
383+ // If my thread enter_shutdown_ is true, then set shared enter_shutdown
384384 if (sim_->enter_shutdown_ == true ) {
385385 enter_shutdown_.fetch_or (true );
386386 endSim_.fetch_or (true );
@@ -390,9 +390,9 @@ SyncManager::handleShutdown() {
390390 }
391391 ic_barrier_.wait ();
392392 if (endSim_ == true ) {
393- sim_->signalShutdown (shutdown_mode_.load ());
393+ sim_->setEndSim ();
394+
394395 }
395- }
396396}
397397
398398void
@@ -403,7 +403,7 @@ SyncManager::handleInteractiveConsole()
403403 // Handle interactive console
404404 if (num_ranks_.thread > 1 ) {
405405
406- // 1) Check enter interactive and set mask if needed
406+ // 1) Check enter interactive and set mask if needed (could use mask to show triggers)
407407 if (sim_->enter_interactive_ == true ) {
408408 unsigned bit = 1UL << rank_.thread ;
409409 enter_interactive_mask_.fetch_or (bit);
@@ -412,8 +412,11 @@ SyncManager::handleInteractiveConsole()
412412
413413 // If enter interactive set for any thread
414414 unsigned ic_mask = enter_interactive_mask_.load ();
415- // out.output("skk:syncmgr:execute: T%d: check enter_interactive_=%d\n", rank_.thread, sim_->enter_interactive_);
416- // out.output("skk:syncmgr:execute: T%d: enter_interactive_mask_=0x%x\n", rank_.thread, ic_mask);
415+ #if 0
416+ Output& out = sim_->getSimulationOutput();
417+ out.output("skk:syncmgr:execute: T%d: check enter_interactive_=%d\n", rank_.thread, sim_->enter_interactive_);
418+ out.output("skk:syncmgr:execute: T%d: enter_interactive_mask_=0x%x\n", rank_.thread, ic_mask);
419+ #endif
417420 if (ic_mask) {
418421 // 2) Print list of threads and whether triggered
419422 for (uint32_t tindex = 0 ; tindex < num_ranks_.thread ; tindex++) {
@@ -429,7 +432,7 @@ SyncManager::handleInteractiveConsole()
429432 else {
430433 std::cout << " (Not Triggered)\n " ;
431434 }
432- #if 0 // Print component summary - will be at whatever level was last (maybe print PWD instead?)
435+ #if 0 // Print component summary? - will be at whatever level was last (maybe print PWD instead?)
433436 if (sim_->interactive_ != nullptr) {
434437 sim_->interactive_->summary();
435438 }
@@ -456,13 +459,14 @@ SyncManager::handleInteractiveConsole()
456459#endif
457460
458461 // 4) Tj: Invoke IC for current thread, with ability to change to new thread
459- int tid = current_ic_thread_.load ();
462+ unsigned int tid = current_ic_thread_.load ();
460463 int ic_state = 0 ;// interactive_state_.load();
461464 while (ic_state != -1 ) {
462465 if ((rank_.thread == tid) && (sim_->interactive_ != nullptr )) {
466+ // Invoke IC for the thread
463467 int result = sim_->interactive_ ->execute (sim_->interactive_msg_ );
464468
465- if (result >= 0 ) { // change thread
469+ if (result >= 0 ) { // change thread to threadID <result>
466470 current_ic_thread_.store (result);
467471 current_ic_state_.store (0 );
468472 }
@@ -471,6 +475,7 @@ SyncManager::handleInteractiveConsole()
471475 }
472476 }
473477 ic_barrier_.wait ();
478+ handleShutdown (); // Check if console issued shutdown command
474479 tid = current_ic_thread_.load ();
475480 ic_state = current_ic_state_.load ();
476481 // out.output("T%d: tid %d, ic_state %d\n", rank_.thread, tid, ic_state);
@@ -611,7 +616,7 @@ SyncManager::execute()
611616 // Handle signals for multi-threaded runs/no MPI
612617 if ( num_ranks_.rank == 1 ) {
613618 signals_received = threadSync_->getSignals (sig_end, sig_usr, sig_alrm);
614- #if 0
619+ #if 1
615620 Output& out = sim_->getSimulationOutput ();
616621 out.output (" skk:syncmgr:execute: T%d: sig_end=%d, sig_usr=%d, sig_alrm=%d, received=%d\n " ,
617622 rank_.thread , sig_end, sig_usr, sig_alrm, signals_received);
0 commit comments