diff --git a/control/async.c b/control/async.c index 5eea9670b1ca115eca94c71df2f037dde6803e5b..1e33237a8be9ab265fc9b2f5af6f7abab56e2f19 100644 --- a/control/async.c +++ b/control/async.c @@ -69,7 +69,14 @@ int chameleon_sequence_destroy(CHAM_context_t *chamctxt, RUNTIME_sequence_t *seq */ int chameleon_sequence_wait(CHAM_context_t *chamctxt, RUNTIME_sequence_t *sequence) { + if ( chamctxt->runtime_paused ) { + chameleon_warning("chameleon_sequence_wait()", "CHAMELEON was paused, so it is resumed and it will be paused after the wait"); + RUNTIME_resume( chamctxt ); + } RUNTIME_sequence_wait( chamctxt, sequence ); + if ( chamctxt->runtime_paused ) { + RUNTIME_pause( chamctxt ); + } return CHAMELEON_SUCCESS; } diff --git a/control/context.c b/control/context.c index a633ecc79fab65ead74f8f06886f12b483274757..cda18348a68d8c5b5164e601a0f719c2715282ce 100644 --- a/control/context.c +++ b/control/context.c @@ -77,6 +77,8 @@ CHAM_context_t *chameleon_context_create() chamctxt->progress_enabled = CHAMELEON_FALSE; chamctxt->generic_enabled = CHAMELEON_FALSE; + chamctxt->runtime_paused = CHAMELEON_FALSE; + chamctxt->householder = ChamFlatHouseholder; chamctxt->translation = ChamOutOfPlace; diff --git a/control/control.c b/control/control.c index f1688b2eb92f046001c2ba370f0e3f0ecda38e22..778e4f2e6feb50d6f0907197d4f2ce3c44ab9eff 100644 --- a/control/control.c +++ b/control/control.c @@ -194,6 +194,11 @@ int CHAMELEON_Pause(void) chameleon_error("CHAMELEON_Pause()", "CHAMELEON not initialized"); return CHAMELEON_ERR_NOT_INITIALIZED; } + if ( chamctxt->runtime_paused ) { + chameleon_warning("CHAMELEON_Pause()", "CHAMELEON already paused"); + return CHAMELEON_SUCCESS; + } + chamctxt->runtime_paused = CHAMELEON_TRUE; RUNTIME_pause(chamctxt); return CHAMELEON_SUCCESS; } @@ -217,6 +222,11 @@ int CHAMELEON_Resume(void) chameleon_error("CHAMELEON_Resume()", "CHAMELEON not initialized"); return CHAMELEON_ERR_NOT_INITIALIZED; } + if ( !chamctxt->runtime_paused ) { + chameleon_warning("CHAMELEON_Resume()", "CHAMELEON was already resumed"); + return CHAMELEON_SUCCESS; + } + chamctxt->runtime_paused = CHAMELEON_FALSE; RUNTIME_resume(chamctxt); return CHAMELEON_SUCCESS; } diff --git a/include/chameleon/struct.h b/include/chameleon/struct.h index 33f19584eef1dcf1272b96530aff0452caff2bc4..6da47e1c9f332a9ac9b3042fe34e5a1bbdd30a93 100644 --- a/include/chameleon/struct.h +++ b/include/chameleon/struct.h @@ -137,6 +137,7 @@ typedef struct chameleon_context_s { cham_bool_t profiling_enabled; cham_bool_t progress_enabled; cham_bool_t generic_enabled; + cham_bool_t runtime_paused; cham_householder_t householder; // "domino" (flat) or tree-based (reduction) Householder cham_translation_t translation; // In place or Out of place layout conversion