Browse Source

mpi: clear htables used by communication cache

Nathalie Furmento 12 years ago
parent
commit
ddb857e7fe
3 changed files with 30 additions and 1 deletions
  1. 3 1
      mpi/src/starpu_mpi.c
  2. 26 0
      mpi/src/starpu_mpi_insert_task.c
  3. 1 0
      mpi/src/starpu_mpi_insert_task.h

+ 3 - 1
mpi/src/starpu_mpi.c

@@ -836,10 +836,11 @@ int starpu_mpi_initialize_extended(int *rank, int *world_size)
 int starpu_mpi_shutdown(void)
 {
 	void *value;
-	int rank;
+	int rank, world_size;
 
 	/* We need to get the  rank before calling MPI_Finalize to pass to _starpu_mpi_comm_amounts_display() */
 	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+	MPI_Comm_size(MPI_COMM_WORLD, &world_size);
 
 	/* kill the progression thread */
 	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
@@ -859,6 +860,7 @@ int starpu_mpi_shutdown(void)
 
 	_starpu_mpi_comm_amounts_display(rank);
 	_starpu_mpi_comm_amounts_free();
+	_starpu_mpi_tables_free(world_size);
 
 	return 0;
 }

+ 26 - 0
mpi/src/starpu_mpi_insert_task.c

@@ -57,6 +57,32 @@ void _starpu_mpi_tables_init(MPI_Comm comm)
 #endif /* STARPU_MPI_CACHE */
 }
 
+void _starpu_mpi_tables_free(int world_size)
+{
+#ifdef STARPU_MPI_CACHE
+	int i;
+
+	_STARPU_MPI_DEBUG("Clearing htable for cache\n");
+
+	for(i=0 ; i<world_size ; i++)
+	{
+		struct _starpu_data_entry *entry, *tmp;
+		HASH_ITER(hh, sent_data[i], entry, tmp)
+		{
+			HASH_DEL(sent_data[i], entry);
+			free(entry);
+		}
+		HASH_ITER(hh, received_data[i], entry, tmp)
+		{
+			HASH_DEL(received_data[i], entry);
+			free(entry);
+		}
+	}
+	free(sent_data);
+	free(received_data);
+#endif
+}
+
 static
 int _starpu_mpi_find_executee_node(starpu_data_handle_t data, enum starpu_access_mode mode, int me, int *do_execute, int *inconsistent_execute, int *dest, size_t *size_on_nodes)
 {

+ 1 - 0
mpi/src/starpu_mpi_insert_task.h

@@ -24,6 +24,7 @@ extern "C" {
 #endif
 
 void _starpu_mpi_tables_init(MPI_Comm comm);
+void _starpu_mpi_tables_free(int world_size);
 
 #ifdef __cplusplus
 }