Browse Source

tests/datawizard/interfaces: simplify test framework and add test for pack/unpack functions

Nathalie Furmento 6 years ago
parent
commit
c583e56fc2

+ 9 - 9
tests/Makefile.am

@@ -60,7 +60,7 @@ EXTRA_DIST =					\
 	datawizard/interfaces/coo/coo_opencl_kernel.cl \
 	datawizard/interfaces/matrix/matrix_opencl_kernel.cl \
 	datawizard/interfaces/variable/variable_opencl_kernel.cl \
-	datawizard/interfaces/vector/test_vector_opencl_kernel.cl \
+	datawizard/interfaces/vector/vector_opencl_kernel.cl \
 	datawizard/interfaces/multiformat/multiformat_types.h \
 	datawizard/interfaces/multiformat/multiformat_opencl_kernel.cl \
 	datawizard/interfaces/multiformat/multiformat_conversion_codelets_kernel.cl \
@@ -308,7 +308,7 @@ myPROGRAMS +=				\
 	datawizard/interfaces/multiformat/advanced/multiformat_handle_conversion \
 	datawizard/interfaces/multiformat/advanced/same_handle \
 	datawizard/interfaces/variable/variable_interface    \
-	datawizard/interfaces/vector/test_vector_interface   \
+	datawizard/interfaces/vector/vector_interface   \
 	datawizard/interfaces/void/void_interface \
 	datawizard/in_place_partition   	\
 	datawizard/partition_dep   		\
@@ -843,20 +843,20 @@ nobase_STARPU_OPENCL_DATA_DATA += \
 endif
 
 
-datawizard_interfaces_vector_test_vector_interface_SOURCES =               \
-	datawizard/interfaces/vector/test_vector_interface.c               \
+datawizard_interfaces_vector_vector_interface_SOURCES =               \
+	datawizard/interfaces/vector/vector_interface.c               \
 	datawizard/interfaces/test_interfaces.c
 
 if STARPU_USE_CUDA
-datawizard_interfaces_vector_test_vector_interface_SOURCES +=               \
-	datawizard/interfaces/vector/test_vector_cuda.cu
+datawizard_interfaces_vector_vector_interface_SOURCES +=               \
+	datawizard/interfaces/vector/vector_cuda.cu
 endif
 
 if STARPU_USE_OPENCL
-datawizard_interfaces_vector_test_vector_interface_SOURCES +=               \
-	datawizard/interfaces/vector/test_vector_opencl.c
+datawizard_interfaces_vector_vector_interface_SOURCES +=               \
+	datawizard/interfaces/vector/vector_opencl.c
 nobase_STARPU_OPENCL_DATA_DATA += \
-	datawizard/interfaces/vector/test_vector_opencl_kernel.cl
+	datawizard/interfaces/vector/vector_opencl_kernel.cl
 endif
 
 ####################

+ 5 - 7
tests/datawizard/interfaces/bcsr/bcsr_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2013                                Inria
- * Copyright (C) 2010-2013,2015,2017                      CNRS
+ * Copyright (C) 2010-2013,2015,2017,2019                 CNRS
  * Copyright (C) 2012,2013,2017                           Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -180,7 +180,7 @@ test_bcsr_cpu_func(void *buffers[], void *args)
 int
 main(int argc, char **argv)
 {
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
 
@@ -193,15 +193,13 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&bcsr_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&bcsr_config, &summary);
 
 	unregister_data();
 
 	starpu_shutdown();
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 }

+ 5 - 7
tests/datawizard/interfaces/block/block_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2013                                Inria
- * Copyright (C) 2012,2013,2015,2017                      CNRS
+ * Copyright (C) 2012,2013,2015,2017,2019                 CNRS
  * Copyright (C) 2012,2013                                Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -136,7 +136,7 @@ void test_block_cpu_func(void *buffers[], void *args)
 int
 main(int argc, char **argv)
 {
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
 	conf.ncuda = 2;
@@ -148,17 +148,15 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&block_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&block_config, &summary);
 
 	unregister_data();
 
 	starpu_shutdown();
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 
 enodev:
 	return STARPU_TEST_SKIPPED;

+ 5 - 7
tests/datawizard/interfaces/coo/coo_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2012,2013                                Inria
- * Copyright (C) 2012,2013,2015,2017                      CNRS
+ * Copyright (C) 2012,2013,2015,2017,2019                 CNRS
  * Copyright (C) 2013                                     Université de Bordeaux
  * Copyright (C) 2013                                     Thibaut Lambert
  *
@@ -154,7 +154,7 @@ int
 main(int argc, char **argv)
 {
 	struct starpu_conf conf;
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 
 	starpu_conf_init(&conf);
 	conf.ncuda = 2;
@@ -166,16 +166,14 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&coo_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&coo_config, &summary);
 
 	unregister_data();
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
 	starpu_shutdown();
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 
 enodev:
 	return STARPU_TEST_SKIPPED;

+ 6 - 9
tests/datawizard/interfaces/csr/csr_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2013                                Inria
- * Copyright (C) 2011-2013,2015,2017                      CNRS
+ * Copyright (C) 2011-2013,2015,2017,2019                 CNRS
  * Copyright (C) 2012,2013                                Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -142,10 +142,9 @@ test_csr_cpu_func(void *buffers[], void *args)
 	}
 }
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
 
@@ -158,17 +157,15 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&csr_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&csr_config, &summary);
 
 	unregister_data();
 
 	starpu_shutdown();
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 
 enodev:
 	return STARPU_TEST_SKIPPED;

+ 6 - 9
tests/datawizard/interfaces/matrix/matrix_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2013                                Inria
- * Copyright (C) 2011-2013,2015,2017                      CNRS
+ * Copyright (C) 2011-2013,2015,2017,2019                 CNRS
  * Copyright (C) 2012,2013                                Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -117,10 +117,9 @@ test_matrix_cpu_func(void *buffers[], void *args)
 	}
 }
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
 	conf.ncuda = 2;
@@ -132,17 +131,15 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&matrix_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&matrix_config, &summary);
 
 	unregister_data();
 
 	starpu_shutdown();
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 
 enodev:
 	return STARPU_TEST_SKIPPED;

+ 6 - 9
tests/datawizard/interfaces/multiformat/multiformat_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2013                                Inria
- * Copyright (C) 2011-2015,2017                           CNRS
+ * Copyright (C) 2011-2015,2017,2019                      CNRS
  * Copyright (C) 2012,2013                                Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -169,12 +169,11 @@ unregister_data(void)
 	starpu_data_unregister(multiformat_dummy_handle);
 }
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
 #ifdef STARPU_USE_CPU
 	int ret;
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
 	conf.ncuda = 2;
@@ -188,17 +187,15 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&multiformat_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&multiformat_config, &summary);
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
 	unregister_data();
 
 	starpu_shutdown();
 
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 #else
 	/* Without the CPU, there is no point in using the multiformat
 	 * interface, so this test is pointless. */

File diff suppressed because it is too large
+ 264 - 497
tests/datawizard/interfaces/test_interfaces.c


+ 32 - 11
tests/datawizard/interfaces/test_interfaces.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011,2012                                Inria
- * Copyright (C) 2011,2012,2015,2017                      CNRS
+ * Copyright (C) 2011,2012,2015,2017,2019                 CNRS
  * Copyright (C) 2013                                     Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -30,13 +30,13 @@ enum exit_code
 	SUCCESS                 = 0,
 	FAILURE                 = 1,
 	UNTESTED                = 2,
-	TASK_CREATION_FAILURE   = 3,
+	NO_DEVICE		= 3,
 	TASK_SUBMISSION_FAILURE = 4
 };
 
-
 struct test_config
 {
+	/** we use pointers as we want to allow static initializations in the main application */
 	/* A pointer to a registered handle */
 	starpu_data_handle_t *handle;
 
@@ -50,12 +50,8 @@ struct test_config
 	 * 2) Negate every element
 	 */
 	starpu_cpu_func_t cpu_func;
-#ifdef STARPU_USE_CUDA
 	starpu_cuda_func_t cuda_func;
-#endif
-#ifdef STARPU_USE_OPENCL
 	starpu_opencl_func_t opencl_func;
-#endif
 	char *cpu_func_name;
 
 	/* The previous codelets must update this field at the end of their
@@ -66,12 +62,37 @@ struct test_config
 	const char *name;
 };
 
+struct data_interface_test_summary
+{
+	int success;
+
+	/* Copy methods */
+	int cpu_to_cpu;
+	int cpu_to_cuda;
+	int cuda_to_cuda;
+	int cuda_to_cpu;
+	int cpu_to_cuda_async;
+	int cuda_to_cpu_async;
+	int cuda_to_cuda_async;
+	int cpu_to_opencl;
+	int opencl_to_cpu;
+	int cpu_to_opencl_async;
+	int opencl_to_cpu_async;
+	int cpu_to_mic;
+	int mic_to_cpu;
+	int cpu_to_mic_async;
+	int mic_to_cpu_async;
 
-typedef struct data_interface_test_summary data_interface_test_summary;
+	/* Other stuff */
+	int compare;
+	int to_pointer;
+	int pointer_is_inside;
+	int pack;
+};
 
-void data_interface_test_summary_print(FILE *, data_interface_test_summary *);
-int data_interface_test_summary_success(data_interface_test_summary *);
+void data_interface_test_summary_print(FILE *f, struct data_interface_test_summary *summary);
+int data_interface_test_summary_success(struct data_interface_test_summary *summary);
 
-data_interface_test_summary *run_tests(struct test_config*);
+void run_tests(struct test_config*, struct data_interface_test_summary *summary);
 
 #endif /* !TEST_INTERFACES_H */

+ 28 - 0
tests/datawizard/interfaces/test_interfaces.sh

@@ -0,0 +1,28 @@
+#!/bin/sh
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+#
+# Copyright (C) 2019                                      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.
+#
+
+for i in bcsr block coo csr matrix multiformat variable vector void
+do
+    ./tests/datawizard/interfaces/$i/${i}_interface
+    ret=$?
+    if test "$ret" = "0"
+    then
+	echo "Interface $i: success"
+    else
+	echo "Interface $i: failure"
+    fi
+done

+ 6 - 9
tests/datawizard/interfaces/variable/variable_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2013                                Inria
- * Copyright (C) 2012,2015,2017                           CNRS
+ * Copyright (C) 2012,2015,2017,2019                      CNRS
  * Copyright (C) 2012,2013                                Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -92,11 +92,10 @@ void unregister_data(void)
 	starpu_data_unregister(variable2_handle);
 }
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	int ret;
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
@@ -111,15 +110,13 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&variable_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&variable_config, &summary);
 
 	unregister_data();
 
 	starpu_shutdown();
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 }

tests/datawizard/interfaces/vector/test_vector_cuda.cu → tests/datawizard/interfaces/vector/vector_cuda.cu


+ 10 - 16
tests/datawizard/interfaces/vector/test_vector_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2013                                Inria
- * Copyright (C) 2011-2013,2015,2017                      CNRS
+ * Copyright (C) 2011-2013,2015,2017,2019                 CNRS
  * Copyright (C) 2012,2013                                Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -31,9 +31,8 @@ extern void test_vector_cuda_func(void *buffers[], void *_args);
 extern void test_vector_opencl_func(void *buffers[], void *args);
 #endif
 
-
-static starpu_data_handle_t vector_handle;
-static starpu_data_handle_t vector2_handle;
+starpu_data_handle_t vector_handle;
+starpu_data_handle_t vector2_handle;
 
 struct test_config vector_config =
 {
@@ -57,8 +56,7 @@ struct test_config vector_config =
 static int vector[VECTOR_SIZE];
 static int vector2[VECTOR_SIZE];
 
-static void
-register_data(void)
+static void register_data(void)
 {
 	/* Initializing data */
 	int i;
@@ -78,8 +76,7 @@ register_data(void)
 				    sizeof(int));
 }
 
-static void
-unregister_data(void)
+static void unregister_data(void)
 {
 	starpu_data_unregister(vector_handle);
 	starpu_data_unregister(vector2_handle);
@@ -104,10 +101,9 @@ void test_vector_cpu_func(void *buffers[], void *args)
 	}
 }
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
 	conf.ncuda = 2;
@@ -119,17 +115,15 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&vector_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&vector_config, &summary);
 
 	unregister_data();
 
 	starpu_shutdown();
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 
 enodev:
 	return STARPU_TEST_SKIPPED;

+ 5 - 7
tests/datawizard/interfaces/vector/test_vector_opencl.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011,2012                                Inria
- * Copyright (C) 2012,2015-2017                           CNRS
+ * Copyright (C) 2012,2015-2017,2019                      CNRS
  * Copyright (C) 2011                                     Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
 #include <starpu.h>
 #include "../test_interfaces.h"
 
-#define KERNEL_LOCATION "tests/datawizard/interfaces/vector/test_vector_opencl_kernel.cl"
+#define KERNEL_LOCATION "tests/datawizard/interfaces/vector/vector_opencl_kernel.cl"
 extern struct test_config vector_config;
 static struct starpu_opencl_program opencl_program;
 
@@ -47,13 +47,11 @@ test_vector_opencl_func(void *buffers[], void *args)
 	devid = starpu_worker_get_devid(id);
 	starpu_opencl_get_context(devid, &context);
 
-	cl_mem fail = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR,
-		sizeof(int), &vector_config.copy_failed, &err);
+	cl_mem fail = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, sizeof(int), &vector_config.copy_failed, &err);
 
 	if (err != CL_SUCCESS)
 		STARPU_OPENCL_REPORT_ERROR(err);
 
-
 	err = starpu_opencl_load_kernel(&kernel,
 					&queue,
 					&opencl_program,
@@ -75,7 +73,7 @@ test_vector_opencl_func(void *buffers[], void *args)
 		fprintf(stderr, "Failed to set argument #%d\n", err);
 		STARPU_OPENCL_REPORT_ERROR(err);
 	}
-			
+
 	{
 		size_t global=n;
 		size_t local;
@@ -113,7 +111,7 @@ test_vector_opencl_func(void *buffers[], void *args)
 	err = clEnqueueReadBuffer(queue,
 				  fail,
 				  CL_TRUE,
-				  0, 
+				  0,
 				  sizeof(int),
 				  &vector_config.copy_failed,
 				  0,

tests/datawizard/interfaces/vector/test_vector_opencl_kernel.cl → tests/datawizard/interfaces/vector/vector_opencl_kernel.cl


+ 6 - 9
tests/datawizard/interfaces/void/void_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2012                                     Inria
- * Copyright (C) 2012,2013,2017                           CNRS
+ * Copyright (C) 2012,2013,2017,2019                      CNRS
  * Copyright (C) 2012,2013                                Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -60,10 +60,9 @@ unregister_data(void)
 	starpu_data_unregister(void2_handle);
 }
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
-	data_interface_test_summary *summary;
+	struct data_interface_test_summary summary;
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
 	conf.ncuda = 2;
@@ -75,17 +74,15 @@ main(int argc, char **argv)
 
 	register_data();
 
-	summary = run_tests(&void_config);
-	if (!summary)
-		exit(EXIT_FAILURE);
+	run_tests(&void_config, &summary);
 
 	unregister_data();
 
 	starpu_shutdown();
 
-	data_interface_test_summary_print(stderr, summary);
+	data_interface_test_summary_print(stderr, &summary);
 
-	return data_interface_test_summary_success(summary);
+	return data_interface_test_summary_success(&summary);
 
 enodev:
 	return STARPU_TEST_SKIPPED;