瀏覽代碼

Add functions to test for cached values

Samuel Thibault 8 年之前
父節點
當前提交
2c9bbfd30f

+ 3 - 0
doc/doxygen/chapters/410_mpi_support.doxy

@@ -572,6 +572,9 @@ add fine-graph starpu_mpi_cache_flush() calls during the algorithm; the effect
 for the data deallocation will be the same, but it will additionally release some
 for the data deallocation will be the same, but it will additionally release some
 pressure from the StarPU-MPI cache hash table during task submission.
 pressure from the StarPU-MPI cache hash table during task submission.
 
 
+One can determine whether a piece of is cached with starpu_mpi_cached_receive()
+and starpu_mpi_cached_send().
+
 The whole caching behavior can be disabled thanks to the \ref STARPU_MPI_CACHE
 The whole caching behavior can be disabled thanks to the \ref STARPU_MPI_CACHE
 environment variable. The variable \ref STARPU_MPI_CACHE_STATS can be set to <c>1</c>
 environment variable. The variable \ref STARPU_MPI_CACHE_STATS can be set to <c>1</c>
 to enable the runtime to display messages when data are added or removed
 to enable the runtime to display messages when data are added or removed

+ 10 - 0
doc/doxygen/chapters/api/mpi.doxy

@@ -248,6 +248,16 @@ function has to be called at the same point of task graph submission by all the
 function does nothing if the cache mechanism is disabled (see
 function does nothing if the cache mechanism is disabled (see
 \ref STARPU_MPI_CACHE).
 \ref STARPU_MPI_CACHE).
 
 
+\fn int starpu_mpi_cached_receive(starpu_data_handle_t data_handle);
+\ingroup API_MPI_Support
+Test whether \p data_handle is cached for reception, i.e. the value was
+previously received from the owner node, and not flushed since then.
+
+\fn int starpu_mpi_cached_send(starpu_data_handle_t data_handle, int dest);
+\ingroup API_MPI_Support
+Test whether \p data_handle is cached for emission to node \p dest , i.e. the
+value was previously sent to \p dest, and not flushed since then.
+
 @name MPI Insert Task
 @name MPI Insert Task
 \anchor MPIInsertTask
 \anchor MPIInsertTask
 \ingroup API_MPI_Support
 \ingroup API_MPI_Support

+ 4 - 1
mpi/include/starpu_mpi.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2009-2012, 2014-2016  Université de Bordeaux
+ * Copyright (C) 2009-2012, 2014-2017  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2016  Inria
  * Copyright (C) 2016  Inria
  *
  *
@@ -75,6 +75,9 @@ void starpu_mpi_comm_amounts_retrieve(size_t *comm_amounts);
 void starpu_mpi_cache_flush(MPI_Comm comm, starpu_data_handle_t data_handle);
 void starpu_mpi_cache_flush(MPI_Comm comm, starpu_data_handle_t data_handle);
 void starpu_mpi_cache_flush_all_data(MPI_Comm comm);
 void starpu_mpi_cache_flush_all_data(MPI_Comm comm);
 
 
+int starpu_mpi_cached_receive(starpu_data_handle_t data_handle);
+int starpu_mpi_cached_send(starpu_data_handle_t data_handle, int dest);
+
 int starpu_mpi_comm_size(MPI_Comm comm, int *size);
 int starpu_mpi_comm_size(MPI_Comm comm, int *size);
 int starpu_mpi_comm_rank(MPI_Comm comm, int *rank);
 int starpu_mpi_comm_rank(MPI_Comm comm, int *rank);
 int starpu_mpi_world_rank(void);
 int starpu_mpi_world_rank(void);

+ 29 - 1
mpi/src/starpu_mpi_cache.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
- * Copyright (C) 2011-2016  Université de Bordeaux
+ * Copyright (C) 2011-2017  Université de Bordeaux
  * Copyright (C) 2014 INRIA
  * Copyright (C) 2014 INRIA
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -319,6 +319,13 @@ void *_starpu_mpi_cache_received_data_get(starpu_data_handle_t data, int mpi_ran
 	return already_received;
 	return already_received;
 }
 }
 
 
+int starpu_mpi_cached_receive(starpu_data_handle_t data_handle)
+{
+	int owner = starpu_mpi_data_get_rank(data_handle);
+	void *already_received = _starpu_mpi_cache_received_data_get(data_handle, owner);
+	return already_received != NULL;
+}
+
 void *_starpu_mpi_cache_sent_data_set(starpu_data_handle_t data, int dest)
 void *_starpu_mpi_cache_sent_data_set(starpu_data_handle_t data, int dest)
 {
 {
 	struct _starpu_data_entry *already_sent;
 	struct _starpu_data_entry *already_sent;
@@ -344,3 +351,24 @@ void *_starpu_mpi_cache_sent_data_set(starpu_data_handle_t data, int dest)
 	STARPU_PTHREAD_MUTEX_UNLOCK(&_cache_sent_mutex[dest]);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&_cache_sent_mutex[dest]);
 	return already_sent;
 	return already_sent;
 }
 }
+
+void *_starpu_mpi_cache_sent_data_get(starpu_data_handle_t data, int dest)
+{
+	struct _starpu_data_entry *already_sent;
+
+	if (_starpu_cache_enabled == 0) return NULL;
+
+	STARPU_MPI_ASSERT_MSG(dest < _starpu_cache_comm_size, "Node %d invalid. Max node is %d\n", dest, _starpu_cache_comm_size);
+
+	STARPU_PTHREAD_MUTEX_LOCK(&_cache_sent_mutex[dest]);
+	HASH_FIND_PTR(_cache_sent_data[dest], &data, already_sent);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&_cache_sent_mutex[dest]);
+	return already_sent;
+}
+
+int starpu_mpi_cached_send(starpu_data_handle_t data_handle, int dest)
+{
+	void *already_sent = _starpu_mpi_cache_sent_data_get(data_handle, dest);
+	return already_sent != NULL;
+}
+

+ 2 - 1
mpi/src/starpu_mpi_cache.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016  CNRS
- * Copyright (C) 2011-2014  Université de Bordeaux
+ * Copyright (C) 2011-2014, 2017  Université de Bordeaux
  * Copyright (C) 2014 INRIA
  * Copyright (C) 2014 INRIA
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -44,6 +44,7 @@ void _starpu_mpi_cache_received_data_clear(starpu_data_handle_t data);
  * If the data is NOT available in the cache, add it to the cache and return NULL
  * If the data is NOT available in the cache, add it to the cache and return NULL
  */
  */
 void *_starpu_mpi_cache_sent_data_set(starpu_data_handle_t data, int dest);
 void *_starpu_mpi_cache_sent_data_set(starpu_data_handle_t data, int dest);
+void *_starpu_mpi_cache_sent_data_get(starpu_data_handle_t data, int dest);
 void _starpu_mpi_cache_sent_data_clear(MPI_Comm comm, starpu_data_handle_t data);
 void _starpu_mpi_cache_sent_data_clear(MPI_Comm comm, starpu_data_handle_t data);
 
 
 void _starpu_mpi_cache_flush(MPI_Comm comm, starpu_data_handle_t data_handle);
 void _starpu_mpi_cache_flush(MPI_Comm comm, starpu_data_handle_t data_handle);