static int bindup_node(context_t *c) { /* choose any node rank here. i use node rank 0 (quid 0) because it's easy. * */ if (0 == c->noderank) { printf("### [rank %d on %s] expanding my cpuset for threading!\n", c->rank, c->hostname); /* QUO_BIND_PUSH_OBJ, so the last argument doesn't matter */ int rc = QUO_bind_push(c->quo, QUO_BIND_PUSH_OBJ, QUO_OBJ_MACHINE, -1); if (QUO_SUCCESS != rc) { fprintf(stderr, "%s fails with rc: %d\n", "QUO_bind_push", rc); return 1; } /* i pushed a policy */ c->pushed_policy = true; demo_emit_sync(c); } else { printf("--- [rank %d on %s] going to sleep...\n", c->rank, c->hostname); demo_emit_sync(c); } return 0; }
static int emit_bind_state(const context_t *c) { char *cbindstr = NULL, *bad_func = NULL; int bound = 0; demo_emit_sync(c); if (QUO_SUCCESS != QUO_stringify_cbind(c->quo, &cbindstr)) { bad_func = "QUO_stringify_cbind"; goto out; } if (QUO_SUCCESS != QUO_bound(c->quo, &bound)) { bad_func = "QUO_bound"; goto out; } printf("### process %d rank %d [%s] bound: %s\n", (int)getpid(), c->rank, cbindstr, bound ? "true" : "false"); fflush(stdout); out: demo_emit_sync(c); if (cbindstr) free(cbindstr); if (bad_func) { fprintf(stderr, "%s: %s failure :-(\n", __func__, bad_func); return 1; } return 0; }
static int emit_node_basics(const p1_context_t *c) { demo_emit_sync(c); /* one proc per node will emit this info */ if (0 == c->noderank) { printf("### [rank %d] quo version: %d.%d ###\n", c->rank, c->qv, c->qsv); printf("### [rank %d] nnodes: %d\n", c->rank, c->nnodes); printf("### [rank %d] nnoderanks: %d\n", c->rank, c->nnoderanks); printf("### [rank %d] nnumanodes: %d\n", c->rank, c->nnumanodes); printf("### [rank %d] nsockets: %d\n", c->rank, c->nsockets); printf("### [rank %d] ncores: %d\n", c->rank, c->ncores); printf("### [rank %d] npus: %d\n", c->rank, c->npus); fflush(stdout); } demo_emit_sync(c); return 0; }
int p1_init(p1_context_t **p1_ctx, MPI_Comm comm) { if (!p1_ctx) return 1; // int inited = 0; if (MPI_SUCCESS != MPI_Initialized(&inited)) return 1; /* QUO requires that MPI be initialized before its use. */ if (!inited) return 1; // p1_context_t *newc = NULL; if (NULL == (newc = calloc(1, sizeof(*newc)))) return 1; // dup initializing comm */ if (MPI_SUCCESS != MPI_Comm_dup(comm, &newc->init_comm_dup)) return 1; /* gather some basic info about initializing communicator */ if (MPI_SUCCESS != MPI_Comm_size(newc->init_comm_dup, &newc->nranks)) { return 1; } if (MPI_SUCCESS != MPI_Comm_rank(newc->init_comm_dup, &newc->rank)) { return 1; } // if (quo_init(newc)) return 1; // if (sys_grok(newc)) return 1; // if (emit_node_basics(newc)) return 1; // demo_emit_sync(newc); if (emit_bind_state(newc, "###")) return 1; demo_emit_sync(newc); // int n_workers = 0; int *worker_comm_ids = NULL; if (get_worker_pes(newc, &n_workers, &worker_comm_ids)) return 1; if (gen_libcomm(newc, n_workers, worker_comm_ids)) return 1; // *p1_ctx = newc; return 0; }
static int cores_in_cur_bind_test(const context_t *c) { int b0 = -1, blast = -1; if (type_in_cur_bind(c, QUO_OBJ_CORE, 0, &b0)) return 1; if (type_in_cur_bind(c, QUO_OBJ_CORE, c->ncores - 1, &blast)) return 1; printf("### [rank %d] core %d in current bind policy: %s\n", c->rank, 0, b0 ? "true" : "false"); printf("### [rank %d] core %d in current bind policy: %s\n", c->rank, c->ncores - 1, blast ? "true" : "false"); demo_emit_sync(c); return 0; }