浏览代码

mpi: Improve default node selection: take into account the writeback cost

Samuel Thibault 5 年之前
父节点
当前提交
ab3c5fa753
共有 3 个文件被更改,包括 14 次插入10 次删除
  1. 11 7
      mpi/src/starpu_mpi_select_node.c
  2. 2 2
      mpi/tests/policy_selection.c
  3. 1 1
      mpi/tests/policy_selection2.c

+ 11 - 7
mpi/src/starpu_mpi_select_node.c

@@ -28,13 +28,13 @@ static int _current_policy = STARPU_MPI_NODE_SELECTION_MOST_R_DATA;
 static int _last_predefined_policy = STARPU_MPI_NODE_SELECTION_MOST_R_DATA;
 static starpu_mpi_select_node_policy_func_t _policies[_STARPU_MPI_NODE_SELECTION_MAX_POLICY];
 
-int _starpu_mpi_select_node_with_most_R_data(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data);
+int _starpu_mpi_select_node_with_most_data(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data);
 
 void _starpu_mpi_select_node_init()
 {
 	int i;
 
-	_policies[STARPU_MPI_NODE_SELECTION_MOST_R_DATA] = _starpu_mpi_select_node_with_most_R_data;
+	_policies[STARPU_MPI_NODE_SELECTION_MOST_R_DATA] = _starpu_mpi_select_node_with_most_data;
 	for(i=_last_predefined_policy+1 ; i<_STARPU_MPI_NODE_SELECTION_MAX_POLICY ; i++)
 		_policies[i] = NULL;
 }
@@ -73,7 +73,7 @@ int starpu_mpi_node_selection_unregister_policy(int policy)
 	return 0;
 }
 
-int _starpu_mpi_select_node_with_most_R_data(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data)
+int _starpu_mpi_select_node_with_most_data(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data)
 {
 	size_t *size_on_nodes;
 	size_t max_size;
@@ -87,11 +87,15 @@ int _starpu_mpi_select_node_with_most_R_data(int me, int nb_nodes, struct starpu
 	{
 		starpu_data_handle_t data = descr[i].handle;
 		enum starpu_data_access_mode mode = descr[i].mode;
+		int rank = starpu_data_get_rank(data);
+		size_t size = data->ops->get_size(data);
+
 		if (mode & STARPU_R)
-		{
-			int rank = starpu_data_get_rank(data);
-			size_on_nodes[rank] += data->ops->get_size(data);
-		}
+			size_on_nodes[rank] += size;
+
+		if (mode & STARPU_W)
+			/* Would have to transfer it back */
+			size_on_nodes[rank] += size;
 	}
 
 	max_size = 0;

+ 2 - 2
mpi/tests/policy_selection.c

@@ -138,9 +138,9 @@ int main(int argc, char **argv)
 				     STARPU_W, handles[0], STARPU_W, handles[1],
 				     0);
 	FPRINTF_MPI(stderr, "Task %p\n", task);
-	if (rank == 2)
+	if (rank == 0)
 	{
-		STARPU_ASSERT_MSG(task, "Task should be executed by rank 2\n");
+		STARPU_ASSERT_MSG(task, "Task should be executed by rank 0\n");
 		task->destroy = 0;
 		starpu_task_destroy(task);
 	}

+ 1 - 1
mpi/tests/policy_selection2.c

@@ -88,7 +88,7 @@ int main(int argc, char **argv)
 	FPRINTF_MPI(stderr, "data[%d,%d,%d] = %d,%d,%d\n", 0, 1, 2, data[0], data[1], data[2]);
 	for(i=0 ; i<2 ; i++) starpu_data_release(handles[i]);
 #ifndef STARPU_SIMGRID
-	if (rank == 2)
+	if (rank == 0)
 	{
 		STARPU_ASSERT_MSG(data[0] == 2*data[2] && data[1] == 2*data[2], "Computation incorrect. data[%d] (%d) != 2*data[%d] (%d) && data[%d] (%d) != 2*data[%d] (%d)\n",
 				  0, data[0], 2, data[2], 1, data[1], 2, data[2]);