Skip to content

Commit b5c66a9

Browse files
authored
Implement bli_thread_reset (#32)
BLIS-specific setting of threading takes precedence over OpenMP thread count ICV values, and if the BLIS-specific threading APIs are used, there was no way for the program to revert to OpenMP settings. This patch implements a function bli_thread_reset() to do this. This is similar to that implemented in upstream BLIS in commit 6dcf766 More specifically, it reverts the internal threading data to that which existed when the program was launched, subject where appropriate to any changes in the OpenMP ICVs. In other words: - It will undo changes to threading set by previous calls to bli_thread_set_num_threads or bli_thread_set_ways. - If the environment variable BLIS_NUM_THREADS was used, this will NOT be cleared, as the initial state of the program is restored. - Changes to OpenMP ICVs from previous calls to omp_set_num_threads() will still be in effect, but can be overridden by further calls to omp_set_num_threads(). Note: the internal BLIS data structure updated by the threading APIs, including bli_thread_reset(), is thread-local to each user (e.g. application) thread. Example usage: omp_set_num_threads(4); bli_thread_set_num_threads(7); dgemm(...); // 7 threads will be used bli_thread_reset(); dgemm(...); // 4 threads will be used
1 parent e097346 commit b5c66a9

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

frame/compat/blis/thread/b77_thread.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,10 @@ f77_int PASTEF770(bli_info_get_info_value)
165165
return f77_info_value;
166166
}
167167

168+
void PASTEF770(bli_thread_reset)
169+
(
170+
)
171+
{
172+
// Call the BLIS function.
173+
bli_thread_reset();
174+
}

frame/compat/blis/thread/b77_thread.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ BLIS_EXPORT_BLAS f77_int PASTEF770(bli_info_get_info_value)
7676
(
7777
);
7878

79+
BLIS_EXPORT_BLAS void PASTEF770(bli_thread_reset)
80+
(
81+
);
82+

frame/thread/bli_thread.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ void bli_thread_finalize_tl( void )
7575
{
7676
}
7777

78+
void bli_thread_reset( void )
79+
{
80+
bli_thread_init_rntm_from_global_rntm( &tl_rntm );
81+
}
82+
7883
// -----------------------------------------------------------------------------
7984

8085
void bli_thread_range_sub

frame/thread/bli_thread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ BLIS_EXPORT_BLIS void bli_thread_init_rntm_from_global_rntm( rntm_t* rntm );
243243

244244
BLIS_EXPORT_BLIS void bli_thread_update_rntm_from_env( rntm_t* rntm );
245245

246+
BLIS_EXPORT_BLIS void bli_thread_reset();
247+
246248
// -----------------------------------------------------------------------------
247249

248250
BLIS_INLINE void bli_thread_range_jrir_rr

0 commit comments

Comments
 (0)