Changeset 3511cc
 Timestamp:
 02/18/09 00:10:49 (7 years ago)
 Branches:
 master, 3.1.x
 Children:
 e73a17
 Parents:
 ef84a3
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

test/mpi/coll/allred.c
r6a1cbd r3511cc 4 4 * See COPYRIGHT in toplevel directory. 5 5 */ 6 #include <math.h> 7 #include "mpi.h" 6 8 7 #include <stdio.h> 9 8 #include <stdlib.h> 10 11 /* Run this test on 2, 4, 6, 8, or 10 processes only */ 12 13 int count, errcnt = 0, gerr = 0, size, rank; 14 MPI_Comm comm; 15 16 void a1(void), b1(void), c1(void), d1(void), e1(void), f1(void), g1(void), h1(void), a2(void), b2(void), c2(void), d2(void), e2(void), f2(void), g2(void), h2(void), a3(void), b3(void), c3(void), d3(void), e3(void), f3(void), g3(void), h3(void), a4(void), b4(void), c4(void), d4(void), e4(void), f4(void), g4(void), h4(void), a5(void), b5(void), c5(void), d5(void), e5(void), f5(void), a6(void), b6(void), c6(void), d6(void), e6(void), f6(void), a7(void), b7(void), c7(void), d7(void), e7(void), f7(void), a8(void), b8(void), c8(void), d8(void), e8(void), f8(void), a9(void), b9(void), c9(void), d9(void), e9(void), f9(void), a10(void), b10(void), c10(void), d10(void), e10(void), f10(void), a11(void), b11(void), c11(void), d11(void), e11(void), f11(void), a12(void), b12(void), c12(void), d12(void), e12(void), f12(void), g12(void), a13(void), b13(void), c13(void), d13(void), e13(void), f13(void), g13(void), a14(void), b14(void), c14(void), d14(void), e14(void), f14(void), a15(void), b15(void), c15(void), d15(void), e15(void), f15(void), a16(void), b16(void), c16(void), d16(void), e16(void), f16(void), a17(void), b17(void), c17(void), d17(void), e17(void), f17(void), a18(void), b18(void), c18(void), d18(void), e18(void), a19(void), b19(void), c19(void), d19(void), e19(void); 17 18 19 void a1(void) 20 { 21 int *in, *out, *sol; 22 int i, fnderr=0; 23 in = (int *)malloc( count * sizeof(int) ); 24 out = (int *)malloc( count * sizeof(int) ); 25 sol = (int *)malloc( count * sizeof(int) ); 26 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = i*size; 27 *(out + i) = 0; } 28 MPI_Allreduce( in, out, count, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); 29 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 30 if (fnderr) fprintf( stderr, 31 "(%d) Error for type MPI_INT and op MPI_SUM\n", rank ); 32 free( in ); 33 free( out ); 34 free( sol ); 35 } 36 37 38 void b1(void) 39 { 40 long *in, *out, *sol; 41 int i, fnderr=0; 42 in = (long *)malloc( count * sizeof(long) ); 43 out = (long *)malloc( count * sizeof(long) ); 44 sol = (long *)malloc( count * sizeof(long) ); 45 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = i*size; 46 *(out + i) = 0; } 47 MPI_Allreduce( in, out, count, MPI_LONG, MPI_SUM, comm ); 48 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 49 if (fnderr) fprintf( stderr, 50 "(%d) Error for type MPI_LONG and op MPI_SUM\n", rank ); 51 free( in ); 52 free( out ); 53 free( sol ); 54 } 55 56 57 void c1(void) 58 { 59 short *in, *out, *sol; 60 int i, fnderr=0; 61 in = (short *)malloc( count * sizeof(short) ); 62 out = (short *)malloc( count * sizeof(short) ); 63 sol = (short *)malloc( count * sizeof(short) ); 64 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = i*size; 65 *(out + i) = 0; } 66 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_SUM, comm ); 67 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 68 if (fnderr) fprintf( stderr, 69 "(%d) Error for type MPI_SHORT and op MPI_SUM\n", rank ); 70 free( in ); 71 free( out ); 72 free( sol ); 73 } 74 75 76 void d1(void) 77 { 78 unsigned short *in, *out, *sol; 79 int i, fnderr=0; 80 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 81 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 82 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 83 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = i*size; 84 *(out + i) = 0; } 85 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_SUM, comm ); 86 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 87 if (fnderr) fprintf( stderr, 88 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_SUM\n", rank ); 89 free( in ); 90 free( out ); 91 free( sol ); 92 } 93 94 95 void e1(void) 96 { 97 unsigned *in, *out, *sol; 98 int i, fnderr=0; 99 in = (unsigned *)malloc( count * sizeof(unsigned) ); 100 out = (unsigned *)malloc( count * sizeof(unsigned) ); 101 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 102 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = i*size; 103 *(out + i) = 0; } 104 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_SUM, comm ); 105 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 106 if (fnderr) fprintf( stderr, 107 "(%d) Error for type MPI_UNSIGNED and op MPI_SUM\n", rank ); 108 free( in ); 109 free( out ); 110 free( sol ); 111 } 112 113 114 void f1(void) 115 { 116 unsigned long *in, *out, *sol; 117 int i, fnderr=0; 118 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 119 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 120 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 121 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = i*size; 122 *(out + i) = 0; } 123 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_SUM, comm ); 124 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 125 if (fnderr) fprintf( stderr, 126 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_SUM\n", rank ); 127 free( in ); 128 free( out ); 129 free( sol ); 130 } 131 132 133 void g1(void) 134 { 135 float *in, *out, *sol; 136 int i, fnderr=0; 137 in = (float *)malloc( count * sizeof(float) ); 138 out = (float *)malloc( count * sizeof(float) ); 139 sol = (float *)malloc( count * sizeof(float) ); 140 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = i*size; 141 *(out + i) = 0; } 142 MPI_Allreduce( in, out, count, MPI_FLOAT, MPI_SUM, comm ); 143 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 144 if (fnderr) fprintf( stderr, 145 "(%d) Error for type MPI_FLOAT and op MPI_SUM\n", rank ); 146 free( in ); 147 free( out ); 148 free( sol ); 149 } 150 151 152 void h1(void) 153 { 154 double *in, *out, *sol; 155 int i, fnderr=0; 156 in = (double *)malloc( count * sizeof(double) ); 157 out = (double *)malloc( count * sizeof(double) ); 158 sol = (double *)malloc( count * sizeof(double) ); 159 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = i*size; 160 *(out + i) = 0; } 161 MPI_Allreduce( in, out, count, MPI_DOUBLE, MPI_SUM, comm ); 162 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 163 if (fnderr) fprintf( stderr, 164 "(%d) Error for type MPI_DOUBLE and op MPI_SUM\n", rank ); 165 free( in ); 166 free( out ); 167 free( sol ); 168 } 169 170 171 void a2(void) 172 { 173 int *in, *out, *sol; 174 int i, fnderr=0; 175 in = (int *)malloc( count * sizeof(int) ); 176 out = (int *)malloc( count * sizeof(int) ); 177 sol = (int *)malloc( count * sizeof(int) ); 178 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = (i > 0) ? (int)(pow((double)(i),(double)size)+0.1) : 0; 179 *(out + i) = 0; } 180 MPI_Allreduce( in, out, count, MPI_INT, MPI_PROD, comm ); 181 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 182 if (fnderr) fprintf( stderr, 183 "(%d) Error for type MPI_INT and op MPI_PROD\n", rank ); 184 free( in ); 185 free( out ); 186 free( sol ); 187 } 188 189 190 void b2(void) 191 { 192 long *in, *out, *sol; 193 int i, fnderr=0; 194 in = (long *)malloc( count * sizeof(long) ); 195 out = (long *)malloc( count * sizeof(long) ); 196 sol = (long *)malloc( count * sizeof(long) ); 197 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = (i > 0) ? (int)(pow((double)(i),(double)size)+0.1) : 0; 198 *(out + i) = 0; } 199 MPI_Allreduce( in, out, count, MPI_LONG, MPI_PROD, comm ); 200 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 201 if (fnderr) fprintf( stderr, 202 "(%d) Error for type MPI_LONG and op MPI_PROD\n", rank ); 203 free( in ); 204 free( out ); 205 free( sol ); 206 } 207 208 209 void c2(void) 210 { 211 short *in, *out, *sol; 212 int i, fnderr=0; 213 in = (short *)malloc( count * sizeof(short) ); 214 out = (short *)malloc( count * sizeof(short) ); 215 sol = (short *)malloc( count * sizeof(short) ); 216 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = (i > 0) ? (int)(pow((double)(i),(double)size)+0.1) : 0; 217 *(out + i) = 0; } 218 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_PROD, comm ); 219 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 220 if (fnderr) fprintf( stderr, 221 "(%d) Error for type MPI_SHORT and op MPI_PROD\n", rank ); 222 free( in ); 223 free( out ); 224 free( sol ); 225 } 226 227 228 void d2(void) 229 { 230 unsigned short *in, *out, *sol; 231 int i, fnderr=0; 232 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 233 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 234 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 235 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = (i > 0) ? (int)(pow((double)(i),(double)size)+0.1) : 0; 236 *(out + i) = 0; } 237 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_PROD, comm ); 238 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 239 if (fnderr) fprintf( stderr, 240 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_PROD\n", rank ); 241 free( in ); 242 free( out ); 243 free( sol ); 244 } 245 246 247 void e2(void) 248 { 249 unsigned *in, *out, *sol; 250 int i, fnderr=0; 251 in = (unsigned *)malloc( count * sizeof(unsigned) ); 252 out = (unsigned *)malloc( count * sizeof(unsigned) ); 253 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 254 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = (i > 0) ? (int)(pow((double)(i),(double)size)+0.1) : 0; 255 *(out + i) = 0; } 256 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_PROD, comm ); 257 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 258 if (fnderr) fprintf( stderr, 259 "(%d) Error for type MPI_UNSIGNED and op MPI_PROD\n", rank ); 260 free( in ); 261 free( out ); 262 free( sol ); 263 } 264 265 266 void f2(void) 267 { 268 unsigned long *in, *out, *sol; 269 int i, fnderr=0; 270 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 271 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 272 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 273 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = (i > 0) ? (int)(pow((double)(i),(double)size)+0.1) : 0; 274 *(out + i) = 0; } 275 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_PROD, comm ); 276 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 277 if (fnderr) fprintf( stderr, 278 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_PROD\n", rank ); 279 free( in ); 280 free( out ); 281 free( sol ); 282 } 283 284 285 void g2(void) 286 { 287 float *in, *out, *sol; 288 int i, fnderr=0; 289 in = (float *)malloc( count * sizeof(float) ); 290 out = (float *)malloc( count * sizeof(float) ); 291 sol = (float *)malloc( count * sizeof(float) ); 292 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = (i > 0) ? (int)(pow((double)(i),(double)size)+0.1) : 0; 293 *(out + i) = 0; } 294 MPI_Allreduce( in, out, count, MPI_FLOAT, MPI_PROD, comm ); 295 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 296 if (fnderr) fprintf( stderr, 297 "(%d) Error for type MPI_FLOAT and op MPI_PROD\n", rank ); 298 free( in ); 299 free( out ); 300 free( sol ); 301 } 302 303 304 void h2(void) 305 { 306 double *in, *out, *sol; 307 int i, fnderr=0; 308 in = (double *)malloc( count * sizeof(double) ); 309 out = (double *)malloc( count * sizeof(double) ); 310 sol = (double *)malloc( count * sizeof(double) ); 311 for (i=0; i<count; i++) { *(in + i) = i; *(sol + i) = (i > 0) ? (int)(pow((double)(i),(double)size)+0.1) : 0; 312 *(out + i) = 0; } 313 MPI_Allreduce( in, out, count, MPI_DOUBLE, MPI_PROD, comm ); 314 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 315 if (fnderr) fprintf( stderr, 316 "(%d) Error for type MPI_DOUBLE and op MPI_PROD\n", rank ); 317 free( in ); 318 free( out ); 319 free( sol ); 320 } 321 322 323 324 void a3(void) 325 { 326 int *in, *out, *sol; 327 int i, fnderr=0; 328 in = (int *)malloc( count * sizeof(int) ); 329 out = (int *)malloc( count * sizeof(int) ); 330 sol = (int *)malloc( count * sizeof(int) ); 331 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = (size  1 + i); 332 *(out + i) = 0; } 333 MPI_Allreduce( in, out, count, MPI_INT, MPI_MAX, comm ); 334 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 335 if (fnderr) fprintf( stderr, 336 "(%d) Error for type MPI_INT and op MPI_MAX\n", rank ); 337 free( in ); 338 free( out ); 339 free( sol ); 340 } 341 342 343 void b3(void) 344 { 345 long *in, *out, *sol; 346 int i, fnderr=0; 347 in = (long *)malloc( count * sizeof(long) ); 348 out = (long *)malloc( count * sizeof(long) ); 349 sol = (long *)malloc( count * sizeof(long) ); 350 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = (size  1 + i); 351 *(out + i) = 0; } 352 MPI_Allreduce( in, out, count, MPI_LONG, MPI_MAX, comm ); 353 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 354 if (fnderr) fprintf( stderr, 355 "(%d) Error for type MPI_LONG and op MPI_MAX\n", rank ); 356 free( in ); 357 free( out ); 358 free( sol ); 359 } 360 361 362 void c3(void) 363 { 364 short *in, *out, *sol; 365 int i, fnderr=0; 366 in = (short *)malloc( count * sizeof(short) ); 367 out = (short *)malloc( count * sizeof(short) ); 368 sol = (short *)malloc( count * sizeof(short) ); 369 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = (size  1 + i); 370 *(out + i) = 0; } 371 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_MAX, comm ); 372 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 373 if (fnderr) fprintf( stderr, 374 "(%d) Error for type MPI_SHORT and op MPI_MAX\n", rank ); 375 free( in ); 376 free( out ); 377 free( sol ); 378 } 379 380 381 void d3(void) 382 { 383 unsigned short *in, *out, *sol; 384 int i, fnderr=0; 385 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 386 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 387 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 388 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = (size  1 + i); 389 *(out + i) = 0; } 390 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_MAX, comm ); 391 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 392 if (fnderr) fprintf( stderr, 393 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_MAX\n", rank ); 394 free( in ); 395 free( out ); 396 free( sol ); 397 } 398 399 400 void e3(void) 401 { 402 unsigned *in, *out, *sol; 403 int i, fnderr=0; 404 in = (unsigned *)malloc( count * sizeof(unsigned) ); 405 out = (unsigned *)malloc( count * sizeof(unsigned) ); 406 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 407 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = (size  1 + i); 408 *(out + i) = 0; } 409 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_MAX, comm ); 410 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 411 if (fnderr) fprintf( stderr, 412 "(%d) Error for type MPI_UNSIGNED and op MPI_MAX\n", rank ); 413 free( in ); 414 free( out ); 415 free( sol ); 416 } 417 418 419 void f3(void) 420 { 421 unsigned long *in, *out, *sol; 422 int i, fnderr=0; 423 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 424 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 425 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 426 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = (size  1 + i); 427 *(out + i) = 0; } 428 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_MAX, comm ); 429 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 430 if (fnderr) fprintf( stderr, 431 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_MAX\n", rank ); 432 free( in ); 433 free( out ); 434 free( sol ); 435 } 436 437 438 void g3(void) 439 { 440 float *in, *out, *sol; 441 int i, fnderr=0; 442 in = (float *)malloc( count * sizeof(float) ); 443 out = (float *)malloc( count * sizeof(float) ); 444 sol = (float *)malloc( count * sizeof(float) ); 445 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = (size  1 + i); 446 *(out + i) = 0; } 447 MPI_Allreduce( in, out, count, MPI_FLOAT, MPI_MAX, comm ); 448 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 449 if (fnderr) fprintf( stderr, 450 "(%d) Error for type MPI_FLOAT and op MPI_MAX\n", rank ); 451 free( in ); 452 free( out ); 453 free( sol ); 454 } 455 456 457 void h3(void) 458 { 459 double *in, *out, *sol; 460 int i, fnderr=0; 461 in = (double *)malloc( count * sizeof(double) ); 462 out = (double *)malloc( count * sizeof(double) ); 463 sol = (double *)malloc( count * sizeof(double) ); 464 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = (size  1 + i); 465 *(out + i) = 0; } 466 MPI_Allreduce( in, out, count, MPI_DOUBLE, MPI_MAX, comm ); 467 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 468 if (fnderr) fprintf( stderr, 469 "(%d) Error for type MPI_DOUBLE and op MPI_MAX\n", rank ); 470 free( in ); 471 free( out ); 472 free( sol ); 473 } 474 475 476 477 void a4(void) 478 { 479 int *in, *out, *sol; 480 int i, fnderr=0; 481 in = (int *)malloc( count * sizeof(int) ); 482 out = (int *)malloc( count * sizeof(int) ); 483 sol = (int *)malloc( count * sizeof(int) ); 484 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = i; 485 *(out + i) = 0; } 486 MPI_Allreduce( in, out, count, MPI_INT, MPI_MIN, comm ); 487 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 488 if (fnderr) fprintf( stderr, 489 "(%d) Error for type MPI_INT and op MPI_MIN\n", rank ); 490 free( in ); 491 free( out ); 492 free( sol ); 493 } 494 495 496 void b4(void) 497 { 498 long *in, *out, *sol; 499 int i, fnderr=0; 500 in = (long *)malloc( count * sizeof(long) ); 501 out = (long *)malloc( count * sizeof(long) ); 502 sol = (long *)malloc( count * sizeof(long) ); 503 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = i; 504 *(out + i) = 0; } 505 MPI_Allreduce( in, out, count, MPI_LONG, MPI_MIN, comm ); 506 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 507 if (fnderr) fprintf( stderr, 508 "(%d) Error for type MPI_LONG and op MPI_MIN\n", rank ); 509 free( in ); 510 free( out ); 511 free( sol ); 512 } 513 514 515 void c4(void) 516 { 517 short *in, *out, *sol; 518 int i, fnderr=0; 519 in = (short *)malloc( count * sizeof(short) ); 520 out = (short *)malloc( count * sizeof(short) ); 521 sol = (short *)malloc( count * sizeof(short) ); 522 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = i; 523 *(out + i) = 0; } 524 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_MIN, comm ); 525 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 526 if (fnderr) fprintf( stderr, 527 "(%d) Error for type MPI_SHORT and op MPI_MIN\n", rank ); 528 free( in ); 529 free( out ); 530 free( sol ); 531 } 532 533 534 void d4(void) 535 { 536 unsigned short *in, *out, *sol; 537 int i, fnderr=0; 538 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 539 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 540 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 541 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = i; 542 *(out + i) = 0; } 543 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_MIN, comm ); 544 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 545 if (fnderr) fprintf( stderr, 546 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_MIN\n", rank ); 547 free( in ); 548 free( out ); 549 free( sol ); 550 } 551 552 553 void e4(void) 554 { 555 unsigned *in, *out, *sol; 556 int i, fnderr=0; 557 in = (unsigned *)malloc( count * sizeof(unsigned) ); 558 out = (unsigned *)malloc( count * sizeof(unsigned) ); 559 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 560 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = i; 561 *(out + i) = 0; } 562 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_MIN, comm ); 563 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 564 if (fnderr) fprintf( stderr, 565 "(%d) Error for type MPI_UNSIGNED and op MPI_MIN\n", rank ); 566 free( in ); 567 free( out ); 568 free( sol ); 569 } 570 571 572 void f4(void) 573 { 574 unsigned long *in, *out, *sol; 575 int i, fnderr=0; 576 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 577 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 578 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 579 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = i; 580 *(out + i) = 0; } 581 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_MIN, comm ); 582 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 583 if (fnderr) fprintf( stderr, 584 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_MIN\n", rank ); 585 free( in ); 586 free( out ); 587 free( sol ); 588 } 589 590 591 void g4(void) 592 { 593 float *in, *out, *sol; 594 int i, fnderr=0; 595 in = (float *)malloc( count * sizeof(float) ); 596 out = (float *)malloc( count * sizeof(float) ); 597 sol = (float *)malloc( count * sizeof(float) ); 598 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = i; 599 *(out + i) = 0; } 600 MPI_Allreduce( in, out, count, MPI_FLOAT, MPI_MIN, comm ); 601 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 602 if (fnderr) fprintf( stderr, 603 "(%d) Error for type MPI_FLOAT and op MPI_MIN\n", rank ); 604 free( in ); 605 free( out ); 606 free( sol ); 607 } 608 609 610 void h4(void) 611 { 612 double *in, *out, *sol; 613 int i, fnderr=0; 614 in = (double *)malloc( count * sizeof(double) ); 615 out = (double *)malloc( count * sizeof(double) ); 616 sol = (double *)malloc( count * sizeof(double) ); 617 for (i=0; i<count; i++) { *(in + i) = (rank + i); *(sol + i) = i; 618 *(out + i) = 0; } 619 MPI_Allreduce( in, out, count, MPI_DOUBLE, MPI_MIN, comm ); 620 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 621 if (fnderr) fprintf( stderr, 622 "(%d) Error for type MPI_DOUBLE and op MPI_MIN\n", rank ); 623 free( in ); 624 free( out ); 625 free( sol ); 626 } 627 628 629 630 void a5(void) 631 { 632 int *in, *out, *sol; 633 int i, fnderr=0; 634 in = (int *)malloc( count * sizeof(int) ); 635 out = (int *)malloc( count * sizeof(int) ); 636 sol = (int *)malloc( count * sizeof(int) ); 637 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = (size > 1); 638 *(out + i) = 0; } 639 MPI_Allreduce( in, out, count, MPI_INT, MPI_LOR, comm ); 640 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 641 if (fnderr) fprintf( stderr, 642 "(%d) Error for type MPI_INT and op MPI_LOR\n", rank ); 643 free( in ); 644 free( out ); 645 free( sol ); 646 } 647 648 649 void b5(void) 650 { 651 long *in, *out, *sol; 652 int i, fnderr=0; 653 in = (long *)malloc( count * sizeof(long) ); 654 out = (long *)malloc( count * sizeof(long) ); 655 sol = (long *)malloc( count * sizeof(long) ); 656 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = (size > 1); 657 *(out + i) = 0; } 658 MPI_Allreduce( in, out, count, MPI_LONG, MPI_LOR, comm ); 659 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 660 if (fnderr) fprintf( stderr, 661 "(%d) Error for type MPI_LONG and op MPI_LOR\n", rank ); 662 free( in ); 663 free( out ); 664 free( sol ); 665 } 666 667 668 void c5(void) 669 { 670 short *in, *out, *sol; 671 int i, fnderr=0; 672 in = (short *)malloc( count * sizeof(short) ); 673 out = (short *)malloc( count * sizeof(short) ); 674 sol = (short *)malloc( count * sizeof(short) ); 675 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = (size > 1); 676 *(out + i) = 0; } 677 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LOR, comm ); 678 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 679 if (fnderr) fprintf( stderr, 680 "(%d) Error for type MPI_SHORT and op MPI_LOR\n", rank ); 681 free( in ); 682 free( out ); 683 free( sol ); 684 } 685 686 687 void d5(void) 688 { 689 unsigned short *in, *out, *sol; 690 int i, fnderr=0; 691 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 692 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 693 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 694 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = (size > 1); 695 *(out + i) = 0; } 696 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LOR, comm ); 697 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 698 if (fnderr) fprintf( stderr, 699 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LOR\n", rank ); 700 free( in ); 701 free( out ); 702 free( sol ); 703 } 704 705 706 void e5(void) 707 { 708 unsigned *in, *out, *sol; 709 int i, fnderr=0; 710 in = (unsigned *)malloc( count * sizeof(unsigned) ); 711 out = (unsigned *)malloc( count * sizeof(unsigned) ); 712 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 713 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = (size > 1); 714 *(out + i) = 0; } 715 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LOR, comm ); 716 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 717 if (fnderr) fprintf( stderr, 718 "(%d) Error for type MPI_UNSIGNED and op MPI_LOR\n", rank ); 719 free( in ); 720 free( out ); 721 free( sol ); 722 } 723 724 725 void f5(void) 726 { 727 unsigned long *in, *out, *sol; 728 int i, fnderr=0; 729 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 730 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 731 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 732 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = (size > 1); 733 *(out + i) = 0; } 734 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LOR, comm ); 735 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 736 if (fnderr) fprintf( stderr, 737 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LOR\n", rank ); 738 free( in ); 739 free( out ); 740 free( sol ); 741 } 742 743 744 745 void a6(void) 746 { 747 int *in, *out, *sol; 748 int i, fnderr=0; 749 in = (int *)malloc( count * sizeof(int) ); 750 out = (int *)malloc( count * sizeof(int) ); 751 sol = (int *)malloc( count * sizeof(int) ); 752 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 753 *(out + i) = 0; } 754 MPI_Allreduce( in, out, count, MPI_INT, MPI_LOR, comm ); 755 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 756 if (fnderr) fprintf( stderr, 757 "(%d) Error for type MPI_INT and op MPI_LOR\n", rank ); 758 free( in ); 759 free( out ); 760 free( sol ); 761 } 762 763 764 void b6(void) 765 { 766 long *in, *out, *sol; 767 int i, fnderr=0; 768 in = (long *)malloc( count * sizeof(long) ); 769 out = (long *)malloc( count * sizeof(long) ); 770 sol = (long *)malloc( count * sizeof(long) ); 771 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 772 *(out + i) = 0; } 773 MPI_Allreduce( in, out, count, MPI_LONG, MPI_LOR, comm ); 774 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 775 if (fnderr) fprintf( stderr, 776 "(%d) Error for type MPI_LONG and op MPI_LOR\n", rank ); 777 free( in ); 778 free( out ); 779 free( sol ); 780 } 781 782 783 void c6(void) 784 { 785 short *in, *out, *sol; 786 int i, fnderr=0; 787 in = (short *)malloc( count * sizeof(short) ); 788 out = (short *)malloc( count * sizeof(short) ); 789 sol = (short *)malloc( count * sizeof(short) ); 790 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 791 *(out + i) = 0; } 792 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LOR, comm ); 793 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 794 if (fnderr) fprintf( stderr, 795 "(%d) Error for type MPI_SHORT and op MPI_LOR\n", rank ); 796 free( in ); 797 free( out ); 798 free( sol ); 799 } 800 801 802 void d6(void) 803 { 804 unsigned short *in, *out, *sol; 805 int i, fnderr=0; 806 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 807 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 808 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 809 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 810 *(out + i) = 0; } 811 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LOR, comm ); 812 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 813 if (fnderr) fprintf( stderr, 814 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LOR\n", rank ); 815 free( in ); 816 free( out ); 817 free( sol ); 818 } 819 820 821 void e6(void) 822 { 823 unsigned *in, *out, *sol; 824 int i, fnderr=0; 825 in = (unsigned *)malloc( count * sizeof(unsigned) ); 826 out = (unsigned *)malloc( count * sizeof(unsigned) ); 827 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 828 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 829 *(out + i) = 0; } 830 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LOR, comm ); 831 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 832 if (fnderr) fprintf( stderr, 833 "(%d) Error for type MPI_UNSIGNED and op MPI_LOR\n", rank ); 834 free( in ); 835 free( out ); 836 free( sol ); 837 } 838 839 840 void f6(void) 841 { 842 unsigned long *in, *out, *sol; 843 int i, fnderr=0; 844 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 845 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 846 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 847 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 848 *(out + i) = 0; } 849 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LOR, comm ); 850 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 851 if (fnderr) fprintf( stderr, 852 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LOR\n", rank ); 853 free( in ); 854 free( out ); 855 free( sol ); 856 } 857 858 859 860 void a7(void) 861 { 862 int *in, *out, *sol; 863 int i, fnderr=0; 864 in = (int *)malloc( count * sizeof(int) ); 865 out = (int *)malloc( count * sizeof(int) ); 866 sol = (int *)malloc( count * sizeof(int) ); 867 for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); 868 *(out + i) = 0; } 869 MPI_Allreduce( in, out, count, MPI_INT, MPI_LXOR, comm ); 870 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 871 if (fnderr) fprintf( stderr, 872 "(%d) Error for type MPI_INT and op MPI_LXOR\n", rank); 873 free( in ); 874 free( out ); 875 free( sol ); 876 } 877 878 879 void b7(void) 880 { 881 long *in, *out, *sol; 882 int i, fnderr=0; 883 in = (long *)malloc( count * sizeof(long) ); 884 out = (long *)malloc( count * sizeof(long) ); 885 sol = (long *)malloc( count * sizeof(long) ); 886 for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); 887 *(out + i) = 0; } 888 MPI_Allreduce( in, out, count, MPI_LONG, MPI_LXOR, comm ); 889 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 890 if (fnderr) fprintf( stderr, 891 "(%d) Error for type MPI_LONG and op MPI_LXOR\n", rank ); 892 free( in ); 893 free( out ); 894 free( sol ); 895 } 896 897 898 void c7(void) 899 { 900 short *in, *out, *sol; 901 int i, fnderr=0; 902 in = (short *)malloc( count * sizeof(short) ); 903 out = (short *)malloc( count * sizeof(short) ); 904 sol = (short *)malloc( count * sizeof(short) ); 905 for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); 906 *(out + i) = 0; } 907 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LXOR, comm ); 908 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 909 if (fnderr) fprintf( stderr, 910 "(%d) Error for type MPI_SHORT and op MPI_LXOR\n", rank ); 911 free( in ); 912 free( out ); 913 free( sol ); 914 } 915 916 917 void d7(void) 918 { 919 unsigned short *in, *out, *sol; 920 int i, fnderr=0; 921 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 922 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 923 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 924 for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); 925 *(out + i) = 0; } 926 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LXOR, comm ); 927 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 928 if (fnderr) fprintf( stderr, 929 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LXOR\n", rank ); 930 free( in ); 931 free( out ); 932 free( sol ); 933 } 934 935 936 void e7(void) 937 { 938 unsigned *in, *out, *sol; 939 int i, fnderr=0; 940 in = (unsigned *)malloc( count * sizeof(unsigned) ); 941 out = (unsigned *)malloc( count * sizeof(unsigned) ); 942 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 943 for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); 944 *(out + i) = 0; } 945 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LXOR, comm ); 946 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 947 if (fnderr) fprintf( stderr, 948 "(%d) Error for type MPI_UNSIGNED and op MPI_LXOR\n", rank ); 949 free( in ); 950 free( out ); 951 free( sol ); 952 } 953 954 955 void f7(void) 956 { 957 unsigned long *in, *out, *sol; 958 int i, fnderr=0; 959 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 960 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 961 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 962 for (i=0; i<count; i++) { *(in + i) = (rank == 1); *(sol + i) = (size > 1); 963 *(out + i) = 0; } 964 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LXOR, comm ); 965 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 966 if (fnderr) fprintf( stderr, 967 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LXOR\n", rank ); 968 free( in ); 969 free( out ); 970 free( sol ); 971 } 972 973 974 975 void a8(void) 976 { 977 int *in, *out, *sol; 978 int i, fnderr=0; 979 in = (int *)malloc( count * sizeof(int) ); 980 out = (int *)malloc( count * sizeof(int) ); 981 sol = (int *)malloc( count * sizeof(int) ); 982 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 983 *(out + i) = 0; } 984 MPI_Allreduce( in, out, count, MPI_INT, MPI_LXOR, comm ); 985 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 986 if (fnderr) fprintf( stderr, 987 "(%d) Error for type MPI_INT and op MPI_LXOR\n", rank ); 988 free( in ); 989 free( out ); 990 free( sol ); 991 } 992 993 994 void b8(void) 995 { 996 long *in, *out, *sol; 997 int i, fnderr=0; 998 in = (long *)malloc( count * sizeof(long) ); 999 out = (long *)malloc( count * sizeof(long) ); 1000 sol = (long *)malloc( count * sizeof(long) ); 1001 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1002 *(out + i) = 0; } 1003 MPI_Allreduce( in, out, count, MPI_LONG, MPI_LXOR, comm ); 1004 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1005 if (fnderr) fprintf( stderr, 1006 "(%d) Error for type MPI_LONG and op MPI_LXOR\n", rank ); 1007 free( in ); 1008 free( out ); 1009 free( sol ); 1010 } 1011 1012 1013 void c8(void) 1014 { 1015 short *in, *out, *sol; 1016 int i, fnderr=0; 1017 in = (short *)malloc( count * sizeof(short) ); 1018 out = (short *)malloc( count * sizeof(short) ); 1019 sol = (short *)malloc( count * sizeof(short) ); 1020 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1021 *(out + i) = 0; } 1022 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LXOR, comm ); 1023 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1024 if (fnderr) fprintf( stderr, 1025 "(%d) Error for type MPI_SHORT and op MPI_LXOR\n", rank ); 1026 free( in ); 1027 free( out ); 1028 free( sol ); 1029 } 1030 1031 1032 void d8(void) 1033 { 1034 unsigned short *in, *out, *sol; 1035 int i, fnderr=0; 1036 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1037 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1038 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1039 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1040 *(out + i) = 0; } 1041 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LXOR, comm ); 1042 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1043 if (fnderr) fprintf( stderr, 1044 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LXOR\n", rank ); 1045 free( in ); 1046 free( out ); 1047 free( sol ); 1048 } 1049 1050 1051 void e8(void) 1052 { 1053 unsigned *in, *out, *sol; 1054 int i, fnderr=0; 1055 in = (unsigned *)malloc( count * sizeof(unsigned) ); 1056 out = (unsigned *)malloc( count * sizeof(unsigned) ); 1057 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 1058 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1059 *(out + i) = 0; } 1060 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LXOR, comm ); 1061 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1062 if (fnderr) fprintf( stderr, 1063 "(%d) Error for type MPI_UNSIGNED and op MPI_LXOR\n", rank ); 1064 free( in ); 1065 free( out ); 1066 free( sol ); 1067 } 1068 1069 1070 void f8(void) 1071 { 1072 unsigned long *in, *out, *sol; 1073 int i, fnderr=0; 1074 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1075 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1076 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1077 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1078 *(out + i) = 0; } 1079 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LXOR, comm ); 1080 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1081 if (fnderr) fprintf( stderr, 1082 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LXOR\n", rank ); 1083 free( in ); 1084 free( out ); 1085 free( sol ); 1086 } 1087 1088 1089 1090 void a9(void) 1091 { 1092 int *in, *out, *sol; 1093 int i, fnderr=0; 1094 in = (int *)malloc( count * sizeof(int) ); 1095 out = (int *)malloc( count * sizeof(int) ); 1096 sol = (int *)malloc( count * sizeof(int) ); 1097 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; 1098 *(out + i) = 0; } 1099 MPI_Allreduce( in, out, count, MPI_INT, MPI_LXOR, comm ); 1100 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1101 if (fnderr) fprintf( stderr, 1102 "(%d) Error for type MPI_INT and op MPI_LXOR\n", rank ); 1103 free( in ); 1104 free( out ); 1105 free( sol ); 1106 } 1107 1108 void b9(void) 1109 { 1110 long *in, *out, *sol; 1111 int i, fnderr=0; 1112 in = (long *)malloc( count * sizeof(long) ); 1113 out = (long *)malloc( count * sizeof(long) ); 1114 sol = (long *)malloc( count * sizeof(long) ); 1115 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; 1116 *(out + i) = 0; } 1117 MPI_Allreduce( in, out, count, MPI_LONG, MPI_LXOR, comm ); 1118 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1119 if (fnderr) fprintf( stderr, 1120 "(%d) Error for type MPI_LONG and op MPI_LXOR\n", rank ); 1121 free( in ); 1122 free( out ); 1123 free( sol ); 1124 } 1125 1126 1127 void c9(void) 1128 { 1129 short *in, *out, *sol; 1130 int i, fnderr=0; 1131 in = (short *)malloc( count * sizeof(short) ); 1132 out = (short *)malloc( count * sizeof(short) ); 1133 sol = (short *)malloc( count * sizeof(short) ); 1134 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; 1135 *(out + i) = 0; } 1136 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LXOR, comm ); 1137 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1138 if (fnderr) fprintf( stderr, 1139 "(%d) Error for type MPI_SHORT and op MPI_LXOR\n", rank ); 1140 free( in ); 1141 free( out ); 1142 free( sol ); 1143 } 1144 1145 1146 void d9(void) 1147 { 1148 unsigned short *in, *out, *sol; 1149 int i, fnderr=0; 1150 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1151 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1152 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1153 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; 1154 *(out + i) = 0; } 1155 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LXOR, comm ); 1156 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1157 if (fnderr) fprintf( stderr, 1158 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LXOR\n", rank ); 1159 free( in ); 1160 free( out ); 1161 free( sol ); 1162 } 1163 1164 1165 void e9(void) 1166 { 1167 unsigned *in, *out, *sol; 1168 int i, fnderr=0; 1169 in = (unsigned *)malloc( count * sizeof(unsigned) ); 1170 out = (unsigned *)malloc( count * sizeof(unsigned) ); 1171 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 1172 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; 1173 *(out + i) = 0; } 1174 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LXOR, comm ); 1175 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1176 if (fnderr) fprintf( stderr, 1177 "(%d) Error for type MPI_UNSIGNED and op MPI_LXOR\n", rank ); 1178 free( in ); 1179 free( out ); 1180 free( sol ); 1181 } 1182 1183 1184 void f9(void) 1185 { 1186 unsigned long *in, *out, *sol; 1187 int i, fnderr=0; 1188 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1189 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1190 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1191 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 0; 1192 *(out + i) = 0; } 1193 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LXOR, comm ); 1194 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1195 if (fnderr) fprintf( stderr, 1196 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LXOR\n", rank ); 1197 free( in ); 1198 free( out ); 1199 free( sol ); 1200 } 1201 1202 1203 1204 void a10(void) 1205 { 1206 int *in, *out, *sol; 1207 int i, fnderr=0; 1208 in = (int *)malloc( count * sizeof(int) ); 1209 out = (int *)malloc( count * sizeof(int) ); 1210 sol = (int *)malloc( count * sizeof(int) ); 1211 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = 0; 1212 *(out + i) = 0; } 1213 MPI_Allreduce( in, out, count, MPI_INT, MPI_LAND, comm ); 1214 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1215 if (fnderr) fprintf( stderr, 1216 "(%d) Error for type MPI_INT and op MPI_LAND\n", rank ); 1217 free( in ); 1218 free( out ); 1219 free( sol ); 1220 } 1221 1222 1223 void b10(void) 1224 { 1225 long *in, *out, *sol; 1226 int i, fnderr=0; 1227 in = (long *)malloc( count * sizeof(long) ); 1228 out = (long *)malloc( count * sizeof(long) ); 1229 sol = (long *)malloc( count * sizeof(long) ); 1230 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = 0; 1231 *(out + i) = 0; } 1232 MPI_Allreduce( in, out, count, MPI_LONG, MPI_LAND, comm ); 1233 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1234 if (fnderr) fprintf( stderr, 1235 "(%d) Error for type MPI_LONG and op MPI_LAND\n", rank ); 1236 free( in ); 1237 free( out ); 1238 free( sol ); 1239 } 1240 1241 1242 void c10(void) 1243 { 1244 short *in, *out, *sol; 1245 int i, fnderr=0; 1246 in = (short *)malloc( count * sizeof(short) ); 1247 out = (short *)malloc( count * sizeof(short) ); 1248 sol = (short *)malloc( count * sizeof(short) ); 1249 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = 0; 1250 *(out + i) = 0; } 1251 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LAND, comm ); 1252 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1253 if (fnderr) fprintf( stderr, 1254 "(%d) Error for type MPI_SHORT and op MPI_LAND\n", rank ); 1255 free( in ); 1256 free( out ); 1257 free( sol ); 1258 } 1259 1260 1261 void d10(void) 1262 { 1263 unsigned short *in, *out, *sol; 1264 int i, fnderr=0; 1265 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1266 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1267 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1268 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = 0; 1269 *(out + i) = 0; } 1270 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LAND, comm ); 1271 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1272 if (fnderr) fprintf( stderr, 1273 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LAND\n", rank ); 1274 free( in ); 1275 free( out ); 1276 free( sol ); 1277 } 1278 1279 1280 void e10(void) 1281 { 1282 unsigned *in, *out, *sol; 1283 int i, fnderr=0; 1284 in = (unsigned *)malloc( count * sizeof(unsigned) ); 1285 out = (unsigned *)malloc( count * sizeof(unsigned) ); 1286 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 1287 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = 0; 1288 *(out + i) = 0; } 1289 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LAND, comm ); 1290 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1291 if (fnderr) fprintf( stderr, 1292 "(%d) Error for type MPI_UNSIGNED and op MPI_LAND\n", rank ); 1293 free( in ); 1294 free( out ); 1295 free( sol ); 1296 } 1297 1298 1299 void f10(void) 1300 { 1301 unsigned long *in, *out, *sol; 1302 int i, fnderr=0; 1303 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1304 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1305 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1306 for (i=0; i<count; i++) { *(in + i) = (rank & 0x1); *(sol + i) = 0; 1307 *(out + i) = 0; } 1308 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LAND, comm ); 1309 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1310 if (fnderr) fprintf( stderr, 1311 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LAND\n", rank ); 1312 free( in ); 1313 free( out ); 1314 free( sol ); 1315 } 1316 1317 1318 1319 void a11(void) 1320 { 1321 int *in, *out, *sol; 1322 int i, fnderr=0; 1323 in = (int *)malloc( count * sizeof(int) ); 1324 out = (int *)malloc( count * sizeof(int) ); 1325 sol = (int *)malloc( count * sizeof(int) ); 1326 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 1; 1327 *(out + i) = 0; } 1328 MPI_Allreduce( in, out, count, MPI_INT, MPI_LAND, comm ); 1329 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1330 if (fnderr) fprintf( stderr, 1331 "(%d) Error for type MPI_INT and op MPI_LAND\n", rank ); 1332 free( in ); 1333 free( out ); 1334 free( sol ); 1335 } 1336 1337 1338 void b11(void) 1339 { 1340 long *in, *out, *sol; 1341 int i, fnderr=0; 1342 in = (long *)malloc( count * sizeof(long) ); 1343 out = (long *)malloc( count * sizeof(long) ); 1344 sol = (long *)malloc( count * sizeof(long) ); 1345 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 1; 1346 *(out + i) = 0; } 1347 MPI_Allreduce( in, out, count, MPI_LONG, MPI_LAND, comm ); 1348 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1349 if (fnderr) fprintf( stderr, 1350 "(%d) Error for type MPI_LONG and op MPI_LAND\n", rank ); 1351 free( in ); 1352 free( out ); 1353 free( sol ); 1354 } 1355 1356 1357 void c11(void) 1358 { 1359 short *in, *out, *sol; 1360 int i, fnderr=0; 1361 in = (short *)malloc( count * sizeof(short) ); 1362 out = (short *)malloc( count * sizeof(short) ); 1363 sol = (short *)malloc( count * sizeof(short) ); 1364 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 1; 1365 *(out + i) = 0; } 1366 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_LAND, comm ); 1367 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1368 if (fnderr) fprintf( stderr, 1369 "(%d) Error for type MPI_SHORT and op MPI_LAND\n", rank ); 1370 free( in ); 1371 free( out ); 1372 free( sol ); 1373 } 1374 1375 1376 void d11(void) 1377 { 1378 unsigned short *in, *out, *sol; 1379 int i, fnderr=0; 1380 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1381 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1382 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1383 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 1; 1384 *(out + i) = 0; } 1385 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_LAND, comm ); 1386 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1387 if (fnderr) fprintf( stderr, 1388 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_LAND\n", rank ); 1389 free( in ); 1390 free( out ); 1391 free( sol ); 1392 } 1393 1394 1395 void e11(void) 1396 { 1397 unsigned *in, *out, *sol; 1398 int i, fnderr=0; 1399 in = (unsigned *)malloc( count * sizeof(unsigned) ); 1400 out = (unsigned *)malloc( count * sizeof(unsigned) ); 1401 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 1402 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 1; 1403 *(out + i) = 0; } 1404 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_LAND, comm ); 1405 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1406 if (fnderr) fprintf( stderr, 1407 "(%d) Error for type MPI_UNSIGNED and op MPI_LAND\n", rank ); 1408 free( in ); 1409 free( out ); 1410 free( sol ); 1411 } 1412 1413 1414 void f11(void) 1415 { 1416 unsigned long *in, *out, *sol; 1417 int i, fnderr=0; 1418 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1419 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1420 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1421 for (i=0; i<count; i++) { *(in + i) = 1; *(sol + i) = 1; 1422 *(out + i) = 0; } 1423 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_LAND, comm ); 1424 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1425 if (fnderr) fprintf( stderr, 1426 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_LAND\n", rank ); 1427 free( in ); 1428 free( out ); 1429 free( sol ); 1430 } 1431 1432 1433 void a12(void) 1434 { 1435 int *in, *out, *sol; 1436 int i, fnderr=0; 1437 in = (int *)malloc( count * sizeof(int) ); 1438 out = (int *)malloc( count * sizeof(int) ); 1439 sol = (int *)malloc( count * sizeof(int) ); 1440 for (i=0; i<count; i++) { *(in + i) = rank & 0x3; *(sol + i) = (size < 3) ? size  1 : 0x3; 1441 *(out + i) = 0; } 1442 MPI_Allreduce( in, out, count, MPI_INT, MPI_BOR, comm ); 1443 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1444 if (fnderr) fprintf( stderr, 1445 "(%d) Error for type MPI_INT and op MPI_BOR\n", rank ); 1446 free( in ); 1447 free( out ); 1448 free( sol ); 1449 } 1450 1451 1452 void b12(void) 1453 { 1454 long *in, *out, *sol; 1455 int i, fnderr=0; 1456 in = (long *)malloc( count * sizeof(long) ); 1457 out = (long *)malloc( count * sizeof(long) ); 1458 sol = (long *)malloc( count * sizeof(long) ); 1459 for (i=0; i<count; i++) { *(in + i) = rank & 0x3; *(sol + i) = (size < 3) ? size  1 : 0x3; 1460 *(out + i) = 0; } 1461 MPI_Allreduce( in, out, count, MPI_LONG, MPI_BOR, comm ); 1462 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1463 if (fnderr) fprintf( stderr, 1464 "(%d) Error for type MPI_LONG and op MPI_BOR\n", rank ); 1465 free( in ); 1466 free( out ); 1467 free( sol ); 1468 } 1469 1470 1471 void c12(void) 1472 { 1473 short *in, *out, *sol; 1474 int i, fnderr=0; 1475 in = (short *)malloc( count * sizeof(short) ); 1476 out = (short *)malloc( count * sizeof(short) ); 1477 sol = (short *)malloc( count * sizeof(short) ); 1478 for (i=0; i<count; i++) { *(in + i) = rank & 0x3; *(sol + i) = (size < 3) ? size  1 : 0x3; 1479 *(out + i) = 0; } 1480 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BOR, comm ); 1481 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1482 if (fnderr) fprintf( stderr, 1483 "(%d) Error for type MPI_SHORT and op MPI_BOR\n", rank ); 1484 free( in ); 1485 free( out ); 1486 free( sol ); 1487 } 1488 1489 1490 void d12(void) 1491 { 1492 unsigned short *in, *out, *sol; 1493 int i, fnderr=0; 1494 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1495 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1496 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1497 for (i=0; i<count; i++) { *(in + i) = rank & 0x3; *(sol + i) = (size < 3) ? size  1 : 0x3; 1498 *(out + i) = 0; } 1499 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BOR, comm ); 1500 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1501 if (fnderr) fprintf( stderr, 1502 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_BOR\n", rank ); 1503 free( in ); 1504 free( out ); 1505 free( sol ); 1506 } 1507 1508 1509 void e12(void) 1510 { 1511 unsigned *in, *out, *sol; 1512 int i, fnderr=0; 1513 in = (unsigned *)malloc( count * sizeof(unsigned) ); 1514 out = (unsigned *)malloc( count * sizeof(unsigned) ); 1515 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 1516 for (i=0; i<count; i++) { *(in + i) = rank & 0x3; *(sol + i) = (size < 3) ? size  1 : 0x3; 1517 *(out + i) = 0; } 1518 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BOR, comm ); 1519 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1520 if (fnderr) fprintf( stderr, 1521 "(%d) Error for type MPI_UNSIGNED and op MPI_BOR\n", rank ); 1522 free( in ); 1523 free( out ); 1524 free( sol ); 1525 } 1526 1527 1528 void f12(void) 1529 { 1530 unsigned long *in, *out, *sol; 1531 int i, fnderr=0; 1532 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1533 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1534 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1535 for (i=0; i<count; i++) { *(in + i) = rank & 0x3; *(sol + i) = (size < 3) ? size  1 : 0x3; 1536 *(out + i) = 0; } 1537 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BOR, comm ); 1538 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1539 if (fnderr) fprintf( stderr, 1540 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_BOR\n", rank ); 1541 free( in ); 1542 free( out ); 1543 free( sol ); 1544 } 1545 1546 1547 void g12(void) 1548 { 1549 unsigned char *in, *out, *sol; 1550 int i, fnderr=0; 1551 in = (unsigned char *)malloc( count * sizeof(unsigned char) ); 1552 out = (unsigned char *)malloc( count * sizeof(unsigned char) ); 1553 sol = (unsigned char *)malloc( count * sizeof(unsigned char) ); 1554 for (i=0; i<count; i++) { *(in + i) = rank & 0x3; *(sol + i) = (size < 3) ? size  1 : 0x3; 1555 *(out + i) = 0; } 1556 MPI_Allreduce( in, out, count, MPI_BYTE, MPI_BOR, comm ); 1557 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1558 if (fnderr) fprintf( stderr, 1559 "(%d) Error for type MPI_BYTE and op MPI_BOR\n", rank ); 1560 free( in ); 1561 free( out ); 1562 free( sol ); 1563 } 1564 1565 1566 void a13(void) 1567 { 1568 int *in, *out, *sol; 1569 int i, fnderr=0; 1570 in = (int *)malloc( count * sizeof(int) ); 1571 out = (int *)malloc( count * sizeof(int) ); 1572 sol = (int *)malloc( count * sizeof(int) ); 1573 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : ~0); *(sol + i) = i; 1574 *(out + i) = 0; } 1575 MPI_Allreduce( in, out, count, MPI_INT, MPI_BAND, comm ); 1576 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1577 if (fnderr) fprintf( stderr, 1578 "(%d) Error for type MPI_INT and op MPI_BAND\n", rank ); 1579 free( in ); 1580 free( out ); 1581 free( sol ); 1582 } 1583 1584 1585 void b13(void) 1586 { 1587 long *in, *out, *sol; 1588 int i, fnderr=0; 1589 in = (long *)malloc( count * sizeof(long) ); 1590 out = (long *)malloc( count * sizeof(long) ); 1591 sol = (long *)malloc( count * sizeof(long) ); 1592 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : ~0); *(sol + i) = i; 1593 *(out + i) = 0; } 1594 MPI_Allreduce( in, out, count, MPI_LONG, MPI_BAND, comm ); 1595 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1596 if (fnderr) fprintf( stderr, 1597 "(%d) Error for type MPI_LONG and op MPI_BAND\n", rank ); 1598 free( in ); 1599 free( out ); 1600 free( sol ); 1601 } 1602 1603 1604 void c13(void) 1605 { 1606 short *in, *out, *sol; 1607 int i, fnderr=0; 1608 in = (short *)malloc( count * sizeof(short) ); 1609 out = (short *)malloc( count * sizeof(short) ); 1610 sol = (short *)malloc( count * sizeof(short) ); 1611 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : ~0); *(sol + i) = i; 1612 *(out + i) = 0; } 1613 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BAND, comm ); 1614 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1615 if (fnderr) fprintf( stderr, 1616 "(%d) Error for type MPI_SHORT and op MPI_BAND\n", rank ); 1617 free( in ); 1618 free( out ); 1619 free( sol ); 1620 } 1621 1622 1623 void d13(void) 1624 { 1625 unsigned short *in, *out, *sol; 1626 int i, fnderr=0; 1627 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1628 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1629 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1630 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : ~0); *(sol + i) = i; 1631 *(out + i) = 0; } 1632 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BAND, comm ); 1633 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1634 if (fnderr) fprintf( stderr, 1635 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_BAND\n", rank ); 1636 free( in ); 1637 free( out ); 1638 free( sol ); 1639 } 1640 1641 1642 void e13(void) 1643 { 1644 unsigned *in, *out, *sol; 1645 int i, fnderr=0; 1646 in = (unsigned *)malloc( count * sizeof(unsigned) ); 1647 out = (unsigned *)malloc( count * sizeof(unsigned) ); 1648 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 1649 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : ~0); *(sol + i) = i; 1650 *(out + i) = 0; } 1651 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BAND, comm ); 1652 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1653 if (fnderr) fprintf( stderr, 1654 "(%d) Error for type MPI_UNSIGNED and op MPI_BAND\n", rank ); 1655 free( in ); 1656 free( out ); 1657 free( sol ); 1658 } 1659 1660 1661 void f13(void) 1662 { 1663 unsigned long *in, *out, *sol; 1664 int i, fnderr=0; 1665 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1666 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1667 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1668 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : ~0); *(sol + i) = i; 1669 *(out + i) = 0; } 1670 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BAND, comm ); 1671 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1672 if (fnderr) fprintf( stderr, 1673 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_BAND\n", rank ); 1674 free( in ); 1675 free( out ); 1676 free( sol ); 1677 } 1678 1679 1680 void g13(void) 1681 { 1682 unsigned char *in, *out, *sol; 1683 int i, fnderr=0; 1684 in = (unsigned char *)malloc( count * sizeof(unsigned char) ); 1685 out = (unsigned char *)malloc( count * sizeof(unsigned char) ); 1686 sol = (unsigned char *)malloc( count * sizeof(unsigned char) ); 1687 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : ~0); *(sol + i) = i; 1688 *(out + i) = 0; } 1689 MPI_Allreduce( in, out, count, MPI_BYTE, MPI_BAND, comm ); 1690 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1691 if (fnderr) fprintf( stderr, 1692 "(%d) Error for type MPI_BYTE and op MPI_BAND\n", rank ); 1693 free( in ); 1694 free( out ); 1695 free( sol ); 1696 } 1697 1698 1699 void a14(void) 1700 { 1701 int *in, *out, *sol; 1702 int i, fnderr=0; 1703 in = (int *)malloc( count * sizeof(int) ); 1704 out = (int *)malloc( count * sizeof(int) ); 1705 sol = (int *)malloc( count * sizeof(int) ); 1706 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : 0); *(sol + i) = 0; 1707 *(out + i) = 0; } 1708 MPI_Allreduce( in, out, count, MPI_INT, MPI_BAND, comm ); 1709 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1710 if (fnderr) fprintf( stderr, 1711 "(%d) Error for type MPI_INT and op MPI_BAND\n", rank ); 1712 free( in ); 1713 free( out ); 1714 free( sol ); 1715 } 1716 1717 1718 void b14(void) 1719 { 1720 long *in, *out, *sol; 1721 int i, fnderr=0; 1722 in = (long *)malloc( count * sizeof(long) ); 1723 out = (long *)malloc( count * sizeof(long) ); 1724 sol = (long *)malloc( count * sizeof(long) ); 1725 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : 0); *(sol + i) = 0; 1726 *(out + i) = 0; } 1727 MPI_Allreduce( in, out, count, MPI_LONG, MPI_BAND, comm ); 1728 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1729 if (fnderr) fprintf( stderr, 1730 "(%d) Error for type MPI_LONG and op MPI_BAND\n", rank ); 1731 free( in ); 1732 free( out ); 1733 free( sol ); 1734 } 1735 1736 1737 void c14(void) 1738 { 1739 short *in, *out, *sol; 1740 int i, fnderr=0; 1741 in = (short *)malloc( count * sizeof(short) ); 1742 out = (short *)malloc( count * sizeof(short) ); 1743 sol = (short *)malloc( count * sizeof(short) ); 1744 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : 0); *(sol + i) = 0; 1745 *(out + i) = 0; } 1746 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BAND, comm ); 1747 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1748 if (fnderr) fprintf( stderr, 1749 "(%d) Error for type MPI_SHORT and op MPI_BAND\n", rank ); 1750 free( in ); 1751 free( out ); 1752 free( sol ); 1753 } 1754 1755 1756 void d14(void) 1757 { 1758 unsigned short *in, *out, *sol; 1759 int i, fnderr=0; 1760 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1761 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1762 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1763 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : 0); *(sol + i) = 0; 1764 *(out + i) = 0; } 1765 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BAND, comm ); 1766 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1767 if (fnderr) fprintf( stderr, 1768 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_BAND\n", rank ); 1769 free( in ); 1770 free( out ); 1771 free( sol ); 1772 } 1773 1774 1775 void e14(void) 1776 { 1777 unsigned *in, *out, *sol; 1778 int i, fnderr=0; 1779 in = (unsigned *)malloc( count * sizeof(unsigned) ); 1780 out = (unsigned *)malloc( count * sizeof(unsigned) ); 1781 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 1782 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : 0); *(sol + i) = 0; 1783 *(out + i) = 0; } 1784 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BAND, comm ); 1785 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1786 if (fnderr) fprintf( stderr, 1787 "(%d) Error for type MPI_UNSIGNED and op MPI_BAND\n", rank ); 1788 free( in ); 1789 free( out ); 1790 free( sol ); 1791 } 1792 1793 1794 void f14(void) 1795 { 1796 unsigned long *in, *out, *sol; 1797 int i, fnderr=0; 1798 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1799 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1800 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1801 for (i=0; i<count; i++) { *(in + i) = (rank == size1 ? i : 0); *(sol + i) = 0; 1802 *(out + i) = 0; } 1803 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BAND, comm ); 1804 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1805 if (fnderr) fprintf( stderr, 1806 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_BAND\n", rank ); 1807 free( in ); 1808 free( out ); 1809 free( sol ); 1810 } 1811 1812 1813 1814 void a15(void) 1815 { 1816 int *in, *out, *sol; 1817 int i, fnderr=0; 1818 in = (int *)malloc( count * sizeof(int) ); 1819 out = (int *)malloc( count * sizeof(int) ); 1820 sol = (int *)malloc( count * sizeof(int) ); 1821 for (i=0; i<count; i++) { *(in + i) = (rank == 1)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; 1822 *(out + i) = 0; } 1823 MPI_Allreduce( in, out, count, MPI_INT, MPI_BXOR, comm ); 1824 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1825 if (fnderr) fprintf( stderr, 1826 "(%d) Error for type MPI_INT and op MPI_BXOR\n", rank ); 1827 free( in ); 1828 free( out ); 1829 free( sol ); 1830 } 1831 1832 1833 void b15(void) 1834 { 1835 long *in, *out, *sol; 1836 int i, fnderr=0; 1837 in = (long *)malloc( count * sizeof(long) ); 1838 out = (long *)malloc( count * sizeof(long) ); 1839 sol = (long *)malloc( count * sizeof(long) ); 1840 for (i=0; i<count; i++) { *(in + i) = (rank == 1)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; 1841 *(out + i) = 0; } 1842 MPI_Allreduce( in, out, count, MPI_LONG, MPI_BXOR, comm ); 1843 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1844 if (fnderr) fprintf( stderr, 1845 "(%d) Error for type MPI_LONG and op MPI_BXOR\n", rank ); 1846 free( in ); 1847 free( out ); 1848 free( sol ); 1849 } 1850 1851 1852 void c15(void) 1853 { 1854 short *in, *out, *sol; 1855 int i, fnderr=0; 1856 in = (short *)malloc( count * sizeof(short) ); 1857 out = (short *)malloc( count * sizeof(short) ); 1858 sol = (short *)malloc( count * sizeof(short) ); 1859 for (i=0; i<count; i++) { *(in + i) = (rank == 1)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; 1860 *(out + i) = 0; } 1861 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BXOR, comm ); 1862 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1863 if (fnderr) fprintf( stderr, 1864 "(%d) Error for type MPI_SHORT and op MPI_BXOR\n", rank ); 1865 free( in ); 1866 free( out ); 1867 free( sol ); 1868 } 1869 1870 1871 void d15(void) 1872 { 1873 unsigned short *in, *out, *sol; 1874 int i, fnderr=0; 1875 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1876 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1877 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1878 for (i=0; i<count; i++) { *(in + i) = (rank == 1)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; 1879 *(out + i) = 0; } 1880 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BXOR, comm ); 1881 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1882 if (fnderr) fprintf( stderr, 1883 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_BXOR\n", rank ); 1884 free( in ); 1885 free( out ); 1886 free( sol ); 1887 } 1888 1889 1890 void e15(void) 1891 { 1892 unsigned *in, *out, *sol; 1893 int i, fnderr=0; 1894 in = (unsigned *)malloc( count * sizeof(unsigned) ); 1895 out = (unsigned *)malloc( count * sizeof(unsigned) ); 1896 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 1897 for (i=0; i<count; i++) { *(in + i) = (rank == 1)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; 1898 *(out + i) = 0; } 1899 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BXOR, comm ); 1900 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1901 if (fnderr) fprintf( stderr, 1902 "(%d) Error for type MPI_UNSIGNED and op MPI_BXOR\n", rank ); 1903 free( in ); 1904 free( out ); 1905 free( sol ); 1906 } 1907 1908 1909 void f15(void) 1910 { 1911 unsigned long *in, *out, *sol; 1912 int i, fnderr=0; 1913 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1914 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1915 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 1916 for (i=0; i<count; i++) { *(in + i) = (rank == 1)*0xf0 ; *(sol + i) = (size > 1)*0xf0 ; 1917 *(out + i) = 0; } 1918 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BXOR, comm ); 1919 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1920 if (fnderr) fprintf( stderr, 1921 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_BXOR\n", rank ); 1922 free( in ); 1923 free( out ); 1924 free( sol ); 1925 } 1926 1927 1928 1929 void a16(void) 1930 { 1931 int *in, *out, *sol; 1932 int i, fnderr=0; 1933 in = (int *)malloc( count * sizeof(int) ); 1934 out = (int *)malloc( count * sizeof(int) ); 1935 sol = (int *)malloc( count * sizeof(int) ); 1936 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1937 *(out + i) = 0; } 1938 MPI_Allreduce( in, out, count, MPI_INT, MPI_BXOR, comm ); 1939 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1940 if (fnderr) fprintf( stderr, 1941 "(%d) Error for type MPI_INT and op MPI_BXOR\n", rank ); 1942 free( in ); 1943 free( out ); 1944 free( sol ); 1945 } 1946 1947 1948 void b16(void) 1949 { 1950 long *in, *out, *sol; 1951 int i, fnderr=0; 1952 in = (long *)malloc( count * sizeof(long) ); 1953 out = (long *)malloc( count * sizeof(long) ); 1954 sol = (long *)malloc( count * sizeof(long) ); 1955 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1956 *(out + i) = 0; } 1957 MPI_Allreduce( in, out, count, MPI_LONG, MPI_BXOR, comm ); 1958 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1959 if (fnderr) fprintf( stderr, 1960 "(%d) Error for type MPI_LONG and op MPI_BXOR\n", rank ); 1961 free( in ); 1962 free( out ); 1963 free( sol ); 1964 } 1965 1966 1967 void c16(void) 1968 { 1969 short *in, *out, *sol; 1970 int i, fnderr=0; 1971 in = (short *)malloc( count * sizeof(short) ); 1972 out = (short *)malloc( count * sizeof(short) ); 1973 sol = (short *)malloc( count * sizeof(short) ); 1974 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1975 *(out + i) = 0; } 1976 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BXOR, comm ); 1977 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1978 if (fnderr) fprintf( stderr, 1979 "(%d) Error for type MPI_SHORT and op MPI_BXOR\n", rank ); 1980 free( in ); 1981 free( out ); 1982 free( sol ); 1983 } 1984 1985 1986 void d16(void) 1987 { 1988 unsigned short *in, *out, *sol; 1989 int i, fnderr=0; 1990 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1991 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1992 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 1993 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 1994 *(out + i) = 0; } 1995 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BXOR, comm ); 1996 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 1997 if (fnderr) fprintf( stderr, 1998 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_BXOR\n", rank ); 1999 free( in ); 2000 free( out ); 2001 free( sol ); 2002 } 2003 2004 2005 void e16(void) 2006 { 2007 unsigned *in, *out, *sol; 2008 int i, fnderr=0; 2009 in = (unsigned *)malloc( count * sizeof(unsigned) ); 2010 out = (unsigned *)malloc( count * sizeof(unsigned) ); 2011 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 2012 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 2013 *(out + i) = 0; } 2014 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BXOR, comm ); 2015 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 2016 if (fnderr) fprintf( stderr, 2017 "(%d) Error for type MPI_UNSIGNED and op MPI_BXOR\n", rank ); 2018 free( in ); 2019 free( out ); 2020 free( sol ); 2021 } 2022 2023 2024 void f16(void) 2025 { 2026 unsigned long *in, *out, *sol; 2027 int i, fnderr=0; 2028 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 2029 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 2030 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 2031 for (i=0; i<count; i++) { *(in + i) = 0; *(sol + i) = 0; 2032 *(out + i) = 0; } 2033 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BXOR, comm ); 2034 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 2035 if (fnderr) fprintf( stderr, 2036 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_BXOR\n", rank ); 2037 free( in ); 2038 free( out ); 2039 free( sol ); 2040 } 2041 2042 2043 void a17(void) 2044 { 2045 int *in, *out, *sol; 2046 int i, fnderr=0; 2047 in = (int *)malloc( count * sizeof(int) ); 2048 out = (int *)malloc( count * sizeof(int) ); 2049 sol = (int *)malloc( count * sizeof(int) ); 2050 for (i=0; i<count; i++) { *(in + i) = ~0; *(sol + i) = 0; 2051 *(out + i) = 0; } 2052 MPI_Allreduce( in, out, count, MPI_INT, MPI_BXOR, comm ); 2053 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 2054 if (fnderr) fprintf( stderr, 2055 "(%d) Error for type MPI_INT and op MPI_BXOR\n", rank ); 2056 free( in ); 2057 free( out ); 2058 free( sol ); 2059 } 2060 2061 2062 void b17(void) 2063 { 2064 long *in, *out, *sol; 2065 int i, fnderr=0; 2066 in = (long *)malloc( count * sizeof(long) ); 2067 out = (long *)malloc( count * sizeof(long) ); 2068 sol = (long *)malloc( count * sizeof(long) ); 2069 for (i=0; i<count; i++) { *(in + i) = ~0; *(sol + i) = 0; 2070 *(out + i) = 0; } 2071 MPI_Allreduce( in, out, count, MPI_LONG, MPI_BXOR, comm ); 2072 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 2073 if (fnderr) fprintf( stderr, 2074 "(%d) Error for type MPI_LONG and op MPI_BXOR\n", rank ); 2075 free( in ); 2076 free( out ); 2077 free( sol ); 2078 } 2079 2080 2081 void c17(void) 2082 { 2083 short *in, *out, *sol; 2084 int i, fnderr=0; 2085 in = (short *)malloc( count * sizeof(short) ); 2086 out = (short *)malloc( count * sizeof(short) ); 2087 sol = (short *)malloc( count * sizeof(short) ); 2088 for (i=0; i<count; i++) { *(in + i) = ~0; *(sol + i) = 0; 2089 *(out + i) = 0; } 2090 MPI_Allreduce( in, out, count, MPI_SHORT, MPI_BXOR, comm ); 2091 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 2092 if (fnderr) fprintf( stderr, 2093 "(%d) Error for type MPI_SHORT and op MPI_BXOR\n", rank ); 2094 free( in ); 2095 free( out ); 2096 free( sol ); 2097 } 2098 2099 2100 void d17(void) 2101 { 2102 unsigned short *in, *out, *sol; 2103 int i, fnderr=0; 2104 in = (unsigned short *)malloc( count * sizeof(unsigned short) ); 2105 out = (unsigned short *)malloc( count * sizeof(unsigned short) ); 2106 sol = (unsigned short *)malloc( count * sizeof(unsigned short) ); 2107 for (i=0; i<count; i++) { *(in + i) = ~0; *(sol + i) = 0; 2108 *(out + i) = 0; } 2109 MPI_Allreduce( in, out, count, MPI_UNSIGNED_SHORT, MPI_BXOR, comm ); 2110 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 2111 if (fnderr) fprintf( stderr, 2112 "(%d) Error for type MPI_UNSIGNED_SHORT and op MPI_BXOR\n", rank ); 2113 free( in ); 2114 free( out ); 2115 free( sol ); 2116 } 2117 2118 2119 void e17(void) 2120 { 2121 unsigned *in, *out, *sol; 2122 int i, fnderr=0; 2123 in = (unsigned *)malloc( count * sizeof(unsigned) ); 2124 out = (unsigned *)malloc( count * sizeof(unsigned) ); 2125 sol = (unsigned *)malloc( count * sizeof(unsigned) ); 2126 for (i=0; i<count; i++) { *(in + i) = ~0; *(sol + i) = 0; 2127 *(out + i) = 0; } 2128 MPI_Allreduce( in, out, count, MPI_UNSIGNED, MPI_BXOR, comm ); 2129 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 2130 if (fnderr) fprintf( stderr, 2131 "(%d) Error for type MPI_UNSIGNED and op MPI_BXOR\n", rank ); 2132 free( in ); 2133 free( out ); 2134 free( sol ); 2135 } 2136 2137 2138 void f17(void) 2139 { 2140 unsigned long *in, *out, *sol; 2141 int i, fnderr=0; 2142 in = (unsigned long *)malloc( count * sizeof(unsigned long) ); 2143 out = (unsigned long *)malloc( count * sizeof(unsigned long) ); 2144 sol = (unsigned long *)malloc( count * sizeof(unsigned long) ); 2145 for (i=0; i<count; i++) { *(in + i) = ~0; *(sol + i) = 0; 2146 *(out + i) = 0; } 2147 MPI_Allreduce( in, out, count, MPI_UNSIGNED_LONG, MPI_BXOR, comm ); 2148 for (i=0; i<count; i++) { if (*(out + i) != *(sol + i)) {errcnt++; fnderr++;}} 2149 if (fnderr) fprintf( stderr, 2150 "(%d) Error for type MPI_UNSIGNED_LONG and op MPI_BXOR\n", rank ); 2151 free( in ); 2152 free( out ); 2153 free( sol ); 2154 } 2155 2156 2157 2158 void a18(void) 2159 { 2160 struct int_test { int a; int b; } *in, *out, *sol; 2161 int i,fnderr=0; 2162 in = (struct int_test *)malloc( count * sizeof(struct int_test) ); 2163 out = (struct int_test *)malloc( count * sizeof(struct int_test) ); 2164 sol = (struct int_test *)malloc( count * sizeof(struct int_test) ); 2165 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2166 (sol + i)>a = (size  1 + i); (sol + i)>b = (size1); 2167 (out + i)>a = 0; (out + i)>b = 1; } 2168 MPI_Allreduce( in, out, count, MPI_2INT, MPI_MAXLOC, comm ); 2169 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2170 (out + i)>b != (sol + i)>b) { 2171 errcnt++; fnderr++; 2172 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2173 (int)((sol + i)>a), 2174 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2175 }} 2176 if (fnderr) fprintf( stderr, 2177 "(%d) Error for type MPI_2INT and op MPI_MAXLOC (%d of %d wrong)\n", 2178 rank, fnderr, count ); 2179 free( in ); 2180 free( out ); 2181 free( sol ); 2182 } 2183 2184 2185 void b18(void) 2186 { 2187 struct long_test { long a; int b; } *in, *out, *sol; 2188 int i,fnderr=0; 2189 in = (struct long_test *)malloc( count * sizeof(struct long_test) ); 2190 out = (struct long_test *)malloc( count * sizeof(struct long_test) ); 2191 sol = (struct long_test *)malloc( count * sizeof(struct long_test) ); 2192 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2193 (sol + i)>a = (size  1 + i); (sol + i)>b = (size1); 2194 (out + i)>a = 0; (out + i)>b = 1; } 2195 MPI_Allreduce( in, out, count, MPI_LONG_INT, MPI_MAXLOC, comm ); 2196 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2197 (out + i)>b != (sol + i)>b) { 2198 errcnt++; fnderr++; 2199 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2200 (int)((sol + i)>a), 2201 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2202 }} 2203 if (fnderr) fprintf( stderr, 2204 "(%d) Error for type MPI_LONG_INT and op MPI_MAXLOC (%d of %d wrong)\n", 2205 rank, fnderr, count ); 2206 free( in ); 2207 free( out ); 2208 free( sol ); 2209 } 2210 2211 2212 void c18(void) 2213 { 2214 struct short_test { short a; int b; } *in, *out, *sol; 2215 int i,fnderr=0; 2216 in = (struct short_test *)malloc( count * sizeof(struct short_test) ); 2217 out = (struct short_test *)malloc( count * sizeof(struct short_test) ); 2218 sol = (struct short_test *)malloc( count * sizeof(struct short_test) ); 2219 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2220 (sol + i)>a = (size  1 + i); (sol + i)>b = (size1); 2221 (out + i)>a = 0; (out + i)>b = 1; } 2222 MPI_Allreduce( in, out, count, MPI_SHORT_INT, MPI_MAXLOC, comm ); 2223 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2224 (out + i)>b != (sol + i)>b) { 2225 errcnt++; fnderr++; 2226 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2227 (int)((sol + i)>a), 2228 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2229 }} 2230 if (fnderr) fprintf( stderr, 2231 "(%d) Error for type MPI_SHORT_INT and op MPI_MAXLOC (%d of %d wrong)\n", 2232 rank, fnderr, count ); 2233 free( in ); 2234 free( out ); 2235 free( sol ); 2236 } 2237 2238 2239 void d18(void) 2240 { 2241 struct float_test { float a; int b; } *in, *out, *sol; 2242 int i,fnderr=0; 2243 in = (struct float_test *)malloc( count * sizeof(struct float_test) ); 2244 out = (struct float_test *)malloc( count * sizeof(struct float_test) ); 2245 sol = (struct float_test *)malloc( count * sizeof(struct float_test) ); 2246 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2247 (sol + i)>a = (size  1 + i); (sol + i)>b = (size1); 2248 (out + i)>a = 0; (out + i)>b = 1; } 2249 MPI_Allreduce( in, out, count, MPI_FLOAT_INT, MPI_MAXLOC, comm ); 2250 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2251 (out + i)>b != (sol + i)>b) { 2252 errcnt++; fnderr++; 2253 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2254 (int)((sol + i)>a), 2255 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2256 }} 2257 if (fnderr) fprintf( stderr, 2258 "(%d) Error for type MPI_FLOAT_INT and op MPI_MAXLOC (%d of %d wrong)\n", 2259 rank, fnderr, count ); 2260 free( in ); 2261 free( out ); 2262 free( sol ); 2263 } 2264 2265 2266 void e18(void) 2267 { 2268 struct double_test { double a; int b; } *in, *out, *sol; 2269 int i,fnderr=0; 2270 in = (struct double_test *)malloc( count * sizeof(struct double_test) ); 2271 out = (struct double_test *)malloc( count * sizeof(struct double_test) ); 2272 sol = (struct double_test *)malloc( count * sizeof(struct double_test) ); 2273 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2274 (sol + i)>a = (size  1 + i); (sol + i)>b = (size1); 2275 (out + i)>a = 0; (out + i)>b = 1; } 2276 MPI_Allreduce( in, out, count, MPI_DOUBLE_INT, MPI_MAXLOC, comm ); 2277 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2278 (out + i)>b != (sol + i)>b) { 2279 errcnt++; fnderr++; 2280 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2281 (int)((sol + i)>a), 2282 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2283 }} 2284 if (fnderr) fprintf( stderr, 2285 "(%d) Error for type MPI_DOUBLE_INT and op MPI_MAXLOC (%d of %d wrong)\n", 2286 rank, fnderr, count ); 2287 free( in ); 2288 free( out ); 2289 free( sol ); 2290 } 2291 2292 2293 2294 void a19(void) 2295 { 2296 struct int_test { int a; int b; } *in, *out, *sol; 2297 int i,fnderr=0; 2298 in = (struct int_test *)malloc( count * sizeof(struct int_test) ); 2299 out = (struct int_test *)malloc( count * sizeof(struct int_test) ); 2300 sol = (struct int_test *)malloc( count * sizeof(struct int_test) ); 2301 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2302 (sol + i)>a = i; (sol + i)>b = 0; 2303 (out + i)>a = 0; (out + i)>b = 1; } 2304 MPI_Allreduce( in, out, count, MPI_2INT, MPI_MINLOC, comm ); 2305 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2306 (out + i)>b != (sol + i)>b) { 2307 errcnt++; fnderr++; 2308 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2309 (int)((sol + i)>a), 2310 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2311 }} 2312 if (fnderr) fprintf( stderr, 2313 "(%d) Error for type MPI_2INT and op MPI_MINLOC (%d of %d wrong)\n", 2314 rank, fnderr, count ); 2315 free( in ); 2316 free( out ); 2317 free( sol ); 2318 } 2319 2320 2321 void b19(void) 2322 { 2323 struct long_test { long a; int b; } *in, *out, *sol; 2324 int i,fnderr=0; 2325 in = (struct long_test *)malloc( count * sizeof(struct long_test) ); 2326 out = (struct long_test *)malloc( count * sizeof(struct long_test) ); 2327 sol = (struct long_test *)malloc( count * sizeof(struct long_test) ); 2328 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2329 (sol + i)>a = i; (sol + i)>b = 0; 2330 (out + i)>a = 0; (out + i)>b = 1; } 2331 MPI_Allreduce( in, out, count, MPI_LONG_INT, MPI_MINLOC, comm ); 2332 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2333 (out + i)>b != (sol + i)>b) { 2334 errcnt++; fnderr++; 2335 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2336 (int)((sol + i)>a), 2337 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2338 }} 2339 if (fnderr) fprintf( stderr, 2340 "(%d) Error for type MPI_LONG_INT and op MPI_MINLOC (%d of %d wrong)\n", 2341 rank, fnderr, count ); 2342 free( in ); 2343 free( out ); 2344 free( sol ); 2345 } 2346 2347 2348 void c19(void) 2349 { 2350 struct short_test { short a; int b; } *in, *out, *sol; 2351 int i,fnderr=0; 2352 in = (struct short_test *)malloc( count * sizeof(struct short_test) ); 2353 out = (struct short_test *)malloc( count * sizeof(struct short_test) ); 2354 sol = (struct short_test *)malloc( count * sizeof(struct short_test) ); 2355 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2356 (sol + i)>a = i; (sol + i)>b = 0; 2357 (out + i)>a = 0; (out + i)>b = 1; } 2358 MPI_Allreduce( in, out, count, MPI_SHORT_INT, MPI_MINLOC, comm ); 2359 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2360 (out + i)>b != (sol + i)>b) { 2361 errcnt++; fnderr++; 2362 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2363 (int)((sol + i)>a), 2364 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2365 }} 2366 if (fnderr) fprintf( stderr, 2367 "(%d) Error for type MPI_SHORT_INT and op MPI_MINLOC (%d of %d wrong)\n", 2368 rank, fnderr, count ); 2369 free( in ); 2370 free( out ); 2371 free( sol ); 2372 } 2373 2374 2375 void d19(void) 2376 { 2377 struct float_test { float a; int b; } *in, *out, *sol; 2378 int i,fnderr=0; 2379 in = (struct float_test *)malloc( count * sizeof(struct float_test) ); 2380 out = (struct float_test *)malloc( count * sizeof(struct float_test) ); 2381 sol = (struct float_test *)malloc( count * sizeof(struct float_test) ); 2382 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2383 (sol + i)>a = i; (sol + i)>b = 0; 2384 (out + i)>a = 0; (out + i)>b = 1; } 2385 MPI_Allreduce( in, out, count, MPI_FLOAT_INT, MPI_MINLOC, comm ); 2386 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2387 (out + i)>b != (sol + i)>b) { 2388 errcnt++; fnderr++; 2389 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2390 (int)((sol + i)>a), 2391 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2392 }} 2393 if (fnderr) fprintf( stderr, 2394 "(%d) Error for type MPI_FLOAT_INT and op MPI_MINLOC (%d of %d wrong)\n", 2395 rank, fnderr, count ); 2396 free( in ); 2397 free( out ); 2398 free( sol ); 2399 } 2400 2401 2402 void e19(void) 2403 { 2404 struct double_test { double a; int b; } *in, *out, *sol; 2405 int i,fnderr=0; 2406 in = (struct double_test *)malloc( count * sizeof(struct double_test) ); 2407 out = (struct double_test *)malloc( count * sizeof(struct double_test) ); 2408 sol = (struct double_test *)malloc( count * sizeof(struct double_test) ); 2409 for (i=0; i<count; i++) { (in + i)>a = (rank + i); (in + i)>b = rank; 2410 (sol + i)>a = i; (sol + i)>b = 0; 2411 (out + i)>a = 0; (out + i)>b = 1; } 2412 MPI_Allreduce( in, out, count, MPI_DOUBLE_INT, MPI_MINLOC, comm ); 2413 for (i=0; i<count; i++) { if ((out + i)>a != (sol + i)>a  2414 (out + i)>b != (sol + i)>b) { 2415 errcnt++; fnderr++; 2416 fprintf( stderr, "(%d) Expected (%d,%d) got (%d,%d)\n", rank, 2417 (int)((sol + i)>a), 2418 (sol+i)>b, (int)((out+i)>a), (out+i)>b ); 2419 }} 2420 if (fnderr) fprintf( stderr, 2421 "(%d) Error for type MPI_DOUBLE_INT and op MPI_MINLOC (%d of %d wrong)\n", 2422 rank, fnderr, count ); 2423 free( in ); 2424 free( out ); 2425 free( sol ); 2426 } 2427 9 #include <string.h> 10 #include "mpi.h" 11 12 int count, size, rank; 13 int cerrcnt, gerrcnt; 14 15 struct int_test { int a; int b; }; 16 struct long_test { long a; int b; }; 17 struct short_test { short a; int b; }; 18 struct float_test { float a; int b; }; 19 struct double_test { double a; int b; }; 20 21 #define mpi_type2str(type) \ 22 ((type == MPI_INT) ? "MPI_INT" : \ 23 (type == MPI_LONG) ? "MPI_LONG" : \ 24 (type == MPI_SHORT) ? "MPI_SHORT" : \ 25 (type == MPI_UNSIGNED_SHORT) ? "MPI_UNSIGNED_SHORT" : \ 26 (type == MPI_UNSIGNED) ? "MPI_UNSIGNED" : \ 27 (type == MPI_UNSIGNED_LONG) ? "MPI_UNSIGNED_LONG" : \ 28 (type == MPI_FLOAT) ? "MPI_FLOAT" : \ 29 (type == MPI_DOUBLE) ? "MPI_DOUBLE" : \ 30 (type == MPI_2INT) ? "MPI_2INT" : \ 31 (type == MPI_LONG_INT) ? "MPI_LONG_INT" : \ 32 (type == MPI_SHORT_INT) ? "MPI_SHORT_INT" : \ 33 (type == MPI_FLOAT_INT) ? "MPI_FLOAT_INT" : \ 34 (type == MPI_DOUBLE_INT) ? "MPI_DOUBLE_INT" : \ 35 "MPI_NULL_DATATYPE") 36 37 #define mpi_op2str(op) \ 38 ((op == MPI_SUM) ? "MPI_SUM" : \ 39 (op == MPI_PROD) ? "MPI_PROD" : \ 40 (op == MPI_MAX) ? "MPI_MAX" : \ 41 (op == MPI_MIN) ? "MPI_MIN" : \ 42 (op == MPI_LOR) ? "MPI_LOR" : \ 43 (op == MPI_LXOR) ? "MPI_LXOR" : \ 44 (op == MPI_LAND) ? "MPI_LAND" : \ 45 (op == MPI_BOR) ? "MPI_BOR" : \ 46 (op == MPI_BAND) ? "MPI_BAND" : \ 47 (op == MPI_BXOR) ? "MPI_BXOR" : \ 48 (op == MPI_MAXLOC) ? "MPI_MAXLOC" : \ 49 (op == MPI_MINLOC) ? "MPI_MINLOC" : \ 50 "MPI_NO_OP") 51 52 #define DECL_MALLOC_IN_OUT_SOL(type) \ 53 type *in, *out, *sol; \ 54 in = (type *) malloc(count * sizeof(type)); \ 55 out = (type *) malloc(count * sizeof(type)); \ 56 sol = (type *) malloc(count * sizeof(type)); 57 58 #define SET_INDEX_CONST(arr, val) \ 59 { \ 60 int i; \ 61 for (i = 0; i < count; i++) \ 62 arr[i] = val; \ 63 } 64 65 #define SET_INDEX_SUM(arr, val) \ 66 { \ 67 int i; \ 68 for (i = 0; i < count; i++) \ 69 arr[i] = i + val; \ 70 } 71 72 #define SET_INDEX_FACTOR(arr, val) \ 73 { \ 74 int i; \ 75 for (i = 0; i < count; i++) \ 76 arr[i] = i * (val); \ 77 } 78 79 #define SET_INDEX_POWER(arr, val) \ 80 { \ 81 int i, j; \ 82 for (i = 0; i < count; i++) { \ 83 (arr)[i] = 1; \ 84 for (j = 0; j < (val); j++) \ 85 arr[i] *= i; \ 86 } \ 87 } 88 89 #define ERROR_CHECK_AND_FREE(lerrcnt, mpi_type, mpi_op) \ 90 { \ 91 if (lerrcnt) { \ 92 fprintf(stderr, "(%d) Error for type %s and op %s\n", \ 93 rank, mpi_type2str(mpi_type), mpi_op2str(mpi_op)); \ 94 } \ 95 free(in); free(out); free(sol); \ 96 } 97 98 #define ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol) \ 99 { \ 100 int i, lerrcnt = 0; \ 101 MPI_Allreduce(in, out, count, mpi_type, mpi_op, MPI_COMM_WORLD); \ 102 for (i = 0; i < count; i++) { \ 103 if (out[i] != sol[i]) { \ 104 cerrcnt++; \ 105 lerrcnt++; \ 106 } \ 107 } \ 108 ERROR_CHECK_AND_FREE(lerrcnt, mpi_type, mpi_op); \ 109 } 110 111 #define STRUCT_ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol) \ 112 { \ 113 int i, lerrcnt = 0; \ 114 MPI_Allreduce(in, out, count, mpi_type, mpi_op, MPI_COMM_WORLD); \ 115 for (i = 0; i < count; i++) { \ 116 if ((out[i].a != sol[i].a)  (out[i].b != sol[i].b)) { \ 117 cerrcnt++; \ 118 lerrcnt++; \ 119 } \ 120 } \ 121 ERROR_CHECK_AND_FREE(lerrcnt, mpi_type, mpi_op); \ 122 } 123 124 #define SET_INDEX_STRUCT_CONST(arr, val, el) \ 125 { \ 126 int i; \ 127 for (i = 0; i < count; i++) \ 128 arr[i].el = val; \ 129 } 130 131 #define SET_INDEX_STRUCT_SUM(arr, val, el) \ 132 { \ 133 int i; \ 134 for (i = 0; i < count; i++) \ 135 arr[i].el = i + (val); \ 136 } 137 138 #define sum_test1(type, mpi_type) \ 139 { \ 140 DECL_MALLOC_IN_OUT_SOL(type); \ 141 SET_INDEX_SUM(in, 0); \ 142 SET_INDEX_FACTOR(sol, size); \ 143 SET_INDEX_CONST(out, 0); \ 144 ALLREDUCE_AND_FREE(mpi_type, MPI_SUM, in, out, sol); \ 145 } 146 147 #define prod_test1(type, mpi_type) \ 148 { \ 149 DECL_MALLOC_IN_OUT_SOL(type); \ 150 SET_INDEX_SUM(in, 0); \ 151 SET_INDEX_POWER(sol, size); \ 152 SET_INDEX_CONST(out, 0); \ 153 ALLREDUCE_AND_FREE(mpi_type, MPI_PROD, in, out, sol); \ 154 } 155 156 #define max_test1(type, mpi_type) \ 157 { \ 158 DECL_MALLOC_IN_OUT_SOL(type); \ 159 SET_INDEX_SUM(in, rank); \ 160 SET_INDEX_SUM(sol, size  1); \ 161 SET_INDEX_CONST(out, 0); \ 162 ALLREDUCE_AND_FREE(mpi_type, MPI_MAX, in, out, sol); \ 163 } 164 165 #define min_test1(type, mpi_type) \ 166 { \ 167 DECL_MALLOC_IN_OUT_SOL(type); \ 168 SET_INDEX_SUM(in, rank); \ 169 SET_INDEX_SUM(sol, 0); \ 170 SET_INDEX_CONST(out, 0); \ 171 ALLREDUCE_AND_FREE(mpi_type, MPI_MIN, in, out, sol); \ 172 } 173 174 #define const_test(type, mpi_type, mpi_op, val1, val2, val3) \ 175 { \ 176 DECL_MALLOC_IN_OUT_SOL(type); \ 177 SET_INDEX_CONST(in, (val1)); \ 178 SET_INDEX_CONST(sol, (val2)); \ 179 SET_INDEX_CONST(out, (val3)); \ 180 ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol); \ 181 } 182 183 #define lor_test1(type, mpi_type) \ 184 const_test(type, mpi_type, MPI_LOR, (rank & 0x1), (size > 1), 0) 185 #define lor_test2(type, mpi_type) \ 186 const_test(type, mpi_type, MPI_LOR, 0, 0, 0) 187 #define lxor_test1(type, mpi_type) \ 188 const_test(type, mpi_type, MPI_LXOR, (rank == 1), (size > 1), 0) 189 #define lxor_test2(type, mpi_type) \ 190 const_test(type, mpi_type, MPI_LXOR, 0, 0, 0) 191 #define lxor_test3(type, mpi_type) \ 192 const_test(type, mpi_type, MPI_LXOR, 1, 0, 0) 193 #define land_test1(type, mpi_type) \ 194 const_test(type, mpi_type, MPI_LAND, (rank & 0x1), 0, 0) 195 #define land_test2(type, mpi_type) \ 196 const_test(type, mpi_type, MPI_LAND, 1, 1, 0) 197 #define bor_test1(type, mpi_type) \ 198 const_test(type, mpi_type, MPI_BOR, (rank & 0x3), ((size < 3) ? size  1 : 0x3), 0) 199 #define bxor_test1(type, mpi_type) \ 200 const_test(type, mpi_type, MPI_BXOR, (rank == 1) * 0xf0, (size > 1) * 0xf0, 0) 201 #define bxor_test2(type, mpi_type) \ 202 const_test(type, mpi_type, MPI_BXOR, 0, 0, 0) 203 #define bxor_test3(type, mpi_type) \ 204 const_test(type, mpi_type, MPI_BXOR, ~0, 0, 0) 205 206 #define band_test1(type, mpi_type) \ 207 { \ 208 DECL_MALLOC_IN_OUT_SOL(type); \ 209 if (rank == size1) { \ 210 SET_INDEX_SUM(in, 0); \ 211 } \ 212 else { \ 213 SET_INDEX_CONST(in, ~0); \ 214 } \ 215 SET_INDEX_SUM(sol, 0); \ 216 SET_INDEX_CONST(out, 0); \ 217 ALLREDUCE_AND_FREE(mpi_type, MPI_BAND, in, out, sol); \ 218 } 219 220 #define band_test2(type, mpi_type) \ 221 { \ 222 DECL_MALLOC_IN_OUT_SOL(type); \ 223 if (rank == size1) { \ 224 SET_INDEX_SUM(in, 0); \ 225 } \ 226 else { \ 227 SET_INDEX_CONST(in, 0); \ 228 } \ 229 SET_INDEX_CONST(sol, 0); \ 230 SET_INDEX_CONST(out, 0); \ 231 ALLREDUCE_AND_FREE(mpi_type, MPI_BAND, in, out, sol); \ 232 } 233 234 #define maxloc_test(type, mpi_type) \ 235 { \ 236 DECL_MALLOC_IN_OUT_SOL(type); \ 237 SET_INDEX_STRUCT_SUM(in, rank, a); \ 238 SET_INDEX_STRUCT_CONST(in, rank, b); \ 239 SET_INDEX_STRUCT_SUM(sol, size  1, a); \ 240 SET_INDEX_STRUCT_CONST(sol, size  1, b); \ 241 SET_INDEX_STRUCT_CONST(out, 0, a); \ 242 SET_INDEX_STRUCT_CONST(out, 1, b); \ 243 STRUCT_ALLREDUCE_AND_FREE(mpi_type, MPI_MAXLOC, in, out, sol); \ 244 } 245 246 #define minloc_test(type, mpi_type) \ 247 { \ 248 DECL_MALLOC_IN_OUT_SOL(type); \ 249 SET_INDEX_STRUCT_SUM(in, rank, a); \ 250 SET_INDEX_STRUCT_CONST(in, rank, b); \ 251 SET_INDEX_STRUCT_SUM(sol, 0, a); \ 252 SET_INDEX_STRUCT_CONST(sol, 0, b); \ 253 SET_INDEX_STRUCT_CONST(out, 0, a); \ 254 SET_INDEX_STRUCT_CONST(out, 1, b); \ 255 STRUCT_ALLREDUCE_AND_FREE(mpi_type, MPI_MINLOC, in, out, sol); \ 256 } 257 258 #define test_types_set1(op, post) \ 259 { \ 260 op##_test##post(int, MPI_INT); \ 261 op##_test##post(long, MPI_LONG); \ 262 op##_test##post(short, MPI_SHORT); \ 263 op##_test##post(unsigned short, MPI_UNSIGNED_SHORT); \ 264 op##_test##post(unsigned, MPI_UNSIGNED); \ 265 op##_test##post(unsigned long, MPI_UNSIGNED_LONG); \ 266 } 267 268 #define test_types_set2(op, post) \ 269 { \ 270 test_types_set1(op, post); \ 271 op##_test##post(unsigned char, MPI_UNSIGNED_CHAR); \ 272 } 273 274 #define test_types_set3(op, post) \ 275 { \ 276 test_types_set1(op, post); \ 277 op##_test##post(float, MPI_FLOAT); \ 278 op##_test##post(double, MPI_DOUBLE); \ 279 } 2428 280 2429 281 int main( int argc, char **argv ) 2430 282 { 2431 MPI_Init( &argc, &argv);2432 2433 MPI_Comm_size( MPI_COMM_WORLD, &size);2434 MPI_Comm_rank( MPI_COMM_WORLD, &rank);283 MPI_Init(&argc, &argv); 284 285 MPI_Comm_size(MPI_COMM_WORLD, &size); 286 MPI_Comm_rank(MPI_COMM_WORLD, &rank); 2435 287 count = 10; 2436 comm = MPI_COMM_WORLD; 2437 2438 /* Test sum */ 2439 #ifdef DEBUG 2440 if (rank == 0) printf( "Testing MPI_SUM...\n" ); 2441 #endif 2442 2443 a1(); 2444 b1(); 2445 c1(); 2446 d1(); 2447 e1(); 2448 f1(); 2449 g1(); 2450 h1(); 2451 2452 gerr += errcnt; 2453 if (errcnt > 0) 2454 printf( "Found %d errors on %d for MPI_SUM\n", errcnt, rank ); 2455 errcnt = 0; 2456 2457 2458 /* Test product */ 2459 #ifdef DEBUG 2460 if (rank == 0) printf( "Testing MPI_PROD...\n" ); 2461 #endif 2462 2463 a2(); 2464 b2(); 2465 c2(); 2466 d2(); 2467 e2(); 2468 f2(); 2469 g2(); 2470 h2(); 2471 2472 gerr += errcnt; 2473 if (errcnt > 0) 2474 printf( "Found %d errors on %d for MPI_PROD\n", errcnt, rank ); 2475 errcnt = 0; 2476 2477 2478 /* Test max */ 2479 #ifdef DEBUG 2480 if (rank == 0) printf( "Testing MPI_MAX...\n" ); 2481 #endif 2482 2483 a3(); 2484 b3(); 2485 c3(); 2486 d3(); 2487 e3(); 2488 f3(); 2489 g3(); 2490 h3(); 2491 2492 gerr += errcnt; 2493 if (errcnt > 0) 2494 printf( "Found %d errors on %d for MPI_MAX\n", errcnt, rank ); 2495 errcnt = 0; 2496 2497 /* Test min */ 2498 #ifdef DEBUG 2499 if (rank == 0) printf( "Testing MPI_MIN...\n" ); 2500 #endif 2501 2502 a4(); 2503 b4(); 2504 c4(); 2505 d4(); 2506 e4(); 2507 f4(); 2508 g4(); 2509 h4(); 2510 2511 gerr += errcnt; 2512 if (errcnt > 0) 2513 printf( "Found %d errors on %d for MPI_MIN\n", errcnt, rank ); 2514 errcnt = 0; 2515 2516 2517 /* Test LOR */ 2518 #ifdef DEBUG 2519 if (rank == 0) printf( "Testing MPI_LOR...\n" ); 2520 #endif 2521 2522 a5(); 2523 b5(); 2524 c5(); 2525 d5(); 2526 e5(); 2527 f5(); 2528 2529 gerr += errcnt; 2530 if (errcnt > 0) 2531 printf( "Found %d errors on %d for MPI_LOR(1)\n", errcnt, rank ); 2532 errcnt = 0; 2533 2534 2535 a6(); 2536 b6(); 2537 c6(); 2538 d6(); 2539 e6(); 2540 f6(); 2541 2542 gerr += errcnt; 2543 if (errcnt > 0) 2544 printf( "Found %d errors on %d for MPI_LOR(0)\n", errcnt, rank ); 2545 errcnt = 0; 2546 2547 /* Test LXOR */ 2548 #ifdef DEBUG 2549 if (rank == 0) printf( "Testing MPI_LXOR...\n" ); 2550 #endif 2551 2552 a7(); 2553 b7(); 2554 c7(); 2555 d7(); 2556 e7(); 2557 f7(); 2558 2559 gerr += errcnt; 2560 if (errcnt > 0) 2561 printf( "Found %d errors on %d for MPI_LXOR(1)\n", errcnt, rank ); 2562 errcnt = 0; 2563 2564 2565 a8(); 2566 b8(); 2567 c8(); 2568 d8(); 2569 e8(); 2570 f8(); 2571 2572 gerr += errcnt; 2573 if (errcnt > 0) 2574 printf( "Found %d errors on %d for MPI_LXOR(0)\n", errcnt, rank ); 2575 errcnt = 0; 2576 2577 2578 a9(); 2579 b9(); 2580 c9(); 2581 d9(); 2582 e9(); 2583 f9(); 2584 2585 gerr += errcnt; 2586 if (errcnt > 0) 2587 printf( "Found %d errors on %d for MPI_LXOR(10)\n", errcnt, rank ); 2588 errcnt = 0; 2589 2590 /* Test LAND */ 2591 #ifdef DEBUG 2592 if (rank == 0) printf( "Testing MPI_LAND...\n" ); 2593 #endif 2594 2595 a10(); 2596 b10(); 2597 c10(); 2598 d10(); 2599 e10(); 2600 f10(); 2601 2602 gerr += errcnt; 2603 if (errcnt > 0) 2604 printf( "Found %d errors on %d for MPI_LAND(0)\n", errcnt, rank ); 2605 errcnt = 0; 2606 2607 2608 a11(); 2609 b11(); 2610 c11(); 2611 d11(); 2612 e11(); 2613 f11(); 2614 2615 gerr += errcnt; 2616 if (errcnt > 0) 2617 printf( "Found %d errors on %d for MPI_LAND(1)\n", errcnt, rank ); 2618 errcnt = 0; 2619 2620 /* Test BOR */ 2621 #ifdef DEBUG 2622 if (rank == 0) printf( "Testing MPI_BOR...\n" ); 2623 #endif 2624 2625 a12(); 2626 b12(); 2627 c12(); 2628 d12(); 2629 e12(); 2630 f12(); 2631 g12(); 2632 2633 gerr += errcnt; 2634 if (errcnt > 0) 2635 printf( "Found %d errors on %d for MPI_BOR(1)\n", errcnt, rank ); 2636 errcnt = 0; 2637 2638 /* Test BAND */ 2639 #ifdef DEBUG 2640 if (rank == 0) printf( "Testing MPI_BAND...\n" ); 2641 #endif 2642 2643 a13(); 2644 b13(); 2645 c13(); 2646 d13(); 2647 e13(); 2648 f13(); 2649 g13(); 2650 2651 gerr += errcnt; 2652 if (errcnt > 0) 2653 printf( "Found %d errors on %d for MPI_BAND(1)\n", errcnt, rank ); 2654 errcnt = 0; 2655 2656 2657 a14(); 2658 b14(); 2659 c14(); 2660 d14(); 2661 e14(); 2662 f14(); 2663 2664 gerr += errcnt; 2665 if (errcnt > 0) 2666 printf( "Found %d errors on %d for MPI_BAND(0)\n", errcnt, rank ); 2667 errcnt = 0; 2668 2669 /* Test BXOR */ 2670 #ifdef DEBUG 2671 if (rank == 0) printf( "Testing MPI_BXOR...\n" ); 2672 #endif 2673 2674 a15(); 2675 b15(); 2676 c15(); 2677 d15(); 2678 e15(); 2679 f15(); 2680 2681 gerr += errcnt; 2682 if (errcnt > 0) 2683 printf( "Found %d errors on %d for MPI_BXOR(1)\n", errcnt, rank ); 2684 errcnt = 0; 2685 2686 2687 a16(); 2688 b16(); 2689 c16(); 2690 d16(); 2691 e16(); 2692 f16(); 2693 2694 gerr += errcnt; 2695 if (errcnt > 0) 2696 printf( "Found %d errors on %d for MPI_BXOR(0)\n", errcnt, rank ); 2697 errcnt = 0; 2698 2699 2700 a17(); 2701 b17(); 2702 c17(); 2703 d17(); 2704 e17(); 2705 f17(); 2706 2707 gerr += errcnt; 2708 if (errcnt > 0) 2709 printf( "Found %d errors on %d for MPI_BXOR(10)\n", errcnt, rank ); 2710 errcnt = 0; 2711 2712 2713 /* Test Maxloc */ 2714 #ifdef DEBUG 2715 if (rank == 0) printf( "Testing MPI_MAXLOC...\n" ); 2716 #endif 2717 2718 a18(); 2719 b18(); 2720 c18(); 2721 d18(); 2722 e18(); 2723 2724 gerr += errcnt; 2725 if (errcnt > 0) 2726 printf( "Found %d errors on %d for MPI_MAXLOC\n", errcnt, rank ); 2727 errcnt = 0; 2728 2729 2730 /* Test minloc */ 2731 #ifdef DEBUG 2732 if (rank == 0) printf( "Testing MPI_MINLOC...\n" ); 2733 #endif 2734 2735 2736 a19(); 2737 b19(); 2738 c19(); 2739 d19(); 2740 e19(); 2741 2742 gerr += errcnt; 2743 if (errcnt > 0) 2744 printf( "Found %d errors on %d for MPI_MINLOC\n", errcnt, rank ); 2745 errcnt = 0; 2746 2747 if (gerr > 0) { 2748 MPI_Comm_rank( MPI_COMM_WORLD, &rank ); 2749 printf( "Found %d errors overall on %d\n", gerr, rank ); 2750 } 2751 2752 { 2753 int toterrs; 2754 MPI_Allreduce( &gerr, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD ); 2755 if (rank == 0) { 2756 if (toterrs) { 2757 printf( " Found %d errors\n", toterrs ); 2758 } 2759 else { 2760 printf( " No Errors\n" ); 2761 } 2762 fflush( stdout ); 2763 } 2764 } 2765 2766 MPI_Finalize( ); 288 289 test_types_set3(sum, 1); 290 test_types_set3(prod, 1); 291 test_types_set3(max, 1); 292 test_types_set3(min, 1); 293 294 test_types_set1(lor, 1); 295 test_types_set1(lor, 2); 296 297 test_types_set1(lxor, 1); 298 test_types_set1(lxor, 2); 299 test_types_set1(lxor, 3); 300 301 test_types_set1(land, 1); 302 test_types_set1(land, 2); 303 304 test_types_set2(bor, 1); 305 306 test_types_set2(band, 1); 307 test_types_set1(band, 2); 308 309 test_types_set1(bxor, 1); 310 test_types_set1(bxor, 2); 311 test_types_set1(bxor, 3); 312 313 maxloc_test(struct int_test, MPI_2INT); 314 maxloc_test(struct long_test, MPI_LONG_INT); 315 maxloc_test(struct short_test, MPI_SHORT_INT); 316 maxloc_test(struct float_test, MPI_FLOAT_INT); 317 maxloc_test(struct double_test, MPI_DOUBLE_INT); 318 319 minloc_test(struct int_test, MPI_2INT); 320 minloc_test(struct long_test, MPI_LONG_INT); 321 minloc_test(struct short_test, MPI_SHORT_INT); 322 minloc_test(struct float_test, MPI_FLOAT_INT); 323 minloc_test(struct double_test, MPI_DOUBLE_INT); 324 325 MPI_Allreduce(&cerrcnt, &gerrcnt, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); 326 if (rank == 0) { 327 if (gerrcnt) 328 printf(" Found %d errors\n", gerrcnt); 329 else 330 printf(" No Errors\n"); 331 fflush(stdout); 332 } 333 334 MPI_Finalize(); 2767 335 return 0; 2768 336 }
Note: See TracChangeset
for help on using the changeset viewer.