Browse Source

Refs #668. Raise the signal when pthread_create fails.

Thank James K. Lowden for the patch.
tags/v0.2.15^2
Zhang Xianyi 10 years ago
parent
commit
70642fe4ed
2 changed files with 21 additions and 10 deletions
  1. +1
    -1
      appveyor.yml
  2. +20
    -9
      driver/others/blas_server.c

+ 1
- 1
appveyor.yml View File

@@ -39,4 +39,4 @@ before_build:
- cmake -G "Visual Studio 12 Win64" . - cmake -G "Visual Studio 12 Win64" .


test_script: test_script:
- echo Build OK!

+ 20
- 9
driver/others/blas_server.c View File

@@ -70,9 +70,11 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*********************************************************************/ /*********************************************************************/


#include "common.h" #include "common.h"
#ifdef OS_LINUX
#if defined(OS_LINUX) || defined(OS_NETBSD) || defined(OS_DARWIN)
#include <dlfcn.h> #include <dlfcn.h>
#include <signal.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/time.h>
#endif #endif


#ifndef likely #ifndef likely
@@ -265,7 +267,7 @@ int get_node(void);


static int increased_threads = 0; static int increased_threads = 0;


static int blas_thread_server(void *arg){
static void* blas_thread_server(void *arg){


/* Thread identifier */ /* Thread identifier */
BLASLONG cpu = (BLASLONG)arg; BLASLONG cpu = (BLASLONG)arg;
@@ -458,7 +460,7 @@ static int blas_thread_server(void *arg){


//pthread_exit(NULL); //pthread_exit(NULL);


return 0;
return NULL;
} }


#ifdef MONITOR #ifdef MONITOR
@@ -565,14 +567,23 @@ int blas_thread_init(void){


#ifdef NEED_STACKATTR #ifdef NEED_STACKATTR
ret=pthread_create(&blas_threads[i], &attr, ret=pthread_create(&blas_threads[i], &attr,
(void *)&blas_thread_server, (void *)i);
&blas_thread_server, (void *)i);
#else #else
ret=pthread_create(&blas_threads[i], NULL, ret=pthread_create(&blas_threads[i], NULL,
(void *)&blas_thread_server, (void *)i);
&blas_thread_server, (void *)i);
#endif #endif
if(ret!=0){ if(ret!=0){
fprintf(STDERR,"OpenBLAS: pthread_creat error in blas_thread_init function. Error code:%d\n",ret);
exit(1);
struct rlimit rlim;
const char *msg = strerror(ret);
fprintf(STDERR, "OpenBLAS blas_thread_init: pthread_create: %s\n", msg);
if(0 == getrlimit(RLIMIT_NPROC, &rlim)) {
fprintf(STDERR, "OpenBLAS blas_thread_init: RLIMIT_NPROC "
"%ld current, %ld max\n", (long)(rlim.rlim_cur), (long)(rlim.rlim_max));
}
if(0 != raise(SIGINT)) {
fprintf(STDERR, "OpenBLAS blas_thread_init: calling exit(3)\n");
exit(EXIT_FAILURE);
}
} }
} }


@@ -832,10 +843,10 @@ void goto_set_num_threads(int num_threads) {


#ifdef NEED_STACKATTR #ifdef NEED_STACKATTR
pthread_create(&blas_threads[i], &attr, pthread_create(&blas_threads[i], &attr,
(void *)&blas_thread_server, (void *)i);
&blas_thread_server, (void *)i);
#else #else
pthread_create(&blas_threads[i], NULL, pthread_create(&blas_threads[i], NULL,
(void *)&blas_thread_server, (void *)i);
&blas_thread_server, (void *)i);
#endif #endif
} }




Loading…
Cancel
Save