/* * StarPU * Copyright (C) INRIA 2008-2010 (see AUTHORS file) * * This program 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. * * This program 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 #include #define NX 5 #define NY 4 #define NZ 3 #define PARTS 2 #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 cpu_func(void *buffers[], void *cl_arg) { unsigned i, j, k; int *factor = cl_arg; int *block = (int *)STARPU_GET_BLOCK_PTR(buffers[0]); int nx = (int)STARPU_GET_BLOCK_NX(buffers[0]); int ny = (int)STARPU_GET_BLOCK_NY(buffers[0]); int nz = (int)STARPU_GET_BLOCK_NZ(buffers[0]); unsigned ldy = STARPU_GET_BLOCK_LDY(buffers[0]); unsigned ldz = STARPU_GET_BLOCK_LDZ(buffers[0]); for(k=0; kcl = &cl; task->synchronous = 1; task->callback_func = NULL; task->buffers[0].handle = starpu_data_get_sub_data(handle, 1, i); task->buffers[0].mode = STARPU_RW; task->cl_arg = &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, 0); print_data(handle); starpu_data_unregister(handle); /* Print result block */ fprintf(stderr, "OUT Block\n"); print_block(block, NX, NY, NZ, NX, NX*NY); starpu_shutdown(); }