BLIS cpuid: Bugfix for BLAS1/BLAS2 when BLIS_ARCH_TYPE is set

BLAS1 and BLAS2 routines may not immediately call bli_init_auto, as
the full cntx and other global data structures may not be required
for all code paths. This may cause a problem if the user sets
BLIS_ARCH_TYPE, as it needs to check the requested value against the
available options configured in cntx. Solution: add a separate
pthread_once call to run bli_gks_init().

AMD-Internal: [CPUPL-3031]
Change-Id: Icd73a8dd161b34b23cc336623d675248f28ed23f
This commit is contained in:
Edward Smyth
2023-04-04 07:54:31 -04:00
parent 1ac03e64b5
commit 9b9142644f
4 changed files with 20 additions and 4 deletions

View File

@@ -5,7 +5,7 @@
libraries.
Copyright (C) 2014, The University of Texas at Austin
Copyright (C) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -108,6 +108,10 @@ void bli_arch_set_id( void )
bli_check_error_code( e_val );
}
// In BLAS1 and BLAS2 routines, bli_init_auto() may not have been
// called, so ensure cntx has been initialized here.
bli_gks_init_once();
// At this point, we know that req_id is in the valid range, but we
// don't yet know if it refers to a context that was actually
// initialized. Query the address of an internal context data structure

View File

@@ -5,7 +5,7 @@
libraries.
Copyright (C) 2014, The University of Texas at Austin
Copyright (C) 2018-2021, Advanced Micro Devices, Inc.
Copyright (C) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -54,6 +54,16 @@ typedef void (*ind_cntx_init_ft)( ind_t method, num_t dt, cntx_t* cntx );
// -----------------------------------------------------------------------------
// 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.
static bli_pthread_once_t gks_once_init = BLIS_PTHREAD_ONCE_INIT;
void bli_gks_init_once( void )
{
bli_pthread_once( &gks_once_init, bli_gks_init );
}
void bli_gks_init( void )
{
{

View File

@@ -5,6 +5,7 @@
libraries.
Copyright (C) 2014, The University of Texas at Austin
Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -36,6 +37,7 @@
#define BLIS_GKS_H
void bli_gks_init( void );
void bli_gks_init_once( void );
void bli_gks_finalize( void );
BLIS_EXPORT_BLIS void bli_gks_init_index( void );

View File

@@ -5,7 +5,7 @@
libraries.
Copyright (C) 2014, The University of Texas at Austin
Copyright (C) 2018 - 2022, Advanced Micro Devices, Inc. All rights reserved.
Copyright (C) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -85,7 +85,7 @@ void bli_init_apis( void )
/* Initialize DTL Library with trace level set by the user */
AOCL_DTL_INITIALIZE(AOCL_DTL_TRACE_LEVEL);
// Initialize various sub-APIs.
bli_gks_init();
bli_gks_init_once();
bli_ind_init();
bli_thread_init();
bli_pack_init();