| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | 
							- /* StarPU --- Runtime system for heterogeneous multicore architectures.
 
-  *
 
-  * Copyright (C) 2011-2013                                Inria
 
-  * Copyright (C) 2012-2013,2015,2017                      CNRS
 
-  * Copyright (C) 2013                                     Université de Bordeaux
 
-  *
 
-  * 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.h>
 
- #include "../test_interfaces.h"
 
- #include "../../../helper.h"
 
- #define WIDTH  16
 
- #define HEIGHT 16
 
- #ifdef STARPU_USE_CPU
 
- void test_matrix_cpu_func(void *buffers[], void *args);
 
- #endif /* !STARPU_USE_CPU */
 
- #ifdef STARPU_USE_CUDA
 
- extern void test_matrix_cuda_func(void *buffers[], void *_args);
 
- #endif
 
- #ifdef STARPU_USE_OPENCL
 
- extern void test_matrix_opencl_func(void *buffers[], void *args);
 
- #endif
 
- static starpu_data_handle_t matrix_handle;
 
- static starpu_data_handle_t matrix2_handle;
 
- struct test_config matrix_config =
 
- {
 
- #ifdef STARPU_USE_CPU
 
- 	.cpu_func      = test_matrix_cpu_func,
 
- #endif /* ! STARPU_USE_CPU */
 
- #ifdef STARPU_USE_CUDA
 
- 	.cuda_func     = test_matrix_cuda_func,
 
- #endif
 
- #ifdef STARPU_USE_OPENCL
 
- 	.opencl_func   = test_matrix_opencl_func,
 
- #endif
 
- #ifdef STARPU_USE_MIC
 
- 	.cpu_func_name = "test_matrix_cpu_func", 
 
- #endif
 
- 	.handle        = &matrix_handle,
 
- 	.dummy_handle  = &matrix2_handle,
 
- 	.copy_failed   = SUCCESS,
 
- 	.name          = "matrix_interface"
 
- };
 
- static int matrix[WIDTH * HEIGHT];
 
- static int matrix2[WIDTH * HEIGHT];
 
- static void
 
- register_data(void)
 
- {
 
- 	int i;
 
- 	int size = WIDTH * HEIGHT;
 
- 	for (i = 0; i < size; i++)
 
- 		matrix[i] = i;
 
- 	starpu_matrix_data_register(&matrix_handle,
 
- 				    STARPU_MAIN_RAM,
 
- 				    (uintptr_t) matrix,
 
- 				    WIDTH, /* ld */
 
- 				    WIDTH,
 
- 				    HEIGHT,
 
- 				    sizeof(matrix[0]));
 
- 	starpu_matrix_data_register(&matrix2_handle,
 
- 				    STARPU_MAIN_RAM,
 
- 				    (uintptr_t) matrix2,
 
- 				    WIDTH, /* ld */
 
- 				    WIDTH,
 
- 				    HEIGHT,
 
- 				    sizeof(matrix[0]));
 
- }
 
- static void
 
- unregister_data(void)
 
- {
 
- 	starpu_data_unregister(matrix_handle);
 
- 	starpu_data_unregister(matrix2_handle);
 
- }
 
- void
 
- test_matrix_cpu_func(void *buffers[], void *args)
 
- {
 
- 	STARPU_SKIP_IF_VALGRIND;
 
- 	int *val;
 
- 	int factor;
 
- 	int i;
 
- 	int nx, ny;
 
- 	nx = STARPU_MATRIX_GET_NX(buffers[0]);
 
- 	ny = STARPU_MATRIX_GET_NY(buffers[0]);
 
- 	val = (int *) STARPU_MATRIX_GET_PTR(buffers[0]);
 
- 	factor = *(int *) args;
 
- 	for (i = 0; i < nx*ny; i++)
 
- 	{
 
- 		if (val[i] != i * factor)
 
- 		{
 
- 			matrix_config.copy_failed = FAILURE;
 
- 			return;
 
- 		}
 
- 		val[i] *= -1;
 
- 	}
 
- }
 
- int
 
- main(int argc, char **argv)
 
- {
 
- 	data_interface_test_summary *summary;
 
- 	struct starpu_conf conf;
 
- 	starpu_conf_init(&conf);
 
- 	conf.ncuda = 2;
 
- 	conf.nopencl = 1;
 
- 	conf.nmic = -1;
 
- 	if (starpu_initialize(&conf, &argc, &argv) == -ENODEV || starpu_cpu_worker_get_count() == 0)
 
- 		goto enodev;
 
- 	register_data();
 
- 	summary = run_tests(&matrix_config);
 
- 	if (!summary)
 
- 		exit(EXIT_FAILURE);
 
- 	unregister_data();
 
- 	starpu_shutdown();
 
- 	data_interface_test_summary_print(stderr, summary);
 
- 	return data_interface_test_summary_success(summary);
 
- enodev:
 
- 	return STARPU_TEST_SKIPPED;
 
- }
 
 
  |