14 #include <sys/types.h> 28 static struct timeval tv0 = {.tv_sec = 0};
31 cc = gettimeofday(&tv, 0);
33 if (tv0.tv_sec == 0) {
35 assert(tv0.tv_sec != 0);
37 double dt = ((double)(tv.tv_sec - tv0.tv_sec)
38 + ((double)(tv.tv_usec - tv0.tv_usec) * 1e-6));
48 assert(kvs0 == 0 && kv0.klen == 0 && kv0.vlen == 0 && kvo != 0);
53 for (
int i = 0; i < N; i++) {
54 snprintf(k, 80,
"key%d", i);
55 snprintf(v, 80,
"value%d", i);
57 .klen = (int)(strlen(k) + 1), .vlen = (
int)(strlen(v) + 1),
60 assert(cc == MPI_SUCCESS);
70 assert(kvs0 != 0 && kvo != 0);
73 cc = sscanf((&((
char *)kv0.k.p)[3]),
"%d%c", &x, &gomi);
75 snprintf(buf,
sizeof(buf),
"newvalue%d", x);
76 int vlen = (int)(strlen(buf) + 1);
82 assert(cc == MPI_SUCCESS);
90 aggregatevalues0(
const struct kmr_kv_box kv[],
const long n,
94 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
95 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
97 for (
int i = 0; i < n; i++) {
100 switch (kvs->c.key_data) {
102 assert(kvs->c.key_data != KMR_KV_BAD);
105 assert(kv[i].klen == b0.klen
106 && kv[i].k.i == b0.k.i);
109 assert(kv[i].klen == b0.klen
110 && kv[i].k.d == b0.k.d);
114 case KMR_KV_POINTER_OWNED:
115 case KMR_KV_POINTER_UNMANAGED:
116 assert(kv[i].klen == b0.klen
117 && memcmp(kv[i].k.p, b0.k.p, (
size_t)b0.klen) == 0);
127 snprintf(buf, 48,
"%ld_*_%s", n, kv[0].v.p);
128 int len = (int)(strlen(buf) + 1);
134 assert(cc == MPI_SUCCESS);
142 KMR *mr = kvs0->c.mr;
147 cc = sscanf((&((
char *)kv0.k.p)[3]),
"%d%c", &x, &gomi);
149 snprintf(buf,
sizeof(buf),
"%d_*_newvalue%d", mr->nprocs, x);
150 assert(strlen(kv0.v.p) == strlen(buf));
151 size_t len = strlen(buf);
152 assert(strncmp((kv0.v.p), buf, len) == 0);
160 simple0(
int nprocs,
int rank, _Bool pushoff)
162 MPI_Barrier(MPI_COMM_WORLD);
165 if (rank == 0) {printf(
"CHECK SIMPLE OPERATIONS...\n");}
167 if (rank == 0) {printf(
"CHECK PUSH-OFF KVS...\n");}
176 mr->pushoff_stat = 1;
177 mr->preset_block_size = 750;
184 MPI_Barrier(mr->comm);
186 if (rank == 0) {printf(
"ADD (%d elements)\n", N);}
192 assert(cc == MPI_SUCCESS);
196 assert(cc == MPI_SUCCESS);
201 MPI_Barrier(mr->comm);
203 if (rank == 0) {printf(
"REPLICATE\n");}
209 assert(cc == MPI_SUCCESS);
213 assert(cc == MPI_SUCCESS);
214 assert(cnt1 == (N * nprocs));
218 MPI_Barrier(mr->comm);
220 if (rank == 0) {printf(
"PACK+UNPACK\n");}
227 assert(cc == MPI_SUCCESS && data != 0 && sz != 0);
229 assert(cc == MPI_SUCCESS);
233 assert(cc == MPI_SUCCESS);
235 assert((kvs1r->c.key_data == KMR_KV_OPAQUE
236 || kvs1r->c.key_data == KMR_KV_CSTRING)
237 && (kvs1r->c.value_data == KMR_KV_OPAQUE
238 || kvs1r->c.value_data == KMR_KV_CSTRING));
242 MPI_Barrier(mr->comm);
244 if (rank == 0) {printf(
"MAP\n");}
254 __FILE__, __LINE__, __func__);
256 cc =
kmr_map(kvs1r, kvs2, 0, kmr_noopt, replacevalues0);
257 assert(cc == MPI_SUCCESS);
261 assert(cc == MPI_SUCCESS);
262 assert(cnt2 == (N * nprocs));
266 MPI_Barrier(mr->comm);
268 if (rank == 0) {printf(
"SHUFFLE\n");}
274 assert(cc == MPI_SUCCESS);
285 assert(cc == MPI_SUCCESS);
290 assert(cc == MPI_SUCCESS);
291 assert(cnt3 == (N * nprocs));
295 MPI_Barrier(mr->comm);
297 if (rank == 0) {printf(
"REDUCE\n");}
302 cc =
kmr_reduce(kvs3, kvs4, 0, kmr_noopt, aggregatevalues0);
303 assert(cc == MPI_SUCCESS);
309 assert(cc == MPI_SUCCESS);
314 MPI_Barrier(mr->comm);
316 if (rank == 0) {printf(
"GATHER\n");}
323 assert(cc == MPI_SUCCESS);
327 assert(cc == MPI_SUCCESS);
332 cc =
kmr_map(kvs5, 0, 0, kmr_noopt, checkkeyvalues0);
333 assert(cc == MPI_SUCCESS);
335 if (pushoff && mr->pushoff_stat) {
336 char *s =
"STATISTICS on push-off kvs:\n";
337 kmr_print_statistics_on_pushoff(mr, s);
341 assert(cc == MPI_SUCCESS);
350 assert(mr->rank == 0);
353 for (
int i = 0; i < NN; i++) {
355 .klen =
sizeof(long),
356 .vlen =
sizeof(
long),
369 assert(kv0.k.i == i && kv0.v.i == i);
376 simple1(
int nprocs,
int rank)
378 MPI_Barrier(MPI_COMM_WORLD);
379 if (rank == 0) {printf(
"DISTIBUTE\n");}
386 const long NN = MM * nprocs;
396 assert(kvs1->c.element_count == MM);
405 assert(kvs3->c.element_count == MM);
416 kmr_map(kvs5, 0, 0, kmr_noopt, checksorted1);
424 simple2(
int nprocs,
int rank)
426 MPI_Barrier(MPI_COMM_WORLD);
428 if (rank == 0) {printf(
"CHECK OPERATIONS WITH EMPTY KVS...\n");}
441 assert(cc == MPI_SUCCESS);
445 assert(cc == MPI_SUCCESS);
452 assert(cc == MPI_SUCCESS);
457 cc =
kmr_map(kvs1, kvs2, 0, kmr_noopt, 0);
458 assert(cc == MPI_SUCCESS);
464 assert(cc == MPI_SUCCESS);
470 assert(cc == MPI_SUCCESS);
475 cc =
kmr_sort(kvs4, kvs5, kmr_noopt);
476 assert(cc == MPI_SUCCESS);
479 assert(cc == MPI_SUCCESS);
481 assert(cc == MPI_SUCCESS);
487 assert(cc == MPI_SUCCESS);
490 assert(cc == MPI_SUCCESS);
492 KMR_KVS *vec[] = {kvs70, kvs71};
494 assert(cc == MPI_SUCCESS);
496 assert(cc == MPI_SUCCESS);
499 assert(cc == MPI_SUCCESS);
505 simple3(
int nprocs,
int rank)
507 MPI_Barrier(MPI_COMM_WORLD);
509 if (rank == 0) {printf(
"CHECK LOADING OPTIONS (PROPERTY LIST)...\n");}
513 static char props[] =
514 "# Test file for property loader.\n" 519 "key4\\\n" " " ":value4\n" 520 "ke\\\n" " " "y5=val\\\n" " " "ue5\n" 521 "ke\\\n" " " "\\\n" " " "y6\\\n" 522 "=val\\\n" " " "\\\n" " " "ue6\n" 523 "key\\u0037=\\u0076alue7\n" 524 "key#is!anything=value#is!much=more\n";
526 static char *pairs[][2] =
535 {
"key#is!anything",
"value#is!much=more"}};
537 int npairs = (
sizeof(pairs) / (
sizeof(
char *) * 2));
543 system(
"rm -f properties");
544 FILE *f = fopen(
"properties",
"w");
546 size_t cx = fwrite(props, (
sizeof(props) - 1), 1, f);
553 MPI_Info_create(&info);
556 assert(cc == MPI_SUCCESS);
564 cc = MPI_Info_get_nkeys(info, &nkeys);
565 assert(cc == MPI_SUCCESS);
567 assert((npairs - 2) == nkeys);
568 for (
int i = 0; i < npairs; i++) {
569 if (*pairs[i][0] == 0) {
572 if (*pairs[i][1] == 0) {
575 char *key = pairs[i][0];
576 char value[MPI_MAX_INFO_VAL + 1];
579 cc = MPI_Info_get_valuelen(info, key, &vlen, &flag);
580 assert(cc == MPI_SUCCESS && flag != 0);
581 assert(vlen <= MPI_MAX_INFO_VAL);
582 cc = MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag);
583 assert(cc == MPI_SUCCESS && flag != 0);
584 assert(strcmp(pairs[i][1], value) == 0);
588 MPI_Info_free(&info);
591 system(
"rm -f properties");
599 simple4(
int nprocs,
int rank)
604 MPI_Barrier(MPI_COMM_WORLD);
606 if (rank == 0) {printf(
"CHECK SORTER (SMALL DATA)...\n");}
626 printf(
"Checking local sort on opaques N=%d\n", N);
627 printf(
"Generating random strings...\n");
632 for (
int i = 0; i < N; i++) {
635 for (
int j = 0; j < (len - 1); j++) {
638 int c0 = (int)(vv % 26);
639 int c1 = (
'A' + (c0 - 0));
650 assert(cc == MPI_SUCCESS);
653 assert(cc == MPI_SUCCESS);
657 if (rank == 0) {printf(
"Sorting (normal)...\n"); fflush(0);}
661 assert(cc == MPI_SUCCESS);
662 if (rank == 0) {printf(
"Checking...\n"); fflush(0);}
665 if (rank == 0) {printf(
"Sorting (shuffle)...\n"); fflush(0);}
669 assert(cc == MPI_SUCCESS);
670 if (rank == 0) {printf(
"Check...\n"); fflush(0);}
674 assert(cc == MPI_SUCCESS);
683 printf(
"Checking local sort on integers N=%d\n", N);
684 printf(
"Generating random numbers...\n");
689 for (
int i = 0; i < N; i++) {
690 long vv = ((mrand48() << 32) ^ mrand48());
692 .klen =
sizeof(long),
693 .vlen =
sizeof(
long),
698 assert(cc == MPI_SUCCESS);
701 assert(cc == MPI_SUCCESS);
703 if (rank == 0) {printf(
"Sorting (normal)...\n"); fflush(0);}
707 assert(cc == MPI_SUCCESS);
709 if (rank == 0) {printf(
"Checking...\n"); fflush(0);}
712 if (rank == 0) {printf(
"Sorting (shuffle)...\n"); fflush(0);}
716 assert(cc == MPI_SUCCESS);
717 if (rank == 0) {printf(
"Checking...\n"); fflush(0);}
721 assert(cc == MPI_SUCCESS);
730 printf(
"Checking local sort on doubles N=%d\n", N);
731 printf(
"Generating random numbers...\n");
736 for (
int i = 0; i < N; i++) {
737 double vv = (drand48() - 0.5) * 10000.0;
739 .klen =
sizeof(double),
740 .vlen =
sizeof(
double),
745 assert(cc == MPI_SUCCESS);
748 assert(cc == MPI_SUCCESS);
750 if (rank == 0) {printf(
"Sorting (normal)...\n"); fflush(0);}
754 assert(cc == MPI_SUCCESS);
756 if (rank == 0) {printf(
"Checking...\n"); fflush(0);}
759 if (rank == 0) {printf(
"Sorting (shuffle)...\n"); fflush(0);}
763 assert(cc == MPI_SUCCESS);
764 if (rank == 0) {printf(
"Checking...\n"); fflush(0);}
768 assert(cc == MPI_SUCCESS);
776 for (
int i = 0; i < N; i++) {
777 memset(k, 0,
sizeof(k));
778 memset(v, 0,
sizeof(v));
779 snprintf(k, (KLEN+1),
"%05d%05d", rank, (N - 1 - i));
780 snprintf(v, (VLEN+1),
"value=%d/%d", rank, i);
782 .klen = KLEN, .vlen = VLEN, .k.p = k, .v.p = v};
784 assert(cc == MPI_SUCCESS);
787 assert(cc == MPI_SUCCESS);
791 assert(cc == MPI_SUCCESS);
796 assert(cc == MPI_SUCCESS);
798 assert(cc == MPI_SUCCESS);
804 MPI_Barrier(MPI_COMM_WORLD);
806 if (rank == 0) {printf(
"SORT (int) nprocs x nprocs data...\n");}
812 for (
int i = 0; i < N; i++) {
813 snprintf(v, 80,
"value=%d/%d", rank, i);
815 .klen = (int)
sizeof(
long),
816 .vlen = (int)(strlen(v) + 1),
820 assert(cc == MPI_SUCCESS);
823 assert(cc == MPI_SUCCESS);
827 assert(cc == MPI_SUCCESS);
833 assert(cc == MPI_SUCCESS);
839 assert(cc == MPI_SUCCESS);
843 assert(cc == MPI_SUCCESS);
849 MPI_Barrier(MPI_COMM_WORLD);
851 if (rank == 0) {printf(
"SORT (int) nprocs data...\n");}
857 if (rank == (nprocs - 1)) {
858 for (
int i = 0; i < N; i++) {
859 snprintf(v, 80,
"value=%d/%d", rank, i);
861 .klen = (int)
sizeof(
long),
862 .vlen = (int)(strlen(v) + 1),
866 assert(cc == MPI_SUCCESS);
870 assert(cc == MPI_SUCCESS);
874 assert(cc == MPI_SUCCESS);
880 assert(cc == MPI_SUCCESS);
886 assert(cc == MPI_SUCCESS);
890 assert(cc == MPI_SUCCESS);
896 MPI_Barrier(MPI_COMM_WORLD);
898 if (rank == 0) {printf(
"SORT (int) N x nprocs x nprocs data...\n");}
903 int N = (100 * nprocs);
904 for (
int i = 0; i < N; i++) {
905 snprintf(v, 80,
"value=%d/%d", rank, i);
907 .klen = (int)
sizeof(
long),
908 .vlen = (int)(strlen(v) + 1),
912 assert(cc == MPI_SUCCESS);
915 assert(cc == MPI_SUCCESS);
919 assert(cc == MPI_SUCCESS);
925 assert(cc == MPI_SUCCESS);
931 assert(cc == MPI_SUCCESS);
935 assert(cc == MPI_SUCCESS);
941 MPI_Barrier(MPI_COMM_WORLD);
943 if (rank == 0) {printf(
"SORT (byte array) nprocs x nprocs data...\n");}
949 for (
int i = 0; i < N; i++) {
950 memset(k, 0,
sizeof(k));
951 memset(v, 0,
sizeof(v));
952 snprintf(k, (KLEN+1),
"%05d%05d", rank, (N - 1 - i));
953 snprintf(v, (VLEN+1),
"value=%d/%d", rank, i);
955 .klen = KLEN, .vlen = VLEN, .k.p = k, .v.p = v};
957 assert(cc == MPI_SUCCESS);
960 assert(cc == MPI_SUCCESS);
964 assert(cc == MPI_SUCCESS);
970 assert(cc == MPI_SUCCESS);
976 assert(cc == MPI_SUCCESS);
980 assert(cc == MPI_SUCCESS);
984 assert(cc == MPI_SUCCESS);
988 kmr_icmp(
const void *a0,
const void *a1)
992 long d = (*p0 - *p1);
993 return ((d == 0) ? 0 : ((d < 0) ? -1 : 1));
999 simple5(
int nprocs,
int rank)
1001 MPI_Barrier(MPI_COMM_WORLD);
1003 if (rank == 0) {printf(
"CHECK BSEARCH UTILITY...\n");}
1010 #define A0(I) (10 + 10 * (I)) 1013 for (
int i = 0; i < NN; i++) {
1017 for (
int N = 20; N < NN; N++) {
1023 assert(p0 == &a0[0]);
1025 for (
int i = 0; i < N; i++) {
1028 assert(p0 == &a0[i]);
1033 assert(p0 == &a0[N]);
1036 MPI_Barrier(MPI_COMM_WORLD);
1051 for (
int i = 0; i < NN; i++) {
1053 .klen =
sizeof(long),
1054 .vlen =
sizeof(
long),
1068 long *counter = arg;
1069 _Pragma(
"omp critical")
1082 long *counter = arg;
1083 _Pragma(
"omp critical")
1091 simple6(
int nprocs,
int rank)
1093 MPI_Barrier(MPI_COMM_WORLD);
1095 if (rank == 0) {printf(
"CHECK KMR_MAP_FOR_SOME()...\n");}
1103 const long NN = 10000;
1108 kmr_map_once(kvs0, (
void *)&NN, kmr_noopt, 0, addkeys6);
1112 assert(kvs1->c.element_count == NN);
1125 printf(
"ADD ALL count(kvs2)=%ld for %ld (calls=%ld)\n",
1129 assert(c2 > 0 && c2 <= c1);
1132 long e1 = kvs1->c.element_count;
1140 printf(
"ADD NONE count(kvs3)=%ld for %ld (calls=%ld for %ld)\n",
1141 c3, c1, calls3, e1);
1144 assert(c3 == 0 && e1 == calls3);
1150 MPI_Barrier(MPI_COMM_WORLD);
1152 if (rank == 0) {printf(
"CHECK KMR_TAKE_ONE()...\n");}
1159 kmr_map_once(kvs4, (
void *)&ONE, kmr_noopt, 0, addkeys6);
1163 assert(kv.k.i == 0 && kv.v.i == 0);
1167 kmr_map(kvs4, kvs5, &calls4, kmr_noopt, addeach6);
1174 extern void kmr_isort(
void *a,
size_t n,
size_t es,
int depth);
1179 simple7(
int nprocs,
int rank)
1181 MPI_Barrier(MPI_COMM_WORLD);
1183 if (rank == 0) {printf(
"CHECK ISORT UTILITY (local sort)...\n");}
1190 char *fastomp = getenv(
"FLIB_FASTOMP");
1191 if (!(fastomp != 0 && strcmp(fastomp,
"FALSE") == 0)) {
1192 if (rank == 0) {printf(
"Set environment variable FLIB_FASTOMP=FALSE" 1193 " and run again. Otherwise," 1194 " omp_set_num_threads() is ignored.\n");}
1203 long a0[20] = {19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
1204 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
1205 size_t n0 = (
sizeof(a0) /
sizeof(
long));
1206 for (
int i = 0; i < (int)n0; i++) {
1207 a0[i] += 1000000000000;
1210 if (rank == 0) {printf(
"Sorting data N=%zd\n", n0);}
1215 for (
int i = 0; i < (int)n0; i++) {
1216 assert(a0[i] == (i + 1000000000000));
1228 long *a1 = malloc(
sizeof(
long) * (
size_t)n1);
1231 MPI_Abort(MPI_COMM_WORLD, 1);
1234 if (rank == 0) {printf(
"Sorting data N=%zd\n", n1);}
1237 if (rank == 0) {printf(
"Generating random numbers...\n");}
1240 for (
long i = 0; i < n1; i++) {
1241 a1[i] = ((((long)rand()) << 31) ^ ((long)rand()));
1245 printf(
"Problem...\n");
1246 for (
long i = 0; i < 10; i++) {
1247 printf(
"%ld\n", a1[i]);
1252 if (rank == 0) {printf(
"Sorting (threads=1)...\n");}
1255 double t0 = wtime();
1256 kmr_isort(a1, (
size_t)n1,
sizeof(
long), 0);
1257 double t1 = wtime();
1258 if (rank == 0) {printf(
"time=%f\n", (t1 - t0));}
1262 printf(
"Result...\n");
1263 for (
long i = 0; i < 10; i++) {
1264 printf(
"%ld\n", a1[i]);
1269 if (rank == 0) {printf(
"Checking...\n");}
1271 for (
long i = 0; i < n1; i++) {
1272 assert(a1[i] >= lb);
1286 long *a5 = malloc(
sizeof(
long) * (
size_t)n5);
1289 MPI_Abort(MPI_COMM_WORLD, 1);
1292 if (rank == 0) {printf(
"Sorting data N=%zd\n", n5);}
1294 for (
int threads = 1; threads <= 8; threads *= 2) {
1296 omp_set_num_threads(threads);
1299 int threadsused = 0;
1300 #pragma omp parallel 1302 threadsused = omp_get_num_threads();
1305 if (rank == 0) {printf(
"Generating random numbers...\n");}
1309 for (
long i = 0; i < n5; i++) {
1310 a5[i] = ((((long)rand()) << 31) ^ ((long)rand()));
1313 if (rank == 0) {printf(
"Sorting (threads=%d)...\n", threadsused);}
1316 double t0 = wtime();
1317 kmr_isort(a5, (
size_t)n5,
sizeof(
long), 5);
1318 double t1 = wtime();
1319 if (rank == 0) {printf(
"time=%f\n", (t1 - t0));}
1322 if (rank == 0) {printf(
"Checking...\n");}
1325 long lb5 = LONG_MIN;
1326 for (
long i = 0; i < n5; i++) {
1327 assert(a5[i] >= lb5);
1337 printf(
"NOT OMP\n");
1348 makemanyintegerkeys8(
const struct kmr_kv_box kv0,
1353 long MM = *(
long *)p;
1354 KMR *mr = kvo->c.mr;
1355 int rank = mr->rank;
1356 int nprocs = mr->nprocs;
1357 long cnt = (MM * (nprocs - rank) / nprocs);
1358 for (
long i = 0; i < cnt; i++) {
1361 .klen =
sizeof(long),
1362 .vlen =
sizeof(
long),
1363 .k.i = (rank + (j * nprocs)),
1372 makemanystringkeys8(
const struct kmr_kv_box kv0,
1377 long MM = *(
long *)p;
1378 KMR *mr = kvo->c.mr;
1379 int rank = mr->rank;
1380 int nprocs = mr->nprocs;
1381 long cnt = (MM * (nprocs - rank) / nprocs);
1382 for (
long i = 0; i < cnt; i++) {
1385 snprintf(k, 80,
"key%ld", (rank + (j * nprocs)));
1387 .klen = (int)(strlen(k) + 1),
1388 .vlen =
sizeof(
long),
1401 assert(kv0.v.i > 0);
1413 comparebycanceling8(
const struct kmr_kv_box kv[],
const long n,
1417 for (
long i = 0; i < n; i++) {
1418 assert(kv[i].v.i != 0);
1419 values[i] = kv[i].v.i;
1421 for (
long i = 0; i < n; i++) {
1422 if (values[i] == 0) {
1425 assert(i < (n - 1));
1426 for (
long j = (i + 1); j < n; j++) {
1427 if (values[i] == (- values[j])) {
1432 assert(j != (n - 1));
1436 for (
long i = 0; i < n; i++) {
1437 assert(values[i] == 0);
1443 simple8(
int nprocs,
int rank)
1445 MPI_Barrier(MPI_COMM_WORLD);
1446 if (rank == 0) {printf(
"PSEUDO-SCAN\n");}
1452 const long MM = 100;
1458 for (
int i = 0; i < 2; i++) {
1459 assert(i == 0 || i == 1);
1461 ? makemanyintegerkeys8
1462 : makemanystringkeys8);
1468 kmr_map_once(kvs0, (
void *)&MM, kmr_noopt, 0, makedatafn);
1472 kmr_map(kvs0, kvs1, 0, inspect, copynegate8);
1477 long counts[nprocs];
1482 printf(
"number of pairs on ranks:\n");
1483 for (
int r = 0; r < nprocs; r++) {
1484 printf(
"%ld", counts[r]);
1485 if (r == (nprocs - 1)) {
1487 }
else if (r == 10) {
1500 KMR_KVS *kvsvec[2] = {kvs1, kvs2};
1506 kmr_reduce(kvs4, 0, 0, kmr_noopt, comparebycanceling8);
1513 main(
int argc,
char *argv[])
1515 int nprocs, rank, thlv;
1517 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &thlv);
1518 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
1519 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
1525 _Bool assertion = 0;
1527 _Bool assertion = 1;
1530 kmr_error(0,
"Assertion disabled; recompile this test");
1535 simple0(nprocs, rank, 0);
1536 simple0(nprocs, rank, 1);
1537 simple1(nprocs, rank);
1538 simple2(nprocs, rank);
1539 simple3(nprocs, rank);
1540 simple4(nprocs, rank);
1541 simple5(nprocs, rank);
1542 simple6(nprocs, rank);
1543 simple7(nprocs, rank);
1544 simple8(nprocs, rank);
1546 MPI_Barrier(MPI_COMM_WORLD);
1548 if (rank == 0) {printf(
"OK\n");}
Key-Value Stream (abstract).
Utilities Private Part (do not include from applications).
int kmr_map_for_some(KMR_KVS *kvi, KMR_KVS *kvo, void *arg, struct kmr_option opt, kmr_mapfn_t m)
Maps until some key-value are added.
#define kmr_reduce(KVI, KVO, ARG, OPT, R)
Reduces key-value pairs.
Options to Mapping, Shuffling, and Reduction.
int kmr_add_kv(KMR_KVS *kvs, const struct kmr_kv_box kv)
Adds a key-value pair.
KMR_KVS * kmr_create_pushoff_kvs(KMR *mr, enum kmr_kv_field kf, enum kmr_kv_field vf, struct kmr_option opt, const char *, const int, const char *)
Makes a new key-value stream with the specified field data-types.
static int kmr_icmp(const void *a0, const void *a1)
Compares the key field of keyed-records for qsort/bsearch.
int kmr_map_once(KMR_KVS *kvo, void *arg, struct kmr_option opt, _Bool rank_zero_only, kmr_mapfn_t m)
Maps once.
#define kmr_create_kvs(MR, KF, VF)
Makes a new key-value stream (of type KMR_KVS) with the specified field datatypes.
int kmr_save_kvs(KMR_KVS *kvi, void **dataq, size_t *szq, struct kmr_option opt)
Packs locally the contents of a key-value stream to a byte array.
int kmr_shuffle(KMR_KVS *kvi, KMR_KVS *kvo, struct kmr_option opt)
Shuffles key-value pairs to the appropriate destination ranks.
int kmr_distribute(KMR_KVS *kvi, KMR_KVS *kvo, _Bool cyclic, struct kmr_option opt)
Distributes key-values so that each rank has approximately the same number of pairs.
int kmr_add_kv_done(KMR_KVS *kvs)
Marks finished adding key-value pairs.
int kmr_sort_by_one(KMR_KVS *kvi, KMR_KVS *kvo, struct kmr_option opt)
Sort by rank0, a degenerated case for small number of keys.
int kmr_concatenate_kvs(KMR_KVS *kvs[], int nkvs, KMR_KVS *kvo, struct kmr_option opt)
Concatenates a number of KVSes to one.
int kmr_free_kvs(KMR_KVS *kvs)
Releases a key-value stream (type KMR_KVS).
kmr_kv_field
Datatypes of Keys or Values.
void kmr_isort(void *a, size_t n, size_t es, int depth)
Sorts by comparator on long integers.
int kmr_take_one(KMR_KVS *kvi, struct kmr_kv_box *kv)
Extracts a single key-value pair locally in the key-value stream KVI.
#define kmr_map(KVI, KVO, ARG, OPT, M)
Maps simply.
Handy Copy of a Key-Value Field.
int kmr_sort_large(KMR_KVS *kvi, KMR_KVS *kvo, struct kmr_option opt)
Sorts a key-value stream by the regular or the random sampling-sort.
int kmr_fin(void)
Clears the environment.
int kmr_get_element_count(KMR_KVS *kvs, long *v)
Gets the total number of key-value pairs.
#define kmr_init()
Sets up the environment.
void * kmr_bsearch(const void *key, const void *base, size_t nel, size_t size, int(*compar)(const void *, const void *))
Searches a key entry like bsearch(3C), but returns a next greater entry instead of null on no match...
int kmr_sort(KMR_KVS *kvi, KMR_KVS *kvo, struct kmr_option opt)
Sorts a key-value stream globally.
int kmr_assert_sorted(KMR_KVS *kvi, _Bool locally, _Bool shuffling, _Bool ranking)
Checks a key-value stream is sorted.
int kmr_shuffle_leveling_pair_count(KMR_KVS *kvi, KMR_KVS *kvo)
Shuffles key-values so that each rank has approximately the same number of pairs. ...
int kmr_histogram_count_by_ranks(KMR_KVS *kvs, long *frq, double *var, _Bool rankzeroonly)
Fills an integer array FRQ[i] with the count of the elements of each rank.
int kmr_restore_kvs(KMR_KVS *kvo, void *data, size_t sz, struct kmr_option opt)
Unpacks locally the contents of a key-value stream from a byte array.
int kmr_free_context(KMR *mr)
Releases a context created with kmr_create_context().
int kmr_load_properties(MPI_Info conf, char *filename)
Loads properties into MPI_Info (in Latin1 characters).
int kmr_replicate(KMR_KVS *kvi, KMR_KVS *kvo, struct kmr_option opt)
Replicates key-value pairs to be visible on all ranks, that is, it has the effect of bcast or all-gat...
int kmr_sort_small(KMR_KVS *kvi, KMR_KVS *kvo, struct kmr_option opt)
Sorts a key-value stream, by partitioning to equal ranges.
int kmr_sort_locally(KMR_KVS *kvi, KMR_KVS *kvo, _Bool shuffling, struct kmr_option opt)
Reorders key-value pairs in a single rank.
int(* kmr_mapfn_t)(const struct kmr_kv_box kv, const KMR_KVS *kvi, KMR_KVS *kvo, void *arg, const long index)
Map-function Type.
int kmr_map_on_rank_zero(KMR_KVS *kvo, void *arg, struct kmr_option opt, kmr_mapfn_t m)
Maps on rank0 only.
KMR * kmr_create_context(const MPI_Comm comm, const MPI_Info conf, const char *name)
Makes a new KMR context (a context has type KMR).