1 /***********************************************************************
5 The following is a notice of limited availability of the code and
6 Government license and disclaimer which must be included in the
7 prologue of the code and in all source listings of the code.
10 (c) 1977 University of Chicago
12 Permission is hereby granted to use, reproduce, prepare
13 derivative works, and to redistribute to others at no charge. If
14 you distribute a copy or copies of the Software, or you modify a
15 copy or copies of the Software or any portion of it, thus forming
16 a work based on the Software and make and/or distribute copies of
17 such work, you must meet the following conditions:
19 a) If you make a copy of the Software (modified or verbatim)
20 it must include the copyright notice and Government
21 license and disclaimer.
23 b) You must cause the modified Software to carry prominent
24 notices stating that you changed specified portions of
27 This software was authored by:
29 Argonne National Laboratory
30 J. Michalakes: (630) 252-6646; email: michalak@mcs.anl.gov
31 Mathematics and Computer Science Division
32 Argonne National Laboratory, Argonne, IL 60439
34 ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES
35 OF ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT,
36 AND OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A
37 CONTRACT WITH THE DEPARTMENT OF ENERGY.
39 GOVERNMENT LICENSE AND DISCLAIMER
41 This computer code material was prepared, in part, as an account
42 of work sponsored by an agency of the United States Government.
43 The Government is granted for itself and others acting on its
44 behalf a paid-up, nonexclusive, irrevocable worldwide license in
45 this data to reproduce, prepare derivative works, distribute
46 copies to the public, perform publicly and display publicly, and
47 to permit others to do so. NEITHER THE UNITED STATES GOVERNMENT
48 NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, NOR ANY OF
49 THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
50 ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
51 COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS,
52 PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD
53 NOT INFRINGE PRIVATELY OWNED RIGHTS.
55 ***************************************************************************/
62 #define FWD(A,B,C) my_bcopy(A,B,C)
63 #define BWD(A,B,C) my_bcopy(B,A,C)
65 extern int debuggal_pack
;
67 static int first_1
= 1 ;
68 static int first_2
= 1 ;
70 static FILE * xfp
= NULL
;
72 pack_message( msg
, buf
, cursor_p
, d
, ig
, jg
)
76 rsl_index_t d
, ig
, jg
;
80 register int *ips
, *ipd
;
82 unsigned int i
, j
, k
, elemsz
, t0
, t1
, t2
, t3
;
91 sprintf(mess
,"xfp.%03d",rsl_myproc
);
92 if(( xfp
= fopen(mess
,"w")) == NULL
) perror(mess
) ;
96 if ( msg
== NULL
) return(-1) ;
98 i
= ig
- domain_info
[d
].ilocaloffset
; /* this must not go neg */
99 j
= jg
- domain_info
[d
].jlocaloffset
; /* this must not go neg */
104 fprintf(stderr
,"pack_message: %16x, d %d i %d,j %d,ig %d,jg %d, ioff %d, joff %d\n",
105 msg
->fldspecs
->base
, d
, i
,j
,ig
,jg
,domain_info
[d
].ilocaloffset
,domain_info
[d
].jlocaloffset
) ;
109 for ( fld
= msg
->fldspecs
; fld
!= NULL
; fld
= fld
->next
)
112 fprintf(stderr
," : %16x\n",base
) ;
119 for ( fld
= msg
->fldspecs
; fld
!= NULL
; fld
= fld
->next
)
121 elemsz
= fld
->elemsz
;
122 if ( fld
->type
>= 100 )
124 base
= (void *)get_base_for_index( fld
->f90_table_index
) ;
130 switch (fld
->strategy
)
132 case MINNS_MAJEW_2D
: /* <MM> eg: psa(i,j) */
134 FWD( base
+(i
+j
*t0
)*elemsz
,&(buf
[cursor
]),elemsz
) ; cursor
+=elemsz
;
136 case MINEW_MAJNS_2D
: /* eg: xxx(j,i) */
138 FWD( base
+(j
+i
*t0
)*elemsz
,&(buf
[cursor
]),elemsz
) ; cursor
+=elemsz
;
140 case MINNS_MAJEW_K_3D
: /* <MM> eg: ua(i,j,k) */
142 t1
= fld
->llen
[1]*t0
;
148 ipd
= (int *)(&buf
[cursor
]) ;
149 ips
= (int *)(base
+ (i
+ j
*t0
)*elemsz
) ;
150 /* ipd must be aligned on 4 byte boundary on some machines
151 for this to work -- a symptom of it not working would be
152 a bus error, for example. */
153 for ( k
= 0 ; k
< fld
->llen
[2] ; k
++ )
159 cursor
+= fld
->llen
[2] * elemsz
;
163 for( k
= 0 ; k
< fld
->llen
[2] ; k
++ )
165 FWD( base
+(i
+j
*t0
+k
*t1
)*elemsz
,&(buf
[cursor
]),elemsz
) ;
171 case MINEW_MAJNS_K_3D
: /* <MM> eg: u(j,i,k) */
173 t1
= fld
->llen
[1]*t0
;
179 ipd
= (int *)(&buf
[cursor
]) ;
180 ips
= (int *)(base
+ (j
+ i
*t0
)*elemsz
) ;
181 /* ipd must be aligned on 4 byte boundary on some machines
182 for this to work -- a symptom of it not working would be
183 a bus error, for example. */
184 for ( k
= 0 ; k
< fld
->llen
[2] ; k
++ )
190 cursor
+= fld
->llen
[2] * elemsz
;
194 for( k
= 0 ; k
< fld
->llen
[2] ; k
++ )
196 FWD( base
+(j
+i
*t0
+k
*t1
)*elemsz
,&(buf
[cursor
]),elemsz
) ;
203 case K_MIDNS_MAJEW_3D
: /* <MM> eg: u(k,i,j) */
205 t1
= fld
->llen
[1]*t0
;
210 ipd
= (int *)(&buf
[cursor
]) ;
211 ips
= (int *)(base
+ (i
*t0
+j
*t1
)*elemsz
) ;
212 /* ipd must be aligned on 4 byte boundary on some machines
213 for this to work -- a symptom of it not working would be
214 a bus error, for example. */
215 for ( k
= 0 ; k
< t0
; k
++ )
219 cursor
+= t0
*elemsz
;
223 FWD( base
+(i
*t0
+j
*t1
)*elemsz
,&(buf
[cursor
]),t0
*elemsz
) ;
231 RSL_TEST_ERR(1,"pack_message: strategy not supported" ) ;
238 unpack_message( msg
, buf
, cursor_p
, d
, ig
, jg
)
239 message_desc_t
*msg
;
242 rsl_index_t d
, ig
, jg
;
245 register int * ips
, * ipd
;
247 unsigned int i
, j
, k
, elemsz
, t0
, t1
, t2
, t3
;
257 sprintf(mess
,"xfp.%03d",rsl_myproc
);
258 xfp
= fopen(mess
,"w") ;
263 if ( msg
== NULL
) return(-1) ;
265 i
= ig
- domain_info
[d
].ilocaloffset
; /* this must not go neg */
266 j
= jg
- domain_info
[d
].jlocaloffset
; /* this must not go neg */
271 fprintf(stderr
,"unpack_message: %16x, i %d,j %d,ig %d,jg %d, ioff %d, joff %d\n",
272 msg
->fldspecs
->base
,i
,j
,ig
,jg
,domain_info
[d
].ilocaloffset
,domain_info
[d
].jlocaloffset
) ;
276 for ( fld
= msg
->fldspecs
; fld
!= NULL
; fld
= fld
->next
)
279 fprintf(stderr
, " : base=%16x, elemsz=%d, strategy=%d \n"
280 , base
, fld
->elemsz
, fld
->strategy
289 for ( fld
= msg
->fldspecs
; fld
!= NULL
; fld
= fld
->next
)
291 elemsz
= fld
->elemsz
;
292 if ( fld
->type
>= 100 )
294 base
= (void *)get_base_for_index( fld
->f90_table_index
) ;
300 switch (fld
->strategy
)
302 case MINNS_MAJEW_2D
: /* <MM> eg: psa(i,j) */
304 BWD( base
+(i
+j
*t0
)*elemsz
,&(buf
[cursor
]),elemsz
) ; cursor
+=elemsz
;
306 case MINEW_MAJNS_2D
: /* eg: xxx(j,i) */
308 BWD( base
+(j
+i
*t0
)*elemsz
,&(buf
[cursor
]),elemsz
) ; cursor
+=elemsz
;
310 case MINNS_MAJEW_K_3D
: /* <MM> eg: ua(i,j,k) */
312 t1
= fld
->llen
[1]*t0
;
318 ips
= (int *)(&buf
[cursor
]) ;
319 ipd
= (int *)(base
+ (i
+ j
*t0
)*elemsz
) ;
320 /* ipd must be aligned on 4 byte boundary on some machines
321 for this to work -- a symptom of it not working would be
322 a bus error, for example. */
323 for ( k
= 0 ; k
< fld
->llen
[2] ; k
++ )
329 cursor
+= fld
->llen
[2] * elemsz
;
333 for( k
= 0 ; k
< fld
->llen
[2] ; k
++ )
335 BWD( base
+(i
+j
*t0
+k
*t1
)*elemsz
,&(buf
[cursor
]),elemsz
) ;
341 case MINEW_MAJNS_K_3D
: /* <MM> eg: u(j,i,k) */
343 t1
= fld
->llen
[1]*t0
;
349 ips
= (int *)(&buf
[cursor
]) ;
350 ipd
= (int *)(base
+ (j
+ i
*t0
)*elemsz
) ;
351 /* ipd must be aligned on 4 byte boundary on some machines
352 for this to work -- a symptom of it not working would be
353 a bus error, for example. */
354 for ( k
= 0 ; k
< fld
->llen
[2] ; k
++ )
360 cursor
+= fld
->llen
[2] * elemsz
;
364 for( k
= 0 ; k
< fld
->llen
[2] ; k
++ )
366 BWD( base
+(j
+i
*t0
+k
*t1
)*elemsz
,&(buf
[cursor
]),elemsz
) ;
373 case K_MIDNS_MAJEW_3D
: /* <MM> eg: u(k,i,j) */
375 t1
= fld
->llen
[1]*t0
;
380 ips
= (int *)(&buf
[cursor
]) ;
381 ipd
= (int *)(base
+ (i
*t0
+j
*t1
)*elemsz
) ;
382 /* ipd must be aligned on 4 byte boundary on some machines
383 for this to work -- a symptom of it not working would be
384 a bus error, for example. */
385 for ( k
= 0 ; k
< t0
; k
++ )
389 cursor
+= t0
*elemsz
;
393 BWD( base
+(i
*t0
+j
*t1
)*elemsz
,&(buf
[cursor
]),t0
*elemsz
) ;
400 RSL_TEST_ERR(1,"unpack_message: strategy not supported" ) ;
413 for ( i
= 0 ; i
< C
; i
++ ) *(B
+i
) = *(A
+i
) ;