Browse Source

Exit if memory allocation keeps failing, instead of looping forever

pull/5303/head
Martin Kroeker GitHub 3 months ago
parent
commit
31ef2cbbb3
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 2 deletions
  1. +11
    -2
      driver/others/memory.c

+ 11
- 2
driver/others/memory.c View File

@@ -2922,6 +2922,7 @@ void *blas_memory_alloc(int procpos){
blas_unlock(&memory[position].lock); blas_unlock(&memory[position].lock);
#endif #endif
if (!memory[position].addr) { if (!memory[position].addr) {
int failcount = 0;
do { do {
#ifdef DEBUG #ifdef DEBUG
printf("Allocation Start : %lx\n", base_address); printf("Allocation Start : %lx\n", base_address);
@@ -2973,8 +2974,16 @@ void *blas_memory_alloc(int procpos){
#ifdef DEBUG #ifdef DEBUG
printf(" Success -> %08lx\n", map_address); printf(" Success -> %08lx\n", map_address);
#endif #endif
if (((BLASLONG) map_address) == -1) base_address = 0UL;

if (((BLASLONG) map_address) == -1) {
base_address = 0UL;
failcount++;
if (failcount >10) {
fprintf(stderr, "OpenBLAS error: Memory allocation still failed after 10 retries, giving up.\n");
exit(1);
}
} else {
failcount = 0;
}
if (base_address) base_address += BUFFER_SIZE + FIXED_PAGESIZE; if (base_address) base_address += BUFFER_SIZE + FIXED_PAGESIZE;


} while ((BLASLONG)map_address == -1); } while ((BLASLONG)map_address == -1);


Loading…
Cancel
Save