Browse Source

mpi: the node selection policy is stored as an integer instead of a char*

Nathalie Furmento 10 years ago
parent
commit
cad01b97cd

+ 5 - 5
doc/doxygen/chapters/api/mpi.doxy

@@ -278,7 +278,7 @@ The internal algorithm is as follows:
         Find out which MPI node is going to execute the codelet.
         Find out which MPI node is going to execute the codelet.
         <ul>
         <ul>
             <li>If there is only one node owning data in ::STARPU_W mode, it will be selected;
             <li>If there is only one node owning data in ::STARPU_W mode, it will be selected;
-            <li>If there is several nodes owning data in ::STARPU_W node, a node will be selected according to a given node selection policy (see ::STARPU_NODE_SELECTION_POLICY or starpu_mpi_node_selection_set_default_policy())
+            <li>If there is several nodes owning data in ::STARPU_W node, a node will be selected according to a given node selection policy (see ::STARPU_NODE_SELECTION_POLICY or starpu_mpi_node_selection_set_current_policy())
             <li>The argument ::STARPU_EXECUTE_ON_NODE followed by an integer can be used to specify the node;
             <li>The argument ::STARPU_EXECUTE_ON_NODE followed by an integer can be used to specify the node;
             <li>The argument ::STARPU_EXECUTE_ON_DATA followed by a data handle can be used to specify that the node owing the given data will execute the codelet.
             <li>The argument ::STARPU_EXECUTE_ON_DATA followed by a data handle can be used to specify that the node owing the given data will execute the codelet.
         </ul>
         </ul>
@@ -327,13 +327,13 @@ owner if needed. At least the target node and the owner have to call
 the function. On reception, the \p callback function is called with
 the function. On reception, the \p callback function is called with
 the argument \p arg.
 the argument \p arg.
 
 
-\fn char *starpu_mpi_node_selection_get_default_policy()
+\fn int starpu_mpi_node_selection_get_current_policy()
 \ingroup API_MPI_Support
 \ingroup API_MPI_Support
-Return the current default policy used to select the node which will execute the codelet
+Return the current policy used to select the node which will execute the codelet
 
 
-\fn int starpu_mpi_node_selection_set_default_policy(char *policy)
+\fn int starpu_mpi_node_selection_set_current_policy(int policy)
 \ingroup API_MPI_Support
 \ingroup API_MPI_Support
-Set the current default policy used to select the node which will
+Set the current policy used to select the node which will
 execute the codelet. The policy "node_with_most_R_data" selects the
 execute the codelet. The policy "node_with_most_R_data" selects the
 node having the most data in R mode so as to minimize the amount of
 node having the most data in R mode so as to minimize the amount of
 data to be transfered.
 data to be transfered.

+ 5 - 2
mpi/include/starpu_mpi.h

@@ -82,8 +82,11 @@ void starpu_mpi_set_communication_tag(int tag);
 
 
 void starpu_mpi_data_register(starpu_data_handle_t data_handle, int tag, int rank);
 void starpu_mpi_data_register(starpu_data_handle_t data_handle, int tag, int rank);
 
 
-char *starpu_mpi_node_selection_get_default_policy();
-int starpu_mpi_node_selection_set_default_policy(char *policy);
+#define STARPU_MPI_NODE_SELECTION_CURRENT_POLICY 0
+#define STARPU_MPI_NODE_SELECTION_MOST_R_DATA    1
+
+int starpu_mpi_node_selection_get_current_policy();
+int starpu_mpi_node_selection_set_current_policy(int policy);
 
 
 int starpu_mpi_cache_is_enabled();
 int starpu_mpi_cache_is_enabled();
 int starpu_mpi_cache_set(int enabled);
 int starpu_mpi_cache_set(int enabled);

+ 13 - 12
mpi/src/starpu_mpi_select_node.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2014  Centre National de la Recherche Scientifique
+ * Copyright (C) 2014, 2015  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
  * it under the terms of the GNU Lesser General Public License as published by
@@ -24,16 +24,19 @@
 #include <starpu_mpi_task_insert.h>
 #include <starpu_mpi_task_insert.h>
 #include <datawizard/coherency.h>
 #include <datawizard/coherency.h>
 
 
-static char *_default_policy = "node_with_most_R_data";
+static int _current_policy = STARPU_MPI_NODE_SELECTION_MOST_R_DATA;
 
 
-char *starpu_mpi_node_selection_get_default_policy()
+int starpu_mpi_node_selection_get_current_policy()
 {
 {
-	return _default_policy;
+	return _current_policy;
 }
 }
 
 
-int starpu_mpi_node_selection_set_default_policy(char *policy)
+int starpu_mpi_node_selection_set_current_policy(int policy)
 {
 {
-	strcpy(_default_policy, policy);
+#ifdef STARPU_DEVEL
+#warning need to check the policy is valid
+#endif
+	_current_policy = policy;
 	return 0;
 	return 0;
 }
 }
 
 
@@ -71,13 +74,11 @@ int _starpu_mpi_select_node_with_most_R_data(int me, int nb_nodes, struct starpu
 	return xrank;
 	return xrank;
 }
 }
 
 
-int _starpu_mpi_select_node(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data, char *policy)
+int _starpu_mpi_select_node(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data, int policy)
 {
 {
-	char *current_policy = policy ? policy : _default_policy;
-	if (current_policy == NULL)
-		STARPU_ABORT_MSG("Node selection policy MUST be defined\n");
-	if (strcmp(current_policy, "node_with_most_R_data") == 0)
+	int current_policy = policy == STARPU_MPI_NODE_SELECTION_CURRENT_POLICY ? _current_policy : policy;
+	if (current_policy == STARPU_MPI_NODE_SELECTION_MOST_R_DATA)
 		return _starpu_mpi_select_node_with_most_R_data(me, nb_nodes, descr, nb_data);
 		return _starpu_mpi_select_node_with_most_R_data(me, nb_nodes, descr, nb_data);
 	else
 	else
-		STARPU_ABORT_MSG("Node selection policy <%s> unknown\n", current_policy);
+		STARPU_ABORT_MSG("Node selection policy <%d> unknown\n", current_policy);
 }
 }

+ 2 - 2
mpi/src/starpu_mpi_select_node.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2014  Centre National de la Recherche Scientifique
+ * Copyright (C) 2014, 2015  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
  * it under the terms of the GNU Lesser General Public License as published by
@@ -23,7 +23,7 @@
 extern "C" {
 extern "C" {
 #endif
 #endif
 
 
-int _starpu_mpi_select_node(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data, char *policy);
+int _starpu_mpi_select_node(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data, int policy);
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }

+ 2 - 2
mpi/src/starpu_mpi_task_insert.c

@@ -209,7 +209,7 @@ int _starpu_mpi_task_decode_v(struct starpu_codelet *codelet, int me, int nb_nod
 	int nb_allocated_data = 16;
 	int nb_allocated_data = 16;
 	struct starpu_data_descr *descrs;
 	struct starpu_data_descr *descrs;
 	int nb_data;
 	int nb_data;
-	char *select_node_policy = NULL;
+	int select_node_policy = STARPU_MPI_NODE_SELECTION_CURRENT_POLICY;
 
 
 	descrs = (struct starpu_data_descr *)malloc(nb_allocated_data * sizeof(struct starpu_data_descr));
 	descrs = (struct starpu_data_descr *)malloc(nb_allocated_data * sizeof(struct starpu_data_descr));
 	nb_data = 0;
 	nb_data = 0;
@@ -388,7 +388,7 @@ int _starpu_mpi_task_decode_v(struct starpu_codelet *codelet, int me, int nb_nod
 		}
 		}
 		else if (arg_type==STARPU_NODE_SELECTION_POLICY)
 		else if (arg_type==STARPU_NODE_SELECTION_POLICY)
 		{
 		{
-			select_node_policy = va_arg(varg_list, char *);
+			select_node_policy = va_arg(varg_list, int);
 		}
 		}
 		else
 		else
 		{
 		{

+ 3 - 3
src/util/starpu_task_insert_utils.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2011, 2013-2015   Université Bordeaux
  * Copyright (C) 2011, 2013-2015   Université Bordeaux
- * Copyright (C) 2011-2014         Centre National de la Recherche Scientifique
+ * Copyright (C) 2011-2015         Centre National de la Recherche Scientifique
  * Copyright (C) 2011, 2014        INRIA
  * Copyright (C) 2011, 2014        INRIA
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -156,7 +156,7 @@ int _starpu_codelet_pack_args(void **arg_buffer, size_t *arg_buffer_size, va_lis
 		}
 		}
 		else if (arg_type==STARPU_NODE_SELECTION_POLICY)
 		else if (arg_type==STARPU_NODE_SELECTION_POLICY)
 		{
 		{
-			(void)va_arg(varg_list, char *);
+			(void)va_arg(varg_list, int);
 		}
 		}
 		else
 		else
 		{
 		{
@@ -446,7 +446,7 @@ void _starpu_task_insert_create(struct starpu_codelet *cl, struct starpu_task **
 		}
 		}
 		else if (arg_type==STARPU_NODE_SELECTION_POLICY)
 		else if (arg_type==STARPU_NODE_SELECTION_POLICY)
 		{
 		{
-			(void)va_arg(varg_list, char *);
+			(void)va_arg(varg_list, int);
 		}
 		}
 		else
 		else
 		{
 		{