mirror of
https://github.com/amd/blis.git
synced 2026-05-13 10:35:38 +00:00
Fixed one-time use property of bli_init() (#525).
Details: - Fixes a rather obvious bug that resulted in segmentation fault whenever the calling application tried to re-initialize BLIS after its first init/finalize cycle. The bug resulted from the fact that the bli_init.c APIs made no effort to allow bli_init() to be called subsequent times at all due to it, and bli_finalize(), being implemented in terms of pthread_once(). This has been fixed by resetting the pthread_once_t control variable for initialization at the end of bli_finalize_apis(), and by resetting the control variable for finalization at the end of bli_init_apis(). Thanks to @lschork2 for reporting this issue (#525), and to Minh Quan Ho and Devin Matthews for suggesting the chosen solution. - CREDITS file update.
This commit is contained in:
1
CREDITS
1
CREDITS
@@ -52,6 +52,7 @@ but many others have contributed code and feedback, including
|
||||
Kyungmin Lee @kyungminlee (Ohio State University)
|
||||
Michael Lehn @michael-lehn
|
||||
Shmuel Levine @ShmuelLevine
|
||||
@lschork2
|
||||
Dave Love @loveshack
|
||||
Tze Meng Low (The University of Texas at Austin)
|
||||
Ye Luo @ye-luo (Argonne National Laboratory)
|
||||
|
||||
@@ -64,32 +64,9 @@ void bli_finalize_auto( void )
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void bli_init_apis( void )
|
||||
{
|
||||
// Initialize various sub-APIs.
|
||||
bli_gks_init();
|
||||
bli_ind_init();
|
||||
bli_thread_init();
|
||||
bli_pack_init();
|
||||
bli_memsys_init();
|
||||
}
|
||||
|
||||
void bli_finalize_apis( void )
|
||||
{
|
||||
// Finalize various sub-APIs.
|
||||
bli_memsys_finalize();
|
||||
bli_pack_finalize();
|
||||
bli_thread_finalize();
|
||||
bli_ind_finalize();
|
||||
bli_gks_finalize();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// A pthread_once_t variable is a pthread structure used in pthread_once().
|
||||
// pthread_once() is guaranteed to execute exactly once among all threads that
|
||||
// pass in this control object. Thus, we need one for initialization and a
|
||||
// separate one for finalization.
|
||||
// pass in this control object (until/unless the variable is reset).
|
||||
static bli_pthread_once_t once_init = BLIS_PTHREAD_ONCE_INIT;
|
||||
static bli_pthread_once_t once_finalize = BLIS_PTHREAD_ONCE_INIT;
|
||||
|
||||
@@ -103,3 +80,31 @@ void bli_finalize_once( void )
|
||||
bli_pthread_once( &once_finalize, bli_finalize_apis );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void bli_init_apis( void )
|
||||
{
|
||||
// Initialize various sub-APIs.
|
||||
bli_gks_init();
|
||||
bli_ind_init();
|
||||
bli_thread_init();
|
||||
bli_pack_init();
|
||||
bli_memsys_init();
|
||||
|
||||
// Reset the control variable that will allow finalization.
|
||||
once_finalize = BLIS_PTHREAD_ONCE_INIT;
|
||||
}
|
||||
|
||||
void bli_finalize_apis( void )
|
||||
{
|
||||
// Finalize various sub-APIs.
|
||||
bli_memsys_finalize();
|
||||
bli_pack_finalize();
|
||||
bli_thread_finalize();
|
||||
bli_ind_finalize();
|
||||
bli_gks_finalize();
|
||||
|
||||
// Reset the control variable that will allow (re-)initialization.
|
||||
once_init = BLIS_PTHREAD_ONCE_INIT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user