Browse Source

sort unwanted interdependencies of alloc_shm and alloc_hugetlb

tags/v0.3.28^2
Martin Kroeker GitHub 2 years ago
parent
commit
dc99b61380
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 44 additions and 14 deletions
  1. +44
    -14
      driver/others/memory.c

+ 44
- 14
driver/others/memory.c View File

@@ -1165,11 +1165,10 @@ void *blas_memory_alloc(int procpos){
#ifdef ALLOC_DEVICEDRIVER #ifdef ALLOC_DEVICEDRIVER
alloc_devicedirver, alloc_devicedirver,
#endif #endif
/* Hugetlb implicitly assumes ALLOC_SHM */
#ifdef ALLOC_SHM
#ifdef ALLOC_SHM && !defined(ALLOC_HUGETLB)
alloc_shm, alloc_shm,
#endif #endif
#if ((defined ALLOC_SHM) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS))
#if ((defined ALLOC_HUGETLB) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS))
alloc_hugetlb, alloc_hugetlb,
#endif #endif
#ifdef ALLOC_MMAP #ifdef ALLOC_MMAP
@@ -1190,7 +1189,6 @@ void *blas_memory_alloc(int procpos){
struct alloc_t * alloc_info; struct alloc_t * alloc_info;
struct alloc_t ** alloc_table; struct alloc_t ** alloc_table;



#if defined(SMP) && !defined(USE_OPENMP) #if defined(SMP) && !defined(USE_OPENMP)
int mi; int mi;
LOCK_COMMAND(&alloc_lock); LOCK_COMMAND(&alloc_lock);
@@ -1282,7 +1280,7 @@ UNLOCK_COMMAND(&alloc_lock);
} }
#endif #endif


#if (defined ALLOC_SHM) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)
#if (defined ALLOC_HUGETLB) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)
if ((*func == alloc_hugetlb) && (map_address != (void *)-1)) hugetlb_allocated = 1; if ((*func == alloc_hugetlb) && (map_address != (void *)-1)) hugetlb_allocated = 1;
#endif #endif


@@ -2494,7 +2492,7 @@ static void *alloc_devicedirver(void *address){


#endif #endif


#ifdef ALLOC_SHM
#if defined(ALLOC_SHM) && !defined(ALLOC_HUGETLB)


static void alloc_shm_free(struct release_t *release){ static void alloc_shm_free(struct release_t *release){


@@ -2506,7 +2504,9 @@ static void alloc_shm_free(struct release_t *release){
static void *alloc_shm(void *address){ static void *alloc_shm(void *address){
void *map_address; void *map_address;
int shmid; int shmid;

#ifdef DEBUG
fprintf(stderr,"alloc_shm got called\n");
#endif
shmid = shmget(IPC_PRIVATE, BUFFER_SIZE,IPC_CREAT | 0600); shmid = shmget(IPC_PRIVATE, BUFFER_SIZE,IPC_CREAT | 0600);


map_address = (void *)shmat(shmid, address, 0); map_address = (void *)shmat(shmid, address, 0);
@@ -2533,6 +2533,7 @@ static void *alloc_shm(void *address){


return map_address; return map_address;
} }
#endif


#if defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS #if defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS


@@ -2562,6 +2563,10 @@ static void *alloc_hugetlb(void *address){


void *map_address = (void *)-1; void *map_address = (void *)-1;


#ifdef DEBUG
fprintf(stderr,"alloc_hugetlb got called\n");
#endif

#if defined(OS_LINUX) || defined(OS_AIX) #if defined(OS_LINUX) || defined(OS_AIX)
int shmid; int shmid;


@@ -2583,7 +2588,7 @@ static void *alloc_hugetlb(void *address){


if (map_address != (void *)-1){ if (map_address != (void *)-1){
shmctl(shmid, IPC_RMID, 0); shmctl(shmid, IPC_RMID, 0);
}
}else printf("alloc_hugetlb failed\n");
} }
#endif #endif


@@ -2645,7 +2650,6 @@ static void *alloc_hugetlb(void *address){
} }
#endif #endif


#endif


#ifdef ALLOC_HUGETLBFILE #ifdef ALLOC_HUGETLBFILE


@@ -2762,11 +2766,10 @@ void *blas_memory_alloc(int procpos){
#ifdef ALLOC_DEVICEDRIVER #ifdef ALLOC_DEVICEDRIVER
alloc_devicedirver, alloc_devicedirver,
#endif #endif
/* Hugetlb implicitly assumes ALLOC_SHM */
#ifdef ALLOC_SHM
#ifdef ALLOC_SHM && !defined(ALLOC_HUGETLB)
alloc_shm, alloc_shm,
#endif #endif
#if ((defined ALLOC_SHM) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS))
#if ((defined ALLOC_HUGETLB) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS))
alloc_hugetlb, alloc_hugetlb,
#endif #endif
#ifdef ALLOC_MMAP #ifdef ALLOC_MMAP
@@ -2945,8 +2948,22 @@ void *blas_memory_alloc(int procpos){
} }
#endif #endif


#if (defined ALLOC_SHM) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)
#if (defined ALLOC_HUGETLB) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)
if ((*func == alloc_hugetlb) && (map_address != (void *)-1)) hugetlb_allocated = 1; if ((*func == alloc_hugetlb) && (map_address != (void *)-1)) hugetlb_allocated = 1;
#ifdef DEBUG
if (hugetlb_allocated) printf("allocating via shared memory with large page support (hugetlb)\n");
#endif
#endif

#if (defined ALLOC_SHM) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)
#ifdef DEBUG
printf("allocating via shared memory\n");
#endif
if ((*func == alloc_shm) && (map_address == (void *)-1)) {
#ifndef OS_WINDOWS
fprintf(stderr, "OpenBLAS Warning ... shared memory allocation was failed.\n");
#endif
}
#endif #endif


func ++; func ++;
@@ -3061,10 +3078,23 @@ allocation2:
} }
#endif #endif


#if (defined ALLOC_SHM) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)
#if (defined ALLOC_HUGETLB) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)
#ifdef DEBUG
fprintf(stderr,"OpenBLAS: allocating via shared memory with large page support (hugetlb)\n");
#endif
if ((*func == alloc_hugetlb) && (map_address != (void *)-1)) hugetlb_allocated = 1; if ((*func == alloc_hugetlb) && (map_address != (void *)-1)) hugetlb_allocated = 1;
#endif #endif


#if (defined ALLOC_SHM) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)
#ifdef DEBUG
fprintf(stderr,"allocating via shared memory\n");
#endif
if ((*func == alloc_shm) && (map_address == (void *)-1)) {
#ifndef OS_WINDOWS
fprintf(stderr, "OpenBLAS Warning ... shared memory allocation was failed.\n");
#endif
}
#endif
func ++; func ++;
} }




Loading…
Cancel
Save