11 #include <sys/types.h> 24 KMR_KVS *kvo,
void *p,
const long ii)
26 printf(
"mapfn(k=%s, v=%s)\n", kv.k.p, kv.v.p);
33 simple0(
int nprocs,
int rank)
41 MPI_Barrier(MPI_COMM_WORLD);
43 if (rank == 0) {printf(
"Checking kmr_map_ms...\n");}
51 for (
int i = 0; i < 20; i++) {
52 snprintf(k,
sizeof(k),
"key%d", i);
53 snprintf(v,
sizeof(v),
"value%d", i);
62 cc =
kmr_map_ms(kvs00, kvs01, 0, opt, copykvfn);
63 }
while (cc == MPI_ERR_ROOT);
66 assert(kvs01->c.element_count == 20);
68 assert(kvs01->c.element_count == 0);
77 simple1(
int nprocs,
int rank)
85 MPI_Barrier(MPI_COMM_WORLD);
87 if (rank == 0) {printf(
"Checking kmr_map_ms_commands...\n");}
95 snprintf(k,
sizeof(k),
"key");
96 snprintf(v,
sizeof(v),
"./a.out a0 a1 a2");
97 for (
int i = 0; i < 20; i++) {
105 mopt.nothreading = 1;
108 mopt, sopt, copykvfn);
109 }
while (cc == MPI_ERR_ROOT);
112 assert(kvs01->c.element_count == 20);
114 assert(kvs01->c.element_count == 0);
123 main(
int argc,
char *argv[])
125 if (argc == 1 || argc == 2) {
126 int nprocs, rank, lev;
127 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &lev);
128 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
129 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
133 if (rank == 0) {printf(
"CHECK MS MAPPER\n");}
136 simple0(nprocs, rank);
137 simple1(nprocs, rank);
139 MPI_Barrier(MPI_COMM_WORLD);
141 if (rank == 0) {printf(
"OK\n");}
148 printf(
"a process runs: %s %s %s %s\n",
149 argv[0], argv[1], argv[2], argv[3]);
152 printf(
"a process done.\n");
Key-Value Stream (abstract).
Utilities Private Part (do not include from applications).
Options to Mapping, Shuffling, and Reduction.
int kmr_add_kv(KMR_KVS *kvs, const struct kmr_kv_box kv)
Adds a key-value pair.
#define kmr_create_kvs(MR, KF, VF)
Makes a new key-value stream (of type KMR_KVS) with the specified field datatypes.
int kmr_add_kv_done(KMR_KVS *kvs)
Marks finished adding key-value pairs.
int kmr_free_kvs(KMR_KVS *kvs)
Releases a key-value stream (type KMR_KVS).
Handy Copy of a Key-Value Field.
Options to Mapping by Spawns.
int kmr_fin(void)
Clears the environment.
#define kmr_init()
Sets up the environment.
int kmr_map_ms_commands(KMR_KVS *kvi, KMR_KVS *kvo, void *arg, struct kmr_option opt, struct kmr_spawn_option sopt, kmr_mapfn_t m)
Maps in master-slave mode, specialized to run serial commands.
int kmr_free_context(KMR *mr)
Releases a context created with kmr_create_context().
int kmr_map_ms(KMR_KVS *kvi, KMR_KVS *kvo, void *arg, struct kmr_option opt, kmr_mapfn_t m)
Maps in master-slave mode.
int kmr_add_string(KMR_KVS *kvs, const char *k, const char *v)
Adds a key-value pair of strings.
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).