@@ -1165,11 +1165,10 @@ void *blas_memory_alloc(int procpos){
1165
1165
#ifdef ALLOC_DEVICEDRIVER
1166
1166
alloc_devicedirver ,
1167
1167
#endif
1168
- /* Hugetlb implicitly assumes ALLOC_SHM */
1169
- #ifdef ALLOC_SHM
1168
+ #ifdef ALLOC_SHM & & !defined (ALLOC_HUGETLB )
1170
1169
alloc_shm ,
1171
1170
#endif
1172
- #if ((defined ALLOC_SHM ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS ))
1171
+ #if ((defined ALLOC_HUGETLB ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS ))
1173
1172
alloc_hugetlb ,
1174
1173
#endif
1175
1174
#ifdef ALLOC_MMAP
@@ -1190,7 +1189,6 @@ void *blas_memory_alloc(int procpos){
1190
1189
struct alloc_t * alloc_info ;
1191
1190
struct alloc_t * * alloc_table ;
1192
1191
1193
-
1194
1192
#if defined(SMP ) && !defined(USE_OPENMP )
1195
1193
int mi ;
1196
1194
LOCK_COMMAND (& alloc_lock );
@@ -1282,7 +1280,7 @@ UNLOCK_COMMAND(&alloc_lock);
1282
1280
}
1283
1281
#endif
1284
1282
1285
- #if (defined ALLOC_SHM ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS )
1283
+ #if (defined ALLOC_HUGETLB ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS )
1286
1284
if ((* func == alloc_hugetlb ) && (map_address != (void * )-1 )) hugetlb_allocated = 1 ;
1287
1285
#endif
1288
1286
@@ -2494,7 +2492,7 @@ static void *alloc_devicedirver(void *address){
2494
2492
2495
2493
#endif
2496
2494
2497
- #ifdef ALLOC_SHM
2495
+ #if defined( ALLOC_SHM ) && !defined( ALLOC_HUGETLB )
2498
2496
2499
2497
static void alloc_shm_free (struct release_t * release ){
2500
2498
@@ -2506,7 +2504,9 @@ static void alloc_shm_free(struct release_t *release){
2506
2504
static void * alloc_shm (void * address ){
2507
2505
void * map_address ;
2508
2506
int shmid ;
2509
-
2507
+ #ifdef DEBUG
2508
+ fprintf (stderr ,"alloc_shm got called\n" );
2509
+ #endif
2510
2510
shmid = shmget (IPC_PRIVATE , BUFFER_SIZE ,IPC_CREAT | 0600 );
2511
2511
2512
2512
map_address = (void * )shmat (shmid , address , 0 );
@@ -2533,6 +2533,7 @@ static void *alloc_shm(void *address){
2533
2533
2534
2534
return map_address ;
2535
2535
}
2536
+ #endif
2536
2537
2537
2538
#if defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS
2538
2539
@@ -2562,6 +2563,10 @@ static void *alloc_hugetlb(void *address){
2562
2563
2563
2564
void * map_address = (void * )-1 ;
2564
2565
2566
+ #ifdef DEBUG
2567
+ fprintf (stderr ,"alloc_hugetlb got called\n" );
2568
+ #endif
2569
+
2565
2570
#if defined(OS_LINUX ) || defined(OS_AIX )
2566
2571
int shmid ;
2567
2572
@@ -2583,7 +2588,7 @@ static void *alloc_hugetlb(void *address){
2583
2588
2584
2589
if (map_address != (void * )-1 ){
2585
2590
shmctl (shmid , IPC_RMID , 0 );
2586
- }
2591
+ }else printf ( "alloc_hugetlb failed\n" );
2587
2592
}
2588
2593
#endif
2589
2594
@@ -2645,7 +2650,6 @@ static void *alloc_hugetlb(void *address){
2645
2650
}
2646
2651
#endif
2647
2652
2648
- #endif
2649
2653
2650
2654
#ifdef ALLOC_HUGETLBFILE
2651
2655
@@ -2762,11 +2766,10 @@ void *blas_memory_alloc(int procpos){
2762
2766
#ifdef ALLOC_DEVICEDRIVER
2763
2767
alloc_devicedirver ,
2764
2768
#endif
2765
- /* Hugetlb implicitly assumes ALLOC_SHM */
2766
- #ifdef ALLOC_SHM
2769
+ #ifdef ALLOC_SHM & & !defined (ALLOC_HUGETLB )
2767
2770
alloc_shm ,
2768
2771
#endif
2769
- #if ((defined ALLOC_SHM ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS ))
2772
+ #if ((defined ALLOC_HUGETLB ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS ))
2770
2773
alloc_hugetlb ,
2771
2774
#endif
2772
2775
#ifdef ALLOC_MMAP
@@ -2945,8 +2948,22 @@ void *blas_memory_alloc(int procpos){
2945
2948
}
2946
2949
#endif
2947
2950
2948
- #if (defined ALLOC_SHM ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS )
2951
+ #if (defined ALLOC_HUGETLB ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS )
2949
2952
if ((* func == alloc_hugetlb ) && (map_address != (void * )-1 )) hugetlb_allocated = 1 ;
2953
+ #ifdef DEBUG
2954
+ if (hugetlb_allocated ) printf ("allocating via shared memory with large page support (hugetlb)\n" );
2955
+ #endif
2956
+ #endif
2957
+
2958
+ #if (defined ALLOC_SHM ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS )
2959
+ #ifdef DEBUG
2960
+ printf ("allocating via shared memory\n" );
2961
+ #endif
2962
+ if ((* func == alloc_shm ) && (map_address == (void * )-1 )) {
2963
+ #ifndef OS_WINDOWS
2964
+ fprintf (stderr , "OpenBLAS Warning ... shared memory allocation was failed.\n" );
2965
+ #endif
2966
+ }
2950
2967
#endif
2951
2968
2952
2969
func ++ ;
@@ -3061,10 +3078,23 @@ void *blas_memory_alloc(int procpos){
3061
3078
}
3062
3079
#endif
3063
3080
3064
- #if (defined ALLOC_SHM ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS )
3081
+ #if (defined ALLOC_HUGETLB ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS )
3082
+ #ifdef DEBUG
3083
+ fprintf (stderr ,"OpenBLAS: allocating via shared memory with large page support (hugetlb)\n" );
3084
+ #endif
3065
3085
if ((* func == alloc_hugetlb ) && (map_address != (void * )-1 )) hugetlb_allocated = 1 ;
3066
3086
#endif
3067
3087
3088
+ #if (defined ALLOC_SHM ) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS )
3089
+ #ifdef DEBUG
3090
+ fprintf (stderr ,"allocating via shared memory\n" );
3091
+ #endif
3092
+ if ((* func == alloc_shm ) && (map_address == (void * )-1 )) {
3093
+ #ifndef OS_WINDOWS
3094
+ fprintf (stderr , "OpenBLAS Warning ... shared memory allocation was failed.\n" );
3095
+ #endif
3096
+ }
3097
+ #endif
3068
3098
func ++ ;
3069
3099
}
3070
3100
0 commit comments