From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51669 invoked by alias); 2 Nov 2015 20:10:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 51651 invoked by uid 89); 2 Nov 2015 20:10:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Nov 2015 20:10:09 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 02 Nov 2015 12:10:08 -0800 X-ExtLoop1: 1 Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by FMSMGA003.fm.intel.com with ESMTP; 02 Nov 2015 12:10:07 -0800 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.33]) by irsmsx110.ger.corp.intel.com ([169.254.15.151]) with mapi id 14.03.0248.002; Mon, 2 Nov 2015 20:10:06 +0000 From: "Zamyatin, Igor" To: "GCC Patches (gcc-patches@gcc.gnu.org)" CC: "Jeff Law (law@redhat.com)" , "Jakub Jelinek (jakub@redhat.com)" Subject: [PR66326, Cilk+] Fix FP exception occured in CilkPlus runtime Date: Mon, 02 Nov 2015 20:10:00 -0000 Message-ID: <0EFAB2BDD0F67E4FB6CCC8B9F87D7569738142A0@IRSMSX101.ger.corp.intel.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00119.txt.bz2 Hi! This patches fixes FP exception that comes from CilkPlus runtime. Bootstrapped and regtested for x86_64. Is it ok for trunk? Thanks, Igor Changelog: libcilkrts 2015-10-30 Igor Zamyatin PR target/66326 * untime/config/x86/os-unix-sysdep.c (sysdep_save_fp_ctrl_state): Use fnstcw instead fnstsw. testsuite 2015-10-30 Igor Zamyatin PR target/66326 * g++.dg/cilk-plus/CK/pr66326.cc: New test. diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/pr66326.cc b/gcc/testsuite/g= ++.dg/cilk-plus/CK/pr66326.cc new file mode 100644 index 0000000..1114ebd --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/pr66326.cc @@ -0,0 +1,33 @@ +/* { dg-options "-fcilkplus" } */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* } } = } */ + +#include +#include +#include + +template +void do_not_optimize_away(T&& x) { + asm volatile("" : "+r"(x)); +} + +const int N =3D 1'000'000; + +auto compute() { + std::vector v(N); + auto rng =3D std::mt19937{std::random_device{}()}; + std::uniform_real_distribution dist(0, 1); + for (int i =3D 0; i < N; ++i) v[i] =3D std::log(std::sqrt(dist(rng))); + return v; +} + +int main() { + std::vector v1, v2, v3; + cilk_spawn [&] { v1 =3D compute(); }(); + cilk_spawn [&] { v2 =3D compute(); }(); + v3 =3D compute(); + do_not_optimize_away(v1.data()); + do_not_optimize_away(v2.data()); + do_not_optimize_away(v3.data()); + return 0; +} diff --git a/libcilkrts/runtime/config/x86/os-unix-sysdep.c b/libcilkrts/ru= ntime/config/x86/os-unix-sysdep.c index b505ddf..cbc7734 100644 --- a/libcilkrts/runtime/config/x86/os-unix-sysdep.c +++ b/libcilkrts/runtime/config/x86/os-unix-sysdep.c @@ -135,7 +135,7 @@ void sysdep_save_fp_ctrl_state(__cilkrts_stack_frame *s= f) { __asm__ ("stmxcsr %0" : "=3Dm" (sf->mxcsr)); } - __asm__ ("fnstsw %0" : "=3Dm" (sf->fpcsr)); + __asm__ ("fnstcw %0" : "=3Dm" (sf->fpcsr)); } #endif }