public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/60586] New: [Cilk+] Parameters evaluation happens inside spawn worker
@ 2014-03-19 12:36 izamyatin at gmail dot com
2015-08-11 20:45 ` [Bug middle-end/60586] " arch.robison at hotmail dot com
2015-09-03 0:00 ` hjl at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: izamyatin at gmail dot com @ 2014-03-19 12:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60586
Bug ID: 60586
Summary: [Cilk+] Parameters evaluation happens inside spawn
worker
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: izamyatin at gmail dot com
Following test (compiled with eg -O2 -fcilkplus -lcilkrts)
#include <stdio.h>
#include <cilk/cilk.h>
#include <unistd.h>
int noop(int x)
{
return x;
}
int post_increment(int *x)
{
sleep(1);
return (*x)++;
}
int main(int argc, char *argv[])
{
int m = 5;
int n = m;
int r = cilk_spawn noop(post_increment(&n));
int n2 = n;
cilk_sync;
printf("After sync: m = %d, n = %d, r = %d, n2 = %d\n", m, n, r, n2);
if (r != m || n2 != m + 1)
printf("FAILED\n");
else
printf("PASSED\n");
return 0;
}
outputs
After sync: m = 5, n = 6, r = 5, n2 = 5
FAILED
That happens because post_increment is called inside spawn worker which is
incorrect.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/60586] [Cilk+] Parameters evaluation happens inside spawn worker
2014-03-19 12:36 [Bug middle-end/60586] New: [Cilk+] Parameters evaluation happens inside spawn worker izamyatin at gmail dot com
@ 2015-08-11 20:45 ` arch.robison at hotmail dot com
2015-09-03 0:00 ` hjl at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: arch.robison at hotmail dot com @ 2015-08-11 20:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60586
Arch D. Robison <arch.robison at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |arch.robison at hotmail dot com
--- Comment #1 from Arch D. Robison <arch.robison at hotmail dot com> ---
Created attachment 36171
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36171&action=edit
Another demonstration of the bug
Unpack and run "make" to build and run it. Requires routine "usleep" from
<unistid.h>. When compiled correctly, it should run without comment.
Otherwise, as with gcc 5.2.0, it will report errors. E.g., here is a sample
session:
$ make
g++ -O0 -std=c++11 -fcilkplus harness.cpp -c
g++ -O0 -std=c++11 -fcilkplus test.cpp -c
g++ -O0 -std=c++11 -fcilkplus harness.o test.o
./a.out
ERROR: f.val=3, should be 2
ERROR: f.val=6, should be 3
make: *** [all] Aborted
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/60586] [Cilk+] Parameters evaluation happens inside spawn worker
2014-03-19 12:36 [Bug middle-end/60586] New: [Cilk+] Parameters evaluation happens inside spawn worker izamyatin at gmail dot com
2015-08-11 20:45 ` [Bug middle-end/60586] " arch.robison at hotmail dot com
@ 2015-09-03 0:00 ` hjl at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: hjl at gcc dot gnu.org @ 2015-09-03 0:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60586
--- Comment #2 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Wed Sep 2 23:59:21 2015
New Revision: 227423
URL: https://gcc.gnu.org/viewcvs?rev=227423&root=gcc&view=rev
Log:
Fix spawned function with lambda function
Make sure that the spawned function's arguments will not be pushed
into lambda function.
gcc/c-family/
2015-09-02 Balaji V. Iyer <balaji.v.iyer@intel.com>
PR middle-end/60586
* c-common.h (cilk_gimplify_call_params_in_spawned_fn): New
prototype.
* c-gimplify.c (c_gimplify_expr): Added a call to the function
cilk_gimplify_call_params_in_spawned_fn.
* cilk.c (cilk_gimplify_call_params_in_spawned_fn): New function.
(gimplify_cilk_spawn): Removed EXPR_STMT and CLEANUP_POINT_EXPR
unwrapping.
gcc/cp/
2015-09-02 Balaji V. Iyer <balaji.v.iyer@intel.com>
PR middle-end/60586
* cp-gimplify.c (cilk_cp_gimplify_call_params_in_spawned_fn): New
function.
(cp_gimplify_expr): Added a call to the function
cilk_cp_gimplify_call_params_in_spawned_fn.
gcc/testsuite/
2015-09-02 Balaji V. Iyer <balaji.v.iyer@intel.com>
PR middle-end/60586
* c-c++-common/cilk-plus/CK/pr60586.c: New file.
* g++.dg/cilk-plus/CK/pr60586.cc: Likewise.
Added:
trunk/gcc/testsuite/c-c++-common/cilk-plus/CK/pr60586.c
trunk/gcc/testsuite/g++.dg/cilk-plus/CK/pr60586.cc
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.h
trunk/gcc/c-family/c-gimplify.c
trunk/gcc/c-family/cilk.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/cp-gimplify.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-03 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 12:36 [Bug middle-end/60586] New: [Cilk+] Parameters evaluation happens inside spawn worker izamyatin at gmail dot com
2015-08-11 20:45 ` [Bug middle-end/60586] " arch.robison at hotmail dot com
2015-09-03 0:00 ` hjl at gcc dot gnu.org
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).