/* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2011-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. */ #include #include #include "helper.h" #if !defined(STARPU_HAVE_SETENV) #warning setenv is not defined. Skipping test int main(int argc, char **argv) { return STARPU_TEST_SKIPPED; } #else void func_cpu(void *descr[], void *_args) { (void) descr; (void) _args; } struct starpu_codelet mycodelet = { .cpu_funcs = {func_cpu}, .nbuffers = 2, .modes = {STARPU_RW, STARPU_R}, .model = &starpu_perfmodel_nop, }; struct starpu_codelet mycodelet2 = { .cpu_funcs = {func_cpu}, .nbuffers = 1, .modes = {STARPU_RW}, .model = &starpu_perfmodel_nop, }; #define X 4 /* Returns the MPI node number where data is */ int my_distrib(int x, int nb_nodes) { return x % nb_nodes; } void dotest(int rank, int size, char *enabled) { int x, i; int ret; unsigned values[X]; starpu_data_handle_t data_handles[X]; setenv("STARPU_MPI_CACHE", enabled, 1); FPRINTF(stderr, "Testing with cache '%s'\n", enabled); ret = starpu_mpi_init_conf(NULL, NULL, 0, MPI_COMM_WORLD, NULL); STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_conf"); for(x = 0; x < X; x++) { values[x] = (rank+1)*10; } for(x = 0; x < X; x++) { int mpi_rank = my_distrib(x, size); if (mpi_rank == rank) { starpu_variable_data_register(&data_handles[x], STARPU_MAIN_RAM, (uintptr_t)&(values[x]), sizeof(unsigned)); } else { /* I don't own this index, but will need it for my computations */ starpu_variable_data_register(&data_handles[x], -1, (uintptr_t)NULL, sizeof(unsigned)); } if (data_handles[x]) { starpu_mpi_data_register(data_handles[x], x, mpi_rank); } } for(i = 0 ; i