00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "./dataloop.h"
00020 #include "typesize_support.h"
00021
00022 static void DLOOP_Type_calc_footprint_struct(MPI_Datatype type,
00023 int combiner,
00024 int *ints,
00025 MPI_Aint *aints,
00026 MPI_Datatype *types,
00027 DLOOP_Type_footprint *tfp);
00028 static int DLOOP_Named_type_alignsize(MPI_Datatype type, MPI_Aint disp);
00029 static int DLOOP_Structalign_integer_max(void);
00030 static int DLOOP_Structalign_float_max(void);
00031 static int DLOOP_Structalign_double_max(void);
00032 static int DLOOP_Structalign_long_double_max(void);
00033 static int DLOOP_Structalign_double_position(void);
00034 static int DLOOP_Structalign_llint_position(void);
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #define DLOOP_DATATYPE_CONTIG_LB_UB(cnt_, \
00048 old_lb_, \
00049 old_ub_, \
00050 old_extent_, \
00051 lb_, \
00052 ub_) \
00053 { \
00054 if (cnt_ == 0) { \
00055 lb_ = old_lb_; \
00056 ub_ = old_ub_; \
00057 } \
00058 else if (old_ub_ >= old_lb_) { \
00059 lb_ = old_lb_; \
00060 ub_ = old_ub_ + (old_extent_) * (cnt_ - 1); \
00061 } \
00062 else { \
00063 lb_ = old_lb_ + (old_extent_) * (cnt_ - 1); \
00064 ub_ = old_ub_; \
00065 } \
00066 }
00067
00068
00069
00070
00071
00072
00073
00074 #define DLOOP_DATATYPE_VECTOR_LB_UB(cnt_, \
00075 stride_, \
00076 blklen_, \
00077 old_lb_, \
00078 old_ub_, \
00079 old_extent_, \
00080 lb_, \
00081 ub_) \
00082 { \
00083 if (cnt_ == 0 || blklen_ == 0) { \
00084 lb_ = old_lb_; \
00085 ub_ = old_ub_; \
00086 } \
00087 else if (stride_ >= 0 && (old_extent_) >= 0) { \
00088 lb_ = old_lb_; \
00089 ub_ = old_ub_ + (old_extent_) * ((blklen_) - 1) + \
00090 (stride_) * ((cnt_) - 1); \
00091 } \
00092 else if (stride_ < 0 && (old_extent_) >= 0) { \
00093 lb_ = old_lb_ + (stride_) * ((cnt_) - 1); \
00094 ub_ = old_ub_ + (old_extent_) * ((blklen_) - 1); \
00095 } \
00096 else if (stride_ >= 0 && (old_extent_) < 0) { \
00097 lb_ = old_lb_ + (old_extent_) * ((blklen_) - 1); \
00098 ub_ = old_ub_ + (stride_) * ((cnt_) - 1); \
00099 } \
00100 else { \
00101 lb_ = old_lb_ + (old_extent_) * ((blklen_) - 1) + \
00102 (stride_) * ((cnt_) - 1); \
00103 ub_ = old_ub_; \
00104 } \
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 #define DLOOP_DATATYPE_BLOCK_LB_UB(cnt_, \
00117 disp_, \
00118 old_lb_, \
00119 old_ub_, \
00120 old_extent_, \
00121 lb_, \
00122 ub_) \
00123 { \
00124 if (cnt_ == 0) { \
00125 lb_ = old_lb_ + (disp_); \
00126 ub_ = old_ub_ + (disp_); \
00127 } \
00128 else if (old_ub_ >= old_lb_) { \
00129 lb_ = old_lb_ + (disp_); \
00130 ub_ = old_ub_ + (disp_) + (old_extent_) * ((cnt_) - 1); \
00131 } \
00132 else { \
00133 lb_ = old_lb_ + (disp_) + (old_extent_) * ((cnt_) - 1); \
00134 ub_ = old_ub_ + (disp_); \
00135 } \
00136 }
00137
00138 void PREPEND_PREFIX(Type_calc_footprint)(MPI_Datatype type,
00139 DLOOP_Type_footprint *tfp)
00140 {
00141 int mpi_errno;
00142 int nr_ints, nr_aints, nr_types, combiner;
00143 int *ints;
00144 MPI_Aint *aints;
00145 MPI_Datatype *types;
00146
00147
00148 DLOOP_Offset size = 0, lb = 0, ub = 0, true_lb = 0, true_ub = 0;
00149 DLOOP_Offset extent = 0, alignsz;
00150 int has_sticky_lb, has_sticky_ub;
00151
00152
00153 DLOOP_Offset stride;
00154
00155
00156 DLOOP_Offset disp;
00157
00158
00159 DLOOP_Offset i, min_lb, max_ub, ntypes, tmp_lb, tmp_ub;
00160
00161
00162 int ndims;
00163 MPI_Datatype tmptype;
00164
00165 mpi_errno = MPI_Type_get_envelope(type, &nr_ints, &nr_aints,
00166 &nr_types, &combiner);
00167 DLOOP_Assert(mpi_errno == MPI_SUCCESS);
00168
00169 if (combiner == MPI_COMBINER_NAMED) {
00170 int mpisize;
00171 MPI_Aint mpiextent;
00172
00173 MPI_Type_size(type, &mpisize);
00174 MPI_Type_extent(type, &mpiextent);
00175 tfp->size = (DLOOP_Offset) mpisize;
00176 tfp->lb = 0;
00177 tfp->ub = (DLOOP_Offset) mpiextent;
00178 tfp->true_lb = 0;
00179 tfp->true_ub = (DLOOP_Offset) mpiextent;
00180 tfp->extent = (DLOOP_Offset) mpiextent;
00181 tfp->alignsz = DLOOP_Named_type_alignsize(type, (MPI_Aint) 0);
00182 tfp->has_sticky_lb = (type == MPI_LB) ? 1 : 0;
00183 tfp->has_sticky_ub = (type == MPI_UB) ? 1 : 0;
00184
00185 goto clean_exit;
00186 }
00187
00188
00189 PREPEND_PREFIX(Type_access_contents)(type, &ints, &aints, &types);
00190
00191
00192 if ((combiner == MPI_COMBINER_CONTIGUOUS ||
00193 combiner == MPI_COMBINER_VECTOR ||
00194 combiner == MPI_COMBINER_HVECTOR_INTEGER ||
00195 combiner == MPI_COMBINER_HVECTOR ||
00196 combiner == MPI_COMBINER_INDEXED_BLOCK ||
00197 combiner == MPI_COMBINER_INDEXED ||
00198 combiner == MPI_COMBINER_HINDEXED_INTEGER ||
00199 combiner == MPI_COMBINER_STRUCT_INTEGER ||
00200 combiner == MPI_COMBINER_STRUCT) && ints[0] == 0)
00201 {
00202 tfp->size = tfp->lb = tfp->ub = tfp->extent = tfp->alignsz = 0;
00203 tfp->true_lb = tfp->true_ub = 0;
00204 tfp->has_sticky_lb = tfp->has_sticky_ub = 0;
00205 goto clean_exit;
00206 }
00207
00208 if (combiner != MPI_COMBINER_STRUCT &&
00209 combiner != MPI_COMBINER_STRUCT_INTEGER)
00210 {
00211 DLOOP_Type_footprint cfp;
00212
00213 PREPEND_PREFIX(Type_calc_footprint)(types[0], &cfp);
00214 size = cfp.size;
00215 lb = cfp.lb;
00216 ub = cfp.ub;
00217 true_lb = cfp.true_lb;
00218 true_ub = cfp.true_ub;
00219 extent = cfp.extent;
00220 alignsz = cfp.alignsz;
00221 has_sticky_lb = cfp.has_sticky_lb;
00222 has_sticky_ub = cfp.has_sticky_ub;
00223
00224
00225
00226
00227 tfp->alignsz = alignsz;
00228 tfp->has_sticky_lb = has_sticky_lb;
00229 tfp->has_sticky_ub = has_sticky_ub;
00230
00231 }
00232
00233 switch(combiner)
00234 {
00235 case MPI_COMBINER_DUP:
00236 tfp->size = size;
00237 tfp->lb = lb;
00238 tfp->ub = ub;
00239 tfp->true_lb = true_lb;
00240 tfp->true_ub = true_ub;
00241 tfp->extent = extent;
00242 break;
00243 case MPI_COMBINER_RESIZED:
00244 tfp->size = size;
00245 tfp->lb = aints[0];
00246 tfp->ub = aints[0] + aints[1];
00247 tfp->true_lb = true_lb;
00248 tfp->true_ub = true_ub;
00249 tfp->extent = aints[1];
00250 tfp->has_sticky_lb = 1;
00251 tfp->has_sticky_ub = 1;
00252 break;
00253 case MPI_COMBINER_CONTIGUOUS:
00254 DLOOP_DATATYPE_CONTIG_LB_UB(ints[0] ,
00255 lb, ub, extent,
00256 tfp->lb, tfp->ub);
00257 tfp->true_lb = tfp->lb + (true_lb - lb);
00258 tfp->true_ub = tfp->ub + (true_ub - ub);
00259 tfp->size = ints[0] * size;
00260 tfp->extent = tfp->ub - tfp->lb;
00261 break;
00262 case MPI_COMBINER_VECTOR:
00263 case MPI_COMBINER_HVECTOR:
00264 case MPI_COMBINER_HVECTOR_INTEGER:
00265 if (combiner == MPI_COMBINER_VECTOR) stride = ints[2] * extent;
00266 else if (combiner == MPI_COMBINER_HVECTOR) stride = aints[0];
00267 else stride = ints[2];
00268
00269 DLOOP_DATATYPE_VECTOR_LB_UB(ints[0] ,
00270 stride ,
00271 ints[1] ,
00272 lb, ub, extent,
00273 tfp->lb, tfp->ub);
00274 tfp->true_lb = tfp->lb + (true_lb - lb);
00275 tfp->true_ub = tfp->ub + (true_ub - ub);
00276 tfp->size = ints[0] * ints[1] * size;
00277 tfp->extent = tfp->ub - tfp->lb;
00278 break;
00279 case MPI_COMBINER_INDEXED_BLOCK:
00280
00281 DLOOP_DATATYPE_BLOCK_LB_UB(ints[1] ,
00282 ints[2] * extent ,
00283 lb, ub, extent,
00284 min_lb, max_ub);
00285
00286 for (i=1; i < ints[0]; i++) {
00287 DLOOP_DATATYPE_BLOCK_LB_UB(ints[1] ,
00288 ints[i+2] * extent ,
00289 lb, ub, extent,
00290 tmp_lb, tmp_ub);
00291 if (tmp_lb < min_lb) min_lb = tmp_lb;
00292 if (tmp_ub > max_ub) max_ub = tmp_ub;
00293 }
00294 tfp->size = ints[0] * ints[1] * size;
00295 tfp->lb = min_lb;
00296 tfp->ub = max_ub;
00297 tfp->true_lb = min_lb + (true_lb - lb);
00298 tfp->true_ub = max_ub + (true_ub - ub);
00299 tfp->extent = tfp->ub - tfp->lb;
00300 break;
00301 case MPI_COMBINER_INDEXED:
00302 case MPI_COMBINER_HINDEXED_INTEGER:
00303 case MPI_COMBINER_HINDEXED:
00304
00305 for (i=0; i < ints[0] && ints[i+1] == 0; i++);
00306 if (i == ints[0]) {
00307
00308 tfp->size = tfp->lb = tfp->ub = tfp->extent = tfp->alignsz = 0;
00309 tfp->has_sticky_lb = tfp->has_sticky_ub = 0;
00310 }
00311 else {
00312
00313 ntypes = ints[i+1];
00314 if (combiner == MPI_COMBINER_INDEXED)
00315 disp = ints[ints[0]+i+1] * extent;
00316 else if (combiner == MPI_COMBINER_HINDEXED_INTEGER)
00317 disp = ints[ints[0]+i+1];
00318 else
00319 disp = aints[i];
00320
00321 DLOOP_DATATYPE_BLOCK_LB_UB(ints[i+1] ,
00322 disp,
00323 lb, ub, extent,
00324 min_lb, max_ub);
00325
00326 for (i++; i < ints[0]; i++) {
00327
00328 if (ints[i+1] == 0) continue;
00329
00330 ntypes += ints[i+1];
00331 if (combiner == MPI_COMBINER_INDEXED)
00332 disp = ints[ints[0]+i+1] * extent;
00333 else if (combiner == MPI_COMBINER_HINDEXED_INTEGER)
00334 disp = ints[ints[0]+i+1];
00335 else
00336 disp = aints[i];
00337
00338 DLOOP_DATATYPE_BLOCK_LB_UB(ints[i+1],
00339 disp,
00340 lb, ub, extent,
00341 tmp_lb, tmp_ub);
00342 if (tmp_lb < min_lb) min_lb = tmp_lb;
00343 if (tmp_ub > max_ub) max_ub = tmp_ub;
00344 }
00345 tfp->size = ntypes * size;
00346 tfp->lb = min_lb;
00347 tfp->ub = max_ub;
00348 tfp->true_lb = min_lb + (true_lb - lb);
00349 tfp->true_ub = max_ub + (true_ub - ub);
00350 tfp->extent = tfp->ub - tfp->lb;
00351 }
00352 break;
00353 case MPI_COMBINER_STRUCT_INTEGER:
00354 DLOOP_Assert(combiner != MPI_COMBINER_STRUCT_INTEGER);
00355 break;
00356 case MPI_COMBINER_STRUCT:
00357
00358 DLOOP_Type_calc_footprint_struct(type,
00359 combiner, ints, aints, types,
00360 tfp);
00361 break;
00362 case MPI_COMBINER_SUBARRAY:
00363 ndims = ints[0];
00364 PREPEND_PREFIX(Type_convert_subarray)(ndims,
00365 &ints[1] ,
00366 &ints[1+ndims] ,
00367 &ints[1+2*ndims] ,
00368 ints[1+3*ndims] ,
00369 types[0],
00370 &tmptype);
00371 PREPEND_PREFIX(Type_calc_footprint)(tmptype, tfp);
00372 MPI_Type_free(&tmptype);
00373 break;
00374 case MPI_COMBINER_DARRAY:
00375 ndims = ints[2];
00376
00377 PREPEND_PREFIX(Type_convert_darray)(ints[0] ,
00378 ints[1] ,
00379 ndims,
00380 &ints[3] ,
00381 &ints[3+ndims] ,
00382 &ints[3+2*ndims] ,
00383 &ints[3+3*ndims] ,
00384 ints[3+4*ndims] ,
00385 types[0],
00386 &tmptype);
00387
00388 PREPEND_PREFIX(Type_calc_footprint)(tmptype, tfp);
00389 MPI_Type_free(&tmptype);
00390 break;
00391 case MPI_COMBINER_F90_REAL:
00392 case MPI_COMBINER_F90_COMPLEX:
00393 case MPI_COMBINER_F90_INTEGER:
00394 default:
00395 DLOOP_Assert(0);
00396 break;
00397 }
00398
00399 clean_exit:
00400 PREPEND_PREFIX(Type_release_contents)(type, &ints, &aints, &types);
00401 return;
00402 }
00403
00404
00405
00406
00407
00408 static void DLOOP_Type_calc_footprint_struct(MPI_Datatype type,
00409 int struct_combiner,
00410 int *ints,
00411 MPI_Aint *aints,
00412 MPI_Datatype *types,
00413 DLOOP_Type_footprint *tfp)
00414 {
00415 int i, found_sticky_lb = 0, found_sticky_ub = 0, first_iter = 1;
00416 DLOOP_Offset tmp_lb, tmp_ub, tmp_extent, tmp_true_lb, tmp_true_ub;
00417 DLOOP_Offset max_alignsz = 0, tmp_size = 0, min_lb = 0, max_ub = 0;
00418 DLOOP_Offset min_true_lb = 0, max_true_ub = 0;
00419
00420 int nr_ints, nr_aints, nr_types, combiner;
00421
00422
00423 DLOOP_Type_footprint cfp;
00424 DLOOP_Offset size, lb, ub, true_lb, true_ub, extent, alignsz;
00425 int sticky_lb, sticky_ub;
00426
00427
00428 for (i=0; i < ints[0] && ints[i+1] == 0; i++);
00429
00430 if (i == ints[0]) {
00431 tfp->size = tfp->lb = tfp->ub = tfp->extent = tfp->alignsz = 0;
00432 tfp->has_sticky_lb = tfp->has_sticky_ub = 0;
00433 return;
00434 }
00435
00436 for (; i < ints[0]; i++) {
00437
00438 if (ints[i+1] == 0) continue;
00439
00440 MPI_Type_get_envelope(types[i], &nr_ints, &nr_aints, &nr_types,
00441 &combiner);
00442
00443
00444
00445 PREPEND_PREFIX(Type_calc_footprint)(types[i], &cfp);
00446 size = cfp.size;
00447 lb = cfp.lb;
00448 ub = cfp.ub;
00449 true_lb = cfp.true_lb;
00450 true_ub = cfp.true_ub;
00451 extent = cfp.extent;
00452 alignsz = cfp.alignsz;
00453 sticky_lb = cfp.has_sticky_lb;
00454 sticky_ub = cfp.has_sticky_ub;
00455
00456 DLOOP_DATATYPE_BLOCK_LB_UB(ints[i+1] ,
00457 aints[i] ,
00458 lb, ub, extent,
00459 tmp_lb, tmp_ub);
00460
00461 tmp_true_lb = tmp_lb + (true_lb - lb);
00462 tmp_true_ub = tmp_ub + (true_ub - ub);
00463 tmp_size += size * ints[i+1];
00464
00465 if (combiner == MPI_COMBINER_NAMED) {
00466
00467
00468
00469
00470
00471
00472
00473 alignsz = DLOOP_Named_type_alignsize(types[i], aints[i]);
00474 }
00475
00476 if (max_alignsz < alignsz) max_alignsz = alignsz;
00477
00478
00479
00480
00481
00482
00483
00484
00485 if ((first_iter) ||
00486 (!found_sticky_lb && min_lb > tmp_lb) ||
00487 (!found_sticky_lb && sticky_lb) ||
00488 (sticky_lb && min_lb > tmp_lb))
00489 {
00490 min_lb = tmp_lb;
00491 if (sticky_lb) found_sticky_lb = 1;
00492 }
00493
00494 if ((first_iter) ||
00495 (!found_sticky_ub && max_ub < tmp_ub) ||
00496 (!found_sticky_ub && sticky_ub) ||
00497 (sticky_ub && max_ub < tmp_ub))
00498 {
00499 max_ub = tmp_ub;
00500 if (sticky_ub) found_sticky_ub = 1;
00501 }
00502
00503 if ((first_iter) ||
00504 (tmp_true_lb > min_true_lb))
00505 {
00506 min_true_lb = tmp_true_lb;
00507 }
00508
00509 if ((first_iter) ||
00510 (tmp_true_ub < max_true_ub))
00511 {
00512 max_true_ub = tmp_true_ub;
00513 }
00514
00515 first_iter = 0;
00516 }
00517
00518
00519 tmp_extent = max_ub - min_lb;
00520
00521
00522 if ((!found_sticky_lb) && (!found_sticky_ub)) {
00523 DLOOP_Offset epsilon;
00524
00525 epsilon = (max_alignsz > 0) ? tmp_extent % max_alignsz : 0;
00526
00527 if (epsilon) {
00528 max_ub += (max_alignsz - epsilon);
00529 tmp_extent = max_ub - min_lb;
00530 }
00531 }
00532
00533 tfp->size = tmp_size;
00534 tfp->lb = min_lb;
00535 tfp->ub = max_ub;
00536 tfp->true_lb = min_true_lb;
00537 tfp->true_ub = max_true_ub;
00538 tfp->extent = tmp_extent;
00539 tfp->alignsz = max_alignsz;
00540 tfp->has_sticky_lb = found_sticky_lb;
00541 tfp->has_sticky_ub = found_sticky_ub;
00542 return;
00543 }
00544
00545
00546
00547
00548
00549
00550
00551 static int DLOOP_Named_type_alignsize(MPI_Datatype type, MPI_Aint disp)
00552 {
00553 int alignsize = 0;
00554
00555 static int havent_tested_align_rules = 1;
00556 static int max_intalign = 0, max_fpalign = 0;
00557 static int have_double_pos_align = 0, have_llint_pos_align = 0;
00558 static int max_doublealign = 0, max_longdoublealign = 0;
00559
00560 if (havent_tested_align_rules) {
00561 max_intalign = DLOOP_Structalign_integer_max();
00562 max_fpalign = DLOOP_Structalign_float_max();
00563 max_doublealign = DLOOP_Structalign_double_max();
00564 max_longdoublealign = DLOOP_Structalign_long_double_max();
00565 have_double_pos_align = DLOOP_Structalign_double_position();
00566 have_llint_pos_align = DLOOP_Structalign_llint_position();
00567
00568 havent_tested_align_rules = 0;
00569 }
00570
00571
00572 if (type == MPI_LB || type == MPI_UB)
00573 return 0;
00574
00575 MPI_Type_size(type, &alignsize);
00576
00577 switch(type)
00578 {
00579 case MPI_FLOAT:
00580 if (alignsize > max_fpalign)
00581 alignsize = max_fpalign;
00582 break;
00583 case MPI_DOUBLE:
00584 if (alignsize > max_doublealign)
00585 alignsize = max_doublealign;
00586
00587 if (have_double_pos_align && disp != (MPI_Aint) 0)
00588 alignsize = 4;
00589 break;
00590 case MPI_LONG_DOUBLE:
00591 if (alignsize > max_longdoublealign)
00592 alignsize = max_longdoublealign;
00593 break;
00594 default:
00595 if (alignsize > max_intalign)
00596 alignsize = max_intalign;
00597
00598 if (have_llint_pos_align &&
00599 type == MPI_LONG_LONG_INT &&
00600 disp != (MPI_Aint) 0)
00601 {
00602 alignsize = 4;
00603 }
00604 break;
00605 }
00606
00607 return alignsize;
00608 }
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620 static int DLOOP_Structalign_integer_max()
00621 {
00622 int is_packed = 1;
00623 int is_two = 1;
00624 int is_four = 1;
00625 int is_eight = 1;
00626
00627 int size, extent;
00628
00629 struct { char a; int b; } char_int;
00630 struct { char a; short b; } char_short;
00631 struct { char a; long b; } char_long;
00632 struct { char a; int b; char c; } char_int_char;
00633 struct { char a; short b; char c; } char_short_char;
00634 #ifdef HAVE_LONG_LONG_INT
00635 struct { long long int a; char b; } lli_c;
00636 struct { char a; long long int b; } c_lli;
00637 int extent2;
00638 #endif
00639
00640
00641
00642
00643 #ifdef HAVE_LONG_LONG_INT
00644 if (sizeof(int) < 8 && sizeof(long) < 8 && sizeof(long long int) < 8)
00645 is_eight = 0;
00646 #else
00647 if (sizeof(int) < 8 && sizeof(long) < 8) is_eight = 0;
00648 #endif
00649
00650 size = sizeof(char) + sizeof(int);
00651 extent = sizeof(char_int);
00652 if (size != extent) is_packed = 0;
00653 if ( (extent % 2) != 0) is_two = 0;
00654 if ( (extent % 4) != 0) is_four = 0;
00655 if (sizeof(int) == 8 && (extent % 8) != 0) is_eight = 0;
00656
00657 size = sizeof(char) + sizeof(short);
00658 extent = sizeof(char_short);
00659 if (size != extent) is_packed = 0;
00660 if ( (extent % 2) != 0) is_two = 0;
00661 if (sizeof(short) == 4 && (extent % 4) != 0) is_four = 0;
00662 if (sizeof(short) == 8 && (extent % 8) != 0) is_eight = 0;
00663
00664 size = sizeof(char) + sizeof(long);
00665 extent = sizeof(char_long);
00666 if (size != extent) is_packed = 0;
00667 if ( (extent % 2) != 0) is_two = 0;
00668 if ( (extent % 4) != 0) is_four = 0;
00669 if (sizeof(long) == 8 && (extent % 8) != 0) is_eight = 0;
00670
00671 #ifdef HAVE_LONG_LONG_INT
00672 size = sizeof(char) + sizeof(long long int);
00673 extent = sizeof(lli_c);
00674 extent2 = sizeof(c_lli);
00675 if (size != extent) is_packed = 0;
00676 if ( (extent % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
00677 if ( (extent % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
00678 if (sizeof(long long int) >= 8 && (extent % 8) != 0 && (extent2 % 8) != 0)
00679 is_eight = 0;
00680 #endif
00681
00682 size = sizeof(char) + sizeof(int) + sizeof(char);
00683 extent = sizeof(char_int_char);
00684 if (size != extent) is_packed = 0;
00685 if ( (extent % 2) != 0) is_two = 0;
00686 if ( (extent % 4) != 0) is_four = 0;
00687 if (sizeof(int) == 8 && (extent % 8) != 0) is_eight = 0;
00688
00689 size = sizeof(char) + sizeof(short) + sizeof(char);
00690 extent = sizeof(char_short_char);
00691 if (size != extent) is_packed = 0;
00692 if ( (extent % 2) != 0) is_two = 0;
00693 if (sizeof(short) == 4 && (extent % 4) != 0) is_four = 0;
00694 if (sizeof(short) == 8 && (extent % 8) != 0) is_eight = 0;
00695
00696 if (is_eight) { is_four = 0; is_two = 0; }
00697 if (is_four) is_two = 0;
00698
00699 DLOOP_Assert(is_packed + is_two + is_four + is_eight == 1);
00700
00701 if (is_packed) return 1;
00702 if (is_two) return 2;
00703 if (is_four) return 4;
00704 return 8;
00705 }
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715 static int DLOOP_Structalign_float_max()
00716 {
00717 int is_packed = 1;
00718 int is_two = 1;
00719 int is_four = 1;
00720 int is_eight = 1;
00721 int is_sixteen = 1;
00722 struct { char a; float b; } char_float;
00723 struct { float b; char a; } float_char;
00724 int size, extent1, extent2;
00725
00726 size = sizeof(char) + sizeof(float);
00727 extent1 = sizeof(char_float);
00728 extent2 = sizeof(float_char);
00729 if (size != extent1) is_packed = 0;
00730 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
00731 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
00732 if (sizeof(float) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
00733 is_eight = 0;
00734
00735 if (is_sixteen) { is_eight = 0; is_four = 0; is_two = 0; }
00736 if (is_eight) { is_four = 0; is_two = 0; }
00737 if (is_four) is_two = 0;
00738
00739 DLOOP_Assert(is_packed + is_two + is_four + is_eight + is_sixteen == 1);
00740
00741 if (is_packed) return 1;
00742 if (is_two) return 2;
00743 if (is_four) return 4;
00744 if (is_eight) return 8;
00745 return 16;
00746 }
00747
00748
00749
00750
00751
00752
00753
00754 static int DLOOP_Structalign_double_max()
00755 {
00756 int is_packed = 1;
00757 int is_two = 1;
00758 int is_four = 1;
00759 int is_eight = 1;
00760 struct { char a; double b; } char_double;
00761 struct { double b; char a; } double_char;
00762 int size, extent1, extent2;
00763
00764 size = sizeof(char) + sizeof(double);
00765 extent1 = sizeof(char_double);
00766 extent2 = sizeof(double_char);
00767 if (size != extent1) is_packed = 0;
00768 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
00769 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
00770 if (sizeof(double) == 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
00771 is_eight = 0;
00772
00773 if (is_eight) { is_four = 0; is_two = 0; }
00774 if (is_four) is_two = 0;
00775
00776 DLOOP_Assert(is_packed + is_two + is_four + is_eight == 1);
00777
00778 if (is_packed) return 1;
00779 if (is_two) return 2;
00780 if (is_four) return 4;
00781 return 8;
00782 }
00783
00784
00785
00786
00787
00788
00789
00790 static int DLOOP_Structalign_long_double_max()
00791 {
00792 int is_packed = 1;
00793 int is_two = 1;
00794 int is_four = 1;
00795 int is_eight = 1;
00796 int is_sixteen = 1;
00797 struct { char a; long double b; } char_long_double;
00798 struct { long double b; char a; } long_double_char;
00799 struct { long double a; int b; char c; } long_double_int_char;
00800 int size, extent1, extent2;
00801
00802 size = sizeof(char) + sizeof(long double);
00803 extent1 = sizeof(char_long_double);
00804 extent2 = sizeof(long_double_char);
00805 if (size != extent1) is_packed = 0;
00806 if ( (extent1 % 2) != 0 && (extent2 % 2) != 0) is_two = 0;
00807 if ( (extent1 % 4) != 0 && (extent2 % 4) != 0) is_four = 0;
00808 if (sizeof(long double) >= 8 && (extent1 % 8) != 0 && (extent2 % 8) != 0)
00809 is_eight = 0;
00810 if (sizeof(long double) > 8 && (extent1 % 16) != 0
00811 && (extent2 % 16) != 0) is_sixteen = 0;
00812
00813 extent1 = sizeof(long_double_int_char);
00814 if ( (extent1 % 2) != 0) is_two = 0;
00815 if ( (extent1 % 4) != 0) is_four = 0;
00816 if (sizeof(long double) >= 8 && (extent1 % 8) != 0) is_eight = 0;
00817 if (sizeof(long double) > 8 && (extent1 % 16) != 0) is_sixteen = 0;
00818
00819 if (is_sixteen) { is_eight = 0; is_four = 0; is_two = 0; }
00820 if (is_eight) { is_four = 0; is_two = 0; }
00821 if (is_four) is_two = 0;
00822
00823 DLOOP_Assert(is_packed + is_two + is_four + is_eight + is_sixteen == 1);
00824
00825 if (is_packed) return 1;
00826 if (is_two) return 2;
00827 if (is_four) return 4;
00828 if (is_eight) return 8;
00829 return 16;
00830 }
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842 static int DLOOP_Structalign_double_position()
00843 {
00844 int padding_varies_by_pos = 0;
00845 struct { char a; double b; } char_double;
00846 struct { double b; char a; } double_char;
00847 int extent1, extent2;
00848
00849 extent1 = sizeof(char_double);
00850 extent2 = sizeof(double_char);
00851 if (extent1 != extent2) padding_varies_by_pos = 1;
00852
00853 if (padding_varies_by_pos) return 1;
00854 else return 0;
00855 }
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865 static int DLOOP_Structalign_llint_position()
00866 {
00867 int padding_varies_by_pos = 0;
00868 #ifdef HAVE_LONG_LONG_INT
00869 struct { char a; long long int b; } char_llint;
00870 struct { long long int b; char a; } llint_char;
00871 int extent1, extent2;
00872
00873 extent1 = sizeof(char_llint);
00874 extent2 = sizeof(llint_char);
00875 if (extent1 != extent2) padding_varies_by_pos = 1;
00876 #endif
00877
00878 if (padding_varies_by_pos) return 1;
00879 else return 0;
00880 }