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

📄 initthread.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 2 页
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//*  $Id: initthread.c,v 1.105 2007/08/03 21:02:32 buntinas Exp $ * *  (C) 2001 by Argonne National Laboratory. *      See COPYRIGHT in top-level directory. */#include "mpiimpl.h"#include "datatype.h"#include "mpi_init.h"#ifdef HAVE_CRTDBG_H#include <crtdbg.h>#endif/* -- Begin Profiling Symbol Block for routine MPI_Init_thread */#if defined(HAVE_PRAGMA_WEAK)#pragma weak MPI_Init_thread = PMPI_Init_thread#elif defined(HAVE_PRAGMA_HP_SEC_DEF)#pragma _HP_SECONDARY_DEF PMPI_Init_thread  MPI_Init_thread#elif defined(HAVE_PRAGMA_CRI_DUP)#pragma _CRI duplicate MPI_Init_thread as PMPI_Init_thread#endif/* -- End Profiling Symbol Block *//* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build   the MPI routines */#ifndef MPICH_MPI_FROM_PMPI#undef MPI_Init_thread#define MPI_Init_thread PMPI_Init_thread/* Any internal routines can go here.  Make them static if possible *//* Global variables can be initialized here */MPICH_PerProcess_t MPIR_Process = { MPICH_PRE_INIT };      /* all other fields in MPIR_Process are irrelevant */MPICH_ThreadInfo_t MPIR_ThreadInfo = { 0 };/* These are initialized as null (avoids making these into common symbols).   If the Fortran binding is supported, these can be initialized to    their Fortran values (MPI only requires that they be valid between   MPI_Init and MPI_Finalize) */MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUS_IGNORE = 0;MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUSES_IGNORE = 0;/* This will help force the load of initinfo.o, which contains data about   how MPICH2 was configured. */extern const char MPIR_Version_device[];#ifdef HAVE_WINDOWS_H/* User-defined abort hook function.  Exiting here will prevent the system from * bringing up an error dialog box. *//* style: allow:fprintf:1 sig:0 */static int assert_hook( int reportType, char *message, int *returnValue ){    MPIU_UNREFERENCED_ARG(reportType);    fprintf(stderr, "%s", message);    if (returnValue != NULL)	ExitProcess((UINT)(*returnValue));    ExitProcess((UINT)(-1));    return TRUE;}/* MPICH2 dll entry point */BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved){    BOOL result = TRUE;    hinstDLL;    lpReserved;    switch (fdwReason)    {        case DLL_PROCESS_ATTACH:            break;        case DLL_THREAD_ATTACH:	    /* allocate thread specific data */            break;        case DLL_THREAD_DETACH:	    /* free thread specific data */            break;        case DLL_PROCESS_DETACH:            break;    }    return result;}#endif#if !defined(MPICH_IS_THREADED)/* If single threaded, we preallocate this.  Otherwise, we create it */MPICH_PerThread_t  MPIR_Thread = { 0 };#elif defined(HAVE_RUNTIME_THREADCHECK)/* If we may be single threaded, we need a preallocated version to use   if we are single threaded case */MPICH_PerThread_t  MPIR_ThreadSingle = { 0 };#endif#if defined(MPICH_IS_THREADED)/* This routine is called when a thread exits; it is passed the value    associated with the key.  In our case, this is simply storage allocated   with MPIU_Calloc */void MPIR_CleanupThreadStorage( void *a ){    if (a != 0) {	MPIU_Free( a );    }}#endif /* MPICH_IS_THREADED */int MPIR_Init_thread(int * argc, char ***argv, int required,		     int * provided){    int mpi_errno = MPI_SUCCESS;    int has_args;    int has_env;    int thread_provided;    MPIU_THREADPRIV_DECL;    /* FIXME: Move to os-dependent interface? */#ifdef HAVE_WINDOWS_H    /* prevent the process from bringing up an error message window if mpich        asserts */    _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );    _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );    _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, assert_hook);#ifdef _WIN64    {    /* FIXME: This severly degrades performance but fixes alignment issues        with the datatype code. */    /* Prevent misaligned faults on Win64 machines */    UINT mode, old_mode;        old_mode = SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT);    mode = old_mode | SEM_NOALIGNMENTFAULTEXCEPT;    SetErrorMode(mode);    }#endif#endif    /* We need this inorder to implement IS_THREAD_MAIN */#   if (MPICH_THREAD_LEVEL >= MPI_THREAD_SERIALIZED)    {	MPID_Thread_self(&MPIR_ThreadInfo.master_thread);    }#   endif#if 0    /* This should never happen */    if (MPIR_Version_device == 0) {	    }#endif     #ifdef HAVE_ERROR_CHECKING    /* Eventually this will support commandline and environment options     for controlling error checks.  It will use the routine      MPIR_Err_init, which does as little as possible (e.g., it only      determines the value of do_error_checks) */    MPIR_Process.do_error_checks = 1;#else    MPIR_Process.do_error_checks = 0;#endif    /* Initialize necessary subsystems and setup the predefined attribute       values.  Subsystems may change these values. */    MPIR_Process.attrs.appnum          = -1;    MPIR_Process.attrs.host            = 0;    MPIR_Process.attrs.io              = 0;    MPIR_Process.attrs.lastusedcode    = MPI_ERR_LASTCODE;    MPIR_Process.attrs.tag_ub          = 0;    MPIR_Process.attrs.universe        = MPIR_UNIVERSE_SIZE_NOT_SET;    MPIR_Process.attrs.wtime_is_global = 0;    /* Set the functions used to duplicate attributes.  These are        when the first corresponding keyval is created */    MPIR_Process.attr_dup  = 0;    MPIR_Process.attr_free = 0;#ifdef HAVE_CXX_BINDING    /* Set the functions used to call functions in the C++ binding        for reductions and attribute operations.  These are null       until a C++ operation is defined.  This allows the C code       that implements these operations to not invoke a C++ code       directly, which may force the inclusion of symbols known only       to the C++ compiler (e.g., under more non-GNU compilers, including       Solaris and IRIX). */    MPIR_Process.cxx_call_op_fn = 0;    MPIR_Process.cxx_call_delfn = 0;#endif    /* This allows the device to select an alternative function for        dimsCreate */    MPIR_Process.dimsCreate     = 0;    /* "Allocate" from the reserved space for builtin communicators and       (partially) initialize predefined communicators.  comm_parent is       intially NULL and will be allocated by the device if the process group       was started using one of the MPI_Comm_spawn functions. */    MPIR_Process.comm_world		    = MPID_Comm_builtin + 0;    MPIR_Process.comm_world->handle	    = MPI_COMM_WORLD;    MPIU_Object_set_ref( MPIR_Process.comm_world, 1 );    MPIR_Process.comm_world->context_id	    = 0; /* XXX */    MPIR_Process.comm_world->recvcontext_id = 0;    MPIR_Process.comm_world->attributes	    = NULL;    MPIR_Process.comm_world->local_group    = NULL;    MPIR_Process.comm_world->remote_group   = NULL;    MPIR_Process.comm_world->comm_kind	    = MPID_INTRACOMM;    /* This initialization of the comm name could be done only when        comm_get_name is called */    MPIU_Strncpy(MPIR_Process.comm_world->name, "MPI_COMM_WORLD",		 MPI_MAX_OBJECT_NAME);    MPIR_Process.comm_world->errhandler	    = NULL; /* XXX */    MPIR_Process.comm_world->coll_fns	    = NULL; /* XXX */    MPIR_Process.comm_world->topo_fns	    = NULL; /* XXX */        MPIR_Process.comm_self		    = MPID_Comm_builtin + 1;    MPIR_Process.comm_self->handle	    = MPI_COMM_SELF;    MPIU_Object_set_ref( MPIR_Process.comm_self, 1 );    MPIR_Process.comm_self->context_id	    = 4; /* XXX */    MPIR_Process.comm_self->recvcontext_id  = 4; /* XXX */    MPIR_Process.comm_self->attributes	    = NULL;    MPIR_Process.comm_self->local_group	    = NULL;    MPIR_Process.comm_self->remote_group    = NULL;    MPIR_Process.comm_self->comm_kind	    = MPID_INTRACOMM;    MPIU_Strncpy(MPIR_Process.comm_self->name, "MPI_COMM_SELF",		 MPI_MAX_OBJECT_NAME);    MPIR_Process.comm_self->errhandler	    = NULL; /* XXX */    MPIR_Process.comm_self->coll_fns	    = NULL; /* XXX */    MPIR_Process.comm_self->topo_fns	    = NULL; /* XXX */#ifdef MPID_NEEDS_ICOMM_WORLD    MPIR_Process.icomm_world		    = MPID_Comm_builtin + 2;

⌨️ 快捷键说明

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