Browse Source

omp: use flags for storing implicit/final/untied/undeferred bits

This saves 12 octets for each OpenMP tasks.
Samuel Pitoiset 9 years ago
parent
commit
2fd5021be3

+ 3 - 3
src/datawizard/interfaces/data_interface.c

@@ -153,7 +153,7 @@ void _starpu_data_register_ram_pointer(starpu_data_handle_t handle, void *ptr)
 	struct starpu_omp_task *task = _starpu_omp_get_task();
 	if (task)
 	{
-		if (task->is_implicit)
+		if (task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT)
 		{
 			struct starpu_omp_region *parallel_region = task->owner_region;
 			_starpu_spin_lock(&parallel_region->registered_handles_lock);
@@ -182,7 +182,7 @@ starpu_data_handle_t starpu_data_lookup(const void *ptr)
 	struct starpu_omp_task *task = _starpu_omp_get_task();
 	if (task)
 	{
-		if (task->is_implicit)
+		if (task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT)
 		{
 			struct starpu_omp_region *parallel_region = task->owner_region;
 			_starpu_spin_lock(&parallel_region->registered_handles_lock);
@@ -509,7 +509,7 @@ void _starpu_data_unregister_ram_pointer(starpu_data_handle_t handle)
 		struct starpu_omp_task *task = _starpu_omp_get_task();
 		if (task)
 		{
-			if (task->is_implicit)
+			if (task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT)
 			{
 				struct starpu_omp_region *parallel_region = task->owner_region;
 				_starpu_spin_lock(&parallel_region->registered_handles_lock);

+ 25 - 18
src/util/openmp_runtime_support.c

@@ -351,7 +351,7 @@ static void destroy_omp_thread_struct(struct starpu_omp_thread *thread)
 
 static void starpu_omp_explicit_task_entry(struct starpu_omp_task *task)
 {
-	STARPU_ASSERT(!task->is_implicit);
+	STARPU_ASSERT(!(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT));
 	struct _starpu_worker *starpu_worker = _starpu_get_local_worker_key();
 	if (starpu_worker->arch == STARPU_CPU_WORKER)
 	{
@@ -389,7 +389,7 @@ static void starpu_omp_explicit_task_entry(struct starpu_omp_task *task)
 static void starpu_omp_implicit_task_entry(struct starpu_omp_task *task)
 {
 	struct starpu_omp_thread *thread = _starpu_omp_get_thread();
-	STARPU_ASSERT(task->is_implicit);
+	STARPU_ASSERT(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT);
 	task->cpu_f(task->starpu_buffers, task->starpu_cl_arg);
 	starpu_omp_barrier();
 	if (thread == task->owner_region->master_thread)
@@ -431,7 +431,7 @@ static void starpu_omp_task_preempt(void)
 static void starpu_omp_implicit_task_exec(void *buffers[], void *cl_arg)
 {
 	struct starpu_omp_task *task = starpu_task_get_current()->omp_task;
-	STARPU_ASSERT(task->is_implicit);
+	STARPU_ASSERT(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT);
 	_starpu_omp_set_task(task);
 	struct starpu_omp_thread *thread = get_local_thread();
 	if (task->state != starpu_omp_task_state_preempted)
@@ -492,7 +492,7 @@ static void starpu_omp_task_completion_accounting(struct starpu_omp_task *task)
 	{
 		if (parent_task->state == starpu_omp_task_state_zombie)
 		{
-			STARPU_ASSERT(!parent_task->is_implicit);
+			STARPU_ASSERT(!(parent_task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT));
 			weak_task_unlock(parent_task);
 			destroy_omp_task_struct(parent_task);
 		}
@@ -560,7 +560,7 @@ static void starpu_omp_task_completion_accounting(struct starpu_omp_task *task)
 static void starpu_omp_explicit_task_exec(void *buffers[], void *cl_arg)
 {
 	struct starpu_omp_task *task = starpu_task_get_current()->omp_task;
-	STARPU_ASSERT(!task->is_implicit);
+	STARPU_ASSERT(!(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT));
 	_starpu_omp_set_task(task);
 
 	struct starpu_omp_thread *thread = get_local_thread();
@@ -600,7 +600,7 @@ static void starpu_omp_explicit_task_exec(void *buffers[], void *cl_arg)
 			}
 		}
 		STARPU_ASSERT(thread != NULL);
-		if (!task->is_untied)
+		if (!(task->flags & STARPU_OMP_TASK_FLAGS_UNTIED))
 		{
 			struct _starpu_worker *starpu_worker = _starpu_get_local_worker_key();
 			task->starpu_task->workerid = starpu_worker->workerid;
@@ -659,7 +659,10 @@ static struct starpu_omp_task *create_omp_task_struct(struct starpu_omp_task *pa
 	task->parent_task = parent_task;
 	task->owner_thread = owner_thread;
 	task->owner_region = owner_region;
-	task->is_implicit = is_implicit;
+	if (is_implicit)
+	{
+		task->flags |= STARPU_OMP_TASK_FLAGS_IMPLICIT;
+	}
 	_starpu_spin_init(&task->lock);
 	/* TODO: initialize task->data_env_icvs with proper values */ 
 	memset(&task->data_env_icvs, 0, sizeof(task->data_env_icvs));
@@ -1243,7 +1246,7 @@ void starpu_omp_barrier(void)
 {
 	struct starpu_omp_task *task = _starpu_omp_get_task();
 	/* Assume barriers are performed in by the implicit tasks of a parallel_region */
-	STARPU_ASSERT(task->is_implicit);
+	STARPU_ASSERT(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT);
 	struct starpu_omp_region *parallel_region = task->owner_region;
 	_starpu_spin_lock(&task->lock);
 	int inc_barrier_count = STARPU_ATOMIC_ADD(&parallel_region->barrier_count, 1);
@@ -1305,7 +1308,7 @@ int starpu_omp_master_inline(void)
 	struct starpu_omp_task *task = _starpu_omp_get_task();
 	struct starpu_omp_thread *thread = _starpu_omp_get_thread();
 	/* Assume master is performed in by the implicit tasks of a region */
-	STARPU_ASSERT(task->is_implicit);
+	STARPU_ASSERT(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT);
 	struct starpu_omp_region *region = task->owner_region;
 
 	return thread == region->master_thread;
@@ -1327,7 +1330,7 @@ int starpu_omp_single_inline(void)
 {
 	struct starpu_omp_task *task = _starpu_omp_get_task();
 	/* Assume singles are performed in by the implicit tasks of a region */
-	STARPU_ASSERT(task->is_implicit);
+	STARPU_ASSERT(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT);
 	struct starpu_omp_region *region = task->owner_region;
 	int first = STARPU_BOOL_COMPARE_AND_SWAP(&region->single_id, task->single_id, task->single_id+1);
 	task->single_id++;
@@ -1373,7 +1376,7 @@ void starpu_omp_single_copyprivate_inline_end(void)
 {
 	struct starpu_omp_task *task = _starpu_omp_get_task();
 	/* Assume singles are performed in by the implicit tasks of a region */
-	STARPU_ASSERT(task->is_implicit);
+	STARPU_ASSERT(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT);
 	if (task->single_first)
 	{
 		task->single_first = 0;
@@ -1467,7 +1470,7 @@ void starpu_omp_critical_inline_end(const char *name)
 static void explicit_task__destroy_callback(void *_task)
 {
 	struct starpu_omp_task *task = _task;
-	STARPU_ASSERT(!task->is_implicit);
+	STARPU_ASSERT(!(task->flags & STARPU_OMP_TASK_FLAGS_IMPLICIT));
 	task->starpu_task->omp_task = NULL;
 	task->starpu_task = NULL;
 	_starpu_spin_lock(&task->lock);
@@ -1494,14 +1497,13 @@ void starpu_omp_task_region(const struct starpu_omp_task_region_attr *attr)
 	int is_final = 0;
 	int is_included = 0;
 	int is_merged = 0;
-	int is_untied = 0;
 	int ret;
 
 	if (!attr->if_clause)
 	{
 		is_undeferred = 1;
 	}
-	if (generating_task->is_final)
+	if (generating_task->flags & STARPU_OMP_TASK_FLAGS_FINAL)
 	{
 		is_final = 1;
 		is_included = 1;
@@ -1566,11 +1568,16 @@ void starpu_omp_task_region(const struct starpu_omp_task_region_attr *attr)
 		generated_task->cl = attr->cl;
 		if (attr->untied_clause)
 		{
-			is_untied = 1;
+			generated_task->flags |= STARPU_OMP_TASK_FLAGS_UNTIED;
+		}
+		if (is_final)
+		{
+			generated_task->flags |= STARPU_OMP_TASK_FLAGS_FINAL;
+		}
+		if (is_undeferred)
+		{
+			generated_task->flags |= STARPU_OMP_TASK_FLAGS_UNDEFERRED;
 		}
-		generated_task->is_undeferred = is_undeferred;
-		generated_task->is_final = is_final;
-		generated_task->is_untied = is_untied;
 		generated_task->task_group = generating_task->task_group;
 		generated_task->rank = -1;
 

+ 9 - 4
src/util/openmp_runtime_support.h

@@ -194,16 +194,20 @@ enum starpu_omp_task_wait_on
 	starpu_omp_task_wait_on_condition    = 1 << 5
 };
 
+enum starpu_omp_task_flags
+{
+	STARPU_OMP_TASK_FLAGS_IMPLICIT	     = 1 << 0,
+	STARPU_OMP_TASK_FLAGS_UNDEFERRED     = 1 << 1,
+	STARPU_OMP_TASK_FLAGS_FINAL	     = 1 << 2,
+	STARPU_OMP_TASK_FLAGS_UNTIED	     = 1 << 3,
+};
+
 LIST_TYPE(starpu_omp_task,
 	struct starpu_omp_implicit_task_icvs icvs;
 	struct starpu_omp_task *parent_task;
 	struct starpu_omp_thread *owner_thread;
 	struct starpu_omp_region *owner_region;
 	struct starpu_omp_region *nested_region;
-	int is_implicit;
-	int is_undeferred;
-	int is_final;
-	int is_untied;
 	int rank;
 	int child_task_count;
 	struct starpu_omp_task_group *task_group;
@@ -236,6 +240,7 @@ LIST_TYPE(starpu_omp_task,
 #endif
 
 	enum starpu_omp_task_state state;
+	enum starpu_omp_task_flags flags;
 
 	/* 
 	 * context to store the processing state of the task

+ 1 - 1
src/util/openmp_runtime_support_omp_api.c

@@ -208,7 +208,7 @@ int starpu_omp_get_active_level (void)
 int starpu_omp_in_final(void)
 {
 	const struct starpu_omp_task *task = _starpu_omp_get_task();
-	return task->is_final;
+	return task->flags & STARPU_OMP_TASK_FLAGS_FINAL;
 }
 
 enum starpu_omp_proc_bind_value starpu_omp_get_proc_bind(void)