/* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017 CNRS * * 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 #include #include #include "helper.h" #define FFACTOR 42 void func_cpu(void *descr[], void *_args) { int num = starpu_task_get_current()->nbuffers; int *factor = (int *)STARPU_VARIABLE_GET_PTR(descr[num-1]); int i; for (i = 0; i < num-1; i++) { int *x = (int *)STARPU_VARIABLE_GET_PTR(descr[i]); *x = *x + 1**factor; } } #ifdef STARPU_SIMGRID /* Dummy cost function for simgrid */ static double cost_function(struct starpu_task *task STARPU_ATTRIBUTE_UNUSED, unsigned nimpl STARPU_ATTRIBUTE_UNUSED) { return 0.000001; } static struct starpu_perfmodel dumb_model = { .type = STARPU_COMMON, .cost_function = cost_function }; #endif struct starpu_codelet codelet = { .cpu_funcs = {func_cpu}, .cpu_funcs_name = {"func_cpu"}, .nbuffers = STARPU_VARIABLE_NBUFFERS, #ifdef STARPU_SIMGRID .model = &dumb_model, #endif }; int main(int argc, char **argv) { int *x; int i, ret, loop; int rank; int factor=0; #ifdef STARPU_QUICK_CHECK int nloops = 4; #else int nloops = 16; #endif starpu_data_handle_t *data_handles; starpu_data_handle_t factor_handle; struct starpu_data_descr *descrs; int mpi_init; MPI_INIT_THREAD(&argc, &argv, MPI_THREAD_SERIALIZED, &mpi_init); ret = starpu_init(NULL); STARPU_CHECK_RETURN_VALUE(ret, "starpu_init"); ret = starpu_mpi_init(NULL, NULL, mpi_init); STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init"); starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank); if (starpu_cpu_worker_get_count() == 0) { if (rank == 0) FPRINTF(stderr, "We need at least 1 CPU worker.\n"); starpu_mpi_shutdown(); starpu_shutdown(); return STARPU_TEST_SKIPPED; } x = calloc(1, (STARPU_NMAXBUFS+15) * sizeof(int)); data_handles = malloc((STARPU_NMAXBUFS+15) * sizeof(starpu_data_handle_t)); descrs = malloc((STARPU_NMAXBUFS+15) * sizeof(struct starpu_data_descr)); for(i=0 ; i