/* 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 "helper.h" /* Returns the MPI node number where data indexes index is */ int my_distrib(int x, int nb_nodes) { return x % nb_nodes; } void cpu_codelet(void *descr[], void *_args) { int *vector = (int *)STARPU_VECTOR_GET_PTR(descr[0]); unsigned nx = STARPU_VECTOR_GET_NX(descr[0]); unsigned i; int rank; starpu_codelet_unpack_args(_args, &rank); for (i = 0; i < nx; i++) { //fprintf(stderr,"rank %d v[%d] = %d\n", rank, i, vector[i]); vector[i] *= rank+2; } } static struct starpu_codelet cl = { .cpu_funcs = {cpu_codelet}, .nbuffers = 1, .modes = {STARPU_RW}, #ifdef STARPU_SIMGRID .model = &starpu_nop_perf_model, #endif }; void scallback(void *arg STARPU_ATTRIBUTE_UNUSED) { char *msg = arg; FPRINTF_MPI(stderr, "Sending completed for <%s>\n", msg); } void rcallback(void *arg STARPU_ATTRIBUTE_UNUSED) { char *msg = arg; FPRINTF_MPI(stderr, "Reception completed for <%s>\n", msg); } int main(int argc, char **argv) { int rank, nodes, ret, x; int *vector = NULL; starpu_data_handle_t *data_handles; int size=10; ret = starpu_init(NULL); STARPU_CHECK_RETURN_VALUE(ret, "starpu_init"); ret = starpu_mpi_init(&argc, &argv, 1); STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init"); starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank); starpu_mpi_comm_size(MPI_COMM_WORLD, &nodes); 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; } if (rank == 0) { /* Allocate the vector */ vector = malloc(size * sizeof(int)); for(x=0 ; x