Browse Source

mpi: new function starpu_mpi_comm_get_attr to get the value of upper bound for tag value (key STARPU_MPI_TAG_UB)

Nathalie Furmento 7 years ago
parent
commit
7fd7cf3f12
6 changed files with 72 additions and 1 deletions
  1. 3 0
      ChangeLog
  2. 12 0
      doc/doxygen/chapters/api/mpi.doxy
  3. 3 0
      mpi/include/starpu_mpi.h
  4. 14 0
      mpi/src/starpu_mpi.c
  5. 3 1
      mpi/tests/Makefile.am
  6. 37 0
      mpi/tests/attr.c

+ 3 - 0
ChangeLog

@@ -56,6 +56,9 @@ Small features:
     variables.
   * Add disk to disk copy functions and support asynchronous full read/write
     in disk backends.
+  * New function starpu_mpi_comm_get_attr() which allows to return the
+    value of the attribute STARPU_MPI_TAG_UB, i.e the upper bound for
+    tag value.
 
 Changes:
   * Vastly improve simgrid simulation time.

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

@@ -245,6 +245,18 @@ It is important that the function is called before any communication can take pl
 \ingroup API_MPI_Support
 Unregister the MPI datatype functions stored for the interface of the given handle.
 
+\def STARPU_MPI_TAG_UB
+\ingroup API_MPI_Support
+When given to the function starpu_mpi_comm_get_attr(), retrieve the
+value for the upper bound for tag value.
+
+\fn int starpu_mpi_comm_get_attr(MPI_Comm comm, int keyval, void *attribute_val, int *flag);
+\ingroup API_MPI_Support
+Retrieve an attribute value by key, similarly to the MPI function \c MPI_comm_get_attr().
+If an attribute is attached on \p comm to \p keyval, then the call
+returns \p flag equal to \c 1, and the attribute value in \p
+attribute_val. Otherwise, \p flag is set to \0.
+
 @name Communication Cache
 \ingroup API_MPI_Support
 

+ 3 - 0
mpi/include/starpu_mpi.h

@@ -138,6 +138,9 @@ int starpu_mpi_datatype_unregister(starpu_data_handle_t handle);
 int starpu_mpi_pre_submit_hook_register(void (*f)(struct starpu_task *));
 int starpu_mpi_pre_submit_hook_unregister();
 
+#define STARPU_MPI_TAG_UB 1
+int starpu_mpi_comm_get_attr(MPI_Comm comm, int keyval, void *attribute_val, int *flag);
+
 #ifdef __cplusplus
 }
 #endif

+ 14 - 0
mpi/src/starpu_mpi.c

@@ -1988,3 +1988,17 @@ int starpu_mpi_wait_for_all(MPI_Comm comm)
 	return 0;
 }
 
+int starpu_mpi_comm_get_attr(MPI_Comm comm, int keyval, void *attribute_val, int *flag)
+{
+	(void) comm;
+	if (keyval == STARPU_MPI_TAG_UB)
+	{
+		*flag = 1;
+		*(int64_t *)attribute_val = INT64_MAX;
+	}
+	else
+	{
+		*flag = 0;
+	}
+	return 0;
+}

+ 3 - 1
mpi/tests/Makefile.am

@@ -101,9 +101,10 @@ AM_LDFLAGS = $(STARPU_OPENCL_LDFLAGS) $(STARPU_CUDA_LDFLAGS) $(FXT_LDFLAGS) $(ST
 
 if BUILD_TESTS
 
-starpu_mpi_TESTS =				
+starpu_mpi_TESTS =
 
 starpu_mpi_TESTS +=				\
+	attr					\
 	cache					\
 	cache_disable				\
 	callback				\
@@ -186,6 +187,7 @@ noinst_PROGRAMS =				\
 	temporary				\
 	block_interface				\
 	block_interface_pinned			\
+	attr					\
 	cache					\
 	cache_disable				\
 	callback				\

+ 37 - 0
mpi/tests/attr.c

@@ -0,0 +1,37 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2017  CNRS
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include <starpu_mpi.h>
+#include "helper.h"
+
+int main(int argc, char **argv)
+{
+	int flag;
+	int64_t value;
+
+	(void) argc;
+	(void) argv;
+
+	starpu_mpi_comm_get_attr(MPI_COMM_WORLD, 42, NULL, &flag);
+	STARPU_ASSERT_MSG(flag == 0, "starpu_mpi_comm_get_attr was called with invalid argument\n");
+
+	starpu_mpi_comm_get_attr(MPI_COMM_WORLD, STARPU_MPI_TAG_UB, &value, &flag);
+	STARPU_ASSERT_MSG(flag == 1, "starpu_mpi_comm_get_attr was called with valid argument\n");
+
+	FPRINTF(stderr, "Value: %ld\n", value);
+
+	return 0;
+}