| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 | /* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2011  Institut National de Recherche en Informatique et Automatique * * 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 <config.h>#include <starpu.h>#include "multiformat_types.h"#include "../test_interfaces.h"#include "../../../helper.h"static void test_multiformat_cpu_func(void *buffers[], void *args);#ifdef STARPU_USE_CUDAextern void test_multiformat_cuda_func(void *buffers[], void *args);#endif#ifdef STARPU_USE_OPENCLextern void test_multiformat_opencl_func(void *buffers[], void *args);#endifstatic struct point array_of_structs[N_ELEMENTS];static struct point array_of_structs_dummy[N_ELEMENTS];static starpu_data_handle_t multiformat_handle;static starpu_data_handle_t multiformat_dummy_handle;struct test_config multiformat_config ={	.cpu_func      = test_multiformat_cpu_func,#ifdef STARPU_USE_CUDA	.cuda_func     = test_multiformat_cuda_func,#endif#ifdef STARPU_USE_OPENCL	.opencl_func   = test_multiformat_opencl_func,#endif	.handle        = &multiformat_handle,	.dummy_handle  = &multiformat_dummy_handle,	.copy_failed   = 0,	.name          = "multiformat_interface"};static voidtest_multiformat_cpu_func(void *buffers[], void *args){	STARPU_SKIP_IF_VALGRIND;	struct point *aos;	unsigned int n, i;	int factor;	aos = (struct point *) STARPU_MULTIFORMAT_GET_CPU_PTR(buffers[0]);	n = STARPU_MULTIFORMAT_GET_NX(buffers[0]);	factor = *(int *) args;	for (i = 0; i < n; i++)	{			FPRINTF(stderr, "(%d %d) [%d]", aos[i].x, aos[i].y, factor);		if (aos[i].x != i * factor || aos[i].y != i * factor)		{			multiformat_config.copy_failed = 1;		}		aos[i].x = -aos[i].x;		aos[i].y = -aos[i].y;	}	FPRINTF(stderr, "\n");}#ifdef STARPU_USE_CUDAextern struct starpu_codelet cpu_to_cuda_cl;extern struct starpu_codelet cuda_to_cpu_cl;#endif#ifdef STARPU_USE_OPENCLextern struct starpu_codelet cpu_to_opencl_cl;extern struct starpu_codelet opencl_to_cpu_cl;#endifstruct starpu_multiformat_data_interface_ops format_ops ={#ifdef STARPU_USE_CUDA	.cuda_elemsize = 2* sizeof(float),	.cpu_to_cuda_cl = &cpu_to_cuda_cl,	.cuda_to_cpu_cl = &cuda_to_cpu_cl,#endif#ifdef STARPU_USE_OPENCL	.opencl_elemsize = 2 * sizeof(float),	.cpu_to_opencl_cl = &cpu_to_opencl_cl,	.opencl_to_cpu_cl = &opencl_to_cpu_cl,#endif	.cpu_elemsize = sizeof(struct point),};static voidregister_data(void){	int i;	for (i = 0; i < N_ELEMENTS; i++)	{		array_of_structs[i].x = i;		array_of_structs[i].y = i;	}	starpu_multiformat_data_register(&multiformat_handle,					 0,					 &array_of_structs,					 N_ELEMENTS,					 &format_ops);	starpu_multiformat_data_register(&multiformat_dummy_handle,					 0,					 &array_of_structs_dummy,					 N_ELEMENTS,					 &format_ops);}static voidunregister_data(void){	starpu_data_unregister(multiformat_handle);	starpu_data_unregister(multiformat_dummy_handle);}intmain(void){#ifdef STARPU_USE_CPU	int ret;	data_interface_test_summary *summary;	struct starpu_conf conf =	{		.ncpus   = -1,		.ncuda   = 2,		.nopencl = 1	};	ret = starpu_init(&conf);	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");	register_data();	summary = run_tests(&multiformat_config);	if (!summary)		exit(EXIT_FAILURE);	data_interface_test_summary_print(stderr, summary);	unregister_data();	starpu_shutdown();	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. */	return STARPU_TEST_SKIPPED;#endif}
 |