/* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2010-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria * * 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. */ /* * This examplifies how to use partitioning filters. We here just split a 3D * matrix into 3D slices (along the X axis), and run a dumb kernel on them. */ #include #define NX 5 #define NY 4 #define NZ 3 #define PARTS 2 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0) extern void cpu_func(void *buffers[], void *cl_arg); #ifdef STARPU_USE_CUDA extern void cuda_func(void *buffers[], void *cl_arg); #endif #ifdef STARPU_USE_OPENCL extern void opencl_func(void *buffers[], void *cl_arg); #endif void print_block(int *block, int nx, int ny, int nz, unsigned ldy, unsigned ldz) { int i, j, k; FPRINTF(stderr, "block=%p nx=%d ny=%d nz=%d ldy=%u ldz=%u\n", block, nx, ny, nz, ldy, ldz); for(k=0 ; kcl = &cl; task->synchronous = 1; task->callback_func = NULL; task->handles[0] = starpu_data_get_sub_data(handle, 1, i); task->cl_arg = &multiplier; task->cl_arg_size = sizeof(multiplier); ret = starpu_task_submit(task); if (ret) { FPRINTF(stderr, "Error when submitting task\n"); exit(ret); } } /* Unpartition the data, unregister it from StarPU and shutdown */ starpu_data_unpartition(handle, STARPU_MAIN_RAM); print_data(handle); starpu_data_unregister(handle); #ifdef STARPU_USE_OPENCL ret = starpu_opencl_unload_opencl(&opencl_program); STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_unload_opencl"); #endif /* Print result block */ FPRINTF(stderr, "OUT Block\n"); print_block(block, NX, NY, NZ, NX, NX*NY); free(block); starpu_shutdown(); return 0; }