public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PR66326, Cilk+] Fix FP exception occured in CilkPlus runtime
@ 2015-11-02 20:10 Zamyatin, Igor
  2015-11-02 21:38 ` Jeff Law
  2015-11-09 16:29 ` Thomas Schwinge
  0 siblings, 2 replies; 3+ messages in thread
From: Zamyatin, Igor @ 2015-11-02 20:10 UTC (permalink / raw)
  To: GCC Patches (gcc-patches@gcc.gnu.org)
  Cc: Jeff Law (law@redhat.com), Jakub Jelinek (jakub@redhat.com)

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  <igor.zamyatin@intel.com>

	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  <igor.zamyatin@intel.com>

	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 <cilk/cilk.h>
+#include <vector>
+#include <random>
+
+template <class T>
+void do_not_optimize_away(T&& x) {
+  asm volatile("" : "+r"(x));
+}
+
+const int N = 1'000'000;
+
+auto compute() {
+  std::vector<double> v(N);
+  auto rng = std::mt19937{std::random_device{}()};
+  std::uniform_real_distribution<double> dist(0, 1);
+  for (int i = 0; i < N; ++i) v[i] = std::log(std::sqrt(dist(rng)));
+  return v;
+}
+
+int main() {
+  std::vector<double> v1, v2, v3;
+  cilk_spawn [&] { v1 = compute(); }();
+  cilk_spawn [&] { v2 = compute(); }();
+  v3 = 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/runtime/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 *sf)
         {
             __asm__ ("stmxcsr %0" : "=m" (sf->mxcsr));
         }
-        __asm__ ("fnstsw %0" : "=m" (sf->fpcsr));
+	__asm__ ("fnstcw %0" : "=m" (sf->fpcsr));
     }
 #endif
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PR66326, Cilk+] Fix FP exception occured in CilkPlus runtime
  2015-11-02 20:10 [PR66326, Cilk+] Fix FP exception occured in CilkPlus runtime Zamyatin, Igor
@ 2015-11-02 21:38 ` Jeff Law
  2015-11-09 16:29 ` Thomas Schwinge
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2015-11-02 21:38 UTC (permalink / raw)
  To: Zamyatin, Igor, GCC Patches (gcc-patches@gcc.gnu.org)
  Cc: Jakub Jelinek (jakub@redhat.com)

On 11/02/2015 01:10 PM, Zamyatin, Igor wrote:
> 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  <igor.zamyatin@intel.com>
>
> 	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  <igor.zamyatin@intel.com>
>
> 	PR target/66326
> 	* g++.dg/cilk-plus/CK/pr66326.cc: New test.
OK.
jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PR66326, Cilk+] Fix FP exception occured in CilkPlus runtime
  2015-11-02 20:10 [PR66326, Cilk+] Fix FP exception occured in CilkPlus runtime Zamyatin, Igor
  2015-11-02 21:38 ` Jeff Law
@ 2015-11-09 16:29 ` Thomas Schwinge
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Schwinge @ 2015-11-09 16:29 UTC (permalink / raw)
  To: Zamyatin, Igor
  Cc: Jeff Law (law@redhat.com), Jakub Jelinek (jakub@redhat.com),
	GCC Patches (gcc-patches@gcc.gnu.org)

[-- Attachment #1: Type: text/plain, Size: 1687 bytes --]

Hi!

On Mon, 2 Nov 2015 20:10:06 +0000, "Zamyatin, Igor" <igor.zamyatin@intel.com> wrote:
> This patches fixes FP exception that comes from CilkPlus runtime.
> 
> Bootstrapped and regtested for x86_64.

> --- /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 <cilk/cilk.h>
> +[...]

I'm seeing:

    FAIL: g++.dg/cilk-plus/CK/pr66326.cc  -O1 -fcilkplus (test for excess errors)
    UNRESOLVED: g++.dg/cilk-plus/CK/pr66326.cc  -O1 -fcilkplus compilation failed to produce executable
    FAIL: g++.dg/cilk-plus/CK/pr66326.cc  -O3 -fcilkplus (test for excess errors)
    UNRESOLVED: g++.dg/cilk-plus/CK/pr66326.cc  -O3 -fcilkplus compilation failed to produce executable
    FAIL: g++.dg/cilk-plus/CK/pr66326.cc  -g -O2 -fcilkplus (test for excess errors)
    UNRESOLVED: g++.dg/cilk-plus/CK/pr66326.cc  -g -O2 -fcilkplus compilation failed to produce executable
    FAIL: g++.dg/cilk-plus/CK/pr66326.cc  -g -fcilkplus (test for excess errors)
    UNRESOLVED: g++.dg/cilk-plus/CK/pr66326.cc  -g -fcilkplus compilation failed to produce executable

..., which is because of:

    [...]/gcc/testsuite/g++.dg/cilk-plus/CK/pr66326.cc:5:23: fatal error: cilk/cilk.h: No such file or directory

This is the only test case trying to include that file:

    $ git grep --cached -F cilk.h -- gcc/testsuite/
    gcc/testsuite/g++.dg/cilk-plus/CK/pr66326.cc:#include <cilk/cilk.h>

..., so I guess that's not supported?


Grüße
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-09 16:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-02 20:10 [PR66326, Cilk+] Fix FP exception occured in CilkPlus runtime Zamyatin, Igor
2015-11-02 21:38 ` Jeff Law
2015-11-09 16:29 ` Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).