本文整理汇总了C++中MPI_Comm_set_errhandler函数的典型用法代码示例。如果您正苦于以下问题:C++ MPI_Comm_set_errhandler函数的具体用法?C++ MPI_Comm_set_errhandler怎么用?C++ MPI_Comm_set_errhandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MPI_Comm_set_errhandler函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
int thread_support;
char root_path[MPI_PMEM_MAX_ROOT_PATH];
char *window_name = "test_window";
void *win_data;
MPI_Aint win_size = 1024;
MPI_Win_pmem win;
int error_code;
int result = 0;
MPI_Init_thread_pmem(&argc, &argv, MPI_THREAD_MULTIPLE, &thread_support);
sprintf(root_path, "%s/0", argv[1]);
MPI_Win_pmem_set_root_path(root_path);
// Create window and 3 checkpoints.
allocate_window(&win, &win_data, window_name, win_size);
create_checkpoint(win, false);
create_checkpoint(win, false);
create_checkpoint(win, false);
MPI_Win_free_pmem(&win);
// Try to delete window version.
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
error_code = MPI_Win_pmem_delete_version(window_name, 3);
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
if (error_code != MPI_ERR_PMEM_CKPT_VER) {
mpi_log_error("Error code is %d, expected %d.", error_code, MPI_ERR_PMEM_CKPT_VER);
result = 1;
}
MPI_Finalize_pmem();
return result;
}
示例2: main
int main(int argc, char *argv[]) {
int thread_support;
char root_path[MPI_PMEM_MAX_ROOT_PATH];
MPI_Info info;
MPI_Win_pmem win;
char *window_name = "test_window";
char *win_data;
MPI_Aint win_size = 1024;
int error_code;
int result = 0;
MPI_Init_thread_pmem(&argc, &argv, MPI_THREAD_MULTIPLE, &thread_support);
sprintf(root_path, "%s/0", argv[1]);
MPI_Win_pmem_set_root_path(root_path);
// Allocate window.
MPI_Info_create(&info);
MPI_Info_set(info, "pmem_is_pmem", "true");
MPI_Info_set(info, "pmem_name", window_name);
MPI_Info_set(info, "pmem_mode", "checkpoint");
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
error_code = MPI_Win_allocate_pmem(win_size, 1, info, MPI_COMM_WORLD, &win_data, &win);
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
MPI_Info_free(&info);
if (error_code != MPI_ERR_PMEM_NAME) {
mpi_log_error("Error code is %d, expected %d.", error_code, MPI_ERR_PMEM_NAME);
result = 1;
}
MPI_Finalize_pmem();
return result;
}
示例3: main
int main (int argc, char **argv)
{
MPI_Errhandler errh;
int wrank;
MPI_Init (&argc, &argv);
MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
MPI_Comm_create_errhandler((MPI_Comm_errhandler_function*)errf, &errh);
MPI_Comm_set_errhandler(MPI_COMM_WORLD, errh);
MPI_Comm_set_errhandler(MPI_COMM_SELF, errh);
MPI_Errhandler_free(&errh);
MPI_Finalize();
/* Test harness requirement is that only one process write No Errors */
if (wrank == 0)
printf(" No Errors\n");
return 0;
}
示例4: main
int main(int argc, char **argv)
{
int err, errs = 0;
MTest_Init(&argc, &argv);
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
* change the error handler to errors return */
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = blockindexed_contig_test();
if (err && verbose)
fprintf(stderr, "%d errors in blockindexed test.\n", err);
errs += err;
err = blockindexed_vector_test();
if (err && verbose)
fprintf(stderr, "%d errors in blockindexed vector test.\n", err);
errs += err;
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
示例5: numProcsFails
int numProcsFails(MPI_Comm mcw){
int rank, ret, numFailures = 0, flag;
MPI_Group fGroup;
MPI_Errhandler newEh;
MPI_Comm dupComm;
// Error handler
MPI_Comm_create_errhandler(mpiErrorHandler, &newEh);
MPI_Comm_rank(mcw, &rank);
// Set error handler for communicator
MPI_Comm_set_errhandler(mcw, newEh);
// Target function
if(MPI_SUCCESS != (ret = MPI_Comm_dup(mcw, &dupComm))) {
//if(MPI_SUCCESS != (ret = MPI_Barrier(mcw))) { // MPI_Comm_dup or MPI_Barrier
OMPI_Comm_failure_ack(mcw);
OMPI_Comm_failure_get_acked(mcw, &fGroup);
// Get the number of failures
MPI_Group_size(fGroup, &numFailures);
}// end of "MPI_Comm_dup failure"
OMPI_Comm_agree(mcw, &flag);
// Memory release
if(numFailures > 0)
MPI_Group_free(&fGroup);
MPI_Errhandler_free(&newEh);
return numFailures;
}//numProcsFails()
示例6: MyMPI_Init
/**
* @brief Wrapper around MPI_Init
*
* We check the error code to detect MPI errors.
*
* This method also initializes the rank and size global variables.
*
* @param argc Pointer to the number of command line arguments
* @param argv Pointer to the command line arguments
*/
inline void MyMPI_Init(int* argc, char*** argv) {
int status = MPI_Init(argc, argv);
if(status != MPI_SUCCESS) {
std::cerr << "Failed to initialize MPI environment!" << std::endl;
my_exit();
}
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
MyMPI_Comm_rank(&MPIGlobal::rank);
MyMPI_Comm_size(&MPIGlobal::size);
MyMPI_Comm_local_vars(&MPIGlobal::local_rank, &MPIGlobal::local_size,
&MPIGlobal::noderank, &MPIGlobal::nodesize,
&MPIGlobal::nodecomm);
// allocate the communication buffers
// we initialize them with 0 size, applications needing it should increase
// the size
// by initializing it here, we are sure that the buffer will exist, so that
// we can safely deallocate it again in MyMPI_Finalize
MPIGlobal::sendsize = 0;
MPIGlobal::sendbuffer = new char[MPIGlobal::sendsize];
MPIGlobal::recvsize = 0;
MPIGlobal::recvbuffer = new char[MPIGlobal::recvsize];
}
示例7: main
int main(int argc, char *argv[])
{
int color, key, ret;
MPI_Errhandler new_eh;
MPI_Comm comm_subset;
/*
* Startup MPI
*/
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_mcw_rank);
MPI_Comm_size(MPI_COMM_WORLD, &mpi_mcw_size);
if( mpi_mcw_size < 2 ) {
printf("Error: Must use at least 2 processes for this test\n");
MPI_Finalize();
return -1;
}
/*
* Create a new error handler for MPI_COMM_WORLD
* This overrides the default MPI_ERRORS_ARE_FATAL so that ranks in this
* communicator will not automatically abort if a failure occurs.
*/
MPI_Comm_create_errhandler(mpi_error_handler, &new_eh);
MPI_Comm_set_errhandler(MPI_COMM_WORLD, new_eh);
signal(SIGUSR2, signal_handler);
iterative_solver(MPI_COMM_WORLD);
MPI_Finalize();
return 0;
}
示例8: main
int main(int argc, char *argv[])
{
int err, errs = 0;
/* Initialize MPI */
MPI_Init(&argc, &argv);
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
change the error handler to errors return */
MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
err = hindexed_zerotype_test();
if (verbose && err) fprintf(stderr, "error in hindexed_zerotype_test\n");
errs += err;
err = hindexed_sparsetype_test();
if (verbose && err) fprintf(stderr, "error in hindexed_sparsetype_test\n");
errs += err;
/* print message and exit */
if (errs) {
fprintf(stderr, "Found %d errors\n", errs);
}
else {
printf(" No Errors\n");
}
MPI_Finalize();
return 0;
}
示例9: wc_mpi_init
int wc_mpi_init(int *argc, char ***argv)
{
int rc = 0;
int flag = 0;
if (MPI_Finalized(&flag) == MPI_SUCCESS) {
if (flag != 0) {
WC_ERROR("MPI has already been finalized.\n");
return -1;
}
}
flag = 0;
if (MPI_Initialized(&flag) == MPI_SUCCESS) {
if (flag == 0) {
rc = MPI_Init(argc, argv);
WC_HANDLE_MPI_ERROR(MPI_Init, rc);
if (rc == MPI_SUCCESS)
rc |= MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
return rc;
} else {
rc = 0;
}
} else {
WC_HANDLE_MPI_ERROR(MPI_Initialized, rc);
}
return rc;
}
示例10: main
int main(int argc, char **argv)
{
int err, errs = 0;
MTest_Init(&argc, &argv);
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
* change the error handler to errors return */
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = darray_2d_c_test1();
if (err && verbose)
fprintf(stderr, "%d errors in 2d darray c test 1.\n", err);
errs += err;
err = darray_4d_c_test1();
if (err && verbose)
fprintf(stderr, "%d errors in 4d darray c test 1.\n", err);
errs += err;
/* print message and exit */
/* Allow the use of more than one process - some MPI implementations
* (including IBM's) check that the number of processes given to
* Type_create_darray is no larger than MPI_COMM_WORLD */
MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
示例11: main
int main( int argc, char *argv[] )
{
int errs = 0;
int rc;
int ranks[2];
MPI_Group ng;
char str[MPI_MAX_ERROR_STRING+1];
int slen;
MTest_Init( &argc, &argv );
/* Set errors return */
MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
/* Create some valid input data except for the group handle */
ranks[0] = 0;
rc = MPI_Group_incl( MPI_COMM_WORLD, 1, ranks, &ng );
if (rc == MPI_SUCCESS) {
errs ++;
printf( "Did not detect invalid handle (comm) in group_incl\n" );
}
else {
if (verbose) {
MPI_Error_string( rc, str, &slen );
printf( "Found expected error; message is: %s\n", str );
}
}
MTest_Finalize( errs );
MPI_Finalize( );
return 0;
}
示例12: main
int main(int argc, char **argv)
{
int err, errs = 0;
MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
change the error handler to errors return */
MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
/* perform some tests */
err = contig_test();
if (err && verbose) fprintf(stderr, "%d errors in contig test.\n",
err);
errs += err;
/* print message and exit */
if (errs) {
fprintf(stderr, "Found %d errors\n", errs);
}
else {
printf(" No Errors\n");
}
MPI_Finalize();
return 0;
}
示例13: main
int main(int argc, char *argv[])
{
int errs = 0, err;
int dims[2];
int periods[2];
int size, rank;
MPI_Comm comm;
MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
dims[0] = size;
dims[1] = size;
periods[0] = 0;
periods[1] = 0;
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &comm);
if (err == MPI_SUCCESS) {
errs++;
printf("Cart_create returned success when dims > size\n");
} else if (comm != MPI_COMM_NULL) {
errs++;
printf("Expected a null comm from cart create\n");
}
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
示例14: main
int main(int argc, char **argv)
{
int err, errs = 0;
MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
change the error handler to errors return */
MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
/* perform some tests */
err = builtin_float_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in builtin float test.\n", err);
}
err = vector_of_vectors_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in vector of vectors test.\n", err);
}
err = optimizable_vector_of_basics_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in vector of basics test.\n", err);
}
err = indexed_of_basics_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in indexed of basics test.\n", err);
}
err = indexed_of_vectors_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in indexed of vectors test.\n", err);
}
#ifdef HAVE_MPI_TYPE_CREATE_STRUCT
err = struct_of_basics_test();
errs += err;
#endif
/* print message and exit */
if (errs) {
fprintf(stderr, "Found %d errors\n", errs);
}
else {
printf(" No Errors\n");
}
MPI_Finalize();
return 0;
}
示例15: main
int main(int argc, char *argv[])
{
int wrank, wsize, rank, size, color;
int tmp, errs = 0;
MPI_Comm newcomm;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &wsize);
MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
/* Color is 0 or 1; 1 will be the processes that "fault" */
/* process 0 and wsize/2+1...wsize-1 are in non-faulting group */
color = (wrank > 0) && (wrank <= wsize / 2);
MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &newcomm);
MPI_Comm_size(newcomm, &size);
MPI_Comm_rank(newcomm, &rank);
/* Set errors return on COMM_WORLD and the new comm */
MPI_Comm_set_errhandler(MPI_ERRORS_RETURN, MPI_COMM_WORLD);
MPI_Comm_set_errhandler(MPI_ERRORS_RETURN, newcomm);
MPI_Barrier(MPI_COMM_WORLD);
if (color) {
/* Simulate a fault on some processes */
exit(1);
}
/* Can we still use newcomm? */
MPI_Allreduce(&rank, &tmp, 1, MPI_INT, MPI_SUM, newcomm);
if (tmp != (size * (size + 1)) / 2) {
printf("Allreduce gave %d but expected %d\n", tmp, (size * (size + 1)) / 2);
errs++;
}
MPI_Comm_free(&newcomm);
MPI_Finalize();
printf(" No Errors\n");
return 0;
}