Browse Source

- add more insert_task modes

Olivier Aumage 8 years ago
parent
commit
f49e1863b5
2 changed files with 217 additions and 0 deletions
  1. 47 0
      include/fstarpu_mod.f90
  2. 170 0
      src/util/fstarpu.c

+ 47 - 0
include/fstarpu_mod.f90

@@ -29,6 +29,29 @@ module fstarpu_mod
         type(c_ptr), bind(C) :: FSTARPU_SSEND
         type(c_ptr), bind(C) :: FSTARPU_LOCALITY
 
+        type(c_ptr), bind(C) :: FSTARPU_DATA_ARRAY
+        type(c_ptr), bind(C) :: FSTARPU_DATA_MODE_ARRAY
+        type(c_ptr), bind(C) :: FSTARPU_CL_ARGS
+        type(c_ptr), bind(C) :: FSTARPU_CALLBACK
+        type(c_ptr), bind(C) :: FSTARPU_CALLBACK_WITH_ARG
+        type(c_ptr), bind(C) :: FSTARPU_CALLBACK_ARG
+        type(c_ptr), bind(C) :: FSTARPU_PROLOGUE_CALLBACK
+        type(c_ptr), bind(C) :: FSTARPU_PROLOGUE_CALLBACK_ARG
+        type(c_ptr), bind(C) :: FSTARPU_PROLOGUE_CALLBACK_POP
+        type(c_ptr), bind(C) :: FSTARPU_PROLOGUE_CALLBACK_POP_ARG
+        type(c_ptr), bind(C) :: FSTARPU_PRIORITY
+        type(c_ptr), bind(C) :: FSTARPU_EXECUTE_ON_NODE
+        type(c_ptr), bind(C) :: FSTARPU_EXECUTE_ON_DATA
+        type(c_ptr), bind(C) :: FSTARPU_EXECUTE_ON_WORKER
+        type(c_ptr), bind(C) :: FSTARPU_WORKER_ORDER
+        type(c_ptr), bind(C) :: FSTARPU_HYPERVISOR_TAG
+        type(c_ptr), bind(C) :: FSTARPU_POSSIBLY_PARALLEL
+        type(c_ptr), bind(C) :: FSTARPU_FLOPS
+        type(c_ptr), bind(C) :: FSTARPU_TAG
+        type(c_ptr), bind(C) :: FSTARPU_TAG_ONLY
+        type(c_ptr), bind(C) :: FSTARPU_NAME
+        type(c_ptr), bind(C) :: FSTARPU_NODE_SELECTION_POLICY
+
         type(c_ptr), bind(C) :: FSTARPU_VALUE
         type(c_ptr), bind(C) :: FSTARPU_SCHED_CTX
 
@@ -1518,6 +1541,30 @@ module fstarpu_mod
                         FSTARPU_SSEND   = fstarpu_get_constant(C_CHAR_"FSTARPU_SSEND"//C_NULL_CHAR)
                         FSTARPU_LOCALITY   = fstarpu_get_constant(C_CHAR_"FSTARPU_LOCALITY"//C_NULL_CHAR)
 
+                        FSTARPU_DATA_ARRAY      = fstarpu_get_constant(C_CHAR_"FSTARPU_DATA_ARRAY"//C_NULL_CHAR)
+                        FSTARPU_DATA_MODE_ARRAY = fstarpu_get_constant(C_CHAR_"FSTARPU_DATA_MODE_ARRAY"//C_NULL_CHAR)
+                        FSTARPU_CL_ARGS = fstarpu_get_constant(C_CHAR_"FSTARPU_CL_ARGS"//C_NULL_CHAR)
+                        FSTARPU_CALLBACK        = fstarpu_get_constant(C_CHAR_"FSTARPU_CALLBACK"//C_NULL_CHAR)
+                        FSTARPU_CALLBACK_WITH_ARG       = fstarpu_get_constant(C_CHAR_"FSTARPU_CALLBACK_WITH_ARG"//C_NULL_CHAR)
+                        FSTARPU_CALLBACK_ARG    = fstarpu_get_constant(C_CHAR_"FSTARPU_CALLBACK_ARG"//C_NULL_CHAR)
+                        FSTARPU_PROLOGUE_CALLBACK       = fstarpu_get_constant(C_CHAR_"FSTARPU_PROLOGUE_CALLBACK"//C_NULL_CHAR)
+                        FSTARPU_PROLOGUE_CALLBACK_ARG   = fstarpu_get_constant(C_CHAR_"FSTARPU_PROLOGUE_CALLBACK_ARG"//C_NULL_CHAR)
+                        FSTARPU_PROLOGUE_CALLBACK_POP   = fstarpu_get_constant(C_CHAR_"FSTARPU_PROLOGUE_CALLBACK_POP"//C_NULL_CHAR)
+                        FSTARPU_PROLOGUE_CALLBACK_POP_ARG       = &
+                                fstarpu_get_constant(C_CHAR_"FSTARPU_PROLOGUE_CALLBACK_POP_ARG"//C_NULL_CHAR)
+                        FSTARPU_PRIORITY        = fstarpu_get_constant(C_CHAR_"FSTARPU_PRIORITY"//C_NULL_CHAR)
+                        FSTARPU_EXECUTE_ON_NODE = fstarpu_get_constant(C_CHAR_"FSTARPU_EXECUTE_ON_NODE"//C_NULL_CHAR)
+                        FSTARPU_EXECUTE_ON_DATA = fstarpu_get_constant(C_CHAR_"FSTARPU_EXECUTE_ON_DATA"//C_NULL_CHAR)
+                        FSTARPU_EXECUTE_ON_WORKER       = fstarpu_get_constant(C_CHAR_"FSTARPU_EXECUTE_ON_WORKER"//C_NULL_CHAR)
+                        FSTARPU_WORKER_ORDER    = fstarpu_get_constant(C_CHAR_"FSTARPU_WORKER_ORDER"//C_NULL_CHAR)
+                        FSTARPU_HYPERVISOR_TAG  = fstarpu_get_constant(C_CHAR_"FSTARPU_HYPERVISOR_TAG"//C_NULL_CHAR)
+                        FSTARPU_POSSIBLY_PARALLEL       = fstarpu_get_constant(C_CHAR_"FSTARPU_POSSIBLY_PARALLEL"//C_NULL_CHAR)
+                        FSTARPU_FLOPS   = fstarpu_get_constant(C_CHAR_"FSTARPU_FLOPS"//C_NULL_CHAR)
+                        FSTARPU_TAG     = fstarpu_get_constant(C_CHAR_"FSTARPU_TAG"//C_NULL_CHAR)
+                        FSTARPU_TAG_ONLY        = fstarpu_get_constant(C_CHAR_"FSTARPU_TAG_ONLY"//C_NULL_CHAR)
+                        FSTARPU_NAME    = fstarpu_get_constant(C_CHAR_"FSTARPU_NAME"//C_NULL_CHAR)
+                        FSTARPU_NODE_SELECTION_POLICY   = fstarpu_get_constant(C_CHAR_"FSTARPU_NODE_SELECTION_POLICY"//C_NULL_CHAR)
+
                         FSTARPU_VALUE   = fstarpu_get_constant(C_CHAR_"FSTARPU_VALUE"//C_NULL_CHAR)
                         FSTARPU_SCHED_CTX   = fstarpu_get_constant(C_CHAR_"FSTARPU_SCHED_CTX"//C_NULL_CHAR)
                         FSTARPU_CPU_WORKER   = fstarpu_get_constant(C_CHAR_"FSTARPU_CPU_WORKER"//C_NULL_CHAR)

+ 170 - 0
src/util/fstarpu.c

@@ -21,6 +21,8 @@
 
 #define _FSTARPU_ERROR(msg) do {fprintf(stderr, "fstarpu error: %s\n", (msg));abort();} while(0)
 
+typedef void (*_starpu_callback_func_t)(void *);
+
 static const intptr_t fstarpu_r	= STARPU_R;
 static const intptr_t fstarpu_w	= STARPU_W;
 static const intptr_t fstarpu_rw	= STARPU_RW;
@@ -30,6 +32,29 @@ static const intptr_t fstarpu_commute	= STARPU_COMMUTE;
 static const intptr_t fstarpu_ssend	= STARPU_SSEND;
 static const intptr_t fstarpu_locality	= STARPU_LOCALITY;
 
+static const intptr_t fstarpu_data_array	= STARPU_DATA_ARRAY;
+static const intptr_t fstarpu_data_mode_array	= STARPU_DATA_MODE_ARRAY;
+static const intptr_t fstarpu_cl_args	= STARPU_CL_ARGS;
+static const intptr_t fstarpu_callback	= STARPU_CALLBACK;
+static const intptr_t fstarpu_callback_with_arg	= STARPU_CALLBACK_WITH_ARG;
+static const intptr_t fstarpu_callback_arg	= STARPU_CALLBACK_ARG;
+static const intptr_t fstarpu_prologue_callback	= STARPU_PROLOGUE_CALLBACK;
+static const intptr_t fstarpu_prologue_callback_arg	= STARPU_PROLOGUE_CALLBACK_ARG;
+static const intptr_t fstarpu_prologue_callback_pop	= STARPU_PROLOGUE_CALLBACK_POP;
+static const intptr_t fstarpu_prologue_callback_pop_arg	= STARPU_PROLOGUE_CALLBACK_POP_ARG;
+static const intptr_t fstarpu_priority	= STARPU_PRIORITY;
+static const intptr_t fstarpu_execute_on_node	= STARPU_EXECUTE_ON_NODE;
+static const intptr_t fstarpu_execute_on_data	= STARPU_EXECUTE_ON_DATA;
+static const intptr_t fstarpu_execute_on_worker	= STARPU_EXECUTE_ON_WORKER;
+static const intptr_t fstarpu_worker_order	= STARPU_WORKER_ORDER;
+static const intptr_t fstarpu_hypervisor_tag	= STARPU_HYPERVISOR_TAG;
+static const intptr_t fstarpu_possibly_parallel	= STARPU_POSSIBLY_PARALLEL;
+static const intptr_t fstarpu_flops	= STARPU_FLOPS;
+static const intptr_t fstarpu_tag	= STARPU_TAG;
+static const intptr_t fstarpu_tag_only	= STARPU_TAG_ONLY;
+static const intptr_t fstarpu_name	= STARPU_NAME;
+static const intptr_t fstarpu_node_selection_policy	= STARPU_NODE_SELECTION_POLICY;
+
 static const intptr_t fstarpu_value = STARPU_VALUE;
 static const intptr_t fstarpu_sched_ctx = STARPU_SCHED_CTX;
 
@@ -53,6 +78,29 @@ intptr_t fstarpu_get_constant(char *s)
 	else if	(!strcmp(s, "FSTARPU_SSEND"))	{ return fstarpu_ssend; }
 	else if	(!strcmp(s, "FSTARPU_LOCALITY"))	{ return fstarpu_locality; }
 
+
+	else if	(!strcmp(s, "FSTARPU_DATA_ARRAY"))	{ return fstarpu_data_array; }
+	else if	(!strcmp(s, "FSTARPU_DATA_MODE_ARRAY"))	{ return fstarpu_data_mode_array; }
+	else if	(!strcmp(s, "FSTARPU_CL_ARGS"))	{ return fstarpu_cl_args; }
+	else if	(!strcmp(s, "FSTARPU_CALLBACK"))	{ return fstarpu_callback; }
+	else if	(!strcmp(s, "FSTARPU_CALLBACK_WITH_ARG"))	{ return fstarpu_callback_with_arg; }
+	else if	(!strcmp(s, "FSTARPU_CALLBACK_ARG"))	{ return fstarpu_callback_arg; }
+	else if	(!strcmp(s, "FSTARPU_PROLOGUE_CALLBACK"))	{ return fstarpu_prologue_callback; }
+	else if	(!strcmp(s, "FSTARPU_PROLOGUE_CALLBACK_ARG"))	{ return fstarpu_prologue_callback_arg; }
+	else if	(!strcmp(s, "FSTARPU_PROLOGUE_CALLBACK_POP"))	{ return fstarpu_prologue_callback_pop; }
+	else if	(!strcmp(s, "FSTARPU_PROLOGUE_CALLBACK_POP_ARG"))	{ return fstarpu_prologue_callback_pop_arg; }
+	else if	(!strcmp(s, "FSTARPU_PRIORITY"))	{ return fstarpu_priority; }
+	else if	(!strcmp(s, "FSTARPU_EXECUTE_ON_NODE"))	{ return fstarpu_execute_on_node; }
+	else if	(!strcmp(s, "FSTARPU_EXECUTE_ON_DATA"))	{ return fstarpu_execute_on_data; }
+	else if	(!strcmp(s, "FSTARPU_EXECUTE_ON_WORKER"))	{ return fstarpu_execute_on_worker; }
+	else if	(!strcmp(s, "FSTARPU_WORKER_ORDER"))	{ return fstarpu_worker_order; }
+	else if	(!strcmp(s, "FSTARPU_HYPERVISOR_TAG"))	{ return fstarpu_hypervisor_tag; }
+	else if	(!strcmp(s, "FSTARPU_POSSIBLY_PARALLEL"))	{ return fstarpu_possibly_parallel; }
+	else if	(!strcmp(s, "FSTARPU_FLOPS"))	{ return fstarpu_flops; }
+	else if	(!strcmp(s, "FSTARPU_TAG"))	{ return fstarpu_tag; }
+	else if	(!strcmp(s, "FSTARPU_TAG_ONLY"))	{ return fstarpu_tag_only; }
+	else if	(!strcmp(s, "FSTARPU_NAME"))	{ return fstarpu_name; }
+	else if	(!strcmp(s, "FSTARPU_NODE_SELECTION_POLICY"))	{ return fstarpu_node_selection_policy; }
 	else if (!strcmp(s, "FSTARPU_VALUE"))	{ return fstarpu_value; }
 	else if (!strcmp(s, "FSTARPU_SCHED_CTX"))	{ return fstarpu_sched_ctx; }
 
@@ -435,6 +483,12 @@ void fstarpu_insert_task(void ***_arglist)
 			}
 			current_buffer++;
 		}
+		//else if (arg_type == fstarpu_data_array)
+		//{
+		//}
+		//else if (arg_type == fstarpu_data_mode_array)
+		//{
+		//}
 		else if (arg_type == fstarpu_value)
 		{
 			i++;
@@ -444,11 +498,127 @@ void fstarpu_insert_task(void ***_arglist)
 			nargs++;
 			_starpu_pack_arguments(&current_offset, &arg_buffer_size_, &arg_buffer_, ptr, ptr_size);
 		}
+		else if (arg_type == fstarpu_cl_args)
+		{
+			i++;
+			task->cl_arg = arglist[i];
+			i++;
+			task->cl_arg_size = (size_t)(intptr_t)arglist[i];
+			task->cl_arg_free = 1;
+		}
+		else if (arg_type == fstarpu_callback)
+		{
+			i++;
+			task->callback_func = (_starpu_callback_func_t)arglist[i];
+		}
+		else if (arg_type == fstarpu_callback_with_arg)
+		{
+			i++;
+			task->callback_func = (_starpu_callback_func_t)arglist[i];
+			i++;
+			task->callback_arg = arglist[i];
+		}
+		else if (arg_type == fstarpu_callback_arg)
+		{
+			i++;
+			task->callback_arg = arglist[i];
+		}
+		else if (arg_type == fstarpu_prologue_callback)
+		{
+			i++;
+			task->prologue_callback_func = (_starpu_callback_func_t)arglist[i];
+		}
+		else if (arg_type == fstarpu_prologue_callback_arg)
+		{
+			i++;
+			task->prologue_callback_arg = arglist[i];
+		}
+		else if (arg_type == fstarpu_prologue_callback_pop)
+		{
+			i++;
+			task->prologue_callback_pop_func = (_starpu_callback_func_t)arglist[i];
+		}
+		else if (arg_type == fstarpu_prologue_callback_pop_arg)
+		{
+			i++;
+			task->prologue_callback_pop_arg = arglist[i];
+		}
+		else if (arg_type == fstarpu_priority)
+		{
+			i++;
+			task->priority = *(int *)arglist[i];
+		}
+		else if (arg_type == fstarpu_execute_on_node)
+		{
+			i++;
+			(void)arglist[i];
+		}
+		else if (arg_type == fstarpu_execute_on_data)
+		{
+			i++;
+			(void)arglist[i];
+		}
+		else if (arg_type == fstarpu_execute_on_worker)
+		{
+			i++;
+			int worker = *(int *)arglist[i];
+			if (worker != -1)
+			{
+				task->workerid = worker;
+				task->execute_on_a_specific_worker = 1;
+			}
+		}
+		else if (arg_type == fstarpu_worker_order)
+		{
+			i++;
+			unsigned order = *(unsigned *)arglist[i];
+			if (order != 0)
+			{
+				STARPU_ASSERT_MSG(task->execute_on_a_specific_worker, "worker order only makes sense if a workerid is provided");
+				task->workerorder = order;
+			}
+		}
 		else if (arg_type == fstarpu_sched_ctx)
 		{
 			i++;
 			task->sched_ctx = *(unsigned *)arglist[i];
 		}
+		else if (arg_type == fstarpu_hypervisor_tag)
+		{
+			i++;
+			task->hypervisor_tag = *(int *)arglist[i];
+		}
+		else if (arg_type == fstarpu_possibly_parallel)
+		{
+			i++;
+			task->possibly_parallel = *(unsigned *)arglist[i];
+		}
+		else if (arg_type == fstarpu_flops)
+		{
+			i++;
+			task->flops = *(double *)arglist[i];
+		}
+		else if (arg_type == fstarpu_tag)
+		{
+			i++;
+			task->tag_id = *(starpu_tag_t *)arglist[i];
+			task->use_tag = 1;
+		}
+		else if (arg_type == fstarpu_tag_only)
+		{
+			i++;
+			task->tag_id = *(starpu_tag_t *)arglist[i];
+		}
+		else if (arg_type == fstarpu_name)
+		{
+			i++;
+			task->name = arglist[i];
+		}
+		else if (arg_type == fstarpu_node_selection_policy)
+		{
+			i++;
+			(void)arglist[i];
+		}
 		else
 		{
 			_FSTARPU_ERROR("unknown/unsupported argument type");