浏览代码

backport branches/starpu-1.1@13965: mpi/tests: new testcase to simply tests data are sent back to their home node after executing the codelet

Nathalie Furmento 10 年之前
父节点
当前提交
d8de52fc1e
共有 2 个文件被更改,包括 116 次插入0 次删除
  1. 6 0
      mpi/tests/Makefile.am
  2. 110 0
      mpi/tests/insert_task_count.c

+ 6 - 0
mpi/tests/Makefile.am

@@ -103,6 +103,7 @@ starpu_mpi_TESTS =				\
 	insert_task_owner2			\
 	insert_task_owner_data			\
 	insert_task_node_choice			\
+	insert_task_count			\
 	multiple_send				\
 	mpi_scatter_gather			\
 	mpi_reduction				\
@@ -137,6 +138,7 @@ noinst_PROGRAMS =				\
 	insert_task_owner2			\
 	insert_task_owner_data			\
 	insert_task_node_choice			\
+	insert_task_count			\
 	multiple_send				\
 	mpi_scatter_gather			\
 	mpi_reduction				\
@@ -196,6 +198,8 @@ insert_task_owner_data_LDADD =			\
 	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
 insert_task_node_choice_LDADD =			\
 	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
+insert_task_count_LDADD =				\
+	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
 multiple_send_LDADD =				\
 	../src/libstarpumpi-@STARPU_EFFECTIVE_VERSION@.la
 mpi_scatter_gather_LDADD =			\
@@ -212,10 +216,12 @@ gather2_LDADD =			\
 ring_SOURCES = ring.c
 ring_async_SOURCES = ring_async.c
 ring_async_implicit_SOURCES = ring_async_implicit.c
+insert_task_count_SOURCES = insert_task_count.c
 if STARPU_USE_CUDA
 ring_SOURCES += ring_kernel.cu
 ring_async_SOURCES += ring_kernel.cu
 ring_async_implicit_SOURCES += ring_kernel.cu
+insert_task_count_SOURCES += ring_kernel.cu
 endif
 mpi_reduction_SOURCES = mpi_reduction.c
 mpi_reduction_SOURCES += mpi_reduction_kernels.c

+ 110 - 0
mpi/tests/insert_task_count.c

@@ -0,0 +1,110 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014  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"
+
+#ifdef STARPU_QUICK_CHECK
+#  define NITER	32
+#else
+#  define NITER	2048
+#endif
+
+#ifdef STARPU_USE_CUDA
+extern void increment_cuda(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args);
+#endif
+
+void increment_cpu(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
+{
+	int *tokenptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
+	(*tokenptr)++;
+}
+
+static struct starpu_codelet increment_cl =
+{
+#ifdef STARPU_USE_CUDA
+	.cuda_funcs = {increment_cuda},
+#endif
+	.cpu_funcs = {increment_cpu},
+	.nbuffers = 1,
+	.modes = {STARPU_RW}
+};
+
+int main(int argc, char **argv)
+{
+	int ret, rank, size;
+	int token = 0;
+	starpu_data_handle_t token_handle;
+
+	MPI_Init(NULL, NULL);
+	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");
+
+	if (rank == 1)
+		starpu_vector_data_register(&token_handle, 0, (uintptr_t)&token, 1, sizeof(token));
+	else
+		starpu_vector_data_register(&token_handle, -1, (uintptr_t)NULL, 1, sizeof(token));
+	starpu_mpi_data_register(token_handle, 12, 1);
+
+	int nloops = NITER;
+	int loop;
+
+	FPRINTF_MPI("Start with token value %d\n", token);
+
+	for (loop = 0; loop < nloops; loop++)
+	{
+		starpu_mpi_insert_task(MPI_COMM_WORLD, &increment_cl,
+				       STARPU_RW, token_handle,
+				       STARPU_EXECUTE_ON_NODE, 0,
+				       0);
+	}
+
+	starpu_task_wait_for_all();
+	starpu_data_unregister(token_handle);
+	starpu_mpi_shutdown();
+	starpu_shutdown();
+
+	FPRINTF_MPI("Final value for token %d\n", token);
+
+	MPI_Finalize();
+
+	if (rank == 1)
+	{
+		STARPU_ASSERT_MSG(token == nloops, "token==%d != expected_value==%d\n", token, nloops);
+	}
+	else
+	{
+		STARPU_ASSERT_MSG(token == 0, "token==%d != expected_value==0\n", token);
+
+	}
+
+	return 0;
+}