Skip to content

Exit if memory allocation keeps failing, instead of retrying forever #5303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions driver/others/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2922,6 +2922,7 @@ void *blas_memory_alloc(int procpos){
blas_unlock(&memory[position].lock);
#endif
if (!memory[position].addr) {
int failcount = 0;
do {
#ifdef DEBUG
printf("Allocation Start : %lx\n", base_address);
Expand Down Expand Up @@ -2973,8 +2974,16 @@ void *blas_memory_alloc(int procpos){
#ifdef DEBUG
printf(" Success -> %08lx\n", map_address);
#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;

} while ((BLASLONG)map_address == -1);
Expand Down
Loading