| 1 |
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 2 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 4 |
// vi: set et ts=4 sw=2 sts=2: |
| 5 |
/****************************************************************************/ |
| 6 |
/* */ |
| 7 |
/* File: std_parallel.c */ |
| 8 |
/* */ |
| 9 |
/* Purpose: parallel part of standard ug domain description */ |
| 10 |
/* */ |
| 11 |
/* Author: Klaus Birken / Christian Wieners */ |
| 12 |
/* Institut fuer Computeranwendungen III */ |
| 13 |
/* Universitaet Stuttgart */ |
| 14 |
/* Pfaffenwaldring 27 */ |
| 15 |
/* 70550 Stuttgart */ |
| 16 |
/* email: [email protected] */ |
| 17 |
/* */ |
| 18 |
/* History: Sep 12 1996 ug version 3.4 */ |
| 19 |
/* */ |
| 20 |
/* Remarks: */ |
| 21 |
/* */ |
| 22 |
/****************************************************************************/ |
| 23 |
|
| 24 |
#ifdef ModelP |
| 25 |
|
| 26 |
/****************************************************************************/ |
| 27 |
/* */ |
| 28 |
/* include files */ |
| 29 |
/* system include files */ |
| 30 |
/* application include files */ |
| 31 |
/* */ |
| 32 |
/****************************************************************************/ |
| 33 |
|
| 34 |
/* standard C library */ |
| 35 |
#include <config.h> |
| 36 |
#include <cstdlib> |
| 37 |
#include <cstddef> |
| 38 |
#include <cstdio> |
| 39 |
#include <cstring> |
| 40 |
#include <cassert> |
| 41 |
|
| 42 |
/* low modules */ |
| 43 |
#include <dune/uggrid/low/architecture.h> |
| 44 |
#include <dune/uggrid/low/debug.h> |
| 45 |
#include <dune/uggrid/low/heaps.h> |
| 46 |
#include <dune/uggrid/low/namespace.h> |
| 47 |
#include <dune/uggrid/low/ugtypes.h> |
| 48 |
|
| 49 |
/* parallel modules */ |
| 50 |
#include <dune/uggrid/parallel/ddd/include/memmgr.h> |
| 51 |
#include <dune/uggrid/parallel/dddif/parallel.h> |
| 52 |
|
| 53 |
/* domain module */ |
| 54 |
#include "std_domain.h" |
| 55 |
|
| 56 |
USING_UGDIM_NAMESPACE |
| 57 |
USING_UG_NAMESPACE |
| 58 |
|
| 59 |
#ifdef ModelP |
| 60 |
using namespace PPIF; |
| 61 |
#endif |
| 62 |
|
| 63 |
/****************************************************************************/ |
| 64 |
/* */ |
| 65 |
/* defines in the following order */ |
| 66 |
/* */ |
| 67 |
/* compile time constants defining static data size (i.e. arrays) */ |
| 68 |
/* other constants */ |
| 69 |
/* macros */ |
| 70 |
/* */ |
| 71 |
/****************************************************************************/ |
| 72 |
|
| 73 |
#define CEIL(n) ((n)+((ALIGNMENT-((n)&(ALIGNMENT-1)))&(ALIGNMENT-1))) |
| 74 |
|
| 75 |
/****************************************************************************/ |
| 76 |
/* */ |
| 77 |
/* data structures used in this source file (exported data structures are */ |
| 78 |
/* in the corresponding include file!) */ |
| 79 |
/* */ |
| 80 |
/****************************************************************************/ |
| 81 |
|
| 82 |
/****************************************************************************/ |
| 83 |
/* */ |
| 84 |
/* definition of exported global variables */ |
| 85 |
/* */ |
| 86 |
/****************************************************************************/ |
| 87 |
|
| 88 |
/****************************************************************************/ |
| 89 |
/* */ |
| 90 |
/* definition of variables global to this source file only (static!) */ |
| 91 |
/* */ |
| 92 |
/****************************************************************************/ |
| 93 |
|
| 94 |
/****************************************************************************/ |
| 95 |
/* */ |
| 96 |
/* forward declarations of functions used before they are defined */ |
| 97 |
/* */ |
| 98 |
/****************************************************************************/ |
| 99 |
|
| 100 |
void NS_DIM_PREFIX DomInitParallel (INT TypeBndP, INT TypeBndS) |
| 101 |
{} |
| 102 |
|
| 103 |
void NS_DIM_PREFIX DomHandlerInit (INT handlerSet) |
| 104 |
{} |
| 105 |
|
| 106 |
void NS_DIM_PREFIX BElementXferBndS(DDD::DDDContext& context, BNDS **bnds, int n, int proc, int prio) |
| 107 |
{ |
| 108 |
INT size,i,size0; |
| 109 |
|
| 110 |
size = CEIL(sizeof(INT)); |
| 111 |
for (i=0; i<n; i++) |
| 112 |
if (bnds[i] != NULL) |
| 113 |
{ |
| 114 |
size0 = BND_SIZE(bnds[i]); |
| 115 |
size += CEIL(size0) + CEIL(sizeof(INT)); |
| 116 |
|
| 117 |
PRINTDEBUG(dom,1,("BElementXferBndS(): Xfer " |
| 118 |
"%x pid %d n %d size %d\n", |
| 119 |
bnds[i],BND_PATCH_ID(bnds[i]), |
| 120 |
BND_N(bnds[i]),BND_SIZE(bnds[i]))); |
| 121 |
|
| 122 |
} |
| 123 |
|
| 124 |
DDD_XferAddData(context, size, DDD_DOMAIN_DATA); |
| 125 |
} |
| 126 |
|
| 127 |
void NS_DIM_PREFIX BElementGatherBndS (BNDS **bnds, int n, int cnt, char *data) |
| 128 |
{ |
| 129 |
INT size,i; |
| 130 |
|
| 131 |
for (i=0; i<n; i++) |
| 132 |
if (bnds[i] != NULL) |
| 133 |
{ |
| 134 |
|
| 135 |
PRINTDEBUG(dom,1,("BElementGatherBndS(): %d " |
| 136 |
"%x pid %d n %d size %d\n",i, |
| 137 |
bnds[i],BND_PATCH_ID(bnds[i]), |
| 138 |
BND_N(bnds[i]),BND_SIZE(bnds[i]))); |
| 139 |
|
| 140 |
|
| 141 |
size = BND_SIZE(bnds[i]); |
| 142 |
memcpy(data,&i,sizeof(INT)); |
| 143 |
data += CEIL(sizeof(INT)); |
| 144 |
memcpy(data,bnds[i],size); |
| 145 |
data += CEIL(size); |
| 146 |
} |
| 147 |
i = -1; |
| 148 |
memcpy(data,&i,sizeof(INT)); |
| 149 |
} |
| 150 |
|
| 151 |
void NS_DIM_PREFIX BElementScatterBndS (const DDD::DDDContext& context, BNDS **bnds, int n, int cnt, char *data) |
| 152 |
{ |
| 153 |
INT size,i; |
| 154 |
BNDS *bs; |
| 155 |
|
| 156 |
memcpy(&i,data,sizeof(INT)); |
| 157 |
while (i != -1) |
| 158 |
{ |
| 159 |
data += CEIL(sizeof(INT)); |
| 160 |
bs = (BNDS *) data; |
| 161 |
size = BND_SIZE(bs); |
| 162 |
|
| 163 |
PRINTDEBUG(dom,1,("BElementScatterBndS(): %d me %d\n",i,size)); |
| 164 |
|
| 165 |
if (bnds[i] == NULL) |
| 166 |
{ |
| 167 |
bs = (BNDS *) memmgr_AllocOMEM((size_t)size,ddd_ctrl(context).TypeBndS,0,0); |
| 168 |
memcpy(bs,data,size); |
| 169 |
bnds[i] = bs; |
| 170 |
} |
| 171 |
data += CEIL(size); |
| 172 |
memcpy(&i,data,sizeof(INT)); |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
void NS_DIM_PREFIX BVertexXferBndP (DDD::DDDContext& context, BNDP *bndp, int proc, int prio) |
| 177 |
{ |
| 178 |
INT size; |
| 179 |
|
| 180 |
size = BND_SIZE(bndp); |
| 181 |
|
| 182 |
PRINTDEBUG(dom,1,("BVertexXferBndP(): %x pid %d n %d size %d\n", |
| 183 |
bndp,BND_PATCH_ID(bndp),BND_N(bndp),BND_SIZE(bndp))); |
| 184 |
|
| 185 |
DDD_XferAddData(context, size, DDD_DOMAIN_DATA); |
| 186 |
} |
| 187 |
|
| 188 |
void NS_DIM_PREFIX BVertexGatherBndP (BNDP *bndp, int cnt, char *data) |
| 189 |
{ |
| 190 |
PRINTDEBUG(dom,1,("BVertexGatherBnd(): pid %d " |
| 191 |
"n %d size %d cnt %d\n", |
| 192 |
BND_PATCH_ID(bndp), |
| 193 |
BND_N(bndp),BND_SIZE(bndp),cnt)); |
| 194 |
|
| 195 |
ASSERT(cnt == BND_SIZE(bndp)); |
| 196 |
|
| 197 |
memcpy(data,bndp,cnt); |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
void NS_DIM_PREFIX BVertexScatterBndP (const DDD::DDDContext& context, BNDP **bndp, int cnt, char *data) |
| 202 |
{ |
| 203 |
if (*bndp == NULL) |
| 204 |
{ |
| 205 |
*bndp = (BNDS *) memmgr_AllocOMEM((size_t)cnt,ddd_ctrl(context).TypeBndP,0,0); |
| 206 |
memcpy(*bndp,data,cnt); |
| 207 |
PRINTDEBUG(dom,1,("BVertexScatterBndP(): pid " |
| 208 |
"%d n %d size %d cnt %d\n", |
| 209 |
BND_PATCH_ID(*bndp), |
| 210 |
BND_N(*bndp),BND_SIZE(*bndp),cnt)); |
| 211 |
} |
| 212 |
} |
| 213 |
#endif /* ModelP */ |