From 024acc392ebd9e72c2b6b3a2940bb21e50d6f969 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 4 Dec 2014 17:19:31 -0500 Subject: [PATCH] P4 to Git Change 1102693 by jsjodin@jsjodin_linux_avx_hsa on 2014/12/04 17:11:26 ECR #304775 - Change the way SIGFPE is handled. Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpucommand.hpp#38 edit ... //depot/stg/opencl/drivers/opencl/runtime/os/os_posix.cpp#39 edit ... //depot/stg/opencl/drivers/opencl/runtime/os/os_win32.cpp#42 edit ... //depot/stg/opencl/drivers/opencl/runtime/thread/thread.hpp#14 edit --- rocclr/runtime/device/cpu/cpucommand.hpp | 2 ++ rocclr/runtime/os/os_posix.cpp | 19 +++++++------------ rocclr/runtime/os/os_win32.cpp | 13 ++++--------- rocclr/runtime/thread/thread.hpp | 3 +++ 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/rocclr/runtime/device/cpu/cpucommand.hpp b/rocclr/runtime/device/cpu/cpucommand.hpp index fe582bcc32..abd195da0b 100644 --- a/rocclr/runtime/device/cpu/cpucommand.hpp +++ b/rocclr/runtime/device/cpu/cpucommand.hpp @@ -353,6 +353,8 @@ public: loop(); } + bool isWorkerThread() const { return true; } + //! Return the currently executing WorkerThread's instance. static WorkerThread* current() { diff --git a/rocclr/runtime/os/os_posix.cpp b/rocclr/runtime/os/os_posix.cpp index 0c2bd457bb..9cc5a76d2f 100644 --- a/rocclr/runtime/os/os_posix.cpp +++ b/rocclr/runtime/os/os_posix.cpp @@ -96,18 +96,7 @@ divisionErrorHandler(int sig, siginfo_t* info, void* ptr) assert(!"Unimplemented"); #endif - // Call the chained signal handler - if (callOldSignalHandler(sig, info, ptr)) { - return; - } - - // @todo: only handle exception in the generated code. - // - //if (!isKernelCode(insn)) { - // return; - //} - - if (sig == SIGFPE && info->si_code == FPE_INTDIV) { + if(Thread::current()->isWorkerThread()) { if (Os::skipIDIV(insn)) { #if defined(ATI_ARCH_X86) uc->uc_mcontext.gregs[LP64_SWITCH(REG_EIP,REG_RIP)] = (greg_t)insn; @@ -118,6 +107,12 @@ divisionErrorHandler(int sig, siginfo_t* info, void* ptr) } } + // Call the chained signal handler + if (callOldSignalHandler(sig, info, ptr)) { + return; + } + + std::cerr << "Unhandled signal in divisionErrorHandler()" << std::endl; ::abort(); } diff --git a/rocclr/runtime/os/os_win32.cpp b/rocclr/runtime/os/os_win32.cpp index 1de814b559..1b1bb0faff 100644 --- a/rocclr/runtime/os/os_win32.cpp +++ b/rocclr/runtime/os/os_win32.cpp @@ -450,15 +450,11 @@ divExceptionFilter(struct _EXCEPTION_POINTERS* ep) { DWORD code = ep->ExceptionRecord->ExceptionCode; - if (code == EXCEPTION_INT_DIVIDE_BY_ZERO - || code == EXCEPTION_INT_OVERFLOW) { - // @todo: only handle exception in the generated code. - // - //if (!isKernelCode(insn)) { - // return; - //} + if (code == EXCEPTION_INT_DIVIDE_BY_ZERO || + code == EXCEPTION_INT_OVERFLOW) { address insn = (address)ep->ContextRecord->LP64_SWITCH(Eip,Rip); + if (Os::skipIDIV(insn)) { ep->ContextRecord->LP64_SWITCH(Eip,Rip) = (uintptr_t)insn; return EXCEPTION_CONTINUE_EXECUTION; @@ -471,9 +467,8 @@ void* Thread::entry(Thread* thread) { void* ret = NULL; - // @todo: We only need this for CPU worker threads. #if !defined(_WIN64) - if (true /*thread->isWorkerThread()*/) { + if (thread->isWorkerThread()) { __try { ret = thread->main(); } diff --git a/rocclr/runtime/thread/thread.hpp b/rocclr/runtime/thread/thread.hpp index 8fa9d4601e..c2b5ca274c 100644 --- a/rocclr/runtime/thread/thread.hpp +++ b/rocclr/runtime/thread/thread.hpp @@ -131,6 +131,9 @@ public: //! Return true is this is the host thread. virtual bool isHostThread() const { return false; } + //! Return true if this is a worker thread. + virtual bool isWorkerThread() const { return false; } + //! Get the current thread state. ThreadState state() const { return state_; }