Skip to content

Commit

Permalink
small tweak for blas detection
Browse files Browse the repository at this point in the history
  • Loading branch information
AllinCottrell committed Jan 6, 2025
1 parent aa4dc6d commit ca40c3d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/src/gretl_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2959,17 +2959,18 @@ static void blas_init (void)
#endif

ptr = dlopen(NULL, RTLD_NOW);
if (ptr == NULL) {
goto getout;
}

if (ptr != NULL) {
OB_set_num_threads = dlsym(ptr, "openblas_set_num_threads");
OB_get_num_threads = dlsym(ptr, "openblas_get_num_threads");
if (OB_set_num_threads != NULL) {
blas_variant = BLAS_OPENBLAS;
register_openblas_details(ptr);
}
OB_set_num_threads = dlsym(ptr, "openblas_set_num_threads");
OB_get_num_threads = dlsym(ptr, "openblas_get_num_threads");
if (OB_set_num_threads != NULL) {
blas_variant = BLAS_OPENBLAS;
register_openblas_details(ptr);
}

if (ptr != NULL && blas_variant == BLAS_UNKNOWN) {
if (blas_variant == BLAS_UNKNOWN) {
BLIS_init = dlsym(ptr, "bli_init");
BLIS_finalize = dlsym(ptr, "bli_finalize");
BLIS_set_num_threads = dlsym(ptr, "bli_thread_set_num_threads");
Expand All @@ -2981,7 +2982,7 @@ static void blas_init (void)
}
}

if (ptr != NULL && blas_variant == BLAS_UNKNOWN) {
if (blas_variant == BLAS_UNKNOWN) {
MKL_finalize = dlsym(ptr, "mkl_finalize");
MKL_domain_get_max_threads = dlsym(ptr, "MKL_Domain_Get_Max_Threads");
MKL_domain_set_num_threads = dlsym(ptr, "MKL_Domain_Set_Num_Threads");
Expand All @@ -2991,22 +2992,21 @@ static void blas_init (void)
}
}

if (ptr != NULL && FLAME_init == NULL) {
if (FLAME_init == NULL) {
FLAME_init = dlsym(ptr, "FLA_Init");
if (FLAME_init != NULL) {
FLAME_init();
libflame_utils(ptr);
}
}

if (blas_variant != BLAS_VECLIB &&
blas_variant != BLAS_OPENBLAS &&
blas_variant != BLAS_BLIS &&
blas_variant != BLAS_MKL) {
getout:

#ifndef WIN32
if (blas_variant == BLAS_UNKNOWN) {
blas_variant = detect_blas_via_ldd();
#endif
}
#endif
}

void blas_cleanup (void)
Expand Down

0 comments on commit ca40c3d

Please sign in to comment.