void sc_finalize (void) { int i; int retval; /* sc_packages is static and thus initialized to all zeros */ for (i = SC_MAX_PACKAGES - 1; i >= 0; --i) if (sc_packages[i].is_registered) sc_package_unregister (i); SC_ASSERT (sc_num_packages == 0); sc_memory_check (-1); sc_set_signal_handler (0); sc_mpicomm = MPI_COMM_NULL; sc_print_backtrace = 0; sc_identifier = -1; /* close trace file */ if (sc_trace_file != NULL) { retval = fclose (sc_trace_file); SC_CHECK_ABORT (!retval, "Trace file close"); sc_trace_file = NULL; } }
void sc_finalize (void) { int i; int retval; #if defined(SC_ENABLE_MPI) && defined(SC_ENABLE_MPICOMMSHARED) sc_mpi_comm_detach_node_comms (sc_mpicomm); #endif /* sc_packages is static and thus initialized to all zeros */ for (i = sc_num_packages_alloc - 1; i >= 0; --i) if (sc_packages[i].is_registered) sc_package_unregister (i); SC_ASSERT (sc_num_packages == 0); sc_memory_check (-1); free (sc_packages); sc_packages = NULL; sc_num_packages_alloc = 0; sc_set_signal_handler (0); sc_mpicomm = sc_MPI_COMM_NULL; sc_print_backtrace = 0; sc_identifier = -1; /* close trace file */ if (sc_trace_file != NULL) { retval = fclose (sc_trace_file); SC_CHECK_ABORT (!retval, "Trace file close"); sc_trace_file = NULL; } }
void sc_init (sc_MPI_Comm mpicomm, int catch_signals, int print_backtrace, sc_log_handler_t log_handler, int log_threshold) { int w; const char *trace_file_name; const char *trace_file_prio; sc_identifier = -1; sc_mpicomm = sc_MPI_COMM_NULL; sc_print_backtrace = print_backtrace; if (mpicomm != sc_MPI_COMM_NULL) { int mpiret; sc_mpicomm = mpicomm; mpiret = sc_MPI_Comm_rank (sc_mpicomm, &sc_identifier); SC_CHECK_MPI (mpiret); } sc_set_signal_handler (catch_signals); sc_package_id = sc_package_register (log_handler, log_threshold, "libsc", "The SC Library"); trace_file_name = getenv ("SC_TRACE_FILE"); if (trace_file_name != NULL) { char buffer[BUFSIZ]; if (sc_identifier >= 0) { snprintf (buffer, BUFSIZ, "%s.%d.log", trace_file_name, sc_identifier); } else { snprintf (buffer, BUFSIZ, "%s.log", trace_file_name); } SC_CHECK_ABORT (sc_trace_file == NULL, "Trace file not NULL"); sc_trace_file = fopen (buffer, "wb"); SC_CHECK_ABORT (sc_trace_file != NULL, "Trace file open"); trace_file_prio = getenv ("SC_TRACE_LP"); if (trace_file_prio != NULL) { if (!strcmp (trace_file_prio, "SC_LP_TRACE")) { sc_trace_prio = SC_LP_TRACE; } else if (!strcmp (trace_file_prio, "SC_LP_DEBUG")) { sc_trace_prio = SC_LP_DEBUG; } else if (!strcmp (trace_file_prio, "SC_LP_VERBOSE")) { sc_trace_prio = SC_LP_VERBOSE; } else if (!strcmp (trace_file_prio, "SC_LP_INFO")) { sc_trace_prio = SC_LP_INFO; } else if (!strcmp (trace_file_prio, "SC_LP_STATISTICS")) { sc_trace_prio = SC_LP_STATISTICS; } else if (!strcmp (trace_file_prio, "SC_LP_PRODUCTION")) { sc_trace_prio = SC_LP_PRODUCTION; } else if (!strcmp (trace_file_prio, "SC_LP_ESSENTIAL")) { sc_trace_prio = SC_LP_ESSENTIAL; } else if (!strcmp (trace_file_prio, "SC_LP_ERROR")) { sc_trace_prio = SC_LP_ERROR; } else { SC_ABORT ("Invalid trace priority"); } } } w = 24; SC_GLOBAL_ESSENTIALF ("This is %s\n", SC_PACKAGE_STRING); #if 0 SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "F77", SC_F77); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "FFLAGS", SC_FFLAGS); #endif SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "CPP", SC_CPP); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "CPPFLAGS", SC_CPPFLAGS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "CC", SC_CC); #if 0 SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "C_VERSION", SC_C_VERSION); #endif SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "CFLAGS", SC_CFLAGS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "LDFLAGS", SC_LDFLAGS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "LIBS", SC_LIBS); #if 0 SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "BLAS_LIBS", SC_BLAS_LIBS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "LAPACK_LIBS", SC_LAPACK_LIBS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "FLIBS", SC_FLIBS); #endif #if defined(SC_ENABLE_MPI) && defined(SC_ENABLE_MPICOMMSHARED) if (mpicomm != MPI_COMM_NULL) { int mpiret; MPI_Comm intranode, internode; /* compute the node comms by default */ sc_mpi_comm_attach_node_comms (mpicomm, 0); sc_mpi_comm_get_node_comms (mpicomm, &intranode, &internode); if (intranode == MPI_COMM_NULL) { SC_GLOBAL_STATISTICS ("No shared memory node communicators\n"); } else { int intrasize; mpiret = MPI_Comm_size (intranode, &intrasize); SC_CHECK_MPI (mpiret); SC_GLOBAL_STATISTICSF ("Shared memory node communicator size: %d\n", intrasize); } } #endif }
void sc_init (MPI_Comm mpicomm, int catch_signals, int print_backtrace, sc_log_handler_t log_handler, int log_threshold) { int w; const char *trace_file_name; const char *trace_file_prio; sc_identifier = -1; sc_mpicomm = MPI_COMM_NULL; sc_print_backtrace = print_backtrace; if (mpicomm != MPI_COMM_NULL) { int mpiret; sc_mpicomm = mpicomm; mpiret = MPI_Comm_rank (sc_mpicomm, &sc_identifier); SC_CHECK_MPI (mpiret); } sc_set_signal_handler (catch_signals); sc_package_id = sc_package_register (log_handler, log_threshold, "libsc", "The SC Library"); trace_file_name = getenv ("SC_TRACE_FILE"); if (trace_file_name != NULL) { char buffer[BUFSIZ]; if (sc_identifier >= 0) { snprintf (buffer, BUFSIZ, "%s.%d.log", trace_file_name, sc_identifier); } else { snprintf (buffer, BUFSIZ, "%s.log", trace_file_name); } SC_CHECK_ABORT (sc_trace_file == NULL, "Trace file not NULL"); sc_trace_file = fopen (buffer, "wb"); SC_CHECK_ABORT (sc_trace_file != NULL, "Trace file open"); trace_file_prio = getenv ("SC_TRACE_LP"); if (trace_file_prio != NULL) { if (!strcmp (trace_file_prio, "SC_LP_TRACE")) { sc_trace_prio = SC_LP_TRACE; } else if (!strcmp (trace_file_prio, "SC_LP_DEBUG")) { sc_trace_prio = SC_LP_DEBUG; } else if (!strcmp (trace_file_prio, "SC_LP_VERBOSE")) { sc_trace_prio = SC_LP_VERBOSE; } else if (!strcmp (trace_file_prio, "SC_LP_INFO")) { sc_trace_prio = SC_LP_INFO; } else if (!strcmp (trace_file_prio, "SC_LP_STATISTICS")) { sc_trace_prio = SC_LP_STATISTICS; } else if (!strcmp (trace_file_prio, "SC_LP_PRODUCTION")) { sc_trace_prio = SC_LP_PRODUCTION; } else if (!strcmp (trace_file_prio, "SC_LP_ESSENTIAL")) { sc_trace_prio = SC_LP_ESSENTIAL; } else if (!strcmp (trace_file_prio, "SC_LP_ERROR")) { sc_trace_prio = SC_LP_ERROR; } else { SC_ABORT ("Invalid trace priority"); } } } w = 24; SC_GLOBAL_ESSENTIALF ("This is %s\n", SC_PACKAGE_STRING); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "CC", SC_CC); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "C_VERSION", SC_C_VERSION); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "CFLAGS", SC_CFLAGS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "CPP", SC_CPP); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "CPPFLAGS", SC_CPPFLAGS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "F77", SC_F77); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "FFLAGS", SC_FFLAGS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "LDFLAGS", SC_LDFLAGS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "BLAS_LIBS", SC_BLAS_LIBS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "LAPACK_LIBS", SC_LAPACK_LIBS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "LIBS", SC_LIBS); SC_GLOBAL_PRODUCTIONF ("%-*s %s\n", w, "FLIBS", SC_FLIBS); }