Przeglądaj źródła

mpi/tests: new testcase to register and unregister node selection policies

Nathalie Furmento 10 lat temu
rodzic
commit
6d14036308

+ 22 - 2
mpi/tests/Makefile.am

@@ -116,7 +116,11 @@ starpu_mpi_TESTS =				\
 	mpi_reduction				\
 	user_defined_datatype			\
 	gather					\
-	gather2
+	gather2					\
+	policy_register				\
+	policy_register_many			\
+	policy_register_toomany			\
+	policy_unregister
 
 noinst_PROGRAMS =				\
 	datatypes				\
@@ -158,7 +162,15 @@ noinst_PROGRAMS =				\
 	mpi_reduction				\
 	user_defined_datatype			\
 	gather					\
-	gather2
+	gather2					\
+	policy_register				\
+	policy_register_many			\
+	policy_register_toomany			\
+	policy_unregister
+
+XFAIL_TESTS=					\
+	policy_register_toomany			\
+	policy_unregister
 
 mpi_isend_LDADD =					\
 	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
@@ -240,6 +252,14 @@ gather_LDADD =			\
 	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
 gather2_LDADD =			\
 	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
+policy_register_LDADD =			\
+	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
+policy_register_many_LDADD =			\
+	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
+policy_register_toomany_LDADD =			\
+	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
+policy_unregister_LDADD =			\
+	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
 
 ring_SOURCES = ring.c
 ring_sync_SOURCES = ring_sync.c

+ 127 - 0
mpi/tests/policy_register.c

@@ -0,0 +1,127 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2015  Centre National de la Recherche Scientifique
+ *
+ * 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"
+
+void func_cpu(void *descr[], void *_args)
+{
+	(void)descr;
+	(void)_args;
+}
+
+struct starpu_codelet mycodelet =
+{
+	.cpu_funcs = {func_cpu},
+	.nbuffers = 2,
+	.modes = {STARPU_W, STARPU_W}
+};
+
+int starpu_mpi_select_node_my_policy_0(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data)
+{
+	(void) me;
+	(void) nb_nodes;
+	(void) descr;
+	(void) nb_data;
+	return 0;
+}
+
+int starpu_mpi_select_node_my_policy_1(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data)
+{
+	(void) me;
+	(void) nb_nodes;
+	(void) descr;
+	(void) nb_data;
+	return 1;
+}
+
+int main(int argc, char **argv)
+{
+	int ret;
+	int rank, size;
+	int policy;
+	struct starpu_task *task;
+	starpu_data_handle_t handles[2];
+
+	MPI_Init(&argc, &argv);
+	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+	MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+	if (size < 2)
+	{
+		if (rank == 0)
+			FPRINTF(stderr, "We need at least 2 processes.\n");
+
+		MPI_Finalize();
+		return STARPU_TEST_SKIPPED;
+	}
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_init(NULL, NULL, 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
+
+	if (rank == 0)
+		starpu_variable_data_register(&handles[0], STARPU_MAIN_RAM, (uintptr_t)&policy, sizeof(int));
+	else
+		starpu_variable_data_register(&handles[0], -1, (uintptr_t)NULL, sizeof(int));
+	starpu_mpi_data_register(handles[0], 10, 0);
+	if (rank == 1)
+		starpu_variable_data_register(&handles[1], STARPU_MAIN_RAM, (uintptr_t)&policy, sizeof(int));
+	else
+		starpu_variable_data_register(&handles[1], -1, (uintptr_t)NULL, sizeof(int));
+	starpu_mpi_data_register(handles[1], 20, 1);
+
+	policy = starpu_mpi_node_selection_register_policy(starpu_mpi_select_node_my_policy_1);
+	starpu_mpi_node_selection_set_current_policy(policy);
+
+	task = starpu_mpi_task_build(MPI_COMM_WORLD, &mycodelet,
+				     STARPU_W, handles[0], STARPU_W, handles[1],
+				     0);
+	FPRINTF_MPI(stderr, "Task %p\n", task);
+	if (rank == 1)
+	{
+		STARPU_ASSERT_MSG(task, "Task should be executed by rank 1\n");
+	}
+	else
+	{
+		STARPU_ASSERT_MSG(task == NULL, "Task should be executed by rank 1\n");
+	}
+
+	policy = starpu_mpi_node_selection_register_policy(starpu_mpi_select_node_my_policy_0);
+	task = starpu_mpi_task_build(MPI_COMM_WORLD, &mycodelet,
+				     STARPU_W, handles[0], STARPU_W, handles[1],
+				     STARPU_NODE_SELECTION_POLICY, policy,
+				     0);
+	FPRINTF_MPI(stderr, "Task %p\n", task);
+	if (rank == 0)
+	{
+		STARPU_ASSERT_MSG(task, "Task should be executed by rank 0\n");
+	}
+	else
+	{
+		STARPU_ASSERT_MSG(task == NULL, "Task should be executed by rank 0\n");
+	}
+
+	starpu_data_unregister(handles[0]);
+	starpu_data_unregister(handles[1]);
+	starpu_mpi_shutdown();
+	starpu_shutdown();
+	MPI_Finalize();
+
+	return 0;
+}

+ 54 - 0
mpi/tests/policy_register_many.c

@@ -0,0 +1,54 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2015  Centre National de la Recherche Scientifique
+ *
+ * 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 <starpu_mpi_select_node.h>
+#include "helper.h"
+
+int starpu_mpi_select_node_my_policy(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data)
+{
+	(void) me;
+	(void) nb_nodes;
+	(void) descr;
+	(void) nb_data;
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	int ret;
+	int i, policy;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_init(&argc, &argv, 1);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
+
+	for(i=0 ; i<_STARPU_MPI_NODE_SELECTION_MAX_POLICY ; i++)
+	{
+		policy = starpu_mpi_node_selection_register_policy(starpu_mpi_select_node_my_policy);
+		FPRINTF_MPI(stderr, "New policy %d\n", policy);
+	}
+	starpu_mpi_node_selection_unregister_policy(_STARPU_MPI_NODE_SELECTION_MAX_POLICY-2);
+	policy = starpu_mpi_node_selection_register_policy(starpu_mpi_select_node_my_policy);
+	FPRINTF_MPI(stderr, "New policy %d\n", policy);
+	STARPU_ASSERT(policy==_STARPU_MPI_NODE_SELECTION_MAX_POLICY-2);
+
+	starpu_mpi_shutdown();
+	starpu_shutdown();
+
+	return 0;
+}

+ 50 - 0
mpi/tests/policy_register_toomany.c

@@ -0,0 +1,50 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2015  Centre National de la Recherche Scientifique
+ *
+ * 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 <starpu_mpi_select_node.h>
+#include "helper.h"
+
+int starpu_mpi_select_node_my_policy(int me, int nb_nodes, struct starpu_data_descr *descr, int nb_data)
+{
+	(void) me;
+	(void) nb_nodes;
+	(void) descr;
+	(void) nb_data;
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	int ret;
+	int i, policy;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_init(&argc, &argv, 1);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
+
+	for(i=0 ; i<_STARPU_MPI_NODE_SELECTION_MAX_POLICY+1 ; i++)
+	{
+		policy = starpu_mpi_node_selection_register_policy(starpu_mpi_select_node_my_policy);
+		FPRINTF_MPI(stderr, "New policy %d\n", policy);
+	}
+
+	starpu_mpi_shutdown();
+	starpu_shutdown();
+
+	return 0;
+}

+ 35 - 0
mpi/tests/policy_unregister.c

@@ -0,0 +1,35 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2015  Centre National de la Recherche Scientifique
+ *
+ * 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 ret;
+
+	ret = starpu_init(NULL);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+	ret = starpu_mpi_init(&argc, &argv, 1);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init");
+
+	starpu_mpi_node_selection_unregister_policy(STARPU_MPI_NODE_SELECTION_MOST_R_DATA);
+
+	starpu_mpi_shutdown();
+	starpu_shutdown();
+
+	return 0;
+}