Skip to content

Commit ff6437f

Browse files
authored
Add workaround for omp_get_max_threads hanging on FreeBSD with libomp from LLVM14
1 parent 9c3c1cf commit ff6437f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

driver/others/blas_server_omp.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,18 @@ void openblas_set_num_threads(int num_threads) {
124124
}
125125

126126
int blas_thread_init(void){
127-
if(blas_omp_number_max <= 0)
128-
blas_omp_number_max = omp_get_max_threads();
129-
127+
128+
#if defined(__FreeBSD__) && defined(__clang__)
129+
extern int openblas_omp_num_threads_env();
130+
131+
if(blas_omp_number_max <= 0)
132+
blas_omp_number_max= openblas_omp_num_threads_env();
133+
if (blas_omp_number_max <= 0)
134+
blas_omp_number_max=MAX_CPU_NUMBER;
135+
#else
136+
blas_omp_number_max = /omp_get_max_threads();
137+
#endif
138+
130139
blas_get_cpu_number();
131140

132141
adjust_thread_buffers();

0 commit comments

Comments
 (0)