示例#1
0
int main(int argc, char **argv)
{
	struct sigaction actions;

	parse_options(&argc, &argv);

	if (asprintf(&libmemtrace, "%s/libmemtrace.so", lib_path) == -1)
		fatal("asprintf (%s)", strerror(errno));

	create_shmem();

	main_pid = app_start((char **)(argv + 1));

	atexit(cleanup);

	signal(SIGINT, sigint_handler);

	sigemptyset(&actions.sa_mask);
	actions.sa_flags = SA_RESTART;
	actions.sa_handler = sigchld_handler;

	if (sigaction(SIGCHLD, &actions, NULL)) {
		perror("sigaction(SIGCHLD)");
		return 1;
	}

	create_socket();
	create_comm();
	init_server();

	server_run();

	return EXIT_SUCCESS;
}
int ompi_attr_create_predefined(void)
{
    int ret;
    char *univ_size;
    int usize;

    /* Create all the keyvals */

    /* DO NOT CHANGE THE ORDER OF CREATING THESE KEYVALS!  This order
       strictly adheres to the order in mpi.h.  If you change the
       order here, you must change the order in mpi.h as well! */

    if (OMPI_SUCCESS != (ret = create_comm(MPI_TAG_UB, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_HOST, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_IO, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_WTIME_IS_GLOBAL, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_APPNUM, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_LASTUSEDCODE, false)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_UNIVERSE_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_BASE)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_SIZE)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_DISP_UNIT)) ||
#if 0
        /* JMS For when we implement IMPI */
        OMPI_SUCCESS != (ret = create_comm(IMPI_CLIENT_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_CLIENT_COLOR, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_HOST_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_HOST_COLOR, true)) ||
#endif
        0) {
        return ret;
    }

    /* Set default values for everything except MPI_UNIVERSE_SIZE */

    if (OMPI_SUCCESS != (ret = set_f(MPI_TAG_UB, mca_pml.pml_max_tag)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_HOST, MPI_PROC_NULL)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_IO, MPI_ANY_SOURCE)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_WTIME_IS_GLOBAL, 0)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_LASTUSEDCODE,
                                     ompi_mpi_errcode_lastused)) ||
#if 0
        /* JMS For when we implement IMPI */
        OMPI_SUCCESS != (ret = set(IMPI_CLIENT_SIZE,
                                   &attr_impi_client_size)) ||
        OMPI_SUCCESS != (ret = set(IMPI_CLIENT_COLOR,
                                   &attr_impi_client_color)) ||
        OMPI_SUCCESS != (ret = set(IMPI_HOST_SIZE,
                                   &attr_impi_host_size)) ||
        OMPI_SUCCESS != (ret = set(IMPI_HOST_COLOR,
                                   &attr_impi_host_color)) ||
#endif
        0) {
        return ret;
    }

    /* If the universe size is set, then use it. Otherwise default
     * to the size of MPI_COMM_WORLD */
    univ_size = getenv("OMPI_UNIVERSE_SIZE");
    if (NULL == univ_size || (usize = strtol(univ_size, NULL, 0)) <= 0) {
        ret = set_f(MPI_UNIVERSE_SIZE, ompi_comm_size(MPI_COMM_WORLD));
    } else {
        ret = set_f(MPI_UNIVERSE_SIZE, usize);
    }
    if (OMPI_SUCCESS != ret) {
        return ret;
    }
    
    /* check the app_num - if it was set, then define it - otherwise, don't */
    if (orte_process_info.app_num >= 0) {
        ret = set_f(MPI_APPNUM, orte_process_info.app_num);
    }
    
    return ret;
}