55 #include <sys/types.h> 60 #define NUM_COMMANDS 10 66 char *cmd1 =
"maxprocs=1 /bin/sleep 1";
67 char *cmd2 =
"maxprocs=1 /bin/sleep 5";
68 char *cmd3 =
"maxprocs=1 /bin/sleep 10";
69 int vlen = (int)strlen(cmd2) + 1;
70 for (
int i = 0; i < NUM_COMMANDS; i++) {
74 }
else if (i % 3 == 1) {
79 struct kmr_kv_box nkv = { .klen =
sizeof(long),
80 .vlen = vlen * (
int)
sizeof(char),
92 struct kmr_kv_box nkv = { .klen =
sizeof(long),
101 main(
int argc,
char **argv)
103 MPI_Init(&argc, &argv);
107 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
109 MPI_Barrier(MPI_COMM_WORLD);
111 fprintf(stderr,
"Start\n");
113 MPI_Barrier(MPI_COMM_WORLD);
116 int ret =
kmr_map_once(kvs_commands, 0, kmr_noopt, 1, gen_cmdkvs);
117 if (ret != MPI_SUCCESS) {
118 MPI_Abort(MPI_COMM_WORLD, 1);
122 MPI_Barrier(MPI_COMM_WORLD);
124 fprintf(stderr,
"MAP_ONCE DONE\n");
126 MPI_Barrier(MPI_COMM_WORLD);
129 ret =
kmr_shuffle(kvs_commands, kvs_runcmds, kmr_noopt);
130 if (ret != MPI_SUCCESS) {
131 MPI_Abort(MPI_COMM_WORLD, 1);
135 MPI_Barrier(MPI_COMM_WORLD);
137 fprintf(stderr,
"SHUFFLE DONE\n");
139 MPI_Barrier(MPI_COMM_WORLD);
144 sopt_sepsp, output_result);
148 MPI_Barrier(MPI_COMM_WORLD);
150 fprintf(stderr,
"MAP_SPAWN DONE\n");
152 MPI_Barrier(MPI_COMM_WORLD);
155 fprintf(stderr,
"Finish\n");
int kmr_map_serial_processes(KMR_KVS *kvi, KMR_KVS *kvo, void *arg, MPI_Info info, struct kmr_spawn_option opt, kmr_mapfn_t mapfn)
Maps on processes started by MPI_Comm_spawn() to run serial processes.
Key-Value Stream (abstract).
int kmr_add_kv(KMR_KVS *kvs, const struct kmr_kv_box kv)
Adds a key-value pair.
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_shuffle(KMR_KVS *kvi, KMR_KVS *kvo, struct kmr_option opt)
Shuffles key-value pairs to the appropriate destination ranks.
int kmr_free_kvs(KMR_KVS *kvs)
Releases a key-value stream (type KMR_KVS).
Handy Copy of a Key-Value Field.
int kmr_dump_kvs(KMR_KVS *kvs, int flag)
Dumps contents of a key-value stream to stdout.
Options to Mapping by Spawns.
int kmr_fin(void)
Clears the environment.
#define kmr_init()
Sets up the environment.
int kmr_free_context(KMR *mr)
Releases a context created with kmr_create_context().
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).