Skip to content

Commit

Permalink
Merge pull request #16406 from JuliaLang/yyc/threads/opt
Browse files Browse the repository at this point in the history
Allow building julia with more than one worker thread by default
  • Loading branch information
yuyichao committed May 19, 2016
2 parents 55e3a39 + 5249037 commit 17bc2a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ USE_INTEL_JITEVENTS ?= 0
USEICC ?= 0
USEIFC ?= 0

JULIA_THREADS := 1 # Enable threading with one thread

ifeq ($(USE_MKL), 1)
$(warning "The julia make variable USE_MKL has been renamed to USE_INTEL_MKL")
USE_INTEL_MKL := 1
Expand Down Expand Up @@ -896,7 +898,7 @@ endif

# Threads
ifneq ($(JULIA_THREADS), 0)
JCPPFLAGS += -DJULIA_ENABLE_THREADING
JCPPFLAGS += -DJULIA_ENABLE_THREADING -DJULIA_NUM_THREADS=$(JULIA_THREADS)
endif

# Intel VTune Amplifier
Expand Down
4 changes: 3 additions & 1 deletion src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@

// defaults for # threads
#define NUM_THREADS_NAME "JULIA_NUM_THREADS"
#define DEFAULT_NUM_THREADS 1
#ifndef JULIA_NUM_THREADS
# define JULIA_NUM_THREADS 1
#endif

// affinitization behavior
#define MACHINE_EXCLUSIVE_NAME "JULIA_EXCLUSIVE"
Expand Down
4 changes: 3 additions & 1 deletion src/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,15 @@ void jl_init_threading(void)

// how many threads available, usable
int max_threads = jl_cpu_cores();
jl_n_threads = DEFAULT_NUM_THREADS;
jl_n_threads = JULIA_NUM_THREADS;
cp = getenv(NUM_THREADS_NAME);
if (cp) {
jl_n_threads = (uint64_t)strtol(cp, NULL, 10);
}
if (jl_n_threads > max_threads)
jl_n_threads = max_threads;
if (jl_n_threads <= 0)
jl_n_threads = 1;

// set up space for per-thread heaps
jl_all_heaps = (struct _jl_thread_heap_t **)malloc(jl_n_threads * sizeof(void*));
Expand Down

0 comments on commit 17bc2a4

Please sign in to comment.