/* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique * * 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 #define NX 21 #define PARTS 3 #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0) void cpu_func(void *buffers[], void *cl_arg) { unsigned i; int *factor = (int *) cl_arg; /* length of the vector */ unsigned n = STARPU_VECTOR_GET_NX(buffers[0]); /* local copy of the vector pointer */ int *val = (int *)STARPU_VECTOR_GET_PTR(buffers[0]); for (i = 0; i < n; i++) val[i] *= *factor; } int main(int argc, char **argv) { int i; int vector[NX]; starpu_data_handle_t handle; int factor=1; int ret; struct starpu_codelet cl = { .cpu_funcs = {cpu_func, NULL}, .cpu_funcs_name = {"cpu_func", NULL}, .nbuffers = 1, .modes = {STARPU_RW}, .name = "vector_scal" }; for(i=0 ; ihandles[0] = sub_handle; task->cl = &cl; task->synchronous = 1; task->cl_arg = &factor; task->cl_arg_size = sizeof(factor); ret = starpu_task_submit(task); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit"); } starpu_data_unpartition(handle, 0); starpu_data_unregister(handle); starpu_shutdown(); FPRINTF(stderr,"OUT Vector: "); for(i=0 ; i