Improve the "tried to allocate too many buffers" error message

This commit is contained in:
Martin Kroeker 2021-07-31 17:23:40 +02:00 committed by GitHub
parent e0e88f9edc
commit f2a7a67f5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 24 deletions

View File

@ -222,11 +222,11 @@ int get_num_procs(void);
#else #else
int get_num_procs(void) { int get_num_procs(void) {
static int nums = 0; static int nums = 0;
#if defined(__GLIBC_PREREQ)
cpu_set_t cpuset,*cpusetp; cpu_set_t cpuset,*cpusetp;
size_t size; size_t size;
int ret; int ret;
#if defined(__GLIBC_PREREQ)
#if !__GLIBC_PREREQ(2, 7) #if !__GLIBC_PREREQ(2, 7)
int i; int i;
#if !__GLIBC_PREREQ(2, 6) #if !__GLIBC_PREREQ(2, 6)
@ -428,7 +428,7 @@ extern int openblas_goto_num_threads_env();
extern int openblas_omp_num_threads_env(); extern int openblas_omp_num_threads_env();
int blas_get_cpu_number(void){ int blas_get_cpu_number(void){
#if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID) || defined(OS_HAIKU) #if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID)
int max_num; int max_num;
#endif #endif
int blas_goto_num = 0; int blas_goto_num = 0;
@ -436,7 +436,7 @@ int blas_get_cpu_number(void){
if (blas_num_threads) return blas_num_threads; if (blas_num_threads) return blas_num_threads;
#if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID) || defined(OS_HAIKU) #if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID)
max_num = get_num_procs(); max_num = get_num_procs();
#endif #endif
@ -460,7 +460,7 @@ int blas_get_cpu_number(void){
else if (blas_omp_num > 0) blas_num_threads = blas_omp_num; else if (blas_omp_num > 0) blas_num_threads = blas_omp_num;
else blas_num_threads = MAX_CPU_NUMBER; else blas_num_threads = MAX_CPU_NUMBER;
#if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID) || defined(OS_HAIKU) #if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID)
if (blas_num_threads > max_num) blas_num_threads = max_num; if (blas_num_threads > max_num) blas_num_threads = max_num;
#endif #endif
@ -1241,7 +1241,7 @@ UNLOCK_COMMAND(&alloc_lock);
func = &memoryalloc[0]; func = &memoryalloc[0];
while ((*func != NULL) && (map_address == (void *) -1)) { while ((func != NULL) && (map_address == (void *) -1)) {
map_address = (*func)((void *)base_address); map_address = (*func)((void *)base_address);
@ -1619,12 +1619,10 @@ static int on_process_term(void)
#else #else
#pragma data_seg(".CRT$XLB") #pragma data_seg(".CRT$XLB")
#endif #endif
static void (APIENTRY *dll_callback)(HINSTANCE h, DWORD ul_reason_for_call, PVOID pv) = DllMain;
#ifdef _WIN64 #ifdef _WIN64
static const PIMAGE_TLS_CALLBACK dll_callback(HINSTANCE h, DWORD ul_reason_for_call, PVOID pv) = DllMain;
#pragma const_seg() #pragma const_seg()
#else #else
static void (APIENTRY *dll_callback)(HINSTANCE h, DWORD ul_reason_for_call, PVOID pv) = DllMain;
#pragma data_seg() #pragma data_seg()
#endif #endif
@ -1633,12 +1631,10 @@ static void (APIENTRY *dll_callback)(HINSTANCE h, DWORD ul_reason_for_call, PVOI
#else #else
#pragma data_seg(".CRT$XTU") #pragma data_seg(".CRT$XTU")
#endif #endif
static int(*p_process_term)(void) = on_process_term;
#ifdef _WIN64 #ifdef _WIN64
static const int(*p_process_term)(void) = on_process_term;
#pragma const_seg() #pragma const_seg()
#else #else
static int(*p_process_term)(void) = on_process_term;
#pragma data_seg() #pragma data_seg()
#endif #endif
#endif #endif
@ -1672,23 +1668,16 @@ void gotoblas_dummy_for_PGI(void) {
#ifndef MEM_LARGE_PAGES #ifndef MEM_LARGE_PAGES
#define MEM_LARGE_PAGES 0x20000000 #define MEM_LARGE_PAGES 0x20000000
#endif #endif
#elif !defined(OS_EMBEDDED) #else
#define ALLOC_MMAP #define ALLOC_MMAP
#define ALLOC_MALLOC #define ALLOC_MALLOC
#else
#define ALLOC_MALLOC
inline int puts(const char *str) { return 0; }
inline int printf(const char *format, ...) { return 0; }
inline char *getenv(const char *name) { return ""; }
inline int atoi(const char *str) { return 0; }
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#if (!defined(OS_WINDOWS) || defined(OS_CYGWIN_NT)) && !defined(OS_EMBEDDED) #if !defined(OS_WINDOWS) || defined(OS_CYGWIN_NT)
#include <sys/mman.h> #include <sys/mman.h>
#ifndef NO_SYSV_IPC #ifndef NO_SYSV_IPC
#include <sys/shm.h> #include <sys/shm.h>
@ -1702,6 +1691,7 @@ inline int atoi(const char *str) { return 0; }
#include <sys/sysinfo.h> #include <sys/sysinfo.h>
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
#include <linux/unistd.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
@ -1979,7 +1969,7 @@ extern int openblas_goto_num_threads_env();
extern int openblas_omp_num_threads_env(); extern int openblas_omp_num_threads_env();
int blas_get_cpu_number(void){ int blas_get_cpu_number(void){
#if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID) || defined(OS_HAIKU) #if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID)
int max_num; int max_num;
#endif #endif
int blas_goto_num = 0; int blas_goto_num = 0;
@ -1987,7 +1977,7 @@ int blas_get_cpu_number(void){
if (blas_num_threads) return blas_num_threads; if (blas_num_threads) return blas_num_threads;
#if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID) || defined(OS_HAIKU) #if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID)
max_num = get_num_procs(); max_num = get_num_procs();
#endif #endif
@ -2011,7 +2001,7 @@ int blas_get_cpu_number(void){
else if (blas_omp_num > 0) blas_num_threads = blas_omp_num; else if (blas_omp_num > 0) blas_num_threads = blas_omp_num;
else blas_num_threads = MAX_CPU_NUMBER; else blas_num_threads = MAX_CPU_NUMBER;
#if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID) || defined(OS_HAIKU) #if defined(OS_LINUX) || defined(OS_WINDOWS) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) || defined(OS_DARWIN) || defined(OS_ANDROID)
if (blas_num_threads > max_num) blas_num_threads = max_num; if (blas_num_threads > max_num) blas_num_threads = max_num;
#endif #endif