/* * Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg. * All rights reserved. This file is part of nusif-solver. * Use of this source code is governed by a MIT style * license that can be found in the LICENSE file. */ #ifndef __COMM_H_ #define __COMM_H_ #include /* * Spatial directions: * ICORD (0) from 0 (LEFT) to imax (RIGHT) * JCORD (1) from 0 (BOTTOM) to jmax (TOP) * KCORD (2) from 0 (FRONT) to kmax (BACK) * All derived Subarray types are in C ordering * with indices KDIM (0), JDIM(1) and IDIM(2) * */ typedef enum direction { LEFT = 0, RIGHT, BOTTOM, TOP, FRONT, BACK, NDIRS } Direction; typedef enum coordinates { ICORD = 0, JCORD, KCORD, NCORDS } Coordinates; typedef enum dimension { KDIM = 0, JDIM, IDIM, NDIMS } Dimension; enum layer { HALO = 0, BULK }; enum op { MAX = 0, SUM }; typedef struct { int rank; int size; MPI_Comm comm; MPI_Datatype sbufferTypes[NDIRS]; MPI_Datatype rbufferTypes[NDIRS]; int neighbours[NDIRS]; int coords[NDIMS], dims[NDIMS]; int imaxLocal, jmaxLocal, kmaxLocal; MPI_File fh; } Comm; extern void commInit(Comm* comm, int kmax, int jmax, int imax); extern void commFree(Comm* comm); extern void commPrintConfig(Comm*); extern void commExchange(Comm*, double*); extern void commShift(Comm* c, double* f, double* g, double* h); extern void commReduction(double* v, int op); extern int commIsBoundary(Comm* c, Direction direction); extern void commCollectResult(Comm* c, double* ug, double* vg, double* wg, double* pg, double* u, double* v, double* w, double* p, int kmax, int jmax, int imax); static inline int commIsMaster(Comm* c) { return c->rank == 0; } #endif // __COMM_H_