/* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2010-2021 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 4D * matrix into 4D slices (along the X axis), and run a dumb kernel on them. */ #include #define NX 6 #define NY 5 #define NZ 4 #define NT 3 #define PARTS 2 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0) void cpu_func(void *buffers[], void *cl_arg) { int i, j, k, l; int *factor = (int *) cl_arg; int *val = (int *)STARPU_TENSOR_GET_PTR(buffers[0]); int nx = (int)STARPU_TENSOR_GET_NX(buffers[0]); int ny = (int)STARPU_TENSOR_GET_NY(buffers[0]); int nz = (int)STARPU_TENSOR_GET_NZ(buffers[0]); int nt = (int)STARPU_TENSOR_GET_NT(buffers[0]); unsigned ldy = STARPU_TENSOR_GET_LDY(buffers[0]); unsigned ldz = STARPU_TENSOR_GET_LDZ(buffers[0]); unsigned ldt = STARPU_TENSOR_GET_LDT(buffers[0]); for(l=0; lcl = &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); /* Print result tensor */ FPRINTF(stderr, "OUT Tensor\n"); print_tensor(tensor, NX, NY, NZ, NT, NX, NX*NY, NX*NY*NZ); free(tensor); starpu_shutdown(); return 0; }