int p1_fini(p1_context_t *c) { if (!c) return 0; MPI_Comm_free(&c->init_comm_dup); if (c->in_quo_comm) MPI_Comm_free(&c->quo_comm); QUO_free(c->quo); free(c); return 0; }
int main(int argc, char **argv) { QUO_context q = NULL; assert(MPI_SUCCESS == MPI_Init(&argc, &argv)); assert(QUO_SUCCESS == QUO_create(&q, MPI_COMM_WORLD)); assert(QUO_SUCCESS == QUO_free(q)); assert(MPI_SUCCESS == MPI_Finalize()); return EXIT_SUCCESS; }
static int fini(context_t *c) { if (!c) return 1; if (QUO_SUCCESS != QUO_free(c->quo)) return 1; /* finalize mpi AFTER QUO_destruct - we may mpi in our destruct */ if (c->mpi_inited) MPI_Finalize(); if (c->cbindstr) free(c->cbindstr); free(c); return 0; }
int main() { int number, i; if (MPI_SUCCESS != MPI_Init(NULL, NULL)) return 1; if (MPI_SUCCESS != MPI_Comm_rank(MPI_COMM_WORLD, &rank)) goto err; if (MPI_SUCCESS != MPI_Comm_size(MPI_COMM_WORLD, &size)) goto err; if (QUO_SUCCESS != QUO_create(&context)) goto err; if (QUO_SUCCESS != QUO_bind_push(context, QUO_BIND_PUSH_PROVIDED, QUO_OBJ_SOCKET, rank%2)) { printf("QUO_bind failed\n"); goto err; } omp_set_nested(1); #pragma omp parallel num_threads(4) { if (QUO_SUCCESS != QUO_bind_threads(context, QUO_OBJ_SOCKET, rank%2)) printf("QUO_bind_threads failed\n"); toString("First configuration"); #pragma omp parallel num_threads(2) { if (QUO_SUCCESS != QUO_bind_threads(context, QUO_OBJ_SOCKET, rank%2)) printf("QUO_bind_threads failed\n"); toString("Second configuration"); } } err: if(context) QUO_free(context); MPI_Finalize(); return 0; }
int main(void) { int qrc = QUO_SUCCESS, erc = EXIT_SUCCESS; int qv = 0, qsv = 0, nnodes = 0, nnoderanks = 0; int nsockets = 0, ncores = 0, npus = 0; char *bad_func = NULL; char *cbindstr = NULL, *cbindstr2 = NULL, *cbindstr3 = NULL; int bound = 0, bound2 = 0, bound3 = 0; QUO_context quo = NULL; inf_t info; if (init(&info)) { bad_func = "info"; goto out; } if (QUO_SUCCESS != (qrc = QUO_version(&qv, &qsv))) { bad_func = "QUO_version"; goto out; } /* cheap call */ if (QUO_SUCCESS != (qrc = QUO_create(&quo))) { bad_func = "QUO_create"; goto out; } if (QUO_SUCCESS != (qrc = QUO_nsockets(quo, &nsockets))) { bad_func = "QUO_nsockets"; goto out; } if (QUO_SUCCESS != (qrc = QUO_ncores(quo, &ncores))) { bad_func = "QUO_ncores"; goto out; } if (QUO_SUCCESS != (qrc = QUO_npus(quo, &npus))) { bad_func = "QUO_npus"; goto out; } if (QUO_SUCCESS != (qrc = QUO_bound(quo, &bound))) { bad_func = "QUO_bound"; goto out; } if (QUO_SUCCESS != (qrc = QUO_stringify_cbind(quo, &cbindstr))) { bad_func = "QUO_stringify_cbind"; goto out; } if (QUO_SUCCESS != (qrc = QUO_nnodes(quo, &nnodes))) { bad_func = "QUO_nnodes"; goto out; } if (QUO_SUCCESS != (qrc = QUO_nqids(quo, &nnoderanks))) { bad_func = "QUO_nnodes"; goto out; } /* last argument ignored with QUO_BIND_PUSH_OBJ option */ if (QUO_SUCCESS != (qrc = QUO_bind_push(quo, QUO_BIND_PUSH_OBJ, QUO_OBJ_CORE, 0))) { bad_func = "QUO_bind_push"; goto out; } if (QUO_SUCCESS != (qrc = QUO_stringify_cbind(quo, &cbindstr2))) { bad_func = "QUO_stringify_cbind"; goto out; } if (QUO_SUCCESS != (qrc = QUO_bound(quo, &bound2))) { bad_func = "QUO_bound"; goto out; } if (QUO_SUCCESS != (qrc = QUO_bind_pop(quo))) { bad_func = "QUO_bind_pop"; goto out; } if (QUO_SUCCESS != (qrc = QUO_stringify_cbind(quo, &cbindstr3))) { bad_func = "QUO_stringify_cbind"; goto out; } if (QUO_SUCCESS != (qrc = QUO_bound(quo, &bound3))) { bad_func = "QUO_bound"; goto out; } if (QUO_SUCCESS != (qrc = QUO_free(quo))) { bad_func = "QUO_free"; goto out; } printf("### quo version: %d.%d ###\n", qv, qsv); printf("### nnodes: %d\n", nnodes); printf("### nnoderanks: %d\n", nnoderanks); printf("### nsockets: %d\n", nsockets); printf("### ncores: %d\n", ncores); printf("### npus: %d\n", npus); printf("### process %d [%s] bound: %s\n", (int)getpid(), cbindstr, bound ? "true" : "false"); printf("### process %d [%s] bound: %s\n", (int)getpid(), cbindstr2, bound2 ? "true" : "false"); printf("### process %d [%s] bound: %s\n", (int)getpid(), cbindstr3, bound3 ? "true" : "false"); /* the string returned by QUO_machine_topo_stringify MUST be free'd by us */ free(cbindstr); free(cbindstr2); out: if (NULL != bad_func) { fprintf(stderr, "xxx %s failure in: %s\n", __FILE__, bad_func); erc = EXIT_FAILURE; } (void)fini(&info); return erc; }
int L7_Terminate (void) { /* * Purpose * ======= * L7_Terminate deallocates its workspace, then, if L7 initialized * MPI on behalf of the application program, terminates the MPI * environment. * * Arguments * ========= * none * * Return value * ============ * Returns zero if successful, non-zero for error * * Notes * ===== * 1) Serial compilation (! HAVE_MPI) creates a no-op. * */ #if defined(HAVE_MPI) /* * Local variables */ int flag, /* MPI_Finalized input. */ ierr; /* Error code to be returned. */ /* * Executable Statements */ MPI_Initialized ( &flag ); if ( flag ) { ierr = MPI_Comm_rank ( MPI_COMM_WORLD, &l7.penum ); L7_ASSERT( ierr == MPI_SUCCESS, "MPI_Comm_rank error", ierr ); } else{ return(0); } if ( l7.initialized != 1) { ierr = -1; L7_ASSERT( l7.initialized == 1, "L7 not initialized", ierr ); } if ( l7.initialized_mpi == 1 ){ ierr = MPI_Finalized ( &flag ); if ( !flag ){ ierr = MPI_Finalize (); L7_ASSERT( ierr == MPI_SUCCESS, "MPI_Finalize", ierr ); } l7.initialized_mpi = 0; } if ( l7.send_buffer != NULL ){ free ( l7.send_buffer); l7.sizeof_send_buffer = 0; } l7.initialized = 0; #ifdef HAVE_QUO if (l7.subComm.context) { int rc = QUO_ERR; if (QUO_SUCCESS != (rc = QUO_free(l7.subComm.context))) { printf("QUO_free failure: rc = %d\n",rc); exit(0); } } #endif #ifdef HAVE_OPENCL if (l7.numpes > 1){ ezcl_kernel_release(l7.kernel_pack_int_have_data); ezcl_kernel_release(l7.kernel_pack_float_have_data); ezcl_kernel_release(l7.kernel_pack_double_have_data); ezcl_kernel_release(l7.kernel_copy_ghost_int_data); ezcl_kernel_release(l7.kernel_copy_ghost_float_data); ezcl_kernel_release(l7.kernel_copy_ghost_double_data); } #endif #endif /* HAVE_MPI */ return(0); } /* End L7_Terminate */