Skip to content
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

Remove warnings from Intel VTune Amplifier about signal stack being too small #6778

Merged
merged 1 commit into from
May 7, 2014
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ JCPPFLAGS += -D_WIN32_WINNT=0x0600
UNTRUSTED_SYSTEM_LIBM = 1
endif

# Intel VTune Amplifier
ifeq ($(USE_INTEL_JITEVENTS), 1)
JCPPFLAGS += -DJL_USE_INTEL_JITEVENTS
endif

# Intel libraries

ifeq ($(USE_INTEL_LIBM), 1)
Expand Down
11 changes: 5 additions & 6 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4296,12 +4296,11 @@ extern "C" void jl_init_codegen(void)

jl_jit_events = new JuliaJITEventListener();
jl_ExecutionEngine->RegisterJITEventListener(jl_jit_events);
#if LLVM_USE_INTEL_JITEVENTS
if (const char* jit_profiling = std::getenv("ENABLE_JITPROFILING"))
if (std::atoi(jit_profiling))
jl_ExecutionEngine->RegisterJITEventListener(
JITEventListener::createIntelJITEventListener());
#endif // LLVM_USE_INTEL_JITEVENTS
#ifdef JL_USE_INTEL_JITEVENTS
if (jl_using_intel_jitevents)
jl_ExecutionEngine->RegisterJITEventListener(
JITEventListener::createIntelJITEventListener());
#endif // JL_USE_INTEL_JITEVENTS

BOX_F(int8,int32); BOX_F(uint8,uint32);
BOX_F(int16,int16); BOX_F(uint16,uint16);
Expand Down
28 changes: 25 additions & 3 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,16 @@ void init_stdio()
JL_STDIN = (uv_stream_t*)init_stdio_handle(0,1);
}

#ifdef JL_USE_INTEL_JITEVENTS
char jl_using_intel_jitevents; // Non-zero if running under Intel VTune Amplifier
#endif

#if defined(JL_USE_INTEL_JITEVENTS) && defined(__linux__)
unsigned sig_stack_size = SIGSTKSZ;
#else
#define sig_stack_size SIGSTKSZ
#endif

#ifndef _OS_WINDOWS_
static void *signal_stack;
#endif
Expand Down Expand Up @@ -614,7 +624,7 @@ kern_return_t catch_exception_raise(mach_port_t exception_port,
old_state = state;
// memset(&state,0,sizeof(x86_thread_state64_t));
// Setup libunwind information
state.__rsp = (uint64_t)signal_stack + SIGSTKSZ;
state.__rsp = (uint64_t)signal_stack + sig_stack_size;
state.__rsp -= sizeof(unw_context_t);
state.__rsp &= -16;
unw_context_t *uc = (unw_context_t*)state.__rsp;
Expand Down Expand Up @@ -682,6 +692,18 @@ void julia_init(char *imageFile)
#endif
init_stdio();

#if defined(JL_USE_INTEL_JITEVENTS)
const char* jit_profiling = getenv("ENABLE_JITPROFILING");
if (jit_profiling && atoi(jit_profiling)) {
jl_using_intel_jitevents = 1;
#if defined(__linux__)
// Intel VTune Amplifier needs at least 64k for alternate stack.
if (SIGSTKSZ < 1<<16)
sig_stack_size = 1<<16;
#endif
}
#endif

#if defined(__linux__)
int ncores = jl_cpu_cores();
if (ncores > 1) {
Expand Down Expand Up @@ -765,7 +787,7 @@ void julia_init(char *imageFile)


#ifndef _OS_WINDOWS_
signal_stack = malloc(SIGSTKSZ);
signal_stack = malloc(sig_stack_size);
struct sigaction actf;
memset(&actf, 0, sizeof(struct sigaction));
sigemptyset(&actf.sa_mask);
Expand Down Expand Up @@ -806,7 +828,7 @@ void julia_init(char *imageFile)
#else // defined(_OS_DARWIN_)
stack_t ss;
ss.ss_flags = 0;
ss.ss_size = SIGSTKSZ;
ss.ss_size = sig_stack_size;
ss.ss_sp = signal_stack;
if (sigaltstack(&ss, NULL) < 0) {
JL_PRINTF(JL_STDERR, "sigaltstack: %s\n", strerror(errno));
Expand Down
4 changes: 3 additions & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ void jl_initialize_generic_function(jl_function_t *f, jl_sym_t *name);
void jl_compute_field_offsets(jl_datatype_t *st);
jl_array_t *jl_new_array_for_deserialization(jl_value_t *atype, uint32_t ndims, size_t *dims,
int isunboxed, int elsz);

#ifdef JL_USE_INTEL_JITEVENTS
extern char jl_using_intel_jitevents;
#endif
extern size_t jl_arr_xtralloc_limit;

void jl_init_types(void);
Expand Down