⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch3u_init_sshm.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 2 页
字号:
#endif	{	    mpi_errno = MPIDI_CH3I_BootstrapQ_create_unique_name(queue_name, MPIDI_MAX_SHM_NAME_LENGTH);	    if (mpi_errno != MPI_SUCCESS) {		MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**boot_create");	    }	    /* If you don't have a parent then you must initialize the queue */	    initialize_queue = 1;	    MPIU_Strncpy(val, queue_name, val_max_sz);	    MPIU_Strncpy(pgch->shm_name, val, val_max_sz);	}	mpi_errno = MPIDI_CH3I_BootstrapQ_create_named(&pgch->bootstrapQ, 					       queue_name, initialize_queue);	if (mpi_errno != MPI_SUCCESS) {	    MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**boot_create");	}	/*printf("root process created bootQ: '%s'\n", queue_name);fflush(stdout);*/	mpi_errno = PMI_KVS_Put(kvsname, key, val);          	if (mpi_errno != 0) {	    MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER, "**pmi_kvs_put", 				 "**pmi_kvs_put %d", mpi_errno);	}	mpi_errno = PMI_KVS_Commit(kvsname);	if (mpi_errno != 0) {	    MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER, "**pmi_kvs_commit", 				 "**pmi_kvs_commit %d", mpi_errno);	}	mpi_errno = PMI_Barrier();	if (mpi_errno != 0) {	    MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER, "**pmi_barrier", 				 "**pmi_barrier %d", mpi_errno);	}    }    else    {	mpi_errno = PMI_Barrier();	if (mpi_errno != 0) {	    MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER, "**pmi_barrier", 				 "**pmi_barrier %d", mpi_errno);	}	mpi_errno = PMI_KVS_Get(kvsname, key, val, val_max_sz);	if (mpi_errno != 0) {	    MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER, "**pmi_kvs_get", 				 "**pmi_kvs_get %d", mpi_errno);	}	MPIU_Strncpy(queue_name, val, MPIDI_MAX_SHM_NAME_LENGTH);#ifdef MPIDI_CH3_USES_SHM_NAME	MPIU_Strncpy(pgch->shm_name, val, MPIDI_MAX_SHM_NAME_LENGTH);#endif	/*printf("process %d got bootQ name: '%s'\n", pg_rank, queue_name);fflush(stdout);*/	mpi_errno = getNodeRootRank(pg_rank, &root_rank);	if (mpi_errno != MPI_SUCCESS)	{	    MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**node_root_rank");	}	if (pg_rank == root_rank)	{#ifdef USE_PERSISTENT_SHARED_MEMORY	    /* With persistent shared memory, only the first process of the 	       first group needs to create the bootstrap queue. */	    /* Everyone else including spawned processes will attach to this 	       queue. */	    initialize_queue = !has_parent;#else	    /* Without persistent shared memory the root of each node 	       initializes the queue */	    initialize_queue = 1;#endif	}	else	{	    /* The root process initialized the queue */	    initialize_queue = 0;	}	mpi_errno = MPIDI_CH3I_BootstrapQ_create_named(&pgch->bootstrapQ, 					       queue_name, initialize_queue);	if (mpi_errno != MPI_SUCCESS) {	    MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**boot_create");	}    }    mpi_errno = PMI_Barrier();    if (mpi_errno != 0) {	MPIU_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**pmi_barrier", 			     "**pmi_barrier %d", mpi_errno);    }#ifdef USE_PERSISTENT_SHARED_MEMORY    /* The bootstrap queue cannot be unlinked because it can be used outside        of this process group. */    /* Spawned groups will use it and other MPI jobs may use it by calling        MPI_Comm_connect/accept */    /* By not unlinking here, if the program aborts, the      * shared memory segments can be left dangling.     */#else    /* Unlinking here prevents leaking shared memory segments but also      *  prevents any other processes     * from attaching to the segment later thus preventing the implementation      * of MPI_Comm_connect/accept/spawn/spawn_multiple     */    mpi_errno = MPIDI_CH3I_BootstrapQ_unlink(pgch->bootstrapQ);    if (mpi_errno != MPI_SUCCESS) {        MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**boot_unlink");    }#endif#else    mpi_errno = MPIDI_CH3I_BootstrapQ_create(&pgch->bootstrapQ);    if (mpi_errno != MPI_SUCCESS) {	MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**boot_create");    }#endif    /* brad : the pg needs to be set for sshm channels.  for all channels this       is done in mpid_init.c */    MPIDI_Process.my_pg = pg_p;    /* brad : get the sshm part of the business card  */    mpi_errno = MPIDI_CH3U_Get_business_card_sshm(bc_val_p, val_max_sz_p);    if (mpi_errno != MPI_SUCCESS) {	MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER, "**init_buscard");    } fn_exit:    MPIU_CHKLMEM_FREEALL();    return mpi_errno; fn_fail:    /* --BEGIN ERROR HANDLING-- */    if (pg_p != NULL)    {	MPIDI_PG_Destroy( pg_p );    }    goto fn_exit;    /* --END ERROR HANDLING-- */}/* This routine initializes shm-specific elements of the VC */int MPIDI_VC_InitShm( MPIDI_VC_t *vc ) {    MPIDI_CH3I_VC *vcch = (MPIDI_CH3I_VC *)vc->channel_private;    vcch->recv_active        = NULL;    vcch->send_active        = NULL;    vcch->req                = NULL;    vcch->read_shmq          = NULL;    vcch->write_shmq         = NULL;    vcch->shm                = NULL;    vcch->shm_state          = 0;    vcch->shm_next_reader    = NULL;    vcch->shm_next_writer    = NULL;    vcch->shm_read_connected = 0;    return 0;}/* Return the number of processors, or one if the number cannot be    determined */#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTL) && \    !defined(_POSIX_C_SOURCE)#include <sys/types.h>#include <sys/sysctl.h>#define USE_SYSCTL#endifstatic int getNumProcessors( void ){#ifdef HAVE_WINDOWS_H    SYSTEM_INFO info;    GetSystemInfo(&info);    return info.dwNumberOfProcessors;#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)    int num_cpus;    num_cpus = sysconf(_SC_NPROCESSORS_ONLN);    return num_cpus;#elif defined(USE_SYSCTL) && defined(CTL_HW) && defined(HW_NCPU)    int num_cpus, rc, len=sizeof(int);    int mib[2];    mib[0] = CTL_HW;    mib[1] = HW_NCPU;    rc = sysctl( mib, 2, &num_cpus, &len, (void *)0, 0 );    if (rc != 0) num_cpus = 1;    return num_cpus;#else    return 1;#endif}/* Return the lowest rank on the same node as this process */#undef FUNCNAME#define FUNCNAME getNodeRootRank#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)static int getNodeRootRank(int pg_rank, int *root_rank){    int *ranks = NULL, num_ranks, min_rank;    int pmi_errno, i;    int mpi_errno = MPI_SUCCESS;    MPIU_CHKLMEM_DECL(1);    pmi_errno = PMI_Get_clique_size(&num_ranks);    if (pmi_errno != PMI_SUCCESS)    {	MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER,			     "**pmi_get_clique_size", 			     "**pmi_get_clique_size %d", pmi_errno);    }    if (num_ranks < 1)    {	/* PMI_Get_clique_size returned an invalid size */	MPIU_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER,	    "**pmi_invalid_clique_size",	    "**pmi_invalid_clique_size %d", num_ranks);    }    MPIU_CHKLMEM_MALLOC(ranks, int *, sizeof(int) * num_ranks, mpi_errno, "an array of ranks");    pmi_errno = PMI_Get_clique_ranks(ranks, num_ranks);    if (pmi_errno != PMI_SUCCESS)    {	MPIU_ERR_SETANDJUMP1(mpi_errno,MPI_ERR_OTHER,			     "**pmi_get_clique_ranks", 			     "**pmi_get_clique_ranks %d", pmi_errno);    }    min_rank = ranks[0];    /* If the list is not sorted then find the lowest rank */    for (i=1; i<num_ranks; i++)    {	min_rank = MPIDU_MIN(min_rank, ranks[i]);    }    *root_rank = min_rank;fn_exit:    MPIU_CHKLMEM_FREEALL();    return mpi_errno;fn_fail:    goto fn_exit;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -