mirror of
https://github.com/amd/blis.git
synced 2026-05-11 09:39:59 +00:00
Thread safety: Make the global induced method status array local to thread
BLIS retains a global status array for induced methods, and provides APIs to modify this state during runtime. So, one application thread can modify the state, before another starts the corresponding BLIS operation. This patch solves this issue by making the induced method status array local to threads. Change-Id: Iff59b6f473771344054c010b4eda51b7aa4317fe
This commit is contained in:
@@ -64,6 +64,20 @@
|
||||
#endif
|
||||
|
||||
|
||||
// -- BLIS Thread Local Storage Keyword --
|
||||
|
||||
// __thread for TLS is supported by GCC, CLANG, ICC, and IBMC.
|
||||
// There is a small risk here as __GNUC__ can also be defined by some other
|
||||
// compiler (other than ICC and CLANG which we know define it) that
|
||||
// doesn't support __thread, as __GNUC__ is not quite unique to GCC.
|
||||
// But the possibility of someone using such non-main-stream compiler
|
||||
// for building BLIS is low.
|
||||
#if defined(__GNUC__) || defined(__clang__) || defined(__ICC) || defined(__IBMC__)
|
||||
#define BLIS_THREAD_LOCAL __thread
|
||||
#else
|
||||
#define BLIS_THREAD_LOCAL
|
||||
#endif
|
||||
|
||||
// -- Boolean values --
|
||||
|
||||
#ifndef TRUE
|
||||
|
||||
@@ -60,7 +60,11 @@ static void* bli_l3_ind_oper_fp[BLIS_NUM_IND_METHODS][BLIS_NUM_LEVEL3_OPS] =
|
||||
//
|
||||
// NOTE: "2" is used instead of BLIS_NUM_FP_TYPES/2.
|
||||
//
|
||||
static bool_t bli_l3_ind_oper_st[BLIS_NUM_IND_METHODS][BLIS_NUM_LEVEL3_OPS][2] =
|
||||
// BLIS provides APIs to modify this state during runtime. So, one application thread
|
||||
// can modify the state, before another starts the corresponding BLIS operation.
|
||||
// This is solved by making the induced method status array local to threads.
|
||||
|
||||
static BLIS_THREAD_LOCAL bool_t bli_l3_ind_oper_st[BLIS_NUM_IND_METHODS][BLIS_NUM_LEVEL3_OPS][2] =
|
||||
{
|
||||
/* gemm hemm herk her2k symm syrk, syr2k trmm3 trmm trsm */
|
||||
/* c z */
|
||||
|
||||
Reference in New Issue
Block a user