Przeglądaj źródła

Fix multiple partitioning planning of the same data: they share the same switching codelet, but may have varying nparts

Samuel Thibault 8 lat temu
rodzic
commit
9aa325e691
2 zmienionych plików z 12 dodań i 4 usunięć
  1. 2 0
      src/datawizard/coherency.h
  2. 10 4
      src/datawizard/filters.c

+ 2 - 0
src/datawizard/coherency.h

@@ -152,6 +152,8 @@ struct _starpu_data_state
 	unsigned nplans;
 	unsigned nplans;
 	/* Switch codelet for asynchronous partitioning */
 	/* Switch codelet for asynchronous partitioning */
 	struct starpu_codelet *switch_cl;
 	struct starpu_codelet *switch_cl;
+	/* size of dyn_nodes recorded in switch_cl */
+	int switch_cl_nparts;
 	/* Whether a partition plan is currently submitted and the
 	/* Whether a partition plan is currently submitted and the
 	 * corresponding unpartition has not been yet
 	 * corresponding unpartition has not been yet
 	 *
 	 *

+ 10 - 4
src/datawizard/filters.c

@@ -511,22 +511,28 @@ void starpu_data_partition_plan(starpu_data_handle_t initial_handle, struct star
 	unsigned nparts = _starpu_data_partition_nparts(initial_handle, f);
 	unsigned nparts = _starpu_data_partition_nparts(initial_handle, f);
 	STARPU_ASSERT_MSG(initial_handle->nchildren == 0, "partition planning and synchronous partitioning is not supported");
 	STARPU_ASSERT_MSG(initial_handle->nchildren == 0, "partition planning and synchronous partitioning is not supported");
 	STARPU_ASSERT_MSG(initial_handle->sequential_consistency, "partition planning is currently only supported for data with sequential consistency");
 	STARPU_ASSERT_MSG(initial_handle->sequential_consistency, "partition planning is currently only supported for data with sequential consistency");
+	struct starpu_codelet *cl = initial_handle->switch_cl;
 
 
 	for (i = 0; i < nparts; i++)
 	for (i = 0; i < nparts; i++)
 		childrenp[i] = calloc(1, sizeof(struct _starpu_data_state));
 		childrenp[i] = calloc(1, sizeof(struct _starpu_data_state));
 	_starpu_data_partition(initial_handle, childrenp, nparts, f, 0);
 	_starpu_data_partition(initial_handle, childrenp, nparts, f, 0);
 
 
-	if (!initial_handle->switch_cl)
+	if (!cl)
 	{
 	{
 		/* Create a codelet that will make the coherency on the home node */
 		/* Create a codelet that will make the coherency on the home node */
-		struct starpu_codelet *cl = initial_handle->switch_cl = calloc(1, sizeof(*initial_handle->switch_cl));
+		cl = initial_handle->switch_cl = calloc(1, sizeof(*initial_handle->switch_cl));
 		cl->where = STARPU_NOWHERE;
 		cl->where = STARPU_NOWHERE;
 		cl->nbuffers = STARPU_VARIABLE_NBUFFERS;
 		cl->nbuffers = STARPU_VARIABLE_NBUFFERS;
 		cl->name = "data_partition_switch";
 		cl->name = "data_partition_switch";
 		cl->specific_nodes = 1;
 		cl->specific_nodes = 1;
-		cl->dyn_nodes = malloc((nparts+1) * sizeof(*cl->dyn_nodes));
-		for (i = 0; i < nparts+1; i++)
+	}
+	if (initial_handle->switch_cl_nparts < nparts)
+	{
+		/* First initialization, or previous initialization was with fewer parts, enlarge it */
+		cl->dyn_nodes = realloc(cl->dyn_nodes, (nparts+1) * sizeof(*cl->dyn_nodes));
+		for (i = initial_handle->switch_cl_nparts; i < nparts+1; i++)
 			cl->dyn_nodes[i] = initial_handle->home_node;
 			cl->dyn_nodes[i] = initial_handle->home_node;
+		initial_handle->switch_cl_nparts = nparts;
 	}
 	}
 }
 }