Browse Source

make sure StarPU shouts if the rank or tag of a handle used in MPI is not specified

Samuel Thibault 12 years ago
parent
commit
96f476f087

+ 5 - 4
doc/chapters/mpi-support.texi

@@ -311,10 +311,11 @@ static struct starpu_data_interface_ops interface_complex_ops =
 To save the programmer from having to explicit all communications, StarPU
 To save the programmer from having to explicit all communications, StarPU
 provides an "MPI Insert Task Utility". The principe is that the application
 provides an "MPI Insert Task Utility". The principe is that the application
 decides a distribution of the data over the MPI nodes by allocating it and
 decides a distribution of the data over the MPI nodes by allocating it and
-notifying StarPU of that decision, i.e. tell StarPU which MPI node "owns" which
-data. All MPI nodes then process the whole task graph, and StarPU automatically
-determines which node actually execute which task, as well as the required MPI
-transfers.
+notifying StarPU of that decision, i.e. tell StarPU which MPI node "owns"
+which data. It also decides, for each handle, an MPI tag which will be used to
+exchange the content of the handle. All MPI nodes then process the whole task
+graph, and StarPU automatically determines which node actually execute which
+task, and trigger the required MPI transfers.
 
 
 @deftypefun int starpu_data_set_tag (starpu_data_handle_t @var{handle}, int @var{tag})
 @deftypefun int starpu_data_set_tag (starpu_data_handle_t @var{handle}, int @var{tag})
 Tell StarPU-MPI which MPI tag to use when exchanging the data.
 Tell StarPU-MPI which MPI tag to use when exchanging the data.

+ 40 - 2
mpi/src/starpu_mpi_insert_task.c

@@ -113,7 +113,14 @@ void _starpu_mpi_exchange_data_before_execution(starpu_data_handle_t data, enum
 	if (data && mode & STARPU_R) {
 	if (data && mode & STARPU_R) {
 		int mpi_rank = starpu_data_get_rank(data);
 		int mpi_rank = starpu_data_get_rank(data);
 		int mpi_tag = starpu_data_get_tag(data);
 		int mpi_tag = starpu_data_get_tag(data);
-		STARPU_ASSERT(mpi_tag >= 0 && "StarPU needs to be told the MPI rank of this data, using starpu_data_set_rank");
+		if(mpi_rank == -1) {
+			fprintf(stderr,"StarPU needs to be told the MPI rank of this data, using starpu_data_set_rank\n");
+			STARPU_ABORT();
+		}
+		if(mpi_tag == -1) {
+			fprintf(stderr,"StarPU needs to be told the MPI tag of this data, using starpu_data_set_tag\n");
+			STARPU_ABORT();
+		}
 		/* The task needs to read this data */
 		/* The task needs to read this data */
 		if (do_execute && mpi_rank != me && mpi_rank != -1) {
 		if (do_execute && mpi_rank != me && mpi_rank != -1) {
 			/* I will have to execute but I don't have the data, receive */
 			/* I will have to execute but I don't have the data, receive */
@@ -164,7 +171,14 @@ void _starpu_mpi_exchange_data_after_execution(starpu_data_handle_t data, enum s
 	if (mode & STARPU_W) {
 	if (mode & STARPU_W) {
 		int mpi_rank = starpu_data_get_rank(data);
 		int mpi_rank = starpu_data_get_rank(data);
 		int mpi_tag = starpu_data_get_tag(data);
 		int mpi_tag = starpu_data_get_tag(data);
-		STARPU_ASSERT(mpi_tag >= 0 && "StarPU needs to be told the MPI rank of this data, using starpu_data_set_rank");
+		if(mpi_rank == -1) {
+			fprintf(stderr,"StarPU needs to be told the MPI rank of this data, using starpu_data_set_rank\n");
+			STARPU_ABORT();
+		}
+		if(mpi_tag == -1) {
+			fprintf(stderr,"StarPU needs to be told the MPI tag of this data, using starpu_data_set_tag\n");
+			STARPU_ABORT();
+		}
 		if (mpi_rank == me) {
 		if (mpi_rank == me) {
 			if (xrank != -1 && me != xrank) {
 			if (xrank != -1 && me != xrank) {
 				_STARPU_MPI_DEBUG("Receive data %p back from the task %d which executed the codelet ...\n", data, dest);
 				_STARPU_MPI_DEBUG("Receive data %p back from the task %d which executed the codelet ...\n", data, dest);
@@ -520,6 +534,14 @@ void starpu_mpi_get_data_on_node_detached(MPI_Comm comm, starpu_data_handle_t da
 
 
 	rank = starpu_data_get_rank(data_handle);
 	rank = starpu_data_get_rank(data_handle);
 	tag = starpu_data_get_tag(data_handle);
 	tag = starpu_data_get_tag(data_handle);
+	if(rank == -1) {
+		fprintf(stderr,"StarPU needs to be told the MPI rank of this data, using starpu_data_set_rank\n");
+		STARPU_ABORT();
+	}
+	if(tag == -1) {
+		fprintf(stderr,"StarPU needs to be told the MPI tag of this data, using starpu_data_set_tag\n");
+		STARPU_ABORT();
+	}
 	MPI_Comm_rank(comm, &me);
 	MPI_Comm_rank(comm, &me);
 
 
 	if (node == rank) return;
 	if (node == rank) return;
@@ -540,6 +562,14 @@ void starpu_mpi_get_data_on_node(MPI_Comm comm, starpu_data_handle_t data_handle
 
 
 	rank = starpu_data_get_rank(data_handle);
 	rank = starpu_data_get_rank(data_handle);
 	tag = starpu_data_get_tag(data_handle);
 	tag = starpu_data_get_tag(data_handle);
+	if(rank == -1) {
+		fprintf(stderr,"StarPU needs to be told the MPI rank of this data, using starpu_data_set_rank\n");
+		STARPU_ABORT();
+	}
+	if(tag == -1) {
+		fprintf(stderr,"StarPU needs to be told the MPI tag of this data, using starpu_data_set_tag\n");
+		STARPU_ABORT();
+	}
 	MPI_Comm_rank(comm, &me);
 	MPI_Comm_rank(comm, &me);
 
 
 	if (node == rank) return;
 	if (node == rank) return;
@@ -561,6 +591,14 @@ void starpu_mpi_redux_data(MPI_Comm comm, starpu_data_handle_t data_handle)
 
 
 	rank = starpu_data_get_rank(data_handle);
 	rank = starpu_data_get_rank(data_handle);
 	tag = starpu_data_get_tag(data_handle);
 	tag = starpu_data_get_tag(data_handle);
+	if(rank == -1) {
+		fprintf(stderr,"StarPU needs to be told the MPI rank of this data, using starpu_data_set_rank\n");
+		STARPU_ABORT();
+	}
+	if(tag == -1) {
+		fprintf(stderr,"StarPU needs to be told the MPI tag of this data, using starpu_data_set_tag\n");
+		STARPU_ABORT();
+	}
 
 
 	MPI_Comm_rank(comm, &me);
 	MPI_Comm_rank(comm, &me);
 	MPI_Comm_size(comm, &nb_nodes);
 	MPI_Comm_size(comm, &nb_nodes);

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

@@ -274,6 +274,9 @@ static starpu_data_handle_t _starpu_data_handle_allocate(struct starpu_data_inte
 
 
 	}
 	}
 
 
+	handle->tag = -1;
+	handle->rank = -1;
+
 	return handle;
 	return handle;
 }
 }