Skip to content

Commit eef4d15

Browse files
authored
Merge pull request #4308 from martin-frbg/issue4277-2
Add workaround for omp_get_max_threads hanging on FreeBSD/LLVM14
2 parents 58427ff + 9324520 commit eef4d15

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

driver/others/blas_server_omp.c

Lines changed: 11 additions & 2 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)
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
128136
blas_omp_number_max = omp_get_max_threads();
129-
137+
#endif
138+
130139
blas_get_cpu_number();
131140

132141
adjust_thread_buffers();

0 commit comments

Comments
 (0)