@@ -2871,32 +2871,28 @@ void *blas_memory_alloc(int procpos){
2871
2871
position ++ ;
2872
2872
2873
2873
} while (position < NUM_BUFFERS );
2874
- #if (defined(SMP ) || defined(USE_LOCKING )) && !defined(USE_OPENMP )
2875
- UNLOCK_COMMAND (& alloc_lock );
2876
- #endif
2874
+
2877
2875
if (memory_overflowed ) {
2878
- #if (defined(SMP ) || defined(USE_LOCKING )) && !defined(USE_OPENMP )
2879
- LOCK_COMMAND (& alloc_lock );
2880
- #endif
2881
- do {
2882
- RMB ;
2876
+
2877
+ do {
2878
+ RMB ;
2883
2879
#if defined(USE_OPENMP )
2884
- if (!newmemory [position - NUM_BUFFERS ].used ) {
2885
- blas_lock (& newmemory [position - NUM_BUFFERS ].lock );
2880
+ if (!newmemory [position - NUM_BUFFERS ].used ) {
2881
+ blas_lock (& newmemory [position - NUM_BUFFERS ].lock );
2886
2882
#endif
2887
- if (!newmemory [position - NUM_BUFFERS ].used ) goto allocation2 ;
2883
+ if (!newmemory [position - NUM_BUFFERS ].used ) goto allocation2 ;
2888
2884
2889
2885
#if defined(USE_OPENMP )
2890
- blas_unlock (& newmemory [position - NUM_BUFFERS ].lock );
2891
- }
2886
+ blas_unlock (& newmemory [position - NUM_BUFFERS ].lock );
2887
+ }
2892
2888
#endif
2893
- position ++ ;
2889
+ position ++ ;
2894
2890
2895
- } while (position < 512 + NUM_BUFFERS );
2891
+ } while (position < 512 + NUM_BUFFERS );
2892
+ }
2896
2893
#if (defined(SMP ) || defined(USE_LOCKING )) && !defined(USE_OPENMP )
2897
2894
UNLOCK_COMMAND (& alloc_lock );
2898
2895
#endif
2899
- }
2900
2896
goto error ;
2901
2897
2902
2898
allocation :
@@ -3001,6 +2997,9 @@ void *blas_memory_alloc(int procpos){
3001
2997
return (void * )memory [position ].addr ;
3002
2998
3003
2999
error :
3000
+ #if (defined(SMP ) || defined(USE_LOCKING )) && !defined(USE_OPENMP )
3001
+ LOCK_COMMAND (& alloc_lock );
3002
+ #endif
3004
3003
if (memory_overflowed ) goto terminate ;
3005
3004
fprintf (stderr ,"OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.\n" );
3006
3005
memory_overflowed = 1 ;
@@ -3014,7 +3013,6 @@ void *blas_memory_alloc(int procpos){
3014
3013
newmemory [i ].used = 0 ;
3015
3014
newmemory [i ].lock = 0 ;
3016
3015
}
3017
- newmemory [position - NUM_BUFFERS ].used = 1 ;
3018
3016
3019
3017
allocation2 :
3020
3018
newmemory [position - NUM_BUFFERS ].used = 1 ;
@@ -3086,6 +3084,9 @@ void *blas_memory_alloc(int procpos){
3086
3084
return (void * )newmemory [position - NUM_BUFFERS ].addr ;
3087
3085
3088
3086
terminate :
3087
+ #if (defined(SMP ) || defined(USE_LOCKING )) && !defined(USE_OPENMP )
3088
+ UNLOCK_COMMAND (& alloc_lock );
3089
+ #endif
3089
3090
printf ("OpenBLAS : Program is Terminated. Because you tried to allocate too many memory regions.\n" );
3090
3091
printf ("This library was built to support a maximum of %d threads - either rebuild OpenBLAS\n" , NUM_BUFFERS );
3091
3092
printf ("with a larger NUM_THREADS value or set the environment variable OPENBLAS_NUM_THREADS to\n" );
0 commit comments