1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 /****************************************************************************/
4 /*																			*/
5 /* File:	  std_parallel.c				                                                                */
6 /*																			*/
7 /* Purpose:   parallel part of standard ug domain description                           */
8 /*																			*/
9 /* Author:	  Klaus Birken / Christian Wieners								*/
10 /*			  Institut fuer Computeranwendungen III                                                 */
11 /*			  Universitaet Stuttgart										*/
12 /*			  Pfaffenwaldring 27											*/
13 /*			  70550 Stuttgart												*/
14 /*			  email: ug@ica3.uni-stuttgart.de								*/
15 /*																			*/
16 /* History:   Sep 12 1996 ug version 3.4                                                                */
17 /*																			*/
18 /* Remarks:                                                                                                                             */
19 /*																			*/
20 /****************************************************************************/
21 
22 #ifdef ModelP
23 
24 /****************************************************************************/
25 /*																			*/
26 /* include files															*/
27 /*			  system include files											*/
28 /*			  application include files                                                                     */
29 /*																			*/
30 /****************************************************************************/
31 
32 /* standard C library */
33 #include <config.h>
34 #include <cstdlib>
35 #include <cstddef>
36 #include <cstdio>
37 #include <cstring>
38 #include <cassert>
39 
40 /* low modules */
41 #include <dune/uggrid/low/architecture.h>
42 #include <dune/uggrid/low/debug.h>
43 #include <dune/uggrid/low/heaps.h>
44 #include <dune/uggrid/low/namespace.h>
45 #include <dune/uggrid/low/ugtypes.h>
46 
47 /* parallel modules */
48 #include <dune/uggrid/parallel/ddd/include/memmgr.h>
49 #include <dune/uggrid/parallel/dddif/parallel.h>
50 
51 /* domain module */
52 #include "domain.h"
53 #include "std_domain.h"
54 #include "std_internal.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 
DomInitParallel(INT TypeBndP,INT TypeBndS)100 void NS_DIM_PREFIX DomInitParallel (INT TypeBndP, INT TypeBndS)
101 {}
102 
DomHandlerInit(INT handlerSet)103 void NS_DIM_PREFIX DomHandlerInit (INT handlerSet)
104 {}
105 
BElementXferBndS(DDD::DDDContext & context,BNDS ** bnds,int n,int proc,int prio)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 
BElementGatherBndS(BNDS ** bnds,int n,int cnt,char * data)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 
BElementScatterBndS(const DDD::DDDContext & context,BNDS ** bnds,int n,int cnt,char * data)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 
BVertexXferBndP(DDD::DDDContext & context,BNDP * bndp,int proc,int prio)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 
BVertexGatherBndP(BNDP * bndp,int cnt,char * data)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 
BVertexScatterBndP(const DDD::DDDContext & context,BNDP ** bndp,int cnt,char * data)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 */
214