Commit 0494285a by Jakub Jelinek

libgomp.h (struct gomp_task_depend_entry): Add redundant_out field.

	* libgomp.h (struct gomp_task_depend_entry): Add redundant_out field.
	(struct gomp_taskwait): New type.
	(struct gomp_task): Add taskwait and parent_depends_on, remove
	in_taskwait and taskwait_sem fields.
	(gomp_finish_task): Don't destroy taskwait_sem.
	* task.c (gomp_init_task): Don't init in_taskwait, instead init
	taskwait and parent_depends_on.
	(GOMP_task): For if (0) tasks with depend clause that depend on
	earlier tasks don't defer them, instead call
	gomp_task_maybe_wait_for_dependencies to wait for the dependencies.
	Initialize redundant_out field, for redundant out entries just
	move them at the end of linked list instead of removing them
	completely, and set redundant_out flag instead of redundant.
	(gomp_task_run_pre): Update last_parent_depends_on if scheduling
	that task.
	(gomp_task_run_post_handle_dependers): If parent is in
	gomp_task_maybe_wait_for_dependencies and newly runnable task
	is not parent_depends_on, queue it in parent->children linked
	list after all runnable tasks with parent_depends_on set.
	Adjust for addition of taskwait indirection.
	(gomp_task_run_post_remove_parent): If parent is in
	gomp_task_maybe_wait_for_dependencies and task to be removed
	is parent_depends_on, decrement n_depend and if needed awake
	parent.  Adjust for addition of taskwait indirection.
	(GOMP_taskwait): Adjust for addition of taskwait indirection.
	(gomp_task_maybe_wait_for_dependencies): New function.
	* testsuite/libgomp.c/depend-5.c: New test.

From-SVN: r213408
parent bab9b7cb
2014-08-01 Jakub Jelinek <jakub@redhat.com>
* libgomp.h (struct gomp_task_depend_entry): Add redundant_out field.
(struct gomp_taskwait): New type.
(struct gomp_task): Add taskwait and parent_depends_on, remove
in_taskwait and taskwait_sem fields.
(gomp_finish_task): Don't destroy taskwait_sem.
* task.c (gomp_init_task): Don't init in_taskwait, instead init
taskwait and parent_depends_on.
(GOMP_task): For if (0) tasks with depend clause that depend on
earlier tasks don't defer them, instead call
gomp_task_maybe_wait_for_dependencies to wait for the dependencies.
Initialize redundant_out field, for redundant out entries just
move them at the end of linked list instead of removing them
completely, and set redundant_out flag instead of redundant.
(gomp_task_run_pre): Update last_parent_depends_on if scheduling
that task.
(gomp_task_run_post_handle_dependers): If parent is in
gomp_task_maybe_wait_for_dependencies and newly runnable task
is not parent_depends_on, queue it in parent->children linked
list after all runnable tasks with parent_depends_on set.
Adjust for addition of taskwait indirection.
(gomp_task_run_post_remove_parent): If parent is in
gomp_task_maybe_wait_for_dependencies and task to be removed
is parent_depends_on, decrement n_depend and if needed awake
parent. Adjust for addition of taskwait indirection.
(GOMP_taskwait): Adjust for addition of taskwait indirection.
(gomp_task_maybe_wait_for_dependencies): New function.
* testsuite/libgomp.c/depend-5.c: New test.
2014-07-13 Tobias Burnus <burnus@net-b.de> 2014-07-13 Tobias Burnus <burnus@net-b.de>
* testsuite/libgomp.fortran/pr34020.f90: Make compile * testsuite/libgomp.fortran/pr34020.f90: Make compile
with TS 18508/Fortran 2015 with TS 18508/Fortran 2015.
2014-07-06 Marek Polacek <polacek@redhat.com> 2014-07-06 Marek Polacek <polacek@redhat.com>
......
...@@ -274,6 +274,7 @@ struct gomp_task_depend_entry ...@@ -274,6 +274,7 @@ struct gomp_task_depend_entry
struct gomp_task *task; struct gomp_task *task;
bool is_in; bool is_in;
bool redundant; bool redundant;
bool redundant_out;
}; };
struct gomp_dependers_vec struct gomp_dependers_vec
...@@ -283,6 +284,17 @@ struct gomp_dependers_vec ...@@ -283,6 +284,17 @@ struct gomp_dependers_vec
struct gomp_task *elem[]; struct gomp_task *elem[];
}; };
/* Used when in GOMP_taskwait or in gomp_task_maybe_wait_for_dependencies. */
struct gomp_taskwait
{
bool in_taskwait;
bool in_depend_wait;
size_t n_depend;
struct gomp_task *last_parent_depends_on;
gomp_sem_t taskwait_sem;
};
/* This structure describes a "task" to be run by a thread. */ /* This structure describes a "task" to be run by a thread. */
struct gomp_task struct gomp_task
...@@ -298,17 +310,17 @@ struct gomp_task ...@@ -298,17 +310,17 @@ struct gomp_task
struct gomp_taskgroup *taskgroup; struct gomp_taskgroup *taskgroup;
struct gomp_dependers_vec *dependers; struct gomp_dependers_vec *dependers;
struct htab *depend_hash; struct htab *depend_hash;
struct gomp_taskwait *taskwait;
size_t depend_count; size_t depend_count;
size_t num_dependees; size_t num_dependees;
struct gomp_task_icv icv; struct gomp_task_icv icv;
void (*fn) (void *); void (*fn) (void *);
void *fn_data; void *fn_data;
enum gomp_task_kind kind; enum gomp_task_kind kind;
bool in_taskwait;
bool in_tied_task; bool in_tied_task;
bool final_task; bool final_task;
bool copy_ctors_done; bool copy_ctors_done;
gomp_sem_t taskwait_sem; bool parent_depends_on;
struct gomp_task_depend_entry depend[]; struct gomp_task_depend_entry depend[];
}; };
...@@ -582,7 +594,6 @@ gomp_finish_task (struct gomp_task *task) ...@@ -582,7 +594,6 @@ gomp_finish_task (struct gomp_task *task)
{ {
if (__builtin_expect (task->depend_hash != NULL, 0)) if (__builtin_expect (task->depend_hash != NULL, 0))
free (task->depend_hash); free (task->depend_hash);
gomp_sem_destroy (&task->taskwait_sem);
} }
/* team.c */ /* team.c */
......
#include <stdlib.h>
__attribute__((noinline, noclone)) void
f1 (int ifval)
{
int x = 1, y = 2, z = 3;
#pragma omp parallel
#pragma omp single
{
#pragma omp task shared (x) depend(out: x)
x = 2;
#pragma omp task shared (x) depend(inout: x)
{
if (x != 2)
abort ();
x = 3;
}
#pragma omp task shared (x) depend(inout: x)
{
if (x != 3)
abort ();
x = 4;
}
#pragma omp task shared (z) depend(in: z)
if (z != 3)
abort ();
#pragma omp task shared (z) depend(in: z)
if (z != 3)
abort ();
#pragma omp task shared (z) depend(in: z)
if (z != 3)
abort ();
#pragma omp task shared (z) depend(in: z)
if (z != 3)
abort ();
#pragma omp task shared (z) depend(in: z)
if (z != 3)
abort ();
#pragma omp task shared (z) depend(in: z)
if (z != 3)
abort ();
#pragma omp task shared (y) depend(in: y)
if (y != 2)
abort ();
#pragma omp task shared (y) depend(in: y)
if (y != 2)
abort ();
#pragma omp task shared (y) depend(in: y)
if (y != 2)
abort ();
#pragma omp task shared (y) depend(in: y)
if (y != 2)
abort ();
#pragma omp task if (ifval) shared (x, y) depend(in: x) depend(inout: y)
{
if (x != 4 || y != 2)
abort ();
y = 3;
}
if (ifval == 0)
{
/* The above if (0) task should have waited till all
the tasks with x and y dependencies finish. */
if (x != 4 || y != 3)
abort ();
x = 5;
y = 4;
}
#pragma omp task shared (z) depend(inout: z)
{
if (z != 3)
abort ();
z = 4;
}
#pragma omp task shared (z) depend(inout: z)
{
if (z != 4)
abort ();
z = 5;
}
#pragma omp taskwait
if (x != (ifval ? 4 : 5) || y != (ifval ? 3 : 4) || z != 5)
abort ();
#pragma omp task if (ifval) shared (x, y) depend(in: x) depend(inout: y)
{
if (x != (ifval ? 4 : 5) || y != (ifval ? 3 : 4))
abort ();
}
}
}
int
main ()
{
f1 (0);
f1 (1);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment