├── src ├── mpi │ ├── msmpi │ │ ├── fortran │ │ │ ├── lib │ │ │ │ ├── makefile.inc │ │ │ │ └── mpifort.vcxproj │ │ │ ├── msmpifec │ │ │ │ ├── makefile.inc │ │ │ │ └── msmpifec.vcxproj │ │ │ ├── msmpifes │ │ │ │ ├── makefile.inc │ │ │ │ └── msmpifes.vcxproj │ │ │ ├── msmpifmc │ │ │ │ ├── makefile.inc │ │ │ │ └── msmpifmc.vcxproj │ │ │ ├── msmpifms │ │ │ │ ├── makefile.inc │ │ │ │ └── msmpifms.vcxproj │ │ │ ├── mpi_constants.f90 │ │ │ ├── dirs.proj │ │ │ ├── mpifbind.h │ │ │ ├── setbotf.f │ │ │ ├── mpif90model.h.in │ │ │ └── fortran.props │ │ ├── mpid │ │ │ ├── DynProc.acf │ │ │ ├── DynProcAlloc.h │ │ │ ├── DynProcTypes.h │ │ │ ├── precomp.h │ │ │ ├── DynProcAlloc.cpp │ │ │ ├── mpi_conntbl.h │ │ │ ├── status.cpp │ │ │ ├── namepub.h │ │ │ ├── ch3_compression.h │ │ │ ├── DynProc.idl │ │ │ ├── info.cpp │ │ │ ├── mpidi_ch3_pre.h │ │ │ └── mpidrma.h │ │ ├── io │ │ │ ├── precomp.h │ │ │ ├── adio_extern.h │ │ │ ├── ad_ntfs.h │ │ │ ├── adio_cb_config_list.h │ │ │ ├── ad_init.cpp │ │ │ ├── adioi_error.h │ │ │ ├── mpiio.vcxproj │ │ │ └── malloc.cpp │ │ ├── dll │ │ │ ├── msmpi.rc │ │ │ ├── makefile.inc │ │ │ ├── syminfo.cpp │ │ │ ├── main.cpp │ │ │ └── mpitrace.mof │ │ ├── util │ │ │ ├── precomp.h │ │ │ ├── mpiutil.vcxproj │ │ │ └── gathertuner.cpp │ │ ├── api │ │ │ ├── precomp.h │ │ │ └── mpiapi.vcxproj │ │ ├── channels │ │ │ ├── ch3u_nd2.h │ │ │ ├── ch3u_nd1_err.h │ │ │ ├── ch3u_nd2_err.h │ │ │ ├── ch3u_nd1.h │ │ │ ├── ch3_finalize.cpp │ │ │ ├── precomp.h │ │ │ ├── ch3u_nd1_result.h │ │ │ ├── ch3u_nd2_result.h │ │ │ ├── ch3i_progress.h │ │ │ ├── ch3u_connect_nd.cpp │ │ │ ├── ch3u_finalize_sshm.cpp │ │ │ ├── ch3u_nd2_cq.h │ │ │ ├── ch3u_nd1_core.h │ │ │ ├── ch3u_init_sock.cpp │ │ │ ├── ch3u_nd1_mr.h │ │ │ ├── ch3u_nd2_mr.h │ │ │ ├── ch3u_nd1_cq.h │ │ │ ├── ch3u_sock.h │ │ │ ├── ch3u_get_business_card_sshm.cpp │ │ │ ├── ch3u_nd2_core.h │ │ │ ├── ch3u_sshm.h │ │ │ ├── ch3u_init_sshm.cpp │ │ │ ├── ch3u_nd1_mw.h │ │ │ ├── ch3u_nd1_mw.cpp │ │ │ └── mpichannels.vcxproj │ │ ├── dbg │ │ │ ├── dbgtypes.h │ │ │ ├── README_DBG.txt │ │ │ ├── mpi_debugger.vcxproj │ │ │ └── qdemo.cpp │ │ ├── include │ │ │ ├── romio.h │ │ │ ├── dbgsupport.h │ │ │ ├── MpiCallState.h │ │ │ ├── cs.h │ │ │ ├── mpiimpl.h │ │ │ ├── assertutil.h │ │ │ ├── ThreadHandle.h │ │ │ ├── mpiimplthread.h │ │ │ ├── mpi_fortlogical.h │ │ │ ├── Tls.h │ │ │ ├── vc.h │ │ │ ├── progress.h │ │ │ ├── spawn.h │ │ │ ├── mpierrs.h │ │ │ ├── collutil.h │ │ │ ├── colltunersettings.h │ │ │ └── mpistatus.h │ │ ├── dirs.proj │ │ └── msmpi.props │ ├── pmilib │ │ ├── lib │ │ │ ├── mspms.def │ │ │ └── mspms.rc │ │ ├── SmpdRpc.acf │ │ ├── precomp.h │ │ ├── win_svc_tracing.h │ │ ├── pmi_abort.cpp │ │ ├── dirs.proj │ │ ├── smpd_state_machine.cpp │ │ ├── PmiDbgImpl.h │ │ ├── smpd_queue.h │ │ ├── smpd_service.h │ │ ├── smpd_database.h │ │ ├── smpd_server.cpp │ │ ├── cli │ │ │ └── pmicli.vcxproj │ │ ├── smpd_overlapped.h │ │ └── smpd_read_write.cpp │ ├── smpd │ │ ├── smpd.rc │ │ ├── precomp.h │ │ ├── affinity_calculation.h │ │ └── mgr_abort.cpp │ ├── mpiexec │ │ ├── mpiexec.rc │ │ └── mpiexec_abort.cpp │ ├── common │ │ ├── dbg_printf.h │ │ ├── precomp.h │ │ ├── kernel32util.cpp │ │ ├── mpiiov.h │ │ ├── msgprint.cpp │ │ ├── mpidump.h │ │ ├── mpimem.inl │ │ ├── MpiLock.h │ │ ├── hwtree_common.h │ │ ├── traceManifest.vcxproj │ │ ├── rpcutil.h │ │ ├── assertutil.h │ │ └── Util.cpp │ ├── dirs.proj │ └── stub │ │ ├── mpistub.vcxproj │ │ └── stubs.cpp ├── include │ ├── mpif.h │ ├── mpio.h │ ├── x64 │ │ └── mpifptr.h │ ├── x86 │ │ └── mpifptr.h │ ├── mpiwarning.h │ ├── binplace.proj │ └── oacr.h ├── launchSvc │ ├── launchsvc.rc │ ├── LaunchSvc.h │ ├── msmpiLaunchSvcMc.vcxproj │ ├── launchSvcMsg.mc │ └── msmpiLaunchSvc.vcxproj └── dirs.proj ├── .build └── CBT │ └── CBT.Core.dll ├── examples └── helloworld │ ├── screenshots │ ├── link.png │ ├── compile.png │ ├── inc_dir.png │ ├── lib_dir.png │ ├── mpiexec.png │ ├── vs_build.png │ ├── set_msmpi.png │ └── x64_prompt.png │ ├── Makefile │ ├── MPIHelloWorld.cpp │ ├── MPIHelloWorld.vcxproj │ └── Run_MPIHelloWorld.md ├── dirs.proj ├── NuGet.Config ├── docs └── RunningMSMPI.md ├── LICENSE.txt └── COPYRIGHT-mpich.txt /src/mpi/msmpi/fortran/lib/makefile.inc: -------------------------------------------------------------------------------- 1 | !INCLUDE $(FORTRAN_MAKEFILE_INC) 2 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/msmpifec/makefile.inc: -------------------------------------------------------------------------------- 1 | !INCLUDE $(FORTRAN_MAKEFILE_INC) 2 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/msmpifes/makefile.inc: -------------------------------------------------------------------------------- 1 | !INCLUDE $(FORTRAN_MAKEFILE_INC) 2 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/msmpifmc/makefile.inc: -------------------------------------------------------------------------------- 1 | !INCLUDE $(FORTRAN_MAKEFILE_INC) 2 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/msmpifms/makefile.inc: -------------------------------------------------------------------------------- 1 | !INCLUDE $(FORTRAN_MAKEFILE_INC) 2 | -------------------------------------------------------------------------------- /src/include/mpif.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/src/include/mpif.h -------------------------------------------------------------------------------- /.build/CBT/CBT.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/.build/CBT/CBT.Core.dll -------------------------------------------------------------------------------- /src/mpi/pmilib/lib/mspms.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | EXPORTS 3 | MSMPI_Get_pm_interface 4 | MSMPI_pm_query_interface 5 | -------------------------------------------------------------------------------- /examples/helloworld/screenshots/link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/examples/helloworld/screenshots/link.png -------------------------------------------------------------------------------- /examples/helloworld/screenshots/compile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/examples/helloworld/screenshots/compile.png -------------------------------------------------------------------------------- /examples/helloworld/screenshots/inc_dir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/examples/helloworld/screenshots/inc_dir.png -------------------------------------------------------------------------------- /examples/helloworld/screenshots/lib_dir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/examples/helloworld/screenshots/lib_dir.png -------------------------------------------------------------------------------- /examples/helloworld/screenshots/mpiexec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/examples/helloworld/screenshots/mpiexec.png -------------------------------------------------------------------------------- /examples/helloworld/screenshots/vs_build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/examples/helloworld/screenshots/vs_build.png -------------------------------------------------------------------------------- /examples/helloworld/screenshots/set_msmpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/examples/helloworld/screenshots/set_msmpi.png -------------------------------------------------------------------------------- /examples/helloworld/screenshots/x64_prompt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Microsoft-MPI/HEAD/examples/helloworld/screenshots/x64_prompt.png -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/DynProc.acf: -------------------------------------------------------------------------------- 1 | [explicit_handle, strict_context_handle] 2 | interface DynProc 3 | { 4 | [async] AsyncExchangeConnInfo(); 5 | } 6 | -------------------------------------------------------------------------------- /src/include/mpio.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #error do not include mpio.h, use mpi.h 5 | 6 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/mpi_constants.f90: -------------------------------------------------------------------------------- 1 | ! Copyright(c) Microsoft Corporation.All rights reserved. 2 | ! Licensed under the MIT License. 3 | 4 | MODULE MPI_CONSTANTS 5 | IMPLICIT NONE 6 | INCLUDE 'mpifnoext.h' 7 | END MODULE MPI_CONSTANTS 8 | -------------------------------------------------------------------------------- /src/include/x64/mpifptr.h: -------------------------------------------------------------------------------- 1 | ! -*- Mode: F77; F90; -*- 2 | ! 3 | ! Copyright(c) Microsoft Corporation.All rights reserved. 4 | ! Licensed under the MIT License. 5 | ! 6 | INTEGER MPI_AINT 7 | PARAMETER (MPI_AINT=z'4c00083b') 8 | INTEGER MPI_ADDRESS_KIND 9 | PARAMETER(MPI_ADDRESS_KIND = 8) 10 | -------------------------------------------------------------------------------- /src/mpi/msmpi/io/precomp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | #include 6 | #define WIN32_NO_STATUS 7 | 8 | #include "mpiimpl.h" 9 | #include 10 | #include 11 | 12 | #include "mpimem.inl" 13 | -------------------------------------------------------------------------------- /src/include/x86/mpifptr.h: -------------------------------------------------------------------------------- 1 | ! -*- Mode: F77; F90; -*- 2 | ! 3 | ! Copyright(c) Microsoft Corporation.All rights reserved. 4 | ! Licensed under the MIT License. 5 | ! 6 | INTEGER MPI_AINT 7 | PARAMETER (MPI_AINT=z'4c00043b') 8 | INTEGER MPI_ADDRESS_KIND 9 | PARAMETER(MPI_ADDRESS_KIND = 4) 10 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/DynProcAlloc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | #include "DynProcTypes.h" 6 | 7 | CONN_INFO_TYPE* 8 | ConnInfoAlloc( 9 | size_t count ); 10 | 11 | void 12 | ConnInfoFree( 13 | _In_opt_ CONN_INFO_TYPE* ppConn 14 | ); 15 | -------------------------------------------------------------------------------- /src/mpi/smpd/smpd.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define VER_FILETYPE VFT_APP 5 | #define VER_FILESUBTYPE VFT2_UNKNOWN 6 | #define VER_FILEDESCRIPTION_STR "Microsoft MPI Process Manager" 7 | #define VER_INTERNALNAME_STR "smpd" 8 | #define VER_ORIGINALFILENAME_STR "smpd.exe" 9 | 10 | #include "common.ver" 11 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dll/msmpi.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define VER_FILETYPE VFT_DLL 5 | #define VER_FILESUBTYPE VFT2_UNKNOWN 6 | #define VER_FILEDESCRIPTION_STR "Microsoft MPI 2.0 Library" 7 | #define VER_INTERNALNAME_STR "msmpi" 8 | #define VER_ORIGINALFILENAME_STR "msmpi.dll" 9 | 10 | #include "common.ver" 11 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/DynProcTypes.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | typedef struct ConnInfoType 7 | { 8 | unsigned int pg_size; 9 | unsigned int pg_rank; 10 | char business_card[512]; 11 | GUID pg_id; 12 | } CONN_INFO_TYPE; 13 | -------------------------------------------------------------------------------- /src/mpi/mpiexec/mpiexec.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define VER_FILETYPE VFT_APP 5 | #define VER_FILESUBTYPE VFT2_UNKNOWN 6 | #define VER_FILEDESCRIPTION_STR "Microsoft MPI Application Launch" 7 | #define VER_INTERNALNAME_STR "mpiexec" 8 | #define VER_ORIGINALFILENAME_STR "mpiexec.exe" 9 | 10 | #include "common.ver" 11 | -------------------------------------------------------------------------------- /src/mpi/pmilib/lib/mspms.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define VER_FILETYPE VFT_DLL 5 | #define VER_FILESUBTYPE VFT2_UNKNOWN 6 | #define VER_FILEDESCRIPTION_STR "Microsoft MPI Process Management Services Library" 7 | #define VER_INTERNALNAME_STR "mspms" 8 | #define VER_ORIGINALFILENAME_STR "mspms.dll" 9 | 10 | #include "common.ver" 11 | -------------------------------------------------------------------------------- /src/mpi/msmpi/util/precomp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | #include 6 | #define WIN32_NO_STATUS 7 | 8 | #include "mpidimpl.h" 9 | #include "mpiimpl.h" 10 | #include "mpitrace.h" 11 | #include 12 | #include 13 | 14 | #include "mpimem.inl" 15 | #include "request.inl" 16 | -------------------------------------------------------------------------------- /src/mpi/pmilib/SmpdRpc.acf: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | [explicit_handle, strict_context_handle] 7 | interface SmpdSvcRpc 8 | { 9 | } 10 | 11 | [explicit_handle, strict_context_handle] 12 | interface SmpdMgrRpc 13 | { 14 | [async] SmpdMgrCommandAsync([context_handle_noserialize] pContext); 15 | } 16 | -------------------------------------------------------------------------------- /src/launchSvc/launchsvc.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define VER_FILETYPE VFT_APP 5 | #define VER_FILESUBTYPE VFT2_UNKNOWN 6 | #define VER_FILEDESCRIPTION_STR "Microsoft MPI Launch Service" 7 | #define VER_INTERNALNAME_STR "msmpilaunchsvc" 8 | #define VER_ORIGINALFILENAME_STR "msmpilaunchsvc.exe" 9 | 10 | #include "common.ver" 11 | #include "launchsvcmsg.rc" -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/precomp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | #include 6 | #define WIN32_NO_STATUS 7 | 8 | #include "mpidimpl.h" 9 | #include "mpitrace.h" 10 | #include "util.h" 11 | #include 12 | #include 13 | 14 | #include "comm.inl" 15 | #include "mpimem.inl" 16 | #include "request.inl" 17 | -------------------------------------------------------------------------------- /src/mpi/pmilib/precomp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include 5 | #include "assertutil.h" 6 | #include 7 | #include "mpidef.h" 8 | #include "mpierror.h" 9 | #include "mpiutil.h" 10 | #include "mpistr.h" 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include -------------------------------------------------------------------------------- /src/mpi/smpd/precomp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include 5 | #include 6 | #include "assertutil.h" 7 | #include "mpidef.h" 8 | #include "mpierror.h" 9 | #include "mpiutil.h" 10 | #include "mpistr.h" 11 | #include 12 | #include "rpc.h" 13 | #include 14 | #include 15 | #include -------------------------------------------------------------------------------- /src/mpi/msmpi/api/precomp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | #include 6 | #define WIN32_NO_STATUS 7 | 8 | #include "mpidimpl.h" 9 | #include "mpi_api.h" 10 | #include "mpitrace.h" 11 | #include 12 | #include 13 | 14 | #include "comm.inl" 15 | #include "mpimem.inl" 16 | #include "request.inl" 17 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd2.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "ch3u_nd.h" 7 | #include "ch3u_nd2_err.h" 8 | #include "ch3u_nd2_core.h" 9 | #include "ch3u_nd2_result.h" 10 | #include "ch3u_nd2_mr.h" 11 | #include "ch3u_nd2_cq.h" 12 | #include "ch3u_nd2_adapter.h" 13 | #include "ch3u_nd2_env.h" 14 | #include "ch3u_nd2_endpoint.h" 15 | -------------------------------------------------------------------------------- /src/mpi/common/dbg_printf.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | void MPIU_dbg_preinit(); 7 | 8 | _Success_(return==MPI_SUCCESS) 9 | int 10 | MPIU_dbg_init( 11 | _In_ unsigned int rank, 12 | _In_ unsigned int world_size 13 | ); 14 | 15 | void 16 | MPIU_dbg_printf( 17 | _Printf_format_string_ const char * str, 18 | ... 19 | ); 20 | -------------------------------------------------------------------------------- /src/mpi/common/precomp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "assertutil.h" 11 | #include "mpidef.h" 12 | #include "mpierror.h" 13 | #include "mpiutil.h" 14 | #include "mpimem.h" 15 | #include "mpistr.h" 16 | #include -------------------------------------------------------------------------------- /src/mpi/msmpi/dll/makefile.inc: -------------------------------------------------------------------------------- 1 | 2 | $(OBJ_PATH)\$(O)\typeinfo\binplaced.txt: $(OBJ_PATH)\$(O)\typeinfo\$(TARGETPDB).pdb 3 | 4 | $(OBJ_PATH)\$(O)\msmpidbg.def: $(MPI_SRC_ROOT)\msmpi\dll\msmpi.def $(MPI_SRC_ROOT)\msmpi\dll\dbgsupport.def 5 | copy $(MPI_SRC_ROOT)\msmpi\dll\msmpi.def $(OBJ_PATH)\$(O)\msmpidbg.def 6 | type $(MPI_SRC_ROOT)\msmpi\dll\dbgsupport.def >> $(OBJ_PATH)\$(O)\msmpidbg.def 7 | 8 | clean: 9 | erase $(OBJ_PATH)\$(O)\msmpidbg.def -------------------------------------------------------------------------------- /examples/helloworld/Makefile: -------------------------------------------------------------------------------- 1 | ld=link 2 | cc=cl 3 | 4 | cflags=/I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include" 5 | ldflags=/libpath:"C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64" 6 | 7 | libs=msmpi.lib 8 | 9 | output=affinity.exe 10 | objs=affinity.obj 11 | 12 | all: $(objs) 13 | $(ld) $(libs) $(ldflags) -out:$(output) $(objs) 14 | 15 | .cpp.obj: 16 | $(cc) $(cflags) /c $*.cpp 17 | clean: 18 | @del /Q $(objs) 19 | @del /Q $(output) 20 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd1_err.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3u_nd_err.h - Network Direct MPI CH3 Channel error macros 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | 13 | /* --BEGIN ERROR MACROS-- */ 14 | 15 | #define MPIU_E_ERR( fmt_, ... ) \ 16 | MPIU_ERR_FATAL_GET( MPI_SUCCESS, MPI_ERR_OTHER, fmt_, __VA_ARGS__ ) 17 | 18 | /* --END ERROR MACROS-- */ 19 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd2_err.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3u_nd_err.h - Network Direct MPI CH3 Channel error macros 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | 13 | /* --BEGIN ERROR MACROS-- */ 14 | 15 | #define MPIU_E_ERR( fmt_, ... ) \ 16 | MPIU_ERR_FATAL_GET( MPI_SUCCESS, MPI_ERR_OTHER, fmt_, __VA_ARGS__ ) 17 | 18 | /* --END ERROR MACROS-- */ 19 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd1.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "ch3u_nd.h" 7 | #include "ch3u_nd1_err.h" 8 | #include "ch3u_nd1_core.h" 9 | #include "ch3u_nd1_result.h" 10 | #include "ch3u_nd1_mr.h" 11 | #include "ch3u_nd1_mw.h" 12 | #include "ch3u_nd1_cq.h" 13 | #include "ch3u_nd1_adapter.h" 14 | #include "ch3u_nd1_env.h" 15 | #include "ch3u_nd1_endpoint.h" 16 | -------------------------------------------------------------------------------- /src/mpi/msmpi/io/adio_extern.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * Copyright (C) 1997 University of Chicago. 7 | * See COPYRIGHT notice in top-level directory. 8 | */ 9 | 10 | extern ADIOI_Flatlist_node *ADIOI_Flatlist; 11 | 12 | /* for f2c and c2f conversion */ 13 | extern MPI_File *ADIOI_Ftable; 14 | extern int ADIOI_Ftable_ptr, ADIOI_Ftable_max; 15 | 16 | extern MPI_Errhandler ADIOI_DFLT_ERR_HANDLER; 17 | -------------------------------------------------------------------------------- /examples/helloworld/MPIHelloWorld.cpp: -------------------------------------------------------------------------------- 1 | // A simple MPI code printing a message by each MPI rank 2 | 3 | #include 4 | #include 5 | 6 | 7 | int main() 8 | { 9 | int my_rank; 10 | int world_size; 11 | 12 | MPI_Init(NULL, NULL); 13 | 14 | MPI_Comm_size(MPI_COMM_WORLD, &world_size); 15 | MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); 16 | 17 | std::cout << "Hello World from process " << my_rank << " out of " << world_size << " processes!!!" << std::endl; 18 | 19 | MPI_Finalize(); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /src/mpi/common/kernel32util.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "precomp.h" 5 | #include "kernel32util.h" 6 | #include "util.h" 7 | 8 | // 9 | // Summary: 10 | // Global to indicate if we should use Win7+ features. 11 | // 12 | // NOTE: 13 | // This is not static so we can manipulate this bit from unit tests 14 | // 15 | BOOL g_IsWin7OrGreater = CheckOSVersion(6,1); 16 | BOOL g_IsWin8OrGreater = CheckOSVersion(6,2); 17 | 18 | Kernel32 Kernel32::Methods; -------------------------------------------------------------------------------- /src/include/mpiwarning.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma warning(disable:4200) // nonstandard extension used : zero-sized array in struct/union 5 | #pragma warning(disable:4201) // nonstandard extension used : nameless struct/union 6 | #pragma warning(disable:4204) // nonstandard extension used : non-constant aggregate initializer 7 | #ifdef _PREFIX_ 8 | #pragma warning(disable:4616) // #pragma warning : warning number 'number' not a valid compiler warning 9 | #endif 10 | -------------------------------------------------------------------------------- /dirs.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/DynProcAlloc.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "precomp.h" 5 | #include "DynProc.h" 6 | #include "DynProcAlloc.h" 7 | 8 | 9 | CONN_INFO_TYPE* 10 | ConnInfoAlloc( 11 | size_t count 12 | ) 13 | { 14 | return static_cast( 15 | midl_user_allocate( count * sizeof( CONN_INFO_TYPE ) ) ); 16 | } 17 | 18 | 19 | void 20 | ConnInfoFree( 21 | _In_opt_ CONN_INFO_TYPE* ppConn 22 | ) 23 | { 24 | midl_user_free( ppConn ); 25 | } 26 | -------------------------------------------------------------------------------- /src/mpi/pmilib/win_svc_tracing.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | // 7 | // Main entry point for enabling the MPI Diagnostics trace session 8 | // 9 | ULONG StartTraceSession(void); 10 | 11 | 12 | // 13 | // Main entry point for stopping the MPI Diagnostics trace session 14 | // 15 | ULONG StopTraceSession(void); 16 | 17 | 18 | // 19 | // Entry points for diagnostic tracing in the service. 20 | // 21 | int ServicePrintErrorEvent(const char* pStr, ...); 22 | int ServicePrintInfoEvent(const char* pStr, ...); 23 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dll/syminfo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "precomp.h" 5 | #include "mpidimpl.h" 6 | #include "mpidrma.h" 7 | #include "ch3_compression.h" 8 | #include "mpidi_ch3_impl.h" 9 | #include "dbgtypes.h" 10 | #include "mpitrace.h" 11 | 12 | #define DECLARE_TYPE(Name) Name _DECL_##Name 13 | 14 | DECLARE_TYPE(MPID_Request); 15 | DECLARE_TYPE(MPID_Comm); 16 | DECLARE_TYPE(MPID_Datatype); 17 | DECLARE_TYPE(MPIDI_Request_t); 18 | DECLARE_TYPE(MPIDI_Message_match); 19 | DECLARE_TYPE(MPIR_Comm_list); 20 | DECLARE_TYPE(MPIR_Sendq); 21 | -------------------------------------------------------------------------------- /NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/mpi/mpiexec/mpiexec_abort.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #include "smpd.h" 10 | 11 | 12 | void smpd_post_abort_command(const wchar_t *fmt, ...) 13 | { 14 | va_list list; 15 | va_start(list, fmt); 16 | fwprintf(stderr, L"\nAborting: "); 17 | vfwprintf(stderr, fmt, list); 18 | fflush(stderr); 19 | va_end(list); 20 | 21 | smpd_signal_exit_progress(MPI_ERR_INTERN); 22 | } 23 | 24 | 25 | void smpd_kill_all_processes( void ) 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3_finalize.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #include "precomp.h" 9 | #include "mpidi_ch3_impl.h" 10 | 11 | int MPIDI_CH3_Finalize() 12 | { 13 | MPIDI_CH3U_Finalize_sock(); 14 | 15 | MPIDI_CH3I_Progress_finalize(); 16 | 17 | MPIDI_CH3I_Nd_finalize(); 18 | 19 | /* Free memory allocated in ch3_progress */ 20 | MPIDI_CH3U_Finalize_ssm_memory(); 21 | 22 | MPIDI_CH3U_Finalize_sshm(); 23 | 24 | return MPI_SUCCESS; 25 | } 26 | -------------------------------------------------------------------------------- /src/mpi/pmilib/pmi_abort.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2015 by Microsoft Corporation 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #include "precomp.h" 10 | #include "smpd.h" 11 | 12 | void smpd_post_abort_command(const wchar_t *fmt, ...) 13 | { 14 | va_list list; 15 | va_start(list, fmt); 16 | fwprintf(stderr, L"\nAborting: "); 17 | vfwprintf(stderr, fmt, list); 18 | fflush(stderr); 19 | va_end(list); 20 | 21 | smpd_signal_exit_progress(MPI_ERR_INTERN); 22 | } 23 | 24 | 25 | void smpd_kill_all_processes( void ) 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/precomp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | precomp.h - Network Direct MPI CH3 Channel precompiled header 7 | 8 | --*/ 9 | 10 | #ifndef _ND_PRECOMP_H_ 11 | #define _ND_PRECOMP_H_ 12 | 13 | #pragma once 14 | 15 | #include 16 | #define WIN32_NO_STATUS 17 | 18 | #include "mpidi_ch3_impl.h" 19 | #include "mpitrace.h" 20 | 21 | #include "ndsupport.h" 22 | #include "autoptr.h" 23 | #include "list.h" 24 | #include "cs.h" 25 | #include "util.h" 26 | 27 | #include "comm.inl" 28 | #include "mpimem.inl" 29 | #include "request.inl" 30 | 31 | #endif // _ND_PRECOMP_H_ 32 | -------------------------------------------------------------------------------- /src/mpi/msmpi/io/ad_ntfs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * 7 | * Copyright (C) 1997 University of Chicago. 8 | * See COPYRIGHT notice in top-level directory. 9 | */ 10 | 11 | #ifndef AD_NTFS_INCLUDE 12 | #define AD_NTFS_INCLUDE 13 | 14 | #include "adio.h" 15 | 16 | #define DWORDLOW(x) ((DWORD)( x )) 17 | #define DWORDHIGH(x) ((DWORD)((x) >> 32)) 18 | 19 | int ADIOI_NTFS_aio(MPI_File fd, void *buf, int len, MPI_Offset offset, 20 | int wr, MPI_Request *request); 21 | 22 | int ADIOI_NTFS_Init_blocking_overlapped(OVERLAPPED* pov, MPI_Offset offset); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/mpi/pmilib/dirs.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dbg/dbgtypes.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | struct MPIR_Comm_list 7 | { 8 | int sequence_number; /* Used to detect changes in the list */ 9 | MPID_Comm* head; /* Head of the list */ 10 | }; 11 | 12 | 13 | // 14 | // We save the tag/rank/context_id so that the debugger 15 | // can simplify the data fetching. 16 | // 17 | // 18 | struct MPIR_Sendq 19 | { 20 | LIST_ENTRY ListEntry; 21 | MPID_Request* sreq; 22 | int tag; 23 | int rank; 24 | MPI_CONTEXT_ID context_id; 25 | }; 26 | 27 | extern MPIR_Sendq* MPIR_Sendq_head; 28 | extern MPIR_Sendq* MPIR_Sendq_pool; 29 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/mpi_conntbl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | // 5 | // Connectivity Table: collects and prints information about how processes 6 | // connected to one another (SHM, SOCK, ND.) 7 | // 8 | 9 | #pragma once 10 | 11 | 12 | class ConnectivityTable 13 | { 14 | BYTE* m_pBuf; 15 | SIZE_T m_RowSize; 16 | 17 | public: 18 | ConnectivityTable(); 19 | ~ConnectivityTable(); 20 | 21 | MPI_RESULT AllocateAndGather( int nRows ); 22 | void Print(); 23 | 24 | private: 25 | static void FormatRow( struct CONNECTIVITY_ROW* pRow ); 26 | struct CONNECTIVITY_ROW& At( SIZE_T index ) 27 | { 28 | return *reinterpret_cast( m_pBuf + (m_RowSize * index) ); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /src/mpi/common/mpiiov.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #ifndef MPIIOV_H_INCLUDED 9 | #define MPIIOV_H_INCLUDED 10 | 11 | /* IOVs */ 12 | /* The basic channel interface uses IOVs */ 13 | typedef WSABUF MPID_IOV; 14 | typedef char iovsendbuf_t; 15 | typedef char iovrecvbuf_t; 16 | 17 | /* FIXME: How is IOV_LIMIT chosen? */ 18 | #define MPID_IOV_LIMIT 16 19 | 20 | static inline unsigned iov_size(_In_reads_(n_iov) const MPID_IOV* iov, int n_iov) 21 | { 22 | unsigned total = 0; 23 | while(n_iov--) 24 | { 25 | total += iov->len; 26 | iov++; 27 | } 28 | 29 | return total; 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/dirs.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/romio.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * (C) 2009 by Microsoft Corporation. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifndef ROMIO_H 13 | #define ROMIO_H 14 | 15 | int ADIO_Init(); 16 | void ADIO_Finalize(); 17 | 18 | MPI_Errhandler MPIR_ROMIO_Get_file_errhand( _In_opt_ struct ADIOI_FileD const *file_ptr ); 19 | 20 | void MPIR_ROMIO_Set_file_errhand( _In_opt_ MPI_File file_ptr, _In_ MPI_Errhandler e ); 21 | 22 | _Post_equals_last_error_ 23 | int MPIR_Err_return_file_helper(MPI_Errhandler eh, MPI_File file, int errcode); 24 | 25 | _Post_satisfies_( return != MPI_SUCCESS ) 26 | MPI_RESULT 27 | MPIO_Err_return_file( MPI_File, int ); 28 | 29 | #endif // ROMIO_H 30 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dbg/README_DBG.txt: -------------------------------------------------------------------------------- 1 | Information on the debugger interface 2 | 3 | The debugger interface runs *in the debugger*. The file dll_mpich.c 4 | is used to create a library libtvmpich2.a . This library must be a 5 | dynamically loadable shared library. 6 | 7 | The debugger provides a number of functions that are used by the 8 | debugger interface functions to read the program image. 9 | 10 | Working Notes 11 | 12 | For the queues, we need a stable way of getting successive queue elements. 13 | We could snapshot the queues or could change the (internal) interface 14 | to invalidate the queue information if the queue changes during a 15 | sequence of "next" calls. 16 | 17 | The debugger interface needs to keep a list of several items, 18 | including communicators and all active send requests. We need to make 19 | handling these lists part of the object allocation/deallocation. -------------------------------------------------------------------------------- /docs/RunningMSMPI.md: -------------------------------------------------------------------------------- 1 | The `mpiexec` program from MSMPI can be used to launch applications on multiple nodes. There are two ways to launch applications 2 | on multiple nodes: 3 | 1. Using MS-MPI Launch Service: 4 | * Start MS-MPI Launch Service on all the compute nodes 5 | * Specify your compute nodes in the `mpiexec` command line (either using `hosts` or `hostfile`), for example:
6 | `mpiexec -c 1 -hosts 2 node1 node2 -wdir c:\Tests MPIHelloWorld.exe`
7 | The above command runs the `MPIHelloWorld.exe` program on two hosts (`node1` and `node2`) using one core from each node 8 | 2. Using `spmd`: 9 | * Run `spmd -d` on all compute nodes 10 | * The `spmd.exe` program is availble after installation of MSMPI (in the folder pointed by the `MSMPI_BIN` variable) 11 | * Specify your compute nodes in the `mpiexec` command line (either using `hosts` or `hostfile`) 12 | -------------------------------------------------------------------------------- /src/mpi/pmilib/smpd_state_machine.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #include "precomp.h" 10 | #include "smpd.h" 11 | 12 | 13 | static bool g_exit_progress; 14 | static int g_smpd_exit_code = MPI_SUCCESS; 15 | 16 | void smpd_signal_exit_progress(int rc) 17 | { 18 | g_smpd_exit_code = rc; 19 | g_exit_progress = true; 20 | } 21 | 22 | 23 | int smpd_progress(ExSetHandle_t set) 24 | { 25 | if( g_smpd_exit_code == MPI_SUCCESS ) 26 | { 27 | g_exit_progress = false; 28 | 29 | do 30 | { 31 | ExProcessCompletions(set, INFINITE); 32 | 33 | } while( g_exit_progress == false ); 34 | } 35 | 36 | return g_smpd_exit_code; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/status.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * (C) 2001 by Argonne National Laboratory. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | #include "precomp.h" 10 | 11 | 12 | /* Not quite correct, but much closer for MPI2 */ 13 | /* TODO: still needs to handle partial datatypes and situations where the mpi 14 | * implementation fills status with something other than bytes (globus2 might 15 | * do this) */ 16 | void MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype /*datatype*/, 17 | int nbytes) 18 | { 19 | /* it's ok that ROMIO stores number-of-bytes in status, not 20 | * count-of-copies, as long as MPI_GET_COUNT knows what to do */ 21 | if (status != MPI_STATUS_IGNORE) 22 | NMPI_Status_set_elements(status, MPI_BYTE, nbytes); 23 | } 24 | -------------------------------------------------------------------------------- /src/include/binplace.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <_CopyItems Include="**\*.h;**\*.f90" Exclude="oacr.h"/> 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/include/oacr.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #ifndef OACR_INC_H 5 | #define OACR_INC_H 6 | 7 | #define HRESULT_NOT_CHECKED 25031 8 | #define COMPARING_HRESULT_TO_INT 6221 9 | #define RETVAL_IGNORED_FUNC_COULD_FAIL 6031 10 | #define NONCONST_BUFFER_PARAM 25033 11 | #define EXCEPT_BLOCK_EMPTY 6322 12 | #define PRINTF_FORMAT_STRING_PARAM_NEEDS_REVIEW 25141 13 | #define UNSAFE_STRING_FUNCTION 25025 14 | #define USE_WIDE_API 25068 15 | #define DIFFERENT_PARAM_TYPE_SIZE 25054 16 | 17 | #define OACR_REVIEWED_CALL( reviewer, functionCall ) functionCall 18 | #define OACR_WARNING_SUPPRESS( cWarning, comment ) __pragma ( warning( suppress: cWarning ) ) 19 | #define OACR_WARNING_ENABLE( cWarning, comment ) __pragma ( warning( default: cWarning ) ) 20 | #define OACR_USE_PTR(p) __noop 21 | #define OACR_WARNING_DISABLE( cWarning, comment ) __pragma(warning(disable:cWarning)) 22 | #endif -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/dirs.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/mpi/common/msgprint.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #include "precomp.h" 10 | #include 11 | #include 12 | 13 | _Success_(return>=0) 14 | int 15 | MPIU_Error_printf( 16 | _Printf_format_string_ const char *str, 17 | ... 18 | ) 19 | { 20 | int n; 21 | va_list list; 22 | 23 | va_start(list, str); 24 | n = vfprintf(stderr, str, list); 25 | va_end(list); 26 | 27 | fflush(stderr); 28 | 29 | return n; 30 | } 31 | 32 | _Success_(return>=0) 33 | int 34 | MPIU_Internal_error_printf( 35 | _Printf_format_string_ const char *str, 36 | ... 37 | ) 38 | { 39 | int n; 40 | va_list list; 41 | 42 | va_start(list, str); 43 | n = vfprintf(stderr, str, list); 44 | va_end(list); 45 | 46 | fflush(stderr); 47 | 48 | return n; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/namepub.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #ifndef NAMEPUB_H_INCLUDED 10 | #define NAMEPUB_H_INCLUDED 11 | 12 | struct MPID_NS_t { int dummy; }; /* unused for now */ 13 | 14 | MPI_RESULT MPID_NS_Create( const MPID_Info *, MPID_NS_t ** ); 15 | MPI_RESULT MPID_NS_Publish( const MPID_NS_t *, const MPID_Info *, 16 | const char service_name[], const char port[] ); 17 | MPI_RESULT MPID_NS_Lookup( _In_opt_ const MPID_NS_t *, _In_opt_ const MPID_Info *, 18 | _In_z_ const char service_name[], _Out_writes_z_ ( MPI_MAX_PORT_NAME ) char port[] ); 19 | MPI_RESULT MPID_NS_Unpublish( const MPID_NS_t *, const MPID_Info *, 20 | const char service_name[] ); 21 | MPI_RESULT MPID_NS_Free( MPID_NS_t ** ); 22 | 23 | extern MPID_NS_t * MPIR_Namepub; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd1_result.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3u_nd_result.h - Network Direct MPI CH3 Channel endpoint object 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | #ifndef CH3U_NDV1_RESULT_H 13 | #define CH3U_NDV1_RESULT_H 14 | 15 | namespace CH3_ND 16 | { 17 | namespace v1 18 | { 19 | // 20 | // nd_result 21 | // 22 | // Description: 23 | // Base class for various ND results. Derived objects use the function 24 | // pointers to handle completion processing. 25 | // 26 | struct nd_result_t : public ND_RESULT 27 | { 28 | typedef int 29 | (*CompletionRoutine)( 30 | __in struct nd_result_t* pResult, 31 | __out bool* pfMpiRequestDone 32 | ); 33 | 34 | CompletionRoutine pfnSucceeded; 35 | CompletionRoutine pfnFailed; 36 | }; 37 | 38 | } // namespace v1 39 | } // namespace CH3_ND 40 | 41 | #endif // CH3U_NDV1_RESULT_H 42 | -------------------------------------------------------------------------------- /src/mpi/pmilib/PmiDbgImpl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | #include "PmiDbg.h" 6 | 7 | 8 | typedef struct _PMIDBG_NOTIFICATION 9 | { 10 | PMIDBG_NOTIFY_TYPE Type; 11 | FN_PmiDbgControl* Control; 12 | 13 | } PMIDBG_NOTIFICATION; 14 | 15 | extern const PMIDBG_NOTIFICATION SmpdNotifyInitialize; 16 | extern const PMIDBG_NOTIFICATION SmpdNotifyFinalize; 17 | extern const PMIDBG_NOTIFICATION SmpdNotifyBeforeCreateProcess; 18 | extern const PMIDBG_NOTIFICATION SmpdNotifyAfterCreateProcess; 19 | 20 | extern const PMIDBG_NOTIFICATION MpiexecNotifyInitialize; 21 | extern const PMIDBG_NOTIFICATION MpiexecNotifyFinalize; 22 | extern const PMIDBG_NOTIFICATION MpiexecNotifyBeforeCreateProcesses; 23 | extern const PMIDBG_NOTIFICATION MpiexecNotifyAfterCreateProcesses; 24 | 25 | void LoadPmiDbgExtensions( PMIDBG_HOST_TYPE hostType ); 26 | 27 | void UnloadPmiDbgExtensions(); 28 | 29 | void NotifyPmiDbgExtensions( PMIDBG_NOTIFICATION notify, ... ); 30 | -------------------------------------------------------------------------------- /src/mpi/pmilib/smpd_queue.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #ifndef SMPD_QUEUE_H 9 | #define SMPD_QUEUE_H 10 | 11 | template struct smpd_queue 12 | { 13 | public: 14 | T* m_head; 15 | T* m_tail; 16 | 17 | public: 18 | smpd_queue() : m_head(0) {} 19 | 20 | T* head() const { return m_head; } 21 | void enqueue(T* node); 22 | T* dequeue(); 23 | }; 24 | 25 | template 26 | inline void smpd_queue::enqueue(T* node) 27 | { 28 | node->next = NULL; 29 | if (m_head == NULL) 30 | { 31 | m_head = node; 32 | } 33 | else 34 | { 35 | m_tail->next = node; 36 | } 37 | m_tail = node; 38 | } 39 | 40 | template 41 | inline T* smpd_queue::dequeue() 42 | { 43 | T* node = m_head; 44 | m_head = m_head->next; 45 | return node; 46 | } 47 | 48 | #endif /* SMPD_QUEUE_H */ 49 | -------------------------------------------------------------------------------- /src/mpi/dirs.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/mpi/common/mpidump.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #ifndef MPIDUMP_H_INCLUDED 7 | #define MPIDUMP_H_INCLUDED 8 | 9 | #include 10 | 11 | // 12 | // Constants used to control dump file generation. 13 | // 14 | enum MSMPI_DUMP_MODE 15 | { 16 | MsmpiDumpNone = 0, 17 | MsmpiDumpMini, 18 | MsmpiDumpAllMini, 19 | MsmpiDumpFull, 20 | MsmpiDumpAllFull, 21 | MsmpiDumpMaximumValue 22 | }; 23 | 24 | 25 | MSMPI_DUMP_MODE GetDumpMode(); 26 | 27 | 28 | void 29 | CreateFinalDumpFile( 30 | _In_ HANDLE tempFileHandle, 31 | _In_ int rank, 32 | _In_z_ const wchar_t* dumpPath, 33 | _In_ int jobid, 34 | _In_ int taskid, 35 | _In_ int taskinstid 36 | ); 37 | 38 | 39 | HANDLE 40 | CreateTempDumpFile( 41 | __in HANDLE hProcess, 42 | __in DWORD pid, 43 | __in MINIDUMP_TYPE dumpType, 44 | __in const wchar_t* dumpPath, 45 | __in_opt MINIDUMP_EXCEPTION_INFORMATION* pExrParam 46 | ); 47 | 48 | #endif // MPIDUMP_H_INCLUDED 49 | -------------------------------------------------------------------------------- /src/mpi/pmilib/smpd_service.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #ifndef SMPD_SERVICE_H 10 | #define SMPD_SERVICE_H 11 | 12 | // 13 | // Service Control utility functions 14 | // 15 | DWORD SvcDispatch(const char* pServiceName); 16 | DWORD SvcReportProgress(DWORD MilliSecondsToNextTick); 17 | DWORD SvcQueryState(void); 18 | DWORD SvcReportState(DWORD State); 19 | DWORD SvcQueryControls(void); 20 | DWORD SvcDisableControls(DWORD Controls); 21 | DWORD SvcEnableControls(DWORD Controls); 22 | void SvcSetWin32ExitCode(DWORD ExitCode); 23 | void SvcSetSpecificExitCode(DWORD ExitCode); 24 | 25 | // 26 | // Service specific implementation override functions 27 | // 28 | void service_main(int argc, char* argv[]); 29 | void service_stop(void); 30 | void service_pause(void); 31 | void service_continue(void); 32 | void service_shutdown(void); 33 | 34 | #define SERVICE_LISTENER_PORT 8677 35 | #define SERVICE_NAME TEXT("msmpi") 36 | 37 | #endif // SMPD_SERVICE_H 38 | -------------------------------------------------------------------------------- /src/launchSvc/LaunchSvc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "MsmpiLaunchSvc.h" 8 | 9 | // 10 | // Service settings 11 | // 12 | #define SERVICE_NAME L"MsmpiLaunchSvc" 13 | #define SERVICE_START_TYPE SERVICE_AUTO_START 14 | 15 | // 16 | // A singleton class that will run as a windows service application. 17 | // It handles the interaction with SCM and manages the launch service. 18 | // 19 | class WindowsSvc 20 | { 21 | private: 22 | SERVICE_TABLE_ENTRYW m_ctrlDispatchTable[2]; 23 | SERVICE_STATUS_HANDLE m_serviceStatusHandle; 24 | SERVICE_STATUS m_serviceStatus; 25 | 26 | private: 27 | WindowsSvc(); 28 | HRESULT ChangeState(_In_ DWORD newState); 29 | 30 | public: 31 | MsmpiLaunchService m_launcher; 32 | 33 | HRESULT Start(_In_ DWORD argc, _In_ LPWSTR *argv); 34 | 35 | static WindowsSvc ms_windowsSvc; 36 | 37 | static VOID WINAPI ServiceMain(_In_ DWORD argc, _In_ LPWSTR * argv); 38 | static VOID WINAPI ServiceCtrlHandler(_In_ DWORD ctrl); 39 | }; 40 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd2_result.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3u_nd_result.h - Network Direct MPI CH3 Channel endpoint object 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | #ifndef CH3U_ND_RESULT_H 13 | #define CH3U_ND_RESULT_H 14 | 15 | namespace CH3_ND 16 | { 17 | // 18 | // nd_result 19 | // 20 | // Description: 21 | // Base class for various ND results. Derived objects use the function 22 | // pointers to handle completion processing. 23 | // 24 | struct nd_result_t : public ND_RESULT 25 | { 26 | typedef int 27 | (CALLBACK FN_CompletionHandler)( 28 | __in struct nd_result_t* pResult, 29 | __inout bool* pfMpiRequestDone 30 | ); 31 | 32 | void* QueuePairContext; 33 | enum RequestType 34 | { 35 | NdRequestSend, 36 | NdRequestReceive, 37 | NdRequestBind, 38 | NdRequestInvalidate, 39 | NdRequestRead 40 | } RequestType; 41 | }; 42 | 43 | } // namespace CH3_ND 44 | 45 | #endif // CH3U_ND_RESULT_H 46 | -------------------------------------------------------------------------------- /src/mpi/common/mpimem.inl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "mpimem.h" 7 | 8 | 9 | __forceinline void* __cdecl operator new( size_t size ) 10 | { 11 | return MPIU_Malloc( size ); 12 | } 13 | 14 | 15 | __forceinline void* __cdecl operator new( size_t /*size*/, _In_ void* pMem ) 16 | { 17 | return pMem; 18 | } 19 | 20 | 21 | __forceinline void* __cdecl operator new[]( size_t size ) 22 | { 23 | return MPIU_Malloc( size ); 24 | } 25 | 26 | 27 | __forceinline void* __cdecl operator new[]( size_t /*size*/, _In_ void* pMem ) 28 | { 29 | return pMem; 30 | } 31 | 32 | 33 | __forceinline void __cdecl operator delete( _In_opt_ _Post_ptr_invalid_ void* pObj ) 34 | { 35 | MPIU_Free( pObj ); 36 | } 37 | 38 | 39 | __forceinline void __cdecl operator delete( _In_opt_ void* /*pObj*/, _In_ void* /*pMem*/ ) 40 | { 41 | } 42 | 43 | 44 | __forceinline void __cdecl operator delete[]( _In_opt_ _Post_ptr_invalid_ void* pObj ) 45 | { 46 | MPIU_Free( pObj ); 47 | } 48 | 49 | 50 | __forceinline void __cdecl operator delete[]( _In_opt_ void* /*pObj*/, _In_ void* /*pMem*/ ) 51 | { 52 | } 53 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dirs.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dbg/mpi_debugger.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | mpi_debugger 8 | {f33af1e1-64eb-4615-a187-3c1d6fe0c1a7} 9 | 10 | 11 | 12 | false 13 | StaticLibrary 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | %(AdditionalIncludeDirectories); 22 | .\$(O) 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /src/mpi/common/MpiLock.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | typedef SRWLOCK MPI_RWLOCK; 7 | typedef CRITICAL_SECTION MPI_LOCK; 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | VOID 14 | MpiLockInitializeSingleThreadMode(); 15 | 16 | VOID 17 | MpiLockInitialize( 18 | _Out_ MPI_LOCK* Lock 19 | ); 20 | 21 | VOID 22 | MpiLockDelete( 23 | _Inout_ MPI_LOCK* Lock 24 | ); 25 | 26 | VOID 27 | MpiLockEnter( 28 | _Inout_ MPI_LOCK* Lock 29 | ); 30 | 31 | VOID 32 | MpiLockLeave( 33 | _Inout_ MPI_LOCK* Lock 34 | ); 35 | 36 | #define MPI_RWLOCK_INIT SRWLOCK_INIT 37 | 38 | VOID 39 | MpiRwLockInitialize( 40 | _Out_ MPI_RWLOCK* RwLock 41 | ); 42 | 43 | VOID 44 | MpiRwLockAcquireExclusive( 45 | _Inout_ MPI_RWLOCK* RwLock 46 | ); 47 | 48 | VOID 49 | MpiRwLockReleaseExclusive( 50 | _Inout_ MPI_RWLOCK* RwLock 51 | ); 52 | 53 | VOID 54 | MpiRwLockAcquireShared( 55 | _Inout_ MPI_RWLOCK* RwLock 56 | ); 57 | 58 | VOID 59 | MpiRwLockReleaseShared( 60 | _Inout_ MPI_RWLOCK* RwLock 61 | ); 62 | 63 | 64 | #ifdef __cplusplus 65 | } //extern "C" { 66 | #endif -------------------------------------------------------------------------------- /src/mpi/msmpi/include/dbgsupport.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * (C) 2009 by Microsoft Corporation. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifndef DBGSUPPORT_H 13 | #define DBGSUPPORT_H 14 | 15 | /* These macros allow us to implement a sendq when debugger support is 16 | selected. As there is extra overhead for this, we only do this 17 | when specifically requested 18 | */ 19 | #ifdef HAVE_DEBUGGER_SUPPORT 20 | 21 | void MPIR_Sendq_remember(MPID_Request *, int, int, const MPI_CONTEXT_ID& ); 22 | void MPIR_Sendq_forget(MPID_Request *); 23 | void MPIR_CommL_remember( MPID_Comm * ); 24 | void MPIR_CommL_forget( MPID_Comm * ); 25 | 26 | #define MPIR_SENDQ_REMEMBER(_a,_b,_c,_d) MPIR_Sendq_remember(_a,_b,_c,_d) 27 | #define MPIR_SENDQ_FORGET(_a) MPIR_Sendq_forget(_a) 28 | #define MPIR_COMML_REMEMBER(_a) MPIR_CommL_remember( _a ) 29 | #define MPIR_COMML_FORGET(_a) MPIR_CommL_forget( _a ) 30 | #else 31 | #define MPIR_SENDQ_REMEMBER(a,b,c,d) 32 | #define MPIR_SENDQ_FORGET(a) 33 | #define MPIR_COMML_REMEMBER(_a) 34 | #define MPIR_COMML_FORGET(_a) 35 | #endif 36 | 37 | 38 | #endif // DBGSUPPORT_H 39 | -------------------------------------------------------------------------------- /src/mpi/msmpi/io/adio_cb_config_list.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * Copyright (C) 2001 University of Chicago. 7 | * See COPYRIGHT notice in top-level directory. 8 | */ 9 | 10 | /* I have no idea what the "D" stands for; it's how things are done in adio.h 11 | */ 12 | struct ADIO_cb_name_arrayD 13 | { 14 | int refct; 15 | int namect; 16 | char **names; 17 | }; 18 | 19 | typedef struct ADIO_cb_name_arrayD *ADIO_cb_name_array; 20 | 21 | int ADIOI_cb_gather_name_array(MPI_Comm comm, MPI_Comm dupcomm, 22 | ADIO_cb_name_array *arrayp); 23 | 24 | int ADIOI_cb_copy_name_array(MPI_Comm comm, int keyval, void *extra, 25 | void *attr_in, 26 | void *attr_out, int *flag); 27 | 28 | int ADIOI_cb_delete_name_array(MPI_Comm comm, int keyval, void *attr_val, 29 | void *extra); 30 | 31 | _Success_( return != -1 ) 32 | int 33 | ADIOI_cb_config_list_parse( 34 | _In_opt_z_ PCSTR config_list, 35 | _In_ const ADIO_cb_name_array array, 36 | _In_reads_(cb_nodes) int ranklist[], 37 | _In_ int cb_nodes 38 | ); 39 | 40 | int ADIOI_cb_bcast_rank_map(MPI_File fd); 41 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/mpifbind.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | /* Handle different mechanisms for passing Fortran CHARACTER to routines */ 7 | #ifdef USE_FORT_MIXED_STR_LEN 8 | #define FORT_MIXED_LEN_DECL , MPI_Fint 9 | #define FORT_END_LEN_DECL 10 | #define FORT_MIXED_LEN(a) , MPI_Fint a 11 | #define FORT_END_LEN(a) 12 | #else 13 | #define FORT_MIXED_LEN_DECL 14 | #define FORT_END_LEN_DECL , MPI_Fint 15 | #define FORT_MIXED_LEN(a) 16 | #define FORT_END_LEN(a) , MPI_Fint a 17 | #endif 18 | 19 | 20 | /* Support different calling convention */ 21 | #ifdef USE_FORT_CDECL 22 | #define FORT_CALL __cdecl 23 | #elif defined (USE_FORT_STDCALL) 24 | #define FORT_CALL __stdcall 25 | #else 26 | #define FORT_CALL 27 | #endif 28 | 29 | #define FORT_IMPORT __declspec(dllimport) 30 | #define MSMPI_FORT_CALL __cdecl 31 | 32 | /* ------------------------------------------------------------------------- */ 33 | 34 | /* MPI_FAint is used as the C type corresponding to the Fortran type 35 | used for addresses. For now, we make this the same as MPI_Aint. 36 | Note that since this is defined only for this private include file, 37 | we can get away with calling MPI_xxx */ 38 | typedef MPI_Aint MPI_FAint; 39 | 40 | -------------------------------------------------------------------------------- /src/mpi/common/hwtree_common.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | // 7 | // Represents the node types in the tree. Each value 8 | // corrisponds to depth in the HW tree. 9 | // 10 | typedef enum _HWNODE_TYPE 11 | { 12 | HWNODE_TYPE_WORLD = -1, 13 | HWNODE_TYPE_MACHINE = 0, 14 | HWNODE_TYPE_GROUP = 1, 15 | HWNODE_TYPE_NUMA = 2, 16 | HWNODE_TYPE_PCORE = 3, 17 | HWNODE_TYPE_LCORE = 4, 18 | 19 | HWNODE_TYPE_MAX, 20 | 21 | } HWNODE_TYPE; 22 | 23 | 24 | enum SMPD_AFFINITY_PLACEMENT 25 | { 26 | SMPD_AFFINITY_DISABLED = 0, 27 | SMPD_AFFINITY_SPREAD = 1, 28 | SMPD_AFFINITY_SEQUENTIAL = 2, 29 | SMPD_AFFINITY_BALANCED = 3, 30 | SMPD_AFFINITY_DEFAULT = SMPD_AFFINITY_SPREAD, 31 | }; 32 | 33 | 34 | 35 | typedef struct _AffinityOptions 36 | { 37 | BOOL isSet; 38 | BOOL isExplicit; 39 | BOOL isAuto; 40 | enum SMPD_AFFINITY_PLACEMENT placement; 41 | HWNODE_TYPE target; 42 | HWNODE_TYPE stride; 43 | INT affinityTableStyle; 44 | INT hwTableStyle; 45 | } AffinityOptions; 46 | -------------------------------------------------------------------------------- /src/launchSvc/msmpiLaunchSvcMc.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {8E3235C8-9024-4915-BFA6-8F79FFAEC14A} 5 | 6 | 7 | 8 | 9 | Microsoft MPI Launch Service 10 | 11 | 12 | None 13 | false 14 | WindowsUserModeDriver10.0 15 | 16 | 17 | 18 | 19 | true 20 | $(SrcRoot)\launchsvc\$(O) 21 | true 22 | $(SrcRoot)\launchsvc\$(O) 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3i_progress.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #ifndef CH3I_PROGRESS_H_INCLUDED 9 | #define CH3I_PROGRESS_H_INCLUDED 10 | 11 | int MPIDI_CH3I_SOCK_start_write( 12 | _In_ MPIDI_VC_t* vc, 13 | _In_ MPID_Request* sreq 14 | ); 15 | 16 | 17 | int MPIDI_CH3I_SOCK_write_progress( 18 | _In_ MPIDI_VC_t* vc 19 | ); 20 | 21 | int MPIDI_CH3I_Post_sendv(MPIDI_CH3I_Connection_t* conn, MPID_IOV* iov, int iov_n); 22 | int MPIDI_CH3I_Post_accept(MPIDI_CH3I_Connection_t* listener); 23 | int MPIDI_CH3I_Post_close_connection(MPIDI_CH3I_Connection_t* conn); 24 | 25 | int 26 | MPIDI_CH3I_Post_connect( 27 | _In_ MPIDI_CH3I_Connection_t* conn, 28 | _In_z_ const char* host_description, 29 | _In_ int port 30 | ); 31 | 32 | int MPIDI_CH3I_SHM_write_progress_vc( 33 | _In_ MPIDI_VC_t * firstVc, 34 | _Out_ BOOL* pfProgress 35 | ); 36 | 37 | int MPIDI_CH3I_SHM_write_progress( 38 | _In_ MPIDI_VC_t * vcChain, 39 | _Out_ BOOL* pfProgress 40 | ); 41 | 42 | void MPIDI_CH3I_Progress_spin_up(void); 43 | void MPIDI_CH3I_Progress_spin_down(void); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/mpi/pmilib/smpd_database.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #ifndef SMPD_DATABASE_H 9 | #define SMPD_DATABASE_H 10 | 11 | #define SMPD_MAX_DBS_KEY_LEN 32 12 | #define SMPD_MAX_DBS_VALUE_LEN 512 13 | 14 | bool smpd_dbs_init(); 15 | 16 | void smpd_dbs_finalize(); 17 | 18 | 19 | _Success_( return == true ) 20 | bool 21 | smpd_dbs_create( 22 | _In_ UINT16 size, 23 | _Inout_ GUID* id 24 | ); 25 | 26 | 27 | bool smpd_dbs_destroy(const char *name); 28 | 29 | _Success_(return == true) 30 | bool 31 | smpd_dbs_get( 32 | _In_ const GUID& id, 33 | _In_ PCSTR key, 34 | _Out_writes_z_(val_size) char* value, 35 | _In_ size_t val_size 36 | ); 37 | 38 | 39 | _Success_(return == true) 40 | bool 41 | smpd_dbs_bcget( 42 | _In_ const GUID& id, 43 | _In_ UINT16 rank, 44 | _Out_writes_z_(val_size) char* value, 45 | _In_ size_t val_size 46 | ); 47 | 48 | 49 | bool 50 | smpd_dbs_put( 51 | _In_ const GUID& id, 52 | _In_ PCSTR key, 53 | _In_ PCSTR value 54 | ); 55 | 56 | 57 | bool 58 | smpd_dbs_bcput( 59 | _In_ const GUID& id, 60 | _In_ UINT16 rank, 61 | _In_ PCSTR value 62 | ); 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/mpi/stub/mpistub.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | mpistub 8 | {0d6dc55b-d3f8-4d0b-b04d-4f6b6980639a} 9 | 10 | 11 | 12 | false 13 | StaticLibrary 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | %(AdditionalIncludeDirectories); 26 | $(MPI_SRC_ROOT)\pmilib; 27 | $(MPI_SRC_ROOT)\pmilib\lib\$(O); 28 | $(MPI_SRC_ROOT)\msmpi\include 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_connect_nd.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3_connect_nd.c - Network Direct MPI CH3 Channel connection 7 | related functionality. 8 | 9 | --*/ 10 | #include "precomp.h" 11 | #include "precomp.h" 12 | #include "ch3u_nd1.h" 13 | #include "ch3u_nd2.h" 14 | 15 | using namespace CH3_ND; 16 | 17 | // 18 | // Getting the business card first listens for incoming connections on all 19 | // network direct providers, and then fills in the address:portnum pairs 20 | // in the business card. 21 | // 22 | int 23 | MPIDI_CH3I_Nd_get_business_card( 24 | _Deref_pre_cap_c_( *pcbBusinessCard ) _Deref_out_z_cap_c_( *pcbBusinessCard ) char** pszBusinessCard, 25 | _Inout_ int* pcbBusinessCard 26 | ) 27 | { 28 | return g_NdEnv.GetBusinessCard( pszBusinessCard, pcbBusinessCard ); 29 | } 30 | 31 | 32 | int 33 | MPIDI_CH3I_Nd_connect( 34 | __inout MPIDI_VC_t* pVc, 35 | __in_z const char* szBusinessCard, 36 | __in int fForceUse, 37 | __out int* pbHandled 38 | ) 39 | { 40 | return g_NdEnv.Connect( pVc, szBusinessCard, fForceUse, pbHandled ); 41 | } 42 | 43 | 44 | void 45 | MPIDI_CH3I_Nd_disconnect( 46 | __inout MPIDI_VC_t* pVc 47 | ) 48 | { 49 | MPIU_Assert( pVc->ch.nd.pEp != NULL ); 50 | pVc->ch.nd.pEp->Disconnect(); 51 | } 52 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/ch3_compression.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "mpidimpl.h" 5 | 6 | #pragma once 7 | 8 | #ifndef CH3_COMPRESSION 9 | #define CH3_COMPRESSION 10 | 11 | 12 | // 13 | //Messages that are larger than g_CompressionThreshold in bytes cause an 14 | //attempt at compression. This is set to MSMPI_COMPRESSION_OFF when 15 | //compression should never be attempted. 16 | // 17 | extern int g_CompressionThreshold; 18 | 19 | // 20 | //Initialize the compression library. 21 | //returns 22 | // MPI_ERR_OTHER: Indicates that the library containing the compression 23 | // routine could not be found. 24 | // MPI_ERR_NO_MEM: Indicates that the compression buffers could not 25 | // be allocated. 26 | // MPI_SUCCESS: Indicates the library was successfully initialized. 27 | // 28 | int InitializeCompression(); 29 | 30 | // 31 | //Handle a receive request completing. 32 | //parameters 33 | // pReq: A pointer to the request containing a compressed payload. 34 | // 35 | int DecompressRequest(_Inout_ MPID_Request *pReq); 36 | 37 | #define MSMPI_COMPRESSION_OFF -1 38 | 39 | //Compress the buffer associated with an outgoing send request. 40 | //parameters 41 | // pReq: A pointer to the request that is being sent. 42 | // 43 | int CompressRequest(_Inout_ MPID_Request *pReq); 44 | 45 | #endif //CH3_COMPRESSION -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_finalize_sshm.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #include "precomp.h" 9 | #include "mpidi_ch3_impl.h" 10 | #include "pmi.h" 11 | 12 | 13 | /* MPIDI_CH3U_Finalize_sshm - does scalable shared memory specific channel finalization 14 | */ 15 | 16 | /* FIXME: Should this be registered as a finalize handler? Should there be 17 | a corresponding abort handler? */ 18 | 19 | void MPIDI_CH3U_Finalize_sshm() 20 | { 21 | MPIDI_PG_t * pg; 22 | MPIDI_PG_t * pg_next; 23 | 24 | MPIDI_CH3I_BootstrapQ_unlink(MPIDI_CH3U_BootstrapQ_sshm()); 25 | MPIDI_CH3I_BootstrapQ_destroy(MPIDI_CH3U_BootstrapQ_sshm()); 26 | 27 | /* brad : added for dynamic processes in ssm. needed because the vct's can't be freed 28 | * earlier since the vc's themselves are still needed here to walk though and 29 | * free their member fields. 30 | */ 31 | 32 | MPIDI_PG_Iterate_reset(); 33 | MPIDI_PG_Get_next(&pg); 34 | /* This Get_next causes us to skip the process group associated with 35 | out MPI_COMM_WORLD. */ 36 | MPIDI_PG_Get_next(&pg); 37 | while(pg) 38 | { 39 | MPIDI_PG_Get_next(&pg_next); 40 | MPIDI_PG_release_ref(pg); 41 | pg = pg_next; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/MpiCallState.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | struct MpiCallState 7 | { 8 | private: 9 | ThreadHandle* thread; 10 | 11 | public: 12 | int nest_count; 13 | int op_errno; 14 | 15 | MpiCallState() 16 | : thread(nullptr) 17 | , nest_count(0) 18 | , op_errno(0) 19 | { 20 | } 21 | 22 | ~MpiCallState() 23 | { 24 | if (nullptr != thread) 25 | { 26 | thread->Release(); 27 | } 28 | } 29 | 30 | int OpenThreadHandle(_Outptr_result_maybenull_ ThreadHandle** ppHandle) 31 | { 32 | int result = MPI_SUCCESS; 33 | if (nullptr == thread) 34 | { 35 | thread = new ThreadHandle; 36 | if (nullptr == thread) 37 | { 38 | result = MPIU_ERR_NOMEM(); 39 | goto exit_fn; 40 | } 41 | 42 | result = thread->Initialize(); 43 | if (MPI_SUCCESS != result) 44 | { 45 | thread->Release(); 46 | thread = nullptr; 47 | goto exit_fn; 48 | } 49 | } 50 | 51 | thread->AddRef(); 52 | exit_fn: 53 | *ppHandle = thread; 54 | return result; 55 | } 56 | 57 | private: 58 | MpiCallState(const MpiCallState& other); 59 | MpiCallState& operator = (const MpiCallState& other); 60 | }; 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/mpi/common/traceManifest.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {A697D69E-7F67-457F-9194-267C73C5B8CF} 5 | 6 | 7 | 8 | 9 | false 10 | None 11 | WindowsUserModeDriver10.0 12 | None 13 | 14 | 15 | 16 | 17 | 18 | 19 | true 20 | $(MPI_SRC_ROOT)\common\$(O) 21 | true 22 | $(MPI_SRC_ROOT)\common\$(O) 23 | MpiTraceEvents 24 | true 25 | Trace 26 | EVENT_ 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/mpi/msmpi/msmpi.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Disabled 8 | DBG=1;%(PreprocessorDefinitions) 9 | 10 | 11 | 12 | 13 | MaxSpeed 14 | true 15 | NDEBUG=1;%(PreprocessorDefinitions) 16 | Guard 17 | 18 | 19 | 20 | 21 | 22 | 23 | %(AdditionalIncludeDirectories); 24 | $(MPI_SRC_ROOT)\msmpi\include; 25 | $(MPI_SRC_ROOT)\msmpi\trace; 26 | $(MPI_SRC_ROOT)\msmpi\trace\$(O); 27 | $(MPI_SRC_ROOT)\common; 28 | $(MPI_SRC_ROOT)\common\$(O); 29 | $(MPI_SRC_ROOT)\pmilib; 30 | $(MPI_SRC_ROOT)\msmpi\dbg; 31 | 32 | 33 | %(PreprocessorDefinitions); 34 | HAVE_FORTRAN_BINDING=1 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/cs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | Module Name: 7 | cs.h 8 | 9 | Abstract: 10 | Critical Section Auto classes 11 | 12 | Author: 13 | Erez Haba (erezh) 06-jan-97 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | #ifndef _MSMQ_CS_H_ 20 | #define _MSMQ_CS_H_ 21 | 22 | 23 | //--------------------------------------------------------- 24 | // 25 | // class CriticalSection 26 | // 27 | //--------------------------------------------------------- 28 | class CriticalSection 29 | { 30 | 31 | friend class CS; 32 | 33 | public: 34 | CriticalSection() 35 | { 36 | InitializeCriticalSection(&m_cs); 37 | } 38 | 39 | ~CriticalSection() 40 | { 41 | DeleteCriticalSection(&m_cs); 42 | } 43 | 44 | private: 45 | void Lock() 46 | { 47 | EnterCriticalSection(&m_cs); 48 | } 49 | 50 | 51 | void Unlock() 52 | { 53 | LeaveCriticalSection(&m_cs); 54 | } 55 | 56 | 57 | private: 58 | CRITICAL_SECTION m_cs; 59 | }; 60 | 61 | 62 | //--------------------------------------------------------- 63 | // 64 | // class CS 65 | // 66 | //--------------------------------------------------------- 67 | class CS 68 | { 69 | public: 70 | CS(CriticalSection& lock) : m_lock(&lock) 71 | { 72 | m_lock->Lock(); 73 | } 74 | 75 | 76 | ~CS() 77 | { 78 | m_lock->Unlock(); 79 | } 80 | 81 | private: 82 | CriticalSection* m_lock; 83 | }; 84 | 85 | 86 | 87 | #endif // _MSMQ_CS_H_ 88 | -------------------------------------------------------------------------------- /src/mpi/msmpi/io/ad_init.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * Copyright (C) 1997 University of Chicago. 7 | * See COPYRIGHT notice in top-level directory. 8 | */ 9 | #include "precomp.h" 10 | 11 | #include "adio.h" 12 | 13 | ADIOI_Flatlist_node *ADIOI_Flatlist = NULL; 14 | 15 | /* for f2c and c2f conversion */ 16 | MPI_File *ADIOI_Ftable = NULL; 17 | int ADIOI_Ftable_ptr = 0, ADIOI_Ftable_max = 0; 18 | 19 | MPI_Errhandler ADIOI_DFLT_ERR_HANDLER = MPI_ERRORS_RETURN; 20 | 21 | int ADIO_Init() 22 | { 23 | /* initialize the linked list containing flattened datatypes */ 24 | ADIOI_Flatlist = (ADIOI_Flatlist_node *) ADIOI_Malloc(sizeof(ADIOI_Flatlist_node)); 25 | if( ADIOI_Flatlist == NULL ) 26 | { 27 | return MPIU_ERR_NOMEM(); 28 | } 29 | 30 | ADIOI_Flatlist->type = MPI_DATATYPE_NULL; 31 | ADIOI_Flatlist->next = NULL; 32 | ADIOI_Flatlist->blocklens = NULL; 33 | ADIOI_Flatlist->indices = NULL; 34 | 35 | return MPI_SUCCESS; 36 | } 37 | 38 | 39 | void ADIO_Finalize() 40 | { 41 | ADIOI_Flatlist_node *curr, *next; 42 | 43 | /* delete the flattened datatype list */ 44 | curr = ADIOI_Flatlist; 45 | while (curr) 46 | { 47 | if (curr->blocklens) ADIOI_Free(curr->blocklens); 48 | if (curr->indices) ADIOI_Free(curr->indices); 49 | next = curr->next; 50 | ADIOI_Free(curr); 51 | curr = next; 52 | } 53 | ADIOI_Flatlist = NULL; 54 | 55 | /* free file and info tables used for Fortran interface */ 56 | if (ADIOI_Ftable) ADIOI_Free(ADIOI_Ftable); 57 | } -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/setbotf.f: -------------------------------------------------------------------------------- 1 | C -*- Mode: Fortran; -*- 2 | C 3 | C Copyright (c) Microsoft Corporation. All rights reserved. 4 | C Licensed under the MIT License. 5 | C 6 | C (C) 2001 by Argonne National Laboratory. 7 | C (C) Microsoft Corporation 8 | C See COPYRIGHT in top-level directory. 9 | C 10 | SUBROUTINE MPIRINITF( ) 11 | 12 | C 13 | C The common block must be declared the same here as in 14 | C mpif.h and mpi.f90 15 | C This information is exported by MSMPI.dll and imported by fortran apps. 16 | C 17 | INTEGER MPI_BOTTOM, MPI_IN_PLACE 18 | INTEGER MPI_STATUS_SIZE 19 | PARAMETER (MPI_STATUS_SIZE=5) 20 | INTEGER MPI_STATUS_IGNORE(MPI_STATUS_SIZE) 21 | INTEGER MPI_STATUSES_IGNORE(MPI_STATUS_SIZE,1) 22 | INTEGER MPI_ERRCODES_IGNORE(1) 23 | INTEGER MPI_UNWEIGHTED, MPI_WEIGHTS_EMPTY 24 | CHARACTER*1 MPI_ARGVS_NULL(1,1) 25 | CHARACTER*1 MPI_ARGV_NULL(1) 26 | 27 | COMMON /MPIPRIV1/ MPI_BOTTOM, MPI_IN_PLACE, MPI_STATUS_IGNORE 28 | 29 | COMMON /MPIPRIV2/ MPI_STATUSES_IGNORE, MPI_ERRCODES_IGNORE 30 | SAVE /MPIPRIV1/,/MPIPRIV2/ 31 | 32 | COMMON /MPIFCMB5/ MPI_UNWEIGHTED 33 | COMMON /MPIFCMB9/ MPI_WEIGHTS_EMPTY 34 | SAVE /MPIFCMB5/,/MPIFCMB9/ 35 | 36 | COMMON /MPIPRIVC/ MPI_ARGVS_NULL, MPI_ARGV_NULL 37 | SAVE /MPIPRIVC/ 38 | 39 | CALL MPIRINITC( MPI_BOTTOM, MPI_IN_PLACE, MPI_STATUS_IGNORE, 40 | $ MPI_STATUSES_IGNORE, MPI_ERRCODES_IGNORE, 41 | $ MPI_UNWEIGHTED, MPI_WEIGHTS_EMPTY, 42 | $ MPI_ARGVS_NULL ) 43 | CALL MPIRINITC2( MPI_ARGV_NULL ) 44 | END 45 | -------------------------------------------------------------------------------- /src/mpi/common/rpcutil.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | #include "rpc.h" 6 | 7 | #ifndef SECURITY_WIN32 8 | #define SECURITY_WIN32 9 | #endif 10 | 11 | #include 12 | 13 | #define DISABLE_KERB_STR L"!Kerberos" 14 | __declspec(selectany) extern wchar_t disableKerbStr[] = DISABLE_KERB_STR; 15 | 16 | _Success_(return == NOERROR) 17 | RPC_STATUS 18 | StartRpcServer( 19 | _In_z_ PCWSTR pProtSeq, 20 | _In_opt_z_ PCWSTR pEndpoint, 21 | _In_ RPC_IF_HANDLE rpcInterface, 22 | _In_opt_ RPC_IF_CALLBACK_FN* pSecurityCallbackFn, 23 | _Out_opt_ UINT16* pPort, 24 | _Out_opt_ GUID* pLrpcEndpoint, 25 | _In_ UINT maxConcurrentCalls = RPC_C_LISTEN_MAX_CALLS_DEFAULT, 26 | _In_ bool localOnly = false 27 | ); 28 | 29 | 30 | RPC_STATUS 31 | StopRpcServer( 32 | _In_ RPC_IF_HANDLE rpcInterface 33 | ); 34 | 35 | 36 | _Success_(return == NOERROR) 37 | RPC_STATUS 38 | CreateRpcBinding( 39 | _In_z_ PCWSTR pProtSeq, 40 | _In_opt_z_ PCWSTR pHostName, 41 | _In_z_ PCWSTR pEndpoint, 42 | _In_ UINT AuthnLevel, 43 | _In_ UINT AuthnSvc, 44 | _In_opt_ RPC_AUTH_IDENTITY_HANDLE pAuthIdentity, 45 | _Out_ handle_t* phBinding 46 | ); 47 | 48 | 49 | void 50 | InitializeAuthIdentity( 51 | _In_ PWSTR packageStr, 52 | _In_ DWORD packageLen, 53 | _Out_ SEC_WINNT_AUTH_IDENTITY_EXW* pSecAuth 54 | ); 55 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dbg/qdemo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2005 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #include 10 | #include "mpi.h" 11 | 12 | /* This is a program to enable testing and demonstration of the debugger 13 | interface, particularly in terms of showing message queues. To use 14 | this, run with a few processes and attach with the debugger when the 15 | program stops. You can change the variable "hold" to 0 to allow the 16 | program to complete. */ 17 | int main( int argc, char *argv[] ) 18 | { 19 | int wsize, wrank; 20 | int source, dest; 21 | int buf1[10], buf2[10], buf3[10]; 22 | volatile int hold = 1; 23 | MPI_Comm dupcomm; 24 | MPI_Status status; 25 | 26 | MPI_Init( &argc, &argv ); 27 | 28 | MPI_Comm_size( MPI_COMM_WORLD, &wsize ); 29 | MPI_Comm_rank( MPI_COMM_WORLD, &wrank ); 30 | 31 | /* Set the source and dest in a ring */ 32 | source = (wrank + 1) % wsize; 33 | dest = (wrank + wsize - 1) % wsize; 34 | 35 | MPI_Comm_dup( MPI_COMM_WORLD, &dupcomm ); 36 | MPI_Comm_set_name( dupcomm, "Dup of comm world" ); 37 | 38 | MPI_Send( buf2, 8, MPI_INT, dest, 1, MPI_COMM_WORLD ); 39 | MPI_Send( buf3, 4, MPI_INT, dest, 2, dupcomm ); 40 | 41 | while (hold) ; 42 | 43 | MPI_Recv( buf1, 10, MPI_INT, source, 1, MPI_COMM_WORLD, &status ); 44 | MPI_Recv( buf1, 10, MPI_INT, source, 1, dupcomm, &status ); 45 | 46 | MPI_Comm_free( &dupcomm ); 47 | 48 | 49 | MPI_Finalize(); 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /src/mpi/pmilib/smpd_server.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "precomp.h" 5 | #include "smpd.h" 6 | #include "rpcutil.h" 7 | 8 | 9 | DWORD 10 | smpd_create_mgr_server( 11 | _Inout_opt_ UINT16* pPort, 12 | _Out_opt_ GUID* pLrpcPort 13 | ) 14 | { 15 | const wchar_t* pPortStr; 16 | wchar_t portStr[6]; 17 | if( pPort == nullptr || *pPort == 0 ) 18 | { 19 | pPortStr = nullptr; 20 | } 21 | else 22 | { 23 | MPIU_Snprintf( portStr, _countof(portStr), L"%u", *pPort ); 24 | pPortStr = portStr; 25 | } 26 | 27 | RPC_STATUS status = StartRpcServer( L"ncacn_ip_tcp", 28 | pPortStr, 29 | RpcSrvSmpdMgrRpc_v1_0_s_ifspec, 30 | SmpdSecurityCallbackFn, 31 | pPort, 32 | pLrpcPort, 33 | RPC_C_LISTEN_MAX_CALLS_DEFAULT, 34 | smpd_process.local_root ); 35 | if( status != RPC_S_OK ) 36 | { 37 | return status; 38 | } 39 | 40 | return NOERROR; 41 | } 42 | 43 | 44 | void 45 | smpd_stop_mgr_server() 46 | { 47 | RPC_STATUS status = StopRpcServer( RpcSrvSmpdMgrRpc_v1_0_s_ifspec ); 48 | if( status != RPC_S_OK ) 49 | { 50 | smpd_dbg_printf(L"smpd manager failed to stop rpc server, error: %ld\n", status ); 51 | } 52 | else 53 | { 54 | smpd_dbg_printf(L"smpd manager successfully stopped listening.\n"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/mpi/msmpi/io/adioi_error.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * (C) 2001 by Argonne National Laboratory. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | 10 | 11 | /* MPIO_CHECK_XXX macros are used to clean up error checking and 12 | * handling in many of the romio/mpi-io/ source files. 13 | */ 14 | #define MPIO_CHECK_FILE_HANDLE(fh, mpi_errno) \ 15 | if ((fh <= (MPI_File) 0)) { \ 16 | mpi_errno = MPIU_ERR_CREATE(MPI_ERR_ARG, "**iobadfh"); \ 17 | (fh) = MPI_FILE_NULL; \ 18 | goto fn_fail; \ 19 | } 20 | 21 | /* TODO: handle the independent io case more gracefully */ 22 | __forceinline 23 | MPI_RESULT 24 | MpioOpenDeferred( ADIOI_FileD* file ) 25 | { 26 | if( file->is_open == FALSE ) 27 | { 28 | return ADIO_ImmediateOpen( file ); 29 | } 30 | return MPI_SUCCESS; 31 | } 32 | #define MPIO_OPEN_DEFERRED(fh, mpi_errno) \ 33 | {mpi_errno = MpioOpenDeferred( fh ); \ 34 | if(mpi_errno) \ 35 | goto fn_fail; \ 36 | } 37 | /* MPIO_ERR_CREATE_CODE_XXX macros are used to clean up creation of 38 | * error codes for common cases in romio/adio/ 39 | */ 40 | #define MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(key) \ 41 | MPIU_ERR_CREATE(MPI_ERR_NOT_SAME, "**ioinfokey %s", key); 42 | 43 | #define MPIO_ERR_GLE(gle_) \ 44 | MPIU_ERR_CREATE(MPI_ERR_IO, "**io %s", get_error_string(gle_)) 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd2_cq.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3_nd.h - Network Direct MPI CH3 Channel 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | #ifndef CH3U_ND_CQ_H 13 | #define CH3U_ND_CQ_H 14 | 15 | 16 | namespace CH3_ND 17 | { 18 | 19 | class Adapter; 20 | 21 | class Cq 22 | { 23 | friend class ListHelper; 24 | 25 | LIST_ENTRY m_link; 26 | 27 | StackGuardRef m_pAdapter; 28 | StackGuardRef m_pICq; 29 | 30 | volatile LONG m_nRef; 31 | int m_Size; 32 | int m_nUsed; 33 | 34 | bool m_fArmed; 35 | ND_OVERLAPPED m_NotifyOv; 36 | 37 | private: 38 | Cq(); 39 | Cq( const Cq& rhs ); 40 | ~Cq(); 41 | int Init( __in Adapter& adapter ); 42 | Cq& operator = ( const Cq& rhs ); 43 | 44 | public: 45 | static 46 | MPI_RESULT 47 | Create( 48 | _Inout_ Adapter& adapter, 49 | _Outptr_ Cq** ppCq 50 | ); 51 | 52 | void Shutdown(); 53 | 54 | LONG AddRef() 55 | { 56 | return ::InterlockedIncrement(&m_nRef); 57 | } 58 | 59 | void Release(); 60 | 61 | int Poll(_Inout_ BOOL* pfProgress); 62 | int Arm(); 63 | 64 | bool Full() const{ return (m_nUsed + 1) > m_Size; } 65 | void AllocateEntries(){ m_nUsed++; } 66 | void FreeEntries(){ m_nUsed--; } 67 | 68 | IND2CompletionQueue* ICq(){ return m_pICq.get(); } 69 | 70 | Adapter* GetAdapter(){ return m_pAdapter.get(); } 71 | 72 | private: 73 | static ND_OVERLAPPED::FN_CompletionRoutine NotifyHandler; 74 | }; 75 | 76 | } // namespace CH3_ND 77 | 78 | #endif // #define CH3U_ND_CQ_H 79 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd1_core.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3_nd_core.h - Network Direct MPI CH3 Channel 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | #ifndef CH3U_NDV1_CORE_H 13 | #define CH3U_NDV1_CORE_H 14 | 15 | 16 | namespace CH3_ND 17 | { 18 | namespace v1 19 | { 20 | 21 | // 22 | // The following queue depths should be <= single byte. 23 | // 24 | #define NDv1_SENDQ_SIZE 16 25 | C_ASSERT( NDv1_SENDQ_SIZE <= UCHAR_MAX ); 26 | 27 | #define NDv1_RECVQ_SIZE 64 28 | C_ASSERT( NDv1_RECVQ_SIZE <= UCHAR_MAX ); 29 | 30 | // 31 | // The code assumes that the read limit is equal to the MPI request IOV limit. 32 | // It does not handle the case where the limit is less than the IOV limit. 33 | // 34 | #define NDv1_READ_LIMIT MPID_IOV_LIMIT 35 | C_ASSERT( NDv1_READ_LIMIT <= UCHAR_MAX ); 36 | 37 | // 38 | // We allocate CQEs and send WQEs for sends, RDMA read requests, MW bind, and MW unbind. 39 | // 40 | #define NDv1_ACTIVE_ENTRIES (NDv1_SENDQ_SIZE + (NDv1_READ_LIMIT * 3)) 41 | #define NDv1_PASSIVE_ENTRIES NDv1_RECVQ_SIZE 42 | 43 | #define NDv1_CQ_ENTRIES_PER_EP (NDv1_ACTIVE_ENTRIES + NDv1_PASSIVE_ENTRIES) 44 | 45 | 46 | // 47 | // Caller data is 56 bytes max for IB. 48 | // 49 | struct nd_caller_data_t 50 | { 51 | // 52 | // Version comes first, so that we can change things after it without potentially breaking things. 53 | // 54 | UINT32 Version; 55 | INT32 Rank; 56 | UINT8 Credits; 57 | GUID GroupId; 58 | 59 | }; 60 | C_ASSERT( sizeof(nd_caller_data_t) <= 56 ); 61 | 62 | 63 | } // namespace CH3_ND::v1 64 | } // namespace CH3_ND 65 | 66 | #endif // CH3U_NDV1_CORE_H 67 | -------------------------------------------------------------------------------- /COPYRIGHT-mpich.txt: -------------------------------------------------------------------------------- 1 | 2 | COPYRIGHT 3 | 4 | The following is a notice of limited availability of the code, and disclaimer 5 | which must be included in the prologue of the code and in all source listings 6 | of the code. 7 | 8 | Copyright Notice 9 | + 2002 University of Chicago 10 | 11 | Permission is hereby granted to use, reproduce, prepare derivative works, and 12 | to redistribute to others. This software was authored by: 13 | 14 | Argonne National Laboratory Group 15 | W. Gropp: (630) 252-4318; FAX: (630) 252-5986; e-mail: gropp@mcs.anl.gov 16 | E. Lusk: (630) 252-7852; FAX: (630) 252-5986; e-mail: lusk@mcs.anl.gov 17 | Mathematics and Computer Science Division 18 | Argonne National Laboratory, Argonne IL 60439 19 | 20 | 21 | GOVERNMENT LICENSE 22 | 23 | Portions of this material resulted from work developed under a U.S. 24 | Government Contract and are subject to the following license: the Government 25 | is granted for itself and others acting on its behalf a paid-up, nonexclusive, 26 | irrevocable worldwide license in this computer software to reproduce, prepare 27 | derivative works, and perform publicly and display publicly. 28 | 29 | DISCLAIMER 30 | 31 | This computer code material was prepared, in part, as an account of work 32 | sponsored by an agency of the United States Government. Neither the United 33 | States, nor the University of Chicago, nor any of their employees, makes any 34 | warranty express or implied, or assumes any legal liability or responsibility 35 | for the accuracy, completeness, or usefulness of any information, apparatus, 36 | product, or process disclosed, or represents that its use would not infringe 37 | privately owned rights. 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/mpi/pmilib/cli/pmicli.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | pmicli 8 | {c4b97e13-177e-4aeb-b892-9db114a362f8} 9 | 10 | 11 | 12 | false 13 | StaticLibrary 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Use 25 | precomp.h 26 | $(IntDir)\pch_hdr.src 27 | 28 | %(AdditionalIncludeDirectories); 29 | $(MPI_SRC_ROOT)\msmpi\include; 30 | $(MPI_SRC_ROOT)\pmilib\lib\$(O); 31 | .\$(O) 32 | 33 | 34 | 35 | 36 | 37 | 38 | Create 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_init_sock.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #include "precomp.h" 9 | 10 | /* 11 | * MPIDI_CH3U_Init_sock - does socket specific channel initialization 12 | */ 13 | 14 | int MPIDI_CH3U_Init_sock(void) 15 | { 16 | int mpi_errno = MPIDU_Sock_init(); 17 | ON_ERROR_FAIL(mpi_errno); 18 | 19 | if( MPIDI_CH3I_Process.disable_sock == TRUE ) 20 | { 21 | return MPI_SUCCESS; 22 | } 23 | 24 | // 25 | // Disable sockets by default in SDK mode, except if: 26 | // - SHM is disabled. 27 | // - SOCK is explicitly enabled (MSMPI_DISABLE_SOCK = 0). 28 | // 29 | if( env_is_on(L"MSMPI_LOCAL_ONLY", FALSE) == TRUE && 30 | env_is_on_ex(L"MSMPI_DISABLE_SOCK", L"MPICH_DISABLE_SOCK", TRUE) == TRUE && 31 | MPIDI_CH3I_Process.disable_shm == FALSE ) 32 | { 33 | return MPI_SUCCESS; 34 | } 35 | 36 | // 37 | // Establish non-blocking listener 38 | // 39 | mpi_errno = MPIDU_CH3I_SetupListener( MPIDI_CH3I_set ); 40 | ON_ERROR_FAIL(mpi_errno); 41 | 42 | fn_fail: 43 | return mpi_errno; 44 | } 45 | 46 | 47 | void MPIDI_CH3U_Finalize_sock(void) 48 | { 49 | MPIDU_CH3I_ShutdownListener(); 50 | 51 | /* FIXME: Cleanly shutdown other socks and MPIU_Free connection 52 | structures. (close protocol?) */ 53 | 54 | MPIDU_Sock_finalize(); 55 | } 56 | 57 | 58 | /* This routine initializes Sock-specific elements of the VC */ 59 | void MPIDI_VC_Init_sock( MPIDI_VC_t *vc ) 60 | { 61 | vc->ch.conn = NULL; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd1_mr.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3u_nd_mr.h - Network Direct MPI CH3 Channel Memory Registration 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | #ifndef CH3U_NDV1_MR_H 13 | #define CH3U_NDV1_MR_H 14 | 15 | 16 | namespace CH3_ND 17 | { 18 | namespace v1 19 | { 20 | 21 | class CAdapter; 22 | 23 | class CMr 24 | { 25 | friend class ListHelper; 26 | 27 | private: 28 | CMr(); 29 | ~CMr(); 30 | int Init( _In_ CAdapter* pAdapter, _In_reads_(Length) const char* pBuf, SIZE_T Length ); 31 | 32 | public: 33 | static 34 | MPI_RESULT 35 | Create( 36 | _In_ CAdapter* pAdapter, 37 | _In_reads_(Length) const char* pBuf, 38 | _In_ SIZE_T Length, 39 | _Outptr_ CMr** ppMr 40 | ); 41 | 42 | public: 43 | void Shutdown(); 44 | 45 | LONG AddRef() 46 | { 47 | return ::InterlockedIncrement(&m_nRef); 48 | } 49 | 50 | void Release(); 51 | 52 | bool Matches( const CAdapter* pAdapter, const char* pBuf, SIZE_T Length ); 53 | bool Overlaps( const char* pBuf, SIZE_T Length ) const; 54 | bool Idle() const { return m_nRef == 1; } 55 | bool Stale() const { return m_pAdapter.get() == NULL; } 56 | 57 | ND_MR_HANDLE GetHandle(){ return m_hMr; } 58 | SIZE_T GetLength() const { return m_Length; } 59 | 60 | private: 61 | volatile LONG m_nRef; 62 | 63 | LIST_ENTRY m_link; 64 | 65 | StackGuardRef m_pAdapter; 66 | 67 | const char* m_pBuf; 68 | SIZE_T m_Length; 69 | ND_MR_HANDLE m_hMr; 70 | }; 71 | 72 | } // namespace v1 73 | } // namespace CH3_ND 74 | 75 | #endif // CH3U_NDV1_MR_H 76 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd2_mr.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3u_nd_mr.h - Network Direct MPI CH3 Channel Memory Registration 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | #ifndef CH3U_ND_MR_H 13 | #define CH3U_ND_MR_H 14 | 15 | 16 | namespace CH3_ND 17 | { 18 | 19 | class Adapter; 20 | 21 | class Mr 22 | { 23 | friend class ListHelper; 24 | 25 | volatile LONG m_nRef; 26 | 27 | LIST_ENTRY m_link; 28 | 29 | StackGuardRef m_pAdapter; 30 | 31 | const char* m_pBuf; 32 | SIZE_T m_Length; 33 | IND2MemoryRegion* m_pMr; 34 | 35 | private: 36 | Mr(); 37 | Mr( const Mr& rhs ); 38 | ~Mr(); 39 | int Init( _In_ Adapter& adapter, _In_reads_bytes_(cbBuf) const char* pBuf, _In_ SIZE_T cbBuf ); 40 | Mr& operator = ( const Mr& rhs ); 41 | 42 | public: 43 | static 44 | MPI_RESULT 45 | Create( 46 | _In_ Adapter& adapter, 47 | _In_reads_(cbBuf) const char* pBuf, 48 | _In_ SIZE_T cbBuf, 49 | _Outptr_ Mr** ppMr 50 | ); 51 | 52 | public: 53 | void Shutdown(); 54 | 55 | LONG AddRef() 56 | { 57 | return ::InterlockedIncrement(&m_nRef); 58 | } 59 | 60 | void Release(); 61 | 62 | bool Matches( const Adapter& adapter, const char* pBuf, SIZE_T cbBuf ); 63 | bool Overlaps( const char* pBuf, SIZE_T cbBuf ) const; 64 | bool Idle() const { return m_nRef == 1; } 65 | bool Stale() const { return m_pAdapter.get() == NULL; } 66 | 67 | IND2MemoryRegion* IMr(){ return m_pMr; } 68 | SIZE_T GetLength() const { return m_Length; } 69 | }; 70 | 71 | } // namespace CH3_ND 72 | 73 | #endif // CH3U_ND_MR_H 74 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/mpiimpl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #ifndef MPIIMPL_H_INCLUDED 9 | #define MPIIMPL_H_INCLUDED 10 | 11 | #include 12 | 13 | #include "mpi.h" 14 | #include "nmpi.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "mpidef.h" 26 | #include "mpiiov.h" 27 | #include "ex.h" 28 | #include "mpiimplthread.h" 29 | #include "mpiutil.h" 30 | #include "Tls.h" 31 | #include "mpidpkt.h" 32 | #include "dataloop.h" 33 | #include "MpiLock.h" 34 | #include "mpimem.h" 35 | #include "mpistr.h" 36 | #include "mpihandlemem.h" 37 | #include "mpi_lang.h" 38 | #include "progress.h" 39 | #include "vc.h" 40 | #include "info.h" 41 | #include "errhan.h" 42 | #include "attr.h" 43 | #include "datatype.h" 44 | #include "group.h" 45 | #include "collutil.h" 46 | #include "comm.h" 47 | #include "mpierror.h" 48 | #include "mpierrs.h" 49 | #include "ThreadHandle.h" 50 | #include "MpiCallState.h" 51 | #include "mpistatus.h" 52 | #include "request.h" 53 | #include "topo.h" 54 | #include "win.h" 55 | #include "op.h" 56 | #include "mpichtimer.h" 57 | #include "init.h" 58 | #include "spawn.h" 59 | #include "pt2pt.h" 60 | #include "coll.h" 61 | #include "tasks.h" 62 | #include "mpierrs.h" 63 | #include "dbgsupport.h" 64 | #include "romio.h" 65 | 66 | #include "autoptr.h" 67 | 68 | #ifdef HAVE_DEBUGGER_SUPPORT 69 | #include "dbgtypes.h" 70 | #endif 71 | 72 | #endif /* MPIIMPL_H_INCLUDED */ 73 | 74 | -------------------------------------------------------------------------------- /examples/helloworld/MPIHelloWorld.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | x64 8 | 9 | 10 | 11 | 12 | 16.0 13 | {A05D6B11-34C1-462A-AE8B-93D43A6B358D} 14 | MPIHelloWorld 15 | 16 | 17 | 18 | 19 | 20 | Application 21 | false 22 | v142 23 | Unicode 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | $(MSMPI_INC);$(MSMPI_INC)\x64 32 | 33 | 34 | 35 | Console 36 | $(MSMPI_LIB64) 37 | msmpi.lib;%(AdditionalDependencies) 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dll/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | main.cpp - DllMain implementation for MSMPI 7 | 8 | --*/ 9 | 10 | #include "mpiimpl.h" 11 | 12 | 13 | /* Provide a prototype for the mpirinitf function */ 14 | EXTERN_C void __cdecl mpirinitf( void ); 15 | 16 | extern HMODULE g_hModule; 17 | 18 | EXTERN_C 19 | BOOL 20 | WINAPI 21 | DllMain( 22 | __in HINSTANCE hInst, 23 | __in DWORD reason, 24 | __in VOID* /*reserved*/ 25 | ) 26 | { 27 | switch( reason ) 28 | { 29 | case DLL_PROCESS_DETACH: 30 | #ifdef HAVE_DEBUGGER_SUPPORT 31 | // 32 | // Clean up all the allocated MPIR_Sendq 33 | // 34 | while( MPIR_Sendq_head != nullptr ) 35 | { 36 | MPIR_Sendq* p = MPIR_Sendq_head; 37 | MPIR_Sendq_head = 38 | reinterpret_cast(MPIR_Sendq_head->ListEntry.Flink); 39 | MPIU_Free( p ); 40 | } 41 | 42 | while( MPIR_Sendq_pool != nullptr ) 43 | { 44 | MPIR_Sendq* p = MPIR_Sendq_pool; 45 | MPIR_Sendq_pool = 46 | reinterpret_cast(MPIR_Sendq_pool->ListEntry.Flink); 47 | MPIU_Free( p ); 48 | } 49 | #endif 50 | Mpi.PostFinalize(); 51 | break; 52 | 53 | case DLL_THREAD_DETACH: 54 | Mpi.CallState.DetachCurrentThread(); 55 | break; 56 | 57 | case DLL_PROCESS_ATTACH: 58 | { 59 | g_hModule = hInst; 60 | mpirinitf(); 61 | } 62 | break; 63 | 64 | case DLL_THREAD_ATTACH: 65 | break; 66 | 67 | default: 68 | __assume( 0 ); 69 | } 70 | return TRUE; 71 | } 72 | -------------------------------------------------------------------------------- /src/launchSvc/launchSvcMsg.mc: -------------------------------------------------------------------------------- 1 | ; 2 | ; // Launch Service Message Texts 3 | ; 4 | 5 | 6 | ; 7 | ; // Header 8 | ; 9 | 10 | SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS 11 | Informational=0x1:STATUS_SEVERITY_INFORMATIONAL 12 | Warning=0x2:STATUS_SEVERITY_WARNING 13 | Error=0x3:STATUS_SEVERITY_ERROR 14 | ) 15 | 16 | 17 | FacilityNames=(System=0x0:FACILITY_SYSTEM 18 | Runtime=0x2:FACILITY_RUNTIME 19 | Stubs=0x3:FACILITY_STUBS 20 | Io=0x4:FACILITY_IO_ERROR_CODE 21 | ) 22 | 23 | LanguageNames=(English=0x409:MSG00409) 24 | 25 | 26 | ; 27 | ; // Event Categories 28 | ; 29 | 30 | MessageIdTypedef=WORD 31 | 32 | MessageId=0x1 33 | SymbolicName=SVC_CATEGORY 34 | Language=English 35 | MsMpi Launch Service Events 36 | . 37 | 38 | MessageId=0x2 39 | SymbolicName=CLIENT_CATEGORY 40 | Language=English 41 | MsMpi Launch Service Client Events 42 | . 43 | 44 | 45 | ; 46 | ; // Message Definitions 47 | ; 48 | 49 | MessageIdTypedef=DWORD 50 | 51 | MessageId=0x1 52 | Severity=Success 53 | Facility=Runtime 54 | SymbolicName=SERVICE_EVENT 55 | Language=English 56 | %1 57 | . 58 | 59 | MessageId=0x100 60 | Severity=Success 61 | Facility=Runtime 62 | SymbolicName=SERVICE_STARTED 63 | Language=English 64 | MsMpi Launch Service started succesfully. 65 | . 66 | 67 | 68 | MessageId=0x101 69 | Severity=Informational 70 | Facility=Runtime 71 | SymbolicName=SERVICE_STATE_CHANGE 72 | Language=English 73 | MsMpi Launch Service state change from %1 to %2. 74 | . 75 | 76 | 77 | MessageId=0x102 78 | Severity=Error 79 | Facility=System 80 | ;// !!!!!!!!!!!!!!! 81 | SymbolicName=MSG_BAD_FILE_CONTENTS 82 | Language=English 83 | File %1 contains content that is not valid. 84 | . 85 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/assertutil.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | // 5 | // 6 | // Summary: 7 | // This file contains the assert utility macros. 8 | // Note: the "Invariant" versions that are included in retail. 9 | // 10 | // InvariantAssert/Assert(exp_) : 11 | // This uses interupt 2c, which enables new assert break and skip features. 12 | // If this assert fires, it will raise a fatal error and crash the host process. 13 | // If AeDebug key is set, this will cause the debugger to launch 14 | // When debugger attached, the 'ahi' command can be used to ignore the assertion and continue. 15 | // NOTE: Unlike the CRT assert, the strings for these asserts are stored in the symbols, 16 | // so asserts do not add strings to the image. 17 | // 18 | // InvariantAssertP/AssertP(exp_) : 19 | // This is the same as the InvariantAssert/Assert macro, except that it will only passively fire 20 | // when a debugger is actually attached. 21 | // 22 | // 23 | 24 | #define InvariantAssert(exp_) \ 25 | ((!(exp_)) ? \ 26 | (__annotation(L"Debug", L"AssertFail", L#exp_), \ 27 | __int2c(), FALSE) : \ 28 | TRUE) 29 | 30 | #define InvariantAssertP( exp_ ) \ 31 | ((!(exp_) && IsDebuggerPresent()) ? \ 32 | (__annotation(L"Debug", L"PassiveAssertFail", L#exp_), \ 33 | __int2c(), FALSE) : \ 34 | TRUE) 35 | 36 | #if DBG 37 | # define Assert(exp_) __analysis_assume(exp_);InvariantAssert(exp_) 38 | # define AssertP( exp_ ) __analysis_assume(exp_);InvariantAssertP(exp_) 39 | #else 40 | # define Assert( exp_ ) __analysis_assume(exp_) 41 | # define AssertP( exp_ ) __analysis_assume(exp_) 42 | #endif 43 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd1_cq.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3_nd_cq.h - Network Direct MPI CH3 Channel 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | #ifndef CH3U_NDV1_CQ_H 13 | #define CH3U_NDV1_CQ_H 14 | 15 | 16 | namespace CH3_ND 17 | { 18 | namespace v1 19 | { 20 | 21 | class CAdapter; 22 | 23 | class CCq 24 | { 25 | friend class ListHelper; 26 | 27 | private: 28 | CCq(); 29 | ~CCq(); 30 | int Init( __in CAdapter* pAdapter ); 31 | 32 | public: 33 | static 34 | MPI_RESULT 35 | Create( 36 | _In_ CAdapter* pAdapter, 37 | _Outptr_ CCq** ppCq 38 | ); 39 | 40 | void Shutdown(); 41 | 42 | LONG AddRef() 43 | { 44 | return ::InterlockedIncrement(&m_nRef); 45 | } 46 | 47 | void Release(); 48 | 49 | int Poll(_Inout_ BOOL* pfProgress); 50 | int Arm(); 51 | 52 | bool Full() const{ return (m_nUsed + 1) > m_Size; } 53 | void AllocateEntries(){ m_nUsed++; } 54 | void FreeEntries(){ m_nUsed--; } 55 | 56 | INDCompletionQueue* ICq(){ return m_pICq.get(); } 57 | 58 | CAdapter* Adapter(){ return m_pAdapter.get(); } 59 | 60 | private: 61 | static int WINAPI NotifySucceeded( __in EXOVERLAPPED* pOverlapped ); 62 | static int WINAPI NotifyFailed( __in EXOVERLAPPED* pOverlapped ); 63 | 64 | private: 65 | volatile LONG m_nRef; 66 | 67 | LIST_ENTRY m_link; 68 | 69 | StackGuardRef m_pAdapter; 70 | int m_Size; 71 | int m_nUsed; 72 | StackGuardRef m_pICq; 73 | 74 | bool m_fArmed; 75 | EXOVERLAPPED m_NotifyOv; 76 | }; 77 | 78 | } // namespace v1 79 | } // namespace CH3_ND 80 | 81 | #endif // #define CH3U_NDV1_CQ_H 82 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/DynProc.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | [ 5 | uuid(9b1af77c-4719-48f2-abb7-b5cd2f69d16c), 6 | version(1.0), 7 | pointer_default(unique), 8 | ] 9 | 10 | // 11 | // The RPC interface for the accept server. 12 | // 13 | interface DynProc 14 | { 15 | import "wtypes.idl"; 16 | import "DynProcTypes.h"; 17 | 18 | // 19 | // Summary: 20 | // The client calls into this routine to send PG info to the server 21 | // and retrieve the PG infos from the server 22 | // 23 | // In: 24 | // tag : The tag that indentifies the port 25 | // 26 | // Inout: 27 | // pRoot : [in] The rank of the root in the remote group 28 | // : [out] The rank of the root in the local group 29 | // pContextId : [in] The remote side's context id 30 | // : [out] The context id from the local group 31 | // pCount : [in] The number of processes in the remote group 32 | // : [out] The number of processes in the local group 33 | // pInConnInfos : The array containing the remote side's PG infos 34 | // 35 | // Out: 36 | // ppOutConnInfos: Pointer to receive the array containing local group's PG infos 37 | // 38 | int __stdcall 39 | AsyncExchangeConnInfo( 40 | [in] unsigned int tag, 41 | [in,out] int* pRoot, 42 | [in,out] GUID* pContextId, 43 | [in,out] unsigned int* pCount, 44 | [in,size_is(*pCount)] CONN_INFO_TYPE* pInConnInfos, 45 | [out,size_is(,*pCount)] CONN_INFO_TYPE** ppOutConnInfos 46 | ); 47 | } 48 | -------------------------------------------------------------------------------- /src/mpi/common/assertutil.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | // 7 | // 8 | // Summary: 9 | // This file contains the assert utility macros. 10 | // Note: the "Invariant" versions that are included in retail. 11 | // 12 | // InvariantAssert/Assert(exp_) : 13 | // This uses interupt 2c, which enables new assert break and skip features. 14 | // If this assert fires, it will raise a fatal error and crash the host process. 15 | // If AeDebug key is set, this will cause the debugger to launch 16 | // When debugger attached, the 'ahi' command can be used to ignore the assertion and continue. 17 | // NOTE: Unlike the CRT assert, the strings for these asserts are stored in the symbols, 18 | // so asserts do not add strings to the image. 19 | // 20 | // InvariantAssertP/AssertP(exp_) : 21 | // This is the same as the InvariantAssert/Assert macro, except that it will only passively fire 22 | // when a debugger is actually attached. 23 | // 24 | // 25 | 26 | #define InvariantAssert(exp_) \ 27 | ((!(exp_)) ? \ 28 | (__annotation(L"Debug", L"AssertFail", L#exp_), \ 29 | __int2c(), FALSE) : \ 30 | TRUE) 31 | 32 | #define InvariantAssertP( exp_ ) \ 33 | ((!(exp_) && IsDebuggerPresent()) ? \ 34 | (__annotation(L"Debug", L"PassiveAssertFail", L#exp_), \ 35 | __int2c(), FALSE) : \ 36 | TRUE) 37 | 38 | #if DBG 39 | # define Assert(exp_) __analysis_assume(exp_);InvariantAssert(exp_) 40 | # define AssertP( exp_ ) __analysis_assume(exp_);InvariantAssertP(exp_) 41 | #else 42 | # define Assert( exp_ ) __analysis_assume(exp_) 43 | # define AssertP( exp_ ) __analysis_assume(exp_) 44 | #endif 45 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/mpif90model.h.in: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-basic-offset:4 ; -*- */ 2 | 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // Licensed under the MIT License. 5 | 6 | /* 7 | * 8 | * (C) 2003 by Argonne National Laboratory. 9 | * See COPYRIGHT in top-level directory. 10 | */ 11 | 12 | #ifndef MPIR_F90_INCLUDED 13 | #define MPIR_F90_INCLUDED 14 | 15 | /* Get the parameters that define the integer and real data models 16 | * for Fortran 90. These are needed to implement the MPI_Type_create_f90_xxx 17 | * functions, which are available in C, F90, and C++ (but not in Fortran 77, 18 | * because these are part of the extended Fortran support). 19 | * 20 | * These use the Fortran 90 terms precision and range which have the 21 | * following meanings: 22 | * 23 | * precision - number of digits to ??? (FIXME: exact definition) 24 | * range - number of decimal digits (exponent range for reals) 25 | */ 26 | 27 | /* Real and double model: 28 | * precision and range for reals and for doubles 29 | * The value is two "precision, range", as integers 30 | */ 31 | #define MPIR_F90_REAL_MODEL @F90_REAL_MODEL@ 32 | #define MPIR_F90_DOUBLE_MODEL @F90_DOUBLE_MODEL@ 33 | /* integer model: 34 | * a single integer, giving the value of the range 35 | */ 36 | #define MPIR_F90_INTEGER_MODEL @F90_INTEGER_MODEL@ 37 | /* integer model map: 38 | * a set of triples of integers, giving the maximum range for 39 | * each 'kind', as in the Fortran 90 declaration 40 | * integer(kind=k) . That is, 41 | * 42 | * r1,k1,s1, r2,k2,s2 ... 43 | * 44 | * where kind ki has range ri and is si bytes long 45 | * 46 | * This can be used to find a Fortran 90 integer type with a given range. 47 | * 48 | */ 49 | #define MPIR_F90_INTEGER_MODEL_MAP @F90_INTEGER_MODEL_MAP@ 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/ThreadHandle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "tls.h" 7 | 8 | 9 | class ThreadHandle 10 | { 11 | HANDLE m_hThread; 12 | volatile LONG m_nRef; 13 | 14 | public: 15 | ThreadHandle() 16 | : m_hThread( NULL ) 17 | , m_nRef( 1 ) 18 | { 19 | } 20 | 21 | ~ThreadHandle() 22 | { 23 | if( m_hThread != NULL) 24 | { 25 | MPIU_Assert( m_nRef == 0 ); 26 | ::CloseHandle( m_hThread ); 27 | } 28 | } 29 | 30 | inline void AddRef() 31 | { 32 | MPIU_Assert( m_hThread != NULL ); 33 | InterlockedIncrement( &m_nRef ); 34 | } 35 | 36 | inline LONG Release() 37 | { 38 | MPIU_Assert( m_nRef > 0 ); 39 | MPIU_Assert( m_hThread != NULL ); 40 | LONG nRef = InterlockedDecrement( &m_nRef ); 41 | if( nRef == 0 ) 42 | { 43 | delete this; 44 | } 45 | return nRef; 46 | } 47 | 48 | inline int Initialize() 49 | { 50 | MPIU_Assert( m_hThread == NULL ); 51 | 52 | BOOL ret = ::DuplicateHandle( 53 | GetCurrentProcess(), 54 | GetCurrentThread(), 55 | GetCurrentProcess(), 56 | &m_hThread, 57 | THREAD_SET_CONTEXT, 58 | FALSE, 59 | 0 60 | ); 61 | 62 | if( ret == FALSE ) 63 | { 64 | return MPIU_ERR_FATAL_GET(MPI_SUCCESS, MPI_ERR_OTHER, "**duphandle %d", ::GetLastError()); 65 | } 66 | 67 | return MPI_SUCCESS; 68 | } 69 | 70 | inline void QueueApc( PAPCFUNC pfnApc, ULONG_PTR param ) const 71 | { 72 | MPIU_Assert( m_hThread != NULL ); 73 | MPIU_Assert( m_nRef > 0 ); 74 | 75 | ::QueueUserAPC( pfnApc, m_hThread, param ); 76 | } 77 | }; 78 | -------------------------------------------------------------------------------- /src/mpi/msmpi/util/mpiutil.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | mpiutil 8 | {74f3aa9a-087a-42bc-a273-41947640734c} 9 | 10 | 11 | 12 | false 13 | StaticLibrary 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | %(AdditionalIncludeDirectories); 22 | $(MPI_SRC_ROOT)\msmpi\mpid; 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_sock.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #ifndef CH3U_SOCK_H 10 | #define CH3U_SOCK_H 11 | 12 | #define MPIDI_CH3_USES_SOCK 13 | 14 | struct MPIDI_PG_t; 15 | struct MPIDI_VC_t; 16 | 17 | struct MPIDI_CH3I_Connection_t 18 | { 19 | MPIDI_VC_t * vc; 20 | sock_state_t * sock; 21 | sock_state_t * aux_sock; 22 | MPID_Request * recv_active; 23 | GUID pg_id; 24 | MPID_IOV iov[2]; 25 | BOOL disconnect; 26 | MPIU_Bsize_t recv_buff_end; 27 | union 28 | { 29 | MPIDI_CH3_Pkt_t pkt; 30 | char recv_buffer[0x800 + sizeof(MPIDI_CH3_Pkt_t)]; 31 | }; 32 | }; 33 | 34 | C_ASSERT(sizeof(((MPIDI_CH3I_Connection_t*)0)->pkt) <= sizeof(((MPIDI_CH3I_Connection_t*)0)->recv_buffer)); 35 | 36 | 37 | int MPIDI_CH3I_Connection_alloc(MPIDI_CH3I_Connection_t**); 38 | void MPIDI_CH3I_Connection_free(MPIDI_CH3I_Connection_t* conn); 39 | 40 | /* Routines to get the socket address */ 41 | MPI_RESULT 42 | MPIDU_Sock_get_conninfo_from_bc( 43 | _In_z_ const char* bc, 44 | _Out_z_cap_(maxlen) char* host_description, 45 | _In_ size_t maxlen, 46 | _Out_ int* port 47 | ); 48 | 49 | /* These two routines from util/sock initialize and shutdown the 50 | socket used to establish connections. */ 51 | int MPIDU_CH3I_SetupListener( ExSetHandle_t ); 52 | void MPIDU_CH3I_ShutdownListener( void ); 53 | 54 | int MPIDI_CH3U_Init_sock(void); 55 | void MPIDI_CH3U_Finalize_sock(void); 56 | void MPIDI_VC_Init_sock(MPIDI_VC_t* vc) ; 57 | int MPIDI_CH3U_Get_business_card_sock(_Deref_out_z_cap_c_(*bc_len_p) char** bc_val_p, _Inout_ int* bc_len_p); 58 | 59 | #define MPIDI_PG_Init_sock(a) ((void)0) 60 | 61 | #endif /* CH3_USOCK_H */ 62 | -------------------------------------------------------------------------------- /src/mpi/msmpi/io/mpiio.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | mpiio 8 | {60a35c4f-7fca-40cc-86f3-3aa89fcba1d0} 9 | 10 | 11 | 12 | false 13 | StaticLibrary 14 | 15 | 16 | 17 | 18 | 19 | 20 | Use 21 | precomp.h 22 | $(IntDir)\pch_hdr.src 23 | 24 | %(AdditionalIncludeDirectories) 25 | $(MPI_SRC_ROOT)\msmpi\mpid; 26 | $(MPI_SRC_ROOT)\msmpi\channels\$(O); 27 | 28 | 29 | 30 | 31 | 32 | 33 | Create 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/msmpifec/msmpifec.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | cdecl 8 | 9 | 10 | 11 | msmpifec 12 | {371aaa73-0f45-4c9c-bf91-0c22482d5938} 13 | 14 | 15 | 16 | false 17 | StaticLibrary 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | %(AdditionalIncludeDirectories); 26 | $(MPI_SRC_ROOT)\msmpi\include; 27 | $(MPI_SRC_ROOT)\msmpi\dbg 28 | 29 | 30 | %(PreprocessorDefinitions); 31 | USE_FORT_CDECL=1 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | false 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/msmpifmc/msmpifmc.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | cdecl 8 | 9 | 10 | 11 | msmpifmc 12 | {19ebb640-ed80-4830-9f79-31d4faf1cdc5} 13 | 14 | 15 | 16 | false 17 | StaticLibrary 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | %(AdditionalIncludeDirectories); 26 | $(MPI_SRC_ROOT)\msmpi\include; 27 | $(MPI_SRC_ROOT)\msmpi\dbg 28 | 29 | 30 | %(PreprocessorDefinitions); 31 | USE_FORT_CDECL=1; 32 | USE_FORT_MIXED_STR_LEN=1 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | false 48 | 49 | 50 | 51 | 52 | false 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/mpi/stub/stubs.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "smpd.h" 5 | 6 | // 7 | // This file contains stubs for some MPI internal functions. 8 | // The stubs allow binaries outside of msmpi to use the common static library. 9 | // 10 | // For example, to use MPIR_Err_get_string and to link with MPIR_Err_create_code 11 | // (required by the sock module) without dragging the entire MPI code base. 12 | // 13 | 14 | // 15 | // Implement MPIR vsprintf funciton without the mpi special format specifiers 16 | // 17 | _Success_(return==MPI_SUCCESS) 18 | int MPIR_Err_vsnprintf_mpi( 19 | _Out_writes_z_(maxlen) char* str, 20 | _In_ size_t maxlen, 21 | _Printf_format_string_ const char* fmt, 22 | _In_ va_list list 23 | ) 24 | { 25 | return MPIU_Vsnprintf(str, maxlen, fmt, list); 26 | } 27 | 28 | 29 | // 30 | // Implement MPID Abort function to support MPIU_Assert in debug builds 31 | // 32 | #pragma warning(push) 33 | #pragma warning(disable: 4702) // unreachable code 34 | #pragma warning(disable: 4646) // nonvoid noreturn call 35 | _Analysis_noreturn_ 36 | DECLSPEC_NORETURN 37 | int 38 | MPID_Abort( 39 | _Inout_opt_ struct MPID_Comm* /*comm*/, 40 | _In_ BOOL /*intern*/, 41 | _In_ int exit_code, 42 | _In_z_ const char* /*error_msg*/ 43 | ) 44 | { 45 | exit(exit_code); 46 | } 47 | 48 | #pragma warning(pop) 49 | 50 | 51 | void* MPIU_Malloc( _In_ SIZE_T size ) 52 | { 53 | return ::HeapAlloc( ::GetProcessHeap(), 0, size ); 54 | } 55 | 56 | 57 | void* MPIU_Calloc( _In_ SIZE_T elements, _In_ SIZE_T size ) 58 | { 59 | return ::HeapAlloc( ::GetProcessHeap(), HEAP_ZERO_MEMORY, size * elements ); 60 | } 61 | 62 | 63 | void MPIU_Free( _In_opt_ _Post_ptr_invalid_ void* pMem ) 64 | { 65 | if( pMem != nullptr ) 66 | { 67 | ::HeapFree( ::GetProcessHeap(), 0, pMem ); 68 | } 69 | } 70 | 71 | 72 | void* MPIU_Realloc( _In_ void* pMem, _In_ SIZE_T size ) 73 | { 74 | return ::HeapReAlloc( ::GetProcessHeap(), 0, pMem, size ); 75 | } 76 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_get_business_card_sshm.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #include "precomp.h" 9 | #include "mpidi_ch3_impl.h" 10 | #include "pmi.h" 11 | 12 | 13 | /* MPIDI_CH3U_Get_business_card_sshm - does sshm specific portion of getting 14 | * a business card 15 | * bc_val_p - business card value buffer pointer, updated to the next 16 | * available location or freed if published. 17 | * val_max_sz_p - ptr to maximum value buffer size reduced by the number 18 | * of characters written 19 | */ 20 | MPI_METHOD 21 | MPIDI_CH3U_Get_business_card_sshm( 22 | _Deref_out_z_cap_c_(*val_max_sz_p) char** bc_val_p, 23 | _Inout_ int* val_max_sz_p 24 | ) 25 | { 26 | char queue_name[100]; 27 | int str_errno; 28 | 29 | str_errno = MPIU_Str_add_string_arg(bc_val_p, val_max_sz_p, 30 | MPIDI_CH3I_SHM_HOST_KEY, 31 | MPIDI_CH3U_Hostname_sshm()); 32 | if (str_errno != MPIU_STR_SUCCESS) 33 | { 34 | if (str_errno == MPIU_STR_NOMEM) 35 | return MPIU_ERR_CREATE(MPI_ERR_OTHER, "**buscard_len"); 36 | 37 | return MPIU_ERR_CREATE(MPI_ERR_OTHER, "**buscard"); 38 | } 39 | 40 | queue_name[0] = '\0'; 41 | MPIDI_CH3I_BootstrapQ_tostring(MPIDI_CH3U_BootstrapQ_sshm(), queue_name, _countof(queue_name)); 42 | 43 | str_errno = MPIU_Str_add_string_arg(bc_val_p, val_max_sz_p, 44 | MPIDI_CH3I_SHM_QUEUE_KEY, queue_name); 45 | if (str_errno != MPIU_STR_SUCCESS) 46 | { 47 | if (str_errno == MPIU_STR_NOMEM) 48 | return MPIU_ERR_CREATE(MPI_ERR_OTHER, "**buscard_len"); 49 | 50 | return MPIU_ERR_CREATE(MPI_ERR_OTHER, "**buscard"); 51 | } 52 | 53 | return MPI_SUCCESS; 54 | } 55 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/info.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * (C) 2001 by Argonne National Laboratory. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | #include "precomp.h" 10 | 11 | #include "adio.h" 12 | 13 | 14 | /* This is the utility file for info that contains the basic info items 15 | and storage management */ 16 | #ifndef MPID_INFO_PREALLOC 17 | #define MPID_INFO_PREALLOC 8 18 | #endif 19 | 20 | C_ASSERT( HANDLE_GET_TYPE(MPI_INFO_NULL) == HANDLE_TYPE_INVALID ); 21 | C_ASSERT( HANDLE_GET_MPI_KIND(MPI_INFO_NULL) == MPID_INFO ); 22 | 23 | /* Preallocated info objects */ 24 | MPID_Info MPID_Info_direct[MPID_INFO_PREALLOC] = { { 0 } }; 25 | MPIU_Object_alloc_t MPID_Info_mem = { 0, 0, 0, 0, MPID_INFO, 26 | sizeof(MPID_Info), MPID_Info_direct, 27 | MPID_INFO_PREALLOC, }; 28 | 29 | MPID_Info* MPIU_Info_alloc_node(const char* key, const char* value) 30 | { 31 | MPID_Info* p = (MPID_Info*)MPIU_Handle_obj_alloc(&MPID_Info_mem); 32 | if(p == NULL) 33 | goto fn_fail1; 34 | 35 | p->next = NULL; 36 | p->key = NULL; 37 | p->value = NULL; 38 | 39 | if(key != NULL) 40 | { 41 | p->key = MPIU_Strdup(key); 42 | if((p->key == NULL)) 43 | goto fn_fail2; 44 | } 45 | 46 | if(value != NULL) 47 | { 48 | p->value = MPIU_Strdup(value); 49 | if((p->value == NULL)) 50 | goto fn_fail3; 51 | } 52 | 53 | return p; 54 | 55 | fn_fail3: 56 | MPIU_Free(p->key); 57 | fn_fail2: 58 | MPIU_Handle_obj_free(&MPID_Info_mem, p); 59 | fn_fail1: 60 | return NULL; 61 | } 62 | 63 | 64 | void MPIU_Info_free_node(MPID_Info* p) 65 | { 66 | MPIU_Free(p->value); 67 | MPIU_Free(p->key); 68 | MPIU_Handle_obj_free(&MPID_Info_mem, p); 69 | } 70 | 71 | 72 | void MPIU_Info_free_list(MPID_Info* p) 73 | { 74 | while (p != NULL) 75 | { 76 | MPID_Info* q = p->next; 77 | MPIU_Info_free_node(p); 78 | p = q; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/fortran.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | true 7 | 8 | 9 | 10 | $(MPI_SDK_DESTINATION)\lib 11 | *.lib 12 | 13 | 14 | 15 | 16 | /machine:X86 %(AdditionalOptions) 17 | 18 | 19 | 20 | 21 | cl.exe 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/mpi/msmpi/io/malloc.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * Copyright (C) 1997 University of Chicago. 7 | * See COPYRIGHT notice in top-level directory. 8 | */ 9 | #include "precomp.h" 10 | 11 | /* These are routines for allocating and deallocating memory. 12 | They should be called as ADIOI_Malloc(size) and 13 | ADIOI_Free(ptr). In adio.h, they are macro-replaced to 14 | ADIOI_Malloc(size,__LINE__,__FILE__) and 15 | ADIOI_Free(ptr,__LINE__,__FILE__). 16 | 17 | Later on, add some tracing and error checking, similar to 18 | MPID_trmalloc. */ 19 | 20 | /* can't include adio.h here, because of the macro, so 21 | * include romioconf.h to make sure config-time defines get included */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "mpiutil.h" 28 | 29 | #pragma warning(push) 30 | #pragma warning(disable:4702) 31 | 32 | _Ret_notnull_ 33 | void* 34 | ADIOI_Malloc( 35 | _In_ size_t size 36 | ) 37 | { 38 | void *new_ptr; 39 | 40 | new_ptr = (void *) malloc(size); 41 | 42 | if (!new_ptr) 43 | { 44 | MPID_Abort(NULL, TRUE, 1, "out of memory"); 45 | } 46 | 47 | return new_ptr; 48 | } 49 | 50 | 51 | _Ret_notnull_ 52 | void* 53 | ADIOI_Calloc( 54 | _In_ size_t nelem, 55 | _In_ size_t elsize 56 | ) 57 | { 58 | void *new_ptr; 59 | 60 | new_ptr = (void *) calloc(nelem, elsize); 61 | if (!new_ptr) 62 | { 63 | MPID_Abort(NULL, TRUE, 1, "out of memory"); 64 | } 65 | 66 | return new_ptr; 67 | } 68 | 69 | 70 | _Ret_notnull_ 71 | void* 72 | ADIOI_Realloc( 73 | _In_ void* ptr, 74 | _In_ size_t size 75 | ) 76 | { 77 | void *new_ptr; 78 | 79 | new_ptr = (void *) realloc(ptr, size); 80 | if (!new_ptr) 81 | { 82 | MPID_Abort(NULL, TRUE, 1, "out of memory"); 83 | } 84 | return new_ptr; 85 | } 86 | 87 | 88 | void 89 | ADIOI_Free( 90 | _In_opt_ _Post_ptr_invalid_ void* ptr 91 | ) 92 | { 93 | free(ptr); 94 | } 95 | #pragma warning(pop) 96 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/msmpifes/msmpifes.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | true 8 | 9 | 10 | stdcall 11 | 12 | 13 | 14 | msmpifes 15 | {add22d52-cc12-4462-9044-63c2ec8f485b} 16 | 17 | 18 | 19 | false 20 | StaticLibrary 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | %(AdditionalIncludeDirectories); 29 | $(MPI_SRC_ROOT)\msmpi\include; 30 | $(MPI_SRC_ROOT)\msmpi\dbg 31 | 32 | 33 | %(PreprocessorDefinitions); 34 | USE_FORT_STDCALL=1 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | false 50 | 51 | 52 | 53 | 54 | false 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd2_core.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3_nd.h - Network Direct MPI CH3 Channel 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | #ifndef CH3U_ND_CORE_H 13 | #define CH3U_ND_CORE_H 14 | 15 | 16 | namespace CH3_ND 17 | { 18 | 19 | // 20 | // The following queue depths should be <= single byte. 21 | // 22 | #define ND_SENDQ_DEPTH 16 23 | C_ASSERT( ND_SENDQ_DEPTH <= MAXUINT8 ); 24 | #define ND_SENDQ_MINDEPTH 1 25 | C_ASSERT( ND_SENDQ_MINDEPTH <= ND_SENDQ_DEPTH ); 26 | 27 | #define ND_RECVQ_DEPTH 128 28 | C_ASSERT( ND_RECVQ_DEPTH <= MAXUINT8 ); 29 | // 30 | // Minimum receive queue depth is 2 to prevent deadlock with credit flow control. 31 | // 32 | #define ND_RECVQ_MINDEPTH 2 33 | C_ASSERT( ND_RECVQ_MINDEPTH <= ND_RECVQ_DEPTH ); 34 | 35 | // 36 | // Maximum queue depth that is a power of 2 and can fit in a UINT8. 37 | // 38 | #define ND_MAX_QUEUE_DEPTH 128 39 | 40 | // 41 | // The code assumes that the read limit is equal to the MPI request IOV limit. 42 | // It does not handle the case where the limit is less than the IOV limit. 43 | // 44 | #define ND_READ_LIMIT MPID_IOV_LIMIT 45 | C_ASSERT( ND_READ_LIMIT <= MAXUINT8 ); 46 | 47 | 48 | // 49 | // Caller data is 56 bytes max for IB. 50 | // 51 | struct nd_caller_data_t 52 | { 53 | // 54 | // Version comes first, so that we can change things after it without 55 | // potentially breaking things. 56 | // 57 | INT32 Version; 58 | INT32 Rank; 59 | UINT8 Credits; 60 | GUID GroupId; 61 | 62 | }; 63 | C_ASSERT( sizeof(nd_caller_data_t) <= 56 ); 64 | 65 | 66 | struct ND_OVERLAPPED : public OVERLAPPED 67 | { 68 | typedef int // mpi_error 69 | (FN_CompletionRoutine)( 70 | __in struct ND_OVERLAPPED* pOverlapped 71 | ); 72 | 73 | FN_CompletionRoutine* pfnCompletion; 74 | 75 | ND_OVERLAPPED( FN_CompletionRoutine* pfn = NULL ) : 76 | pfnCompletion( pfn ) 77 | { 78 | Offset = 0; 79 | OffsetHigh = 0; 80 | hEvent = NULL; 81 | } 82 | }; 83 | 84 | } // namespace CH3_ND 85 | 86 | #endif // CH3U_ND_CORE_H 87 | -------------------------------------------------------------------------------- /src/mpi/smpd/affinity_calculation.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "precomp.h" 5 | #include "smpd.h" 6 | 7 | #pragma once 8 | 9 | #ifndef MSMPI_AA_VERSION 10 | #define MSMPI_AA_VERSION 0x100 11 | #endif 12 | 13 | 14 | typedef struct _AutoAffinityInfo 15 | { 16 | typedef UINT64 MaskType; 17 | 18 | UINT32 version; 19 | UINT32 groupCount; 20 | MaskType occupiedCoresMask[ANYSIZE_ARRAY]; 21 | BOOL published; 22 | 23 | static UINT32 GetSize(UINT32 groupCount) 24 | { 25 | return sizeof(_AutoAffinityInfo) + sizeof(MaskType) * (groupCount - 1); 26 | } 27 | 28 | static _AutoAffinityInfo* Create(UINT32 groupCount) 29 | { 30 | _AutoAffinityInfo* pInfo = nullptr; 31 | 32 | UINT32 infoSize = _AutoAffinityInfo::GetSize(groupCount); 33 | pInfo = static_cast<_AutoAffinityInfo*>(malloc(infoSize)); 34 | if(pInfo != nullptr) 35 | { 36 | ZeroMemory(pInfo, infoSize); 37 | pInfo->version = MSMPI_AA_VERSION; 38 | pInfo->groupCount = groupCount; 39 | } 40 | 41 | return pInfo; 42 | } 43 | } AutoAffinityInfo; 44 | 45 | 46 | HANDLE LockAutoAffinity(); 47 | 48 | 49 | HRESULT WriteAutoAffinity(_In_ smpd_context_t *context, _In_ UINT32 groupCount); 50 | 51 | 52 | void UnlockAutoAffinity(_In_ HANDLE affinityLock); 53 | 54 | 55 | HRESULT 56 | ConstructHwInfo( 57 | _In_ BOOL checkOccupied, 58 | _Inout_ UINT32* pcbView, 59 | _Inout_ HWVIEW** ppView, 60 | _Inout_ UINT32* pcbTree, 61 | _Inout_ HWTREE** ppTree, 62 | _Inout_ UINT32* pcbSummary, 63 | _Inout_ HWSUMMARY** ppSummary, 64 | _Inout_ wchar_t* errorMsg, 65 | _In_ size_t msgSize 66 | ); 67 | 68 | 69 | HRESULT 70 | SetAffinity( 71 | _In_ const AffinityOptions* pOptions, 72 | _In_ const HWSUMMARY* pSummary, 73 | _In_ const HWVIEW* pView, 74 | _Inout_ smpd_context_t* pContext, 75 | _Inout_ wchar_t* errorMsg, 76 | _In_ size_t msgSize 77 | ); 78 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/msmpifms/msmpifms.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | true 8 | 9 | 10 | stdcall 11 | 12 | 13 | 14 | msmpifms 15 | {6b873754-6dd8-405c-afbe-e03a521d3ace} 16 | 17 | 18 | 19 | false 20 | StaticLibrary 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | %(AdditionalIncludeDirectories); 29 | $(MPI_SRC_ROOT)\msmpi\include; 30 | $(MPI_SRC_ROOT)\msmpi\dbg 31 | 32 | 33 | %(PreprocessorDefinitions); 34 | USE_FORT_STDCALL=1; 35 | USE_FORT_MIXED_STR_LEN=1 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | false 51 | 52 | 53 | 54 | 55 | false 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_sshm.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #ifndef CH3U_SSHM_H 10 | #define CH3U_SSHM_H 11 | 12 | // 13 | // TODO: Put this back. 14 | // 15 | //#define MPIDI_CH3_USES_SSHM 16 | 17 | /* 18 | * Define the maximum host name length for the SHM hostname used in the business card, 19 | * as well as in the connectivity table. 20 | */ 21 | #define MAXHOSTNAMELEN 256 22 | 23 | struct MPIDI_PG_t; 24 | struct MPIDI_VC_t; 25 | typedef HANDLE MPIDI_CH3I_BootstrapQ; 26 | typedef ExCompletionProcessor ch3u_bootstrapq_routine; 27 | 28 | void MPIDI_CH3U_Init_sshm(int has_parent, int pg_rank); 29 | void MPIDI_CH3U_Finalize_sshm(void); 30 | 31 | void MPIDI_VC_Init_sshm(MPIDI_VC_t* vc) ; 32 | int MPIDI_CH3I_Connect_to_root_sshm(const char* port_name, MPIDI_VC_t** new_vc); 33 | 34 | MPI_METHOD 35 | MPIDI_CH3U_Get_business_card_sshm( 36 | _Deref_out_z_cap_c_(*val_max_sz_p) char** bc_val_p, 37 | _Inout_ int* val_max_sz_p 38 | ); 39 | 40 | 41 | void MPIDI_PG_Init_sshm(MPIDI_PG_t* pg); 42 | 43 | 44 | MPIDI_CH3I_BootstrapQ MPIDI_CH3U_BootstrapQ_sshm(); 45 | const char* MPIDI_CH3U_Hostname_sshm(); 46 | 47 | void MPIDI_CH3I_BootstrapQ_create(MPIDI_CH3I_BootstrapQ *queue_ptr); 48 | void MPIDI_CH3I_BootstrapQ_tostring(_In_ MPIDI_CH3I_BootstrapQ queue, _Out_writes_z_(length) char *name, _In_range_(>, 20) size_t length); 49 | void MPIDI_CH3I_BootstrapQ_destroy(MPIDI_CH3I_BootstrapQ queue); 50 | void MPIDI_CH3I_BootstrapQ_unlink(MPIDI_CH3I_BootstrapQ queue); 51 | int MPIDI_CH3I_BootstrapQ_attach(const char* name, MPIDI_CH3I_BootstrapQ * queue_ptr); 52 | void MPIDI_CH3I_BootstrapQ_detach(MPIDI_CH3I_BootstrapQ queue); 53 | 54 | int MPIDI_CH3I_Notify_connect(MPIDI_CH3I_BootstrapQ queue, HANDLE hShm, int pid); 55 | void MPIDI_CH3I_Notify_accept_connect(ch3u_bootstrapq_routine pfnAcceptConnection); 56 | 57 | int MPIDI_CH3I_Notify_message(MPIDI_CH3I_BootstrapQ queue); 58 | void MPIDI_CH3I_Notify_accept_message(ch3u_bootstrapq_routine pfnAcceptMessage); 59 | 60 | 61 | #endif /* CH3U_SSHM_H */ 62 | -------------------------------------------------------------------------------- /src/mpi/msmpi/fortran/lib/mpifort.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | mpifort 7 | {a4085965-a1a1-4f4b-a5fd-f3b8da759e82} 8 | 9 | 10 | 11 | -fno-underscoring -D_X86_=1 -Di386=1 -march=x86-64 -m32 12 | 13 | 14 | -fno-underscoring -D_WIN64 -D_AMD64_ -DAMD64 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | false 23 | StaticLibrary 24 | 25 | 26 | 27 | 28 | 29 | %(AdditionalIncludeDirectories); 30 | $(MPI_SRC_ROOT)\msmpi\include; 31 | $(MPI_SRC_ROOT)\msmpi\dbg 32 | 33 | 34 | %(PreprocessorDefinitions); 35 | USE_FORT_CDECL=1 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/mpiimplthread.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #if !defined(MPIIMPLTHREAD_H_INCLUDED) 10 | #define MPIIMPLTHREAD_H_INCLUDED 11 | 12 | /* Rather than embed a conditional test in the MPICH2 code, we define a 13 | single value on which we can test */ 14 | #if (MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE) 15 | #define MPICH_IS_THREADED 1 16 | #endif 17 | 18 | #if (MPICH_THREAD_LEVEL >= MPI_THREAD_SERIALIZED) 19 | #include "mpid_thread.h" 20 | #endif 21 | 22 | typedef struct MPICH_ThreadInfo_t 23 | { 24 | int thread_provided; /* Provided level of thread support */ 25 | /* This is a special case for is_thread_main, which must be 26 | implemented even if MPICH2 itself is single threaded. */ 27 | #if (MPICH_THREAD_LEVEL >= MPI_THREAD_SERIALIZED) 28 | MPID_Thread_tls_t thread_storage; /* Id for perthread data */ 29 | MPID_Thread_id_t master_thread; /* Thread that started MPI */ 30 | #endif 31 | } MPICH_ThreadInfo_t; 32 | extern MPICH_ThreadInfo_t MPIR_ThreadInfo; 33 | 34 | /* 35 | * Get a pointer to the thread's private data 36 | * Also define a macro to release any storage that may be allocated 37 | * by Malloc to ensure that memory leak tools don't report this when 38 | * there is no real leak. 39 | */ 40 | #ifndef MPICH_IS_THREADED 41 | 42 | #define MPIR_GetPerThread() \ 43 | (&MPIR_Thread) 44 | 45 | #else 46 | 47 | /* Define a macro to acquire or create the thread private storage */ 48 | static inline MPICH_PerThread_t* MPIR_GetOrInitThreadPriv(void) 49 | { 50 | MPICH_PerThread_t* pt; 51 | MPID_Thread_tls_get(&MPIR_ThreadInfo.thread_storage, &pt); 52 | if (pt == NULL) 53 | { 54 | pt = (MPICH_PerThread_t *) MPIU_Calloc(1, sizeof(MPICH_PerThread_t)); 55 | MPID_Thread_tls_set(&MPIR_ThreadInfo.thread_storage, pt); 56 | } 57 | 58 | return pt; 59 | } 60 | 61 | #define MPIR_GetPerThread() \ 62 | MPIR_GetOrInitThreadPriv() 63 | 64 | #endif /* MPICH_IS_THREADED */ 65 | 66 | #endif /* !defined(MPIIMPLTHREAD_H_INCLUDED) */ 67 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/mpi_fortlogical.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * (C) 2001 by Argonne National Laboratory. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | 10 | #ifndef MPI_FORTLOGICAL_H_INCLUDED 11 | #define MPI_FORTLOGICAL_H_INCLUDED 12 | 13 | /* Fortran logical values */ 14 | #define MPIR_F_TRUE 1 15 | #define MPIR_F_FALSE 0 16 | 17 | /* 18 | Note on true and false. This code is only an approximation. 19 | Some systems define either true or false, and allow some or ALL other 20 | patterns for the other. This is just like C, where 0 is false and 21 | anything not zero is true. Modify this test as necessary for your 22 | system. 23 | 24 | We check against FALSE instead of TRUE because many (perhaps all at this 25 | point) Fortran compilers use 0 for false and some non-zero value for 26 | true. By using this test, it is possible to use the same Fortran 27 | interface library for multiple compilers that differ only in the 28 | value used for Fortran .TRUE. . 29 | */ 30 | #define MPIR_FROM_FLOG(a) ( (a) == MPIR_F_FALSE ? 0 : 1 ) 31 | #define MPIR_TO_FLOG(a) ((a) ? MPIR_F_TRUE : MPIR_F_FALSE) 32 | 33 | 34 | // 35 | // operators to support logical operations on MPI_Fint (MPI_LOGICAL) 36 | // 37 | class FLogical 38 | { 39 | MPI_Fint _val; 40 | private: 41 | FLogical( MPI_Fint val ) : _val( val ){} 42 | 43 | public: 44 | FLogical operator||( const FLogical& rhs ) const 45 | { 46 | if( rhs._val != MPIR_F_FALSE || _val != MPIR_F_FALSE ) 47 | { 48 | return FLogical( MPIR_F_TRUE ); 49 | } 50 | return FLogical( MPIR_F_FALSE ); 51 | } 52 | 53 | FLogical operator&&( const FLogical& rhs ) const 54 | { 55 | if( rhs._val == MPIR_F_FALSE || _val == MPIR_F_FALSE ) 56 | { 57 | return FLogical( MPIR_F_FALSE ); 58 | } 59 | return FLogical( MPIR_F_TRUE ); 60 | } 61 | 62 | FLogical operator!() const 63 | { 64 | if( _val == MPIR_F_FALSE ) 65 | { 66 | return FLogical( MPIR_F_TRUE ); 67 | } 68 | return FLogical( MPIR_F_FALSE ); 69 | } 70 | }; 71 | 72 | #endif /* MPI_FORTLOGICAL_H_INCLUDED */ 73 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/Tls.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | template 7 | class SimpleAllocator 8 | { 9 | public: 10 | T* Allocate() 11 | { 12 | return new T; 13 | } 14 | void Free(T* p) 15 | { 16 | delete p; 17 | } 18 | }; 19 | 20 | 21 | template> 22 | class Tls 23 | { 24 | public: 25 | typedef typename T ElementType; 26 | typedef typename Tls ThisType; 27 | typedef typename AllocatorT ThisAllocator; 28 | 29 | public: 30 | DWORD SlotIndex; 31 | mutable ThisAllocator Allocator; 32 | 33 | public: 34 | Tls() 35 | : SlotIndex(::TlsAlloc()) 36 | , Allocator() 37 | { 38 | } 39 | ~Tls() 40 | { 41 | if (SlotIndex != TLS_OUT_OF_INDEXES) 42 | { 43 | ::TlsFree(SlotIndex); 44 | } 45 | } 46 | 47 | void DetachCurrentThread() const 48 | { 49 | if (SlotIndex != TLS_OUT_OF_INDEXES) 50 | { 51 | Allocator.Free( 52 | static_cast(::TlsGetValue(SlotIndex)) 53 | ); 54 | ::TlsSetValue(SlotIndex, nullptr); 55 | } 56 | } 57 | 58 | ElementType& Get() const 59 | { 60 | ElementType* p = nullptr; 61 | if (SlotIndex != TLS_OUT_OF_INDEXES) 62 | { 63 | p = static_cast(::TlsGetValue(SlotIndex)); 64 | if (p == nullptr) 65 | { 66 | p = Allocator.Allocate(); 67 | if (p != nullptr) 68 | { 69 | ::TlsSetValue(SlotIndex, p); 70 | } 71 | } 72 | } 73 | 74 | // 75 | // we consider it fatal if pointer is null, so we perform an 76 | // invariant assert so we can fail FRE builds as well as debug. 77 | // 78 | MPIU_Assertp(nullptr != p); 79 | 80 | return *p; 81 | } 82 | 83 | 84 | ElementType* operator ->() 85 | { 86 | return &Get(); 87 | } 88 | 89 | private: 90 | Tls(const ThisType& other); 91 | ThisType& operator = (const ThisType& other); 92 | }; 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/vc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * (C) 2009 by Microsoft Corporation. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifndef VC_H 13 | #define VC_H 14 | 15 | struct MPIDI_VC_t; 16 | 17 | /*S 18 | * MPIDI_VCRT - virtual connection reference table 19 | * 20 | * handle - this element is not used, but exists so that we may use the 21 | * MPIU_Object routines for reference counting 22 | * 23 | * ref_count - number of references to this table 24 | * 25 | * vcr_table - array of virtual connection references 26 | S*/ 27 | struct MPIDI_VCRT_t 28 | { 29 | int handle; 30 | volatile long ref_count; 31 | int size; 32 | MPIDI_VC_t* vcr_table[1]; 33 | }; 34 | 35 | typedef struct MPIDI_VCRT_t MPID_VCRT; 36 | typedef struct MPIDI_VC_t* MPID_VCR; 37 | 38 | /*@ 39 | MPID_VCRT_Create - Create a virtual connection reference table 40 | @*/ 41 | MPID_VCRT* MPID_VCRT_Create(int size); 42 | 43 | /*@ 44 | MPID_VCRT_Add_ref - Add a reference to a VCRT 45 | @*/ 46 | void MPID_VCRT_Add_ref(MPID_VCRT* vcrt); 47 | 48 | /*@ 49 | MPID_VCRT_Release - Release a reference to a VCRT 50 | 51 | Notes: 52 | The 'isDisconnect' argument allows this routine to handle the special 53 | case of 'MPI_Comm_disconnect', which needs to take special action 54 | if all references to a VC are removed. 55 | @*/ 56 | int MPID_VCRT_Release(MPID_VCRT* vcrt, int isDisconnect); 57 | 58 | /*@ 59 | MPID_VCRT_Get_ptr - 60 | @*/ 61 | MPID_VCR* MPID_VCRT_Get_ptr(MPID_VCRT* vcrt); 62 | 63 | /*@ 64 | MPID_VCR_Dup - Create a duplicate reference to a virtual connection 65 | @*/ 66 | _Ret_notnull_ 67 | MPID_VCR MPID_VCR_Dup( _Inout_ MPID_VCR orig_vcr ); 68 | 69 | /*@ 70 | MPID_VCR_Get_lpid - Get the local process id that corresponds to a 71 | virtual connection reference. 72 | 73 | Notes: 74 | The local process ids are described elsewhere. Basically, they are 75 | a nonnegative number by which this process can refer to other processes 76 | to which it is connected. These are local process ids because different 77 | processes may use different ids to identify the same target process 78 | @*/ 79 | int MPID_VCR_Get_lpid(const MPIDI_VC_t *vcr); 80 | 81 | 82 | 83 | #endif // VC_H 84 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/progress.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * (C) 2009 by Microsoft Corporation. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifndef PROGRESS_H 13 | #define PROGRESS_H 14 | 15 | int MPIDI_CH3I_Progress_init(void); 16 | int MPIDI_CH3I_Progress_finalize(void); 17 | 18 | 19 | /*@ 20 | MPID_Progress_wait - Wait for some communication 21 | 22 | Return value: 23 | An mpi error code. 24 | 25 | Notes: 26 | This instructs the progress engine to wait until some communication event 27 | happens since 'MPID_Progress_start' was called. This call blocks the 28 | calling thread (only, not the process). 29 | 30 | @*/ 31 | int MPID_Progress_wait(void); 32 | 33 | /*@ 34 | MPID_Progress_pump - Allow a progress engine to check for pending communication 35 | 36 | Return value: 37 | An mpi error code. 38 | 39 | Notes: 40 | This routine provides a way to invoke the progress engine in a polling 41 | implementation of the ADI. This routine must be nonblocking. 42 | 43 | @*/ 44 | int MPID_Progress_pump(void); 45 | 46 | 47 | /* 48 | * CH3 Progress routines (implemented as macros for performanace) 49 | */ 50 | int MPIDI_CH3I_Progress(DWORD timeout, bool interruptible); 51 | #define MPID_Progress_wait() MPIDI_CH3I_Progress(INFINITE, false) 52 | #define MPID_Progress_pump() MPIDI_CH3I_Progress(0, false) 53 | #define MPID_Progress_wait_interruptible() MPIDI_CH3I_Progress(INFINITE, true) 54 | 55 | MPI_RESULT MPIDI_CH3I_DeferConnect(_In_ struct MPIDI_VC_t* vc, _In_ struct MPID_Request* sreq); 56 | MPI_RESULT MPIDI_CH3I_DeferWrite(_In_ MPIDI_VC_t* vc, _In_ MPID_Request* sreq); 57 | 58 | // 59 | // Stalls the caller for the specified timeout (in milliseconds), but makes progress 60 | // on outstanding MPI operations. 61 | // 62 | // NOTE: Because this function calls into the progress engine, it should never be used 63 | // from paths that could be called by the progress engine, to prevent recursion. 64 | // 65 | int MPIU_Sleep(DWORD timeout); 66 | 67 | 68 | // 69 | // CH3 completion set. 70 | // Completions posted to this 'set' will be executed through the progress engine 71 | // and will wake it up from a wait state. 72 | // 73 | extern ExSetHandle_t MPIDI_CH3I_set; 74 | 75 | 76 | #endif // PROGRESS_H 77 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/spawn.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * (C) 2009 by Microsoft Corporation. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifndef SPAWN_H 13 | #define SPAWN_H 14 | 15 | MPI_RESULT 16 | MPID_Open_port( 17 | _In_opt_ MPID_Info*, 18 | _Out_z_cap_(MPI_MAX_PORT_NAME) char *port_name 19 | ); 20 | 21 | MPI_RESULT 22 | MPID_Close_port( 23 | _In_z_ const char *port_name 24 | ); 25 | 26 | /*@ 27 | MPID_Comm_accept - MPID entry point for MPI_Comm_accept 28 | 29 | Input Parameters: 30 | + port_name - port name 31 | . info - info 32 | . root - root 33 | - comm - communicator 34 | 35 | Output Parameters: 36 | . MPI_Comm *newcomm - new communicator 37 | 38 | Return Value: 39 | 'MPI_SUCCESS' or a valid MPI error code. 40 | @*/ 41 | MPI_RESULT 42 | MPID_Comm_accept( 43 | _In_z_ const char* port_name, 44 | _In_opt_ const MPID_Info* info, 45 | _In_ int root, 46 | _In_ const MPID_Comm* comm_ptr, 47 | _Out_ MPID_Comm** newcomm 48 | ); 49 | 50 | /*@ 51 | MPID_Comm_connect - MPID entry point for MPI_Comm_connect 52 | 53 | Input Parameters: 54 | + port_name - port name 55 | . info - info 56 | . root - root 57 | - comm - communicator 58 | 59 | Output Parameters: 60 | . newcomm_ptr - new intercommunicator 61 | 62 | Return Value: 63 | 'MPI_SUCCESS' or a valid MPI error code. 64 | @*/ 65 | MPI_RESULT 66 | MPID_Comm_connect( 67 | _In_z_ const char* port_name, 68 | _In_opt_ const MPID_Info* info, 69 | _In_ int root, 70 | _In_ const MPID_Comm* comm_ptr, 71 | _Out_ MPID_Comm** newcomm 72 | ); 73 | 74 | MPI_RESULT MPID_Comm_disconnect(MPID_Comm *); 75 | 76 | MPI_RESULT 77 | MPID_Comm_spawn_multiple( 78 | _In_ int count, 79 | _In_z_ char* commands[], 80 | _In_z_ char** arguments[], 81 | _In_ const int* maxprocs, 82 | _In_ MPID_Info** info, 83 | _In_ int root, 84 | _In_ MPID_Comm* comm, 85 | _Out_ MPID_Comm** intercomm, 86 | _Out_ int * errcodes 87 | ); 88 | 89 | MPI_RESULT MPID_Comm_join(_In_ SOCKET fd, _Out_ MPI_Comm *intercomm); 90 | 91 | #endif // SPAWN_H 92 | -------------------------------------------------------------------------------- /src/mpi/msmpi/dll/mpitrace.mof: -------------------------------------------------------------------------------- 1 | #pragma autorecover 2 | #pragma classflags("forceupdate") 3 | #pragma namespace("\\\\.\\root\\WMI") 4 | 5 | 6 | // 7 | // MSMPI Trace Providers 8 | // 9 | [Dynamic, 10 | Description("MSMPI"), 11 | guid("{5b09c0bf-453f-43e6-b344-435148a14443}"), 12 | locale("MS\\0x409")] 13 | class MSMPI:EventTrace 14 | { 15 | [Description ("Enable Components"), 16 | ValueDescriptions 17 | { 18 | "All APIs and communication", 19 | "All APIs", 20 | "Point to point APIs", 21 | "Point to point polling APIs (MPI_Iprobe, MPI_Test***)", 22 | "Collective APIs", 23 | "One sided APIs", 24 | "Comm APIs", 25 | "Error handler APIs", 26 | "Group APIs", 27 | "Attribute APIs", 28 | "Datatype APIs", 29 | "IO APIs", 30 | "Topology APIs", 31 | "Dynamic processes APIs", 32 | "Initialization APIs", 33 | "Info APIs", 34 | "Misc APIs", 35 | "All Interconnects Communication", 36 | "Sockets Interconnect Communication", 37 | "Shared Memory Interconnect Communication", 38 | "Network Direct Interconnect Communiation" 39 | }, 40 | Values 41 | { 42 | "ALL", 43 | "API", 44 | "PT2PT", 45 | "POLL", 46 | "COLL", 47 | "RMA", 48 | "COMM", 49 | "ERRH", 50 | "GROUP", 51 | "ATTR", 52 | "DTYPE", 53 | "IO", 54 | "TOPO", 55 | "SPAWN", 56 | "INIT", 57 | "INFO", 58 | "MISC", 59 | "INTERCONN", 60 | "ICSOCK", 61 | "ICSHM", 62 | "ICND" 63 | }, 64 | ValueMap 65 | { 66 | "0xFFFFFFFF", 67 | "0x00007FFF", 68 | "0x00000001", 69 | "0x00000002", 70 | "0x00000004", 71 | "0x00000008", 72 | "0x00000010", 73 | "0x00000020", 74 | "0x00000040", 75 | "0x00000080", 76 | "0x00000100", 77 | "0x00000200", 78 | "0x00000400", 79 | "0x00000800", 80 | "0x00001000", 81 | "0x00002000", 82 | "0x00004000", 83 | "0x000F8000", 84 | "0x00008000", 85 | "0x00010000", 86 | "0x00020000" 87 | } 88 | ] 89 | uint32 Flags; 90 | }; 91 | 92 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_init_sshm.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #include "precomp.h" 10 | #include "mpidi_ch3_impl.h" 11 | #include "pmi.h" 12 | 13 | static int getNumProcessors( void ); 14 | static int getNodeRootRank( int, int * ); 15 | 16 | 17 | /* 18 | * The shared memory local bootstrapQ and it's access function 19 | */ 20 | static MPIDI_CH3I_BootstrapQ g_sshm_bootstrapQ = NULL; 21 | 22 | MPIDI_CH3I_BootstrapQ MPIDI_CH3U_BootstrapQ_sshm() 23 | { 24 | MPIU_Assert(g_sshm_bootstrapQ != NULL); 25 | return g_sshm_bootstrapQ; 26 | } 27 | 28 | 29 | /* 30 | * The shared memory local hostname and it's access function 31 | */ 32 | static char g_sshm_hostname[MAXHOSTNAMELEN] = {0}; 33 | 34 | const char* MPIDI_CH3U_Hostname_sshm() 35 | { 36 | MPIU_Assert(g_sshm_hostname[0] != '\0'); 37 | return g_sshm_hostname; 38 | } 39 | 40 | /* MPIDI_CH3U_Init_sshm - does scalable shared memory specific channel 41 | * initialization 42 | * 43 | */ 44 | 45 | /* This routine is used only by channels/{sshm,ssm}/src/ch3_init.c */ 46 | 47 | void MPIDI_CH3U_Init_sshm(int /*has_parent*/, int /*pg_rank*/) 48 | { 49 | MPIDI_CH3I_Process.shm_reading_list = NULL; 50 | MPIDI_CH3I_Process.shm_writing_list = NULL; 51 | 52 | gethostname(g_sshm_hostname, _countof(g_sshm_hostname)); 53 | 54 | MPIDI_CH3I_BootstrapQ_create(&g_sshm_bootstrapQ); 55 | MPIDI_CH3I_Notify_accept_connect(MPIDI_CH3I_Accept_shm_connection); 56 | MPIDI_CH3I_Notify_accept_message(MPIDI_CH3I_Accept_shm_message); 57 | } 58 | 59 | 60 | void MPIDI_PG_Init_sshm(MPIDI_PG_t * pg) 61 | { 62 | /* 63 | * Extra pg ref needed for shared memory modules because the 64 | * shm_XXXXing_list's 65 | * need to be walked though in the later stages of finalize to 66 | * free queue_info's. 67 | */ 68 | MPIDI_PG_add_ref(pg); 69 | } 70 | 71 | 72 | /* This routine initializes shm-specific elements of the VC */ 73 | void MPIDI_VC_Init_sshm( MPIDI_VC_t *vc ) 74 | { 75 | vc->ch.shm.recv.next_vc = NULL; 76 | vc->ch.shm.recv.request = NULL; 77 | vc->ch.shm.recv.shm = NULL; 78 | vc->ch.shm.recv.connected = 0; 79 | vc->ch.shm.recv.slot_offset = 0; 80 | 81 | vc->ch.shm.send.next_vc = NULL; 82 | vc->ch.shm.send.shm = NULL; 83 | 84 | vc->ch.shm.queue = NULL; 85 | vc->ch.shm.state = 0; 86 | 87 | vc->ch.shm.send.wait_for_rma = FALSE; 88 | vc->ch.shm.recv.hProcess = NULL; 89 | } 90 | -------------------------------------------------------------------------------- /src/launchSvc/msmpiLaunchSvc.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | msmpiLaunchSvc 8 | {03cfde58-e72e-41d7-85ed-43150db0ca44} 9 | 10 | 11 | 12 | Microsoft MPI Launch Service 13 | 14 | 15 | 16 | false 17 | Application 18 | 19 | 20 | 21 | 22 | 23 | 24 | ProgramDatabase 25 | 26 | %(AdditionalIncludeDirectories); 27 | $(SrcRoot)\mpi\msmpi\include; 28 | $(SrcRoot)\mpi\common; 29 | .\$(O); 30 | 31 | 32 | 33 | 34 | 35 | Console 36 | wmainCRTStartup 37 | 38 | %(AdditionalDependencies); 39 | $(PUBLIC_SDK_LIB)\kernel32.lib; 40 | $(PUBLIC_SDK_LIB)\crypt32.lib; 41 | $(PUBLIC_SDK_LIB)\advapi32.lib; 42 | $(PUBLIC_SDK_LIB)\userenv.lib; 43 | $(CRT_Libs); 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | $(MPI_BIN_DESTINATION) 64 | *.exe 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/mpierrs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * 6 | * (C) 2001 by Argonne National Laboratory. 7 | * See COPYRIGHT in top-level directory. 8 | */ 9 | #ifndef MPIERRS_H_INCLUDED 10 | #define MPIERRS_H_INCLUDED 11 | /* ------------------------------------------------------------------------- */ 12 | /* mpierrs.h */ 13 | /* ------------------------------------------------------------------------- */ 14 | 15 | #define FCNAME __FUNCTION__ 16 | 17 | 18 | struct MPID_Comm; 19 | struct MPID_Win; 20 | /*struct MPID_File;*/ 21 | 22 | /* Bindings for internal routines */ 23 | _Post_satisfies_( return != MPI_SUCCESS ) 24 | MPI_RESULT 25 | MPIR_Err_return_comm( 26 | _In_opt_ MPID_Comm* comm_ptr, 27 | _In_ PCSTR fcname, 28 | _In_ MPI_RESULT errcode 29 | ); 30 | 31 | 32 | _Post_satisfies_( return != MPI_SUCCESS ) 33 | MPI_RESULT 34 | MPIR_Err_return_win( 35 | _In_opt_ MPID_Win* win_ptr, 36 | _In_ PCSTR fcname, 37 | _In_ MPI_RESULT errcode 38 | ); 39 | 40 | /*int MPIR_Err_return_file( struct MPID_File *, const char [], int );*/ 41 | #ifdef MPI__FILE_DEFINED 42 | /* Only define if we have MPI_File */ 43 | _Post_equals_last_error_ 44 | int MPIR_Err_return_file( MPI_File, const char [], int ); /* Romio version */ 45 | #endif 46 | 47 | 48 | /* Valid pointer checks */ 49 | /* This test is lame. Should eventually include cookie test 50 | and in-range addresses */ 51 | #define MPID_Valid_ptr_class(kind,ptr,errclass,err) \ 52 | { \ 53 | if (!(ptr)) \ 54 | { \ 55 | err = MPIU_ERR_CREATE(errclass, "**nullptrtype %s", #kind ); \ 56 | __analysis_assume(err != MPI_SUCCESS); \ 57 | } \ 58 | else \ 59 | { \ 60 | __analysis_assume(ptr != NULL); \ 61 | } \ 62 | } 63 | 64 | #define MPID_Win_valid_ptr(ptr,err) MPID_Valid_ptr_class(Win,ptr,MPI_ERR_WIN,err) 65 | #define MPID_Op_valid_ptr(ptr,err) MPID_Valid_ptr_class(Op,ptr,MPI_ERR_OP,err) 66 | 67 | /* ------------------------------------------------------------------------- */ 68 | /* end of mpierrs.h */ 69 | /* ------------------------------------------------------------------------- */ 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/mpidi_ch3_pre.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #if !defined(MPICH_MPIDI_CH3_PRE_H_INCLUDED) 10 | #define MPICH_MPIDI_CH3_PRE_H_INCLUDED 11 | 12 | namespace CH3_ND 13 | { 14 | class Endpoint; 15 | 16 | namespace v1 17 | { 18 | class CEndpoint; 19 | } 20 | } 21 | 22 | typedef HANDLE MPIDI_CH3I_BootstrapQ; 23 | 24 | enum MPIDI_CH3I_VC_state_t 25 | { 26 | MPIDI_CH3I_VC_STATE_UNCONNECTED, 27 | MPIDI_CH3I_VC_STATE_CONNECTING, 28 | MPIDI_CH3I_VC_STATE_PENDING_ACCEPT, 29 | MPIDI_CH3I_VC_STATE_ACCEPTED, 30 | MPIDI_CH3I_VC_STATE_CONNECTED, 31 | MPIDI_CH3I_VC_STATE_FAILED 32 | }; 33 | 34 | 35 | struct MPIDI_CH3I_SHM_info_t 36 | { 37 | struct MPIDI_CH3I_SHM_Queue_t *addr; 38 | unsigned int size; 39 | HANDLE hShm; 40 | }; 41 | 42 | 43 | struct MPIDI_CH3I_Request_Queue_t 44 | { 45 | struct MPID_Request * head; 46 | struct MPID_Request * tail; 47 | mutable MPI_LOCK lock; 48 | }; 49 | 50 | 51 | struct MPIDI_CH3I_SHM_recv_t 52 | { 53 | MPIDI_VC_t* next_vc; 54 | struct MPID_Request* request; 55 | struct MPIDI_CH3I_SHM_Queue_t* shm; 56 | MPIDI_CH3I_SHM_info_t shm_info; 57 | MPIU_Bsize_t slot_offset; 58 | int connected; 59 | HANDLE hProcess; 60 | }; 61 | 62 | 63 | struct MPIDI_CH3I_SHM_send_t 64 | { 65 | MPIDI_VC_t* next_vc; 66 | struct MPIDI_CH3I_SHM_Queue_t* shm; 67 | MPIDI_CH3I_SHM_info_t shm_info; 68 | BOOL wait_for_rma; 69 | }; 70 | 71 | 72 | struct MPIDI_CH3I_SHM_VC_t 73 | { 74 | MPIDI_CH3I_SHM_recv_t recv; 75 | MPIDI_CH3I_SHM_send_t send; 76 | MPIDI_CH3I_BootstrapQ queue; 77 | int state; 78 | }; 79 | 80 | 81 | union MPIDI_CH3I_ND_VC_t 82 | { 83 | CH3_ND::Endpoint* pEp; 84 | CH3_ND::v1::CEndpoint* pEpV1; 85 | }; 86 | 87 | 88 | enum MPIDI_CH3I_CH_TYPE_t 89 | { 90 | MPIDI_CH3I_CH_TYPE_SHM, 91 | MPIDI_CH3I_CH_TYPE_ND, 92 | MPIDI_CH3I_CH_TYPE_NDv1, 93 | MPIDI_CH3I_CH_TYPE_SOCK 94 | }; 95 | 96 | 97 | struct MPIDI_CH3I_VC_t 98 | { 99 | MPIDI_CH3I_Request_Queue_t sendq; 100 | MPIDI_CH3I_SHM_VC_t shm; 101 | MPIDI_CH3I_ND_VC_t nd; 102 | struct MPIDI_CH3I_Connection_t* conn; 103 | MPIDI_CH3I_VC_state_t state; 104 | MPIDI_CH3I_CH_TYPE_t channel; 105 | volatile long n_recv; 106 | volatile long n_sent; 107 | }; 108 | 109 | 110 | 111 | #endif /* !defined(MPICH_MPIDI_CH3_PRE_H_INCLUDED) */ 112 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd1_mw.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3u_nd_mw.h - Network Direct MPI CH3 Channel Memory Window 7 | 8 | --*/ 9 | 10 | #pragma once 11 | 12 | 13 | namespace CH3_ND 14 | { 15 | namespace v1 16 | { 17 | 18 | class CAdapter; 19 | class CMr; 20 | class CEndpoint; 21 | 22 | class CMw 23 | { 24 | friend class ListHelper; 25 | private: 26 | CMw(); 27 | ~CMw(); 28 | int Init( CAdapter* pAdapter ); 29 | 30 | public: 31 | static 32 | MPI_RESULT 33 | Create( 34 | _In_ CAdapter* pAdapter, 35 | _Outptr_ CMw** ppMw 36 | ); 37 | 38 | public: 39 | LONG AddRef() 40 | { 41 | return ::InterlockedIncrement(&m_nRef); 42 | } 43 | 44 | void Release(); 45 | 46 | INDMemoryWindow* IMw(){ return m_pIMw.get(); } 47 | 48 | void 49 | Bind( 50 | __in CEndpoint* pEp, 51 | __in CMr* pMr, 52 | __in nd_result_t::CompletionRoutine pfnBindSucceeded, 53 | __in nd_result_t::CompletionRoutine pfnBindFailed, 54 | __in nd_result_t::CompletionRoutine pfnInvalidateSucceeded, 55 | __in nd_result_t::CompletionRoutine pfnInvalidateFailed 56 | ); 57 | 58 | void Unbind(); 59 | 60 | inline CEndpoint* Ep(){ return m_pEp.get(); } 61 | 62 | inline ND_RESULT* BindResult(){ return &m_BindResult; } 63 | inline ND_RESULT* InvalidateResult(){ return &m_InvalidateResult; } 64 | 65 | static 66 | inline 67 | CMw* 68 | FromBindResult( 69 | __in nd_result_t* pResult 70 | ) 71 | { 72 | return CONTAINING_RECORD( pResult, CMw, m_BindResult ); 73 | } 74 | 75 | static 76 | inline 77 | CMw* 78 | FromInvalidateResult( 79 | __in nd_result_t* pResult 80 | ) 81 | { 82 | return CONTAINING_RECORD( pResult, CMw, m_InvalidateResult ); 83 | } 84 | 85 | private: 86 | LIST_ENTRY m_link; 87 | 88 | volatile LONG m_nRef; 89 | 90 | StackGuardRef m_pIMw; 91 | 92 | nd_result_t m_BindResult; 93 | // 94 | // The ND SPI requires that an invalidate result be provided when creating a MW, 95 | // for use when using Send w/ invalidate. We don't use send w/ invalidate, though 96 | // we do use this same result for explicit invalidation. 97 | // 98 | nd_result_t m_InvalidateResult; 99 | 100 | StackGuardRef m_pMr; 101 | StackGuardRef m_pEp; 102 | 103 | }; 104 | 105 | } // namespace v1 106 | } // namespace CH3_ND 107 | -------------------------------------------------------------------------------- /examples/helloworld/Run_MPIHelloWorld.md: -------------------------------------------------------------------------------- 1 | ## Compile and run a sample MPI code on Windows 2 | 1. Download MS-MPI SDK and Redist installers and install them. The download link to a stable realease is available from [this](https://github.com/microsoft/Microsoft-MPI/releases) page. 3 | 2. After installation, you can verify that the MS-MPI environment variables have been set correctly (you will want to use these environment variables in Visual Studio) 4 | ![inline](./screenshots/set_msmpi.png) 5 | 3. Open Visual Studio and create a Console App project. Let's name the project `MPIHelloWorld` 6 | * Instead of creating a project, you may open the provided `MPIHelloWorld.vcxproj` project file in Visual Studio and go to step 7. 7 | 4. Use [this](MPIHelloWorld.cpp) code in the newly created project 8 | 5. Setup the include directories so that the compiler can find the MS-MPI header files. Note that we will be building 9 | for 64 bits so we will point the include directory to `$(MSMPI_INC);$(MSMPI_INC)\x64`. If you will be building for 32 bits 10 | please use `$(MSMPI_INC);$(MSMPI_INC)\x86` 11 | ![inline](./screenshots/inc_dir.png) 12 | 6. Setup the linker options. Add `msmpi.lib` to the Additional Dependencies and also add `$(MSMPI_LIB64)` to the Additional 13 | Library Directories. Note that we will be building for 64 bits so we will point the Additional Library Directories to $(MSMPI_LIB64). 14 | If you will be building for 32 bits please use `$(MSMPI_LIB32)` 15 | ![inline](./screenshots/lib_dir.png) 16 | 7. Build the MPIHelloWorld project 17 | ![inline](./screenshots/vs_build.png) 18 | 8. Test run the program on the command line 19 | ![inline](./screenshots/mpiexec.png) 20 | 21 | Alternatively, you can use Developer Command Prompt for your version of Visual Studio to compile and link the `MPIHelloWorld.cpp` 22 | code (replacing steps 3-7 above). To build a 64-bit application, choose x64 Native Tools Command Prompt from the Visual Studio folder 23 | in the Start menu. 24 | ![inline](./screenshots/x64_prompt.png) 25 | 26 | To compile your program into an `.obj` file, go to the folder where `MPIHelloWorld.cpp` exists and run (you may ignore the warning message):
27 | `cl /I"C:\Program Files (x86)\Microsoft SDKs\MPI\Include" /c MPIHelloWorld.cpp` 28 | ![inline](./screenshots/compile.png) 29 | 30 | To create an executable file from the .obj file created in the previous step, run:
31 | `link /machine:x64 /out:MPIHelloWorld.exe "msmpi.lib" /libpath:"C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64" MPIHelloWorld.obj` 32 | ![inline](./screenshots/link.png) 33 | 34 | You may use the `nmake` command from Developer Command Prompt to compile and build the exmaple using the provided [`Makefile`](Makefile). 35 | -------------------------------------------------------------------------------- /src/mpi/common/Util.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "precomp.h" 5 | #include "util.h" 6 | #include "kernel32util.h" 7 | 8 | // 9 | // Summary: 10 | // Ensure that the OS version is greater than or equal to the specified version. 11 | // 12 | // Parameters: 13 | // major - Windows major version 14 | // minor - Windows minor version 15 | // 16 | _Success_(return!=FALSE) 17 | BOOL 18 | CheckOSVersion( 19 | _In_ DWORD major, 20 | _In_ DWORD minor 21 | ) 22 | { 23 | OSVERSIONINFOEX version = {}; 24 | ULONG mask = VER_MAJORVERSION | VER_MINORVERSION; 25 | ULONGLONG conditions = 0; 26 | 27 | version.dwOSVersionInfoSize = sizeof(version); 28 | version.dwMajorVersion = major; 29 | version.dwMinorVersion = minor; 30 | 31 | conditions = ::VerSetConditionMask( conditions, VER_MAJORVERSION, VER_GREATER_EQUAL ); 32 | conditions = ::VerSetConditionMask( conditions, VER_MINORVERSION, VER_GREATER_EQUAL ); 33 | 34 | return ::VerifyVersionInfo( &version, mask, conditions ); 35 | } 36 | 37 | 38 | static const wchar_t * const AZURE_REGISTRY_VALUE = L"NodeLogicalName"; 39 | static const wchar_t * const AZURE_REGISTRY_KEY = L"SOFTWARE\\MICROSOFT\\HPC"; 40 | 41 | // 42 | // Summary: 43 | // Check if the smpd instance is running on azure and if so, 44 | // return the logical name of the node 45 | // 46 | // Input: 47 | // szBuffer: the size of the name buffer 48 | // 49 | // Output: 50 | // buffer : store the logical name. If null, name is not returned 51 | // 52 | // Return: 53 | // true if the node is on azure 54 | // false if the node is not on azure, or if the size of the buffer is 55 | // too small 56 | // 57 | // 58 | bool get_azure_node_logical_name( 59 | _Out_opt_z_cap_(szBuffer) wchar_t* buffer, 60 | _In_ DWORD szBuffer ) 61 | { 62 | HKEY key; 63 | DWORD size = szBuffer - 1; 64 | DWORD status = RegOpenKeyExW( HKEY_LOCAL_MACHINE, 65 | AZURE_REGISTRY_KEY, 66 | NULL, 67 | KEY_READ, 68 | &key ); 69 | 70 | if( status != ERROR_SUCCESS ) 71 | { 72 | return false; 73 | } 74 | 75 | status = RegQueryValueExW( key, 76 | AZURE_REGISTRY_VALUE, 77 | NULL, 78 | NULL, 79 | reinterpret_cast(buffer), 80 | &size ); 81 | 82 | RegCloseKey( key ); 83 | 84 | if( status != ERROR_SUCCESS ) 85 | { 86 | return false; 87 | } 88 | 89 | if( buffer != NULL ) 90 | { 91 | buffer[size] = L'\0'; 92 | } 93 | 94 | return true; 95 | } -------------------------------------------------------------------------------- /src/mpi/smpd/mgr_abort.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #include "precomp.h" 9 | #include "smpd.h" 10 | 11 | 12 | // 13 | // TODO: Need to investigate the return path of this function 14 | // It seems like mpiexec_handle_abort does not return a result 15 | // 16 | static DWORD 17 | smpd_send_abort_command( 18 | const wchar_t* error_str 19 | ) 20 | { 21 | SmpdCmd* pCmd = smpd_create_command( 22 | SMPD_ABORT, 23 | smpd_process.tree_id, 24 | SMPD_IS_ROOT ); 25 | if( pCmd == nullptr ) 26 | { 27 | smpd_err_printf(L"unable to create an abort command.\n"); 28 | return ERROR_NOT_ENOUGH_MEMORY; 29 | } 30 | 31 | size_t len = MPIU_Strlen(error_str) + 1; 32 | pCmd->AbortCmd.error_msg = static_cast( 33 | midl_user_allocate( len * sizeof(wchar_t) )); 34 | if( pCmd->AbortCmd.error_msg == nullptr ) 35 | { 36 | delete pCmd; 37 | smpd_err_printf(L"unable to create an abort command.\n"); 38 | return ERROR_NOT_ENOUGH_MEMORY; 39 | } 40 | 41 | MPIU_Strcpy( pCmd->AbortCmd.error_msg, len, error_str ); 42 | 43 | SmpdResWrapper* pRes = smpd_create_result_command( 44 | smpd_process.tree_id, 45 | nullptr ); 46 | if( pRes == nullptr ) 47 | { 48 | midl_user_free(pCmd->AbortCmd.error_msg); 49 | delete pCmd; 50 | smpd_err_printf(L"unable to create result for 'abort' command.\n"); 51 | return ERROR_NOT_ENOUGH_MEMORY; 52 | } 53 | 54 | smpd_dbg_printf(L"sending abort command to parent context.\n"); 55 | DWORD rc = smpd_post_command( 56 | smpd_process.parent_context, 57 | pCmd, 58 | &pRes->Res, 59 | nullptr ); 60 | if( rc != NOERROR ) 61 | { 62 | midl_user_free(pCmd->AbortCmd.error_msg); 63 | delete pCmd; 64 | delete pRes; 65 | smpd_err_printf(L"Unable to add the error string to the abort command.\n"); 66 | } 67 | 68 | return rc; 69 | } 70 | 71 | 72 | void smpd_post_abort_command(const wchar_t *fmt, ...) 73 | { 74 | wchar_t error_str[2048] = L""; 75 | va_list list; 76 | 77 | va_start(list, fmt); 78 | MPIU_Vsnprintf(error_str, _countof(error_str), fmt, list); 79 | va_end(list); 80 | 81 | if(smpd_process.parent_context == NULL) 82 | { 83 | fwprintf(stderr, L"\nAborting: %s\n", error_str); 84 | fflush(stderr); 85 | smpd_signal_exit_progress(MPI_ERR_INTERN); 86 | } 87 | 88 | int rc = smpd_send_abort_command(error_str); 89 | if(rc != MPI_SUCCESS) 90 | { 91 | smpd_err_printf(L"unable to send abort command to the parent context.\n"); 92 | smpd_signal_exit_progress(rc); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/mpi/pmilib/smpd_overlapped.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #ifndef SMPD_OVERLAPPED_H 9 | #define SMPD_OVERLAPPED_H 10 | 11 | 12 | typedef 13 | void 14 | (WINAPI * smpd_state_completion_routine)( 15 | struct EXOVERLAPPED* pOverlapped 16 | ); 17 | 18 | struct smpd_overlapped_t 19 | { 20 | // 21 | // Caller Executive overlapped. 22 | // * The success/failure callback functions will be invoked on Sock async 23 | // operation completion when MPIDU_Sock_wait is called. 24 | // * The total number of bytes transfered in a successful read/write 25 | // operation is in uov.ov.InernalHigh field of the OVERLAPPED strcture. 26 | // * The Sock MPI error value is in uov.ov.Internal 27 | // 28 | EXOVERLAPPED uov; 29 | 30 | SmpdCmd* pCmd; 31 | SmpdRes* pRes; 32 | RPC_ASYNC_STATE* pAsync; 33 | smpd_context_t* pContext; 34 | char* pPmiTmpBuffer; 35 | DWORD* pPmiTmpErr; 36 | }; 37 | 38 | 39 | static 40 | inline 41 | smpd_overlapped_t* 42 | smpd_ov_from_exov( 43 | EXOVERLAPPED* pexov 44 | ) 45 | { 46 | return CONTAINING_RECORD(pexov, smpd_overlapped_t, uov); 47 | } 48 | 49 | 50 | inline 51 | smpd_overlapped_t* 52 | smpd_create_overlapped() 53 | { 54 | smpd_overlapped_t* pov = new smpd_overlapped_t; 55 | if( pov == nullptr ) 56 | { 57 | return nullptr; 58 | } 59 | 60 | // 61 | // SMPD redirect stdin/out also uses smpd_overlapped 62 | // but does not need to use RPC Async structure so we 63 | // delay the async struct creation. 64 | // 65 | pov->pAsync = nullptr; 66 | 67 | return pov; 68 | } 69 | 70 | 71 | static 72 | inline 73 | int 74 | smpd_get_overlapped_result( 75 | const smpd_overlapped_t* pov 76 | ) 77 | { 78 | return ExGetStatus(&pov->uov); 79 | } 80 | 81 | 82 | static 83 | inline 84 | MPIU_Bsize_t 85 | smpd_get_bytes_transferred( 86 | const smpd_overlapped_t* pov 87 | ) 88 | { 89 | return ExGetBytesTransferred(&pov->uov); 90 | } 91 | 92 | 93 | static 94 | inline 95 | void 96 | smpd_init_overlapped( 97 | smpd_overlapped_t* pov, 98 | smpd_state_completion_routine pfn, 99 | smpd_context_t* pContext 100 | ) 101 | { 102 | ExInitOverlapped(&pov->uov, (ExCompletionRoutine)pfn, (ExCompletionRoutine)pfn); 103 | pov->pContext = pContext; 104 | pov->pPmiTmpBuffer = nullptr; 105 | pov->pPmiTmpErr = nullptr; 106 | } 107 | 108 | 109 | static 110 | inline 111 | void 112 | smpd_free_overlapped( 113 | smpd_overlapped_t* pov 114 | ) 115 | { 116 | delete pov; 117 | } 118 | 119 | 120 | #endif /* SMPD_OVERLAPPED_H */ 121 | -------------------------------------------------------------------------------- /src/mpi/msmpi/api/mpiapi.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | mpiapi 8 | {49a00e51-7f11-4a7f-a9ab-b361269dda3a} 9 | 10 | 11 | 12 | false 13 | StaticLibrary 14 | 15 | 16 | 17 | 18 | 19 | 20 | Use 21 | precomp.h 22 | $(IntDir)\pch_hdr.src 23 | 24 | %(AdditionalIncludeDirectories); 25 | $(MPI_SRC_ROOT)\msmpi\include; 26 | $(MPI_SRC_ROOT)\msmpi\mpid; 27 | $(MPI_SRC_ROOT)\msmpi\io; 28 | 29 | 30 | 31 | 32 | 33 | 34 | Create 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/ch3u_nd1_mw.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /*++ 5 | 6 | ch3u_nd_mw.cpp - Network Direct MPI CH3 Channel Memory Window 7 | 8 | --*/ 9 | 10 | 11 | #include "precomp.h" 12 | #include "ch3u_nd1.h" 13 | 14 | namespace CH3_ND 15 | { 16 | namespace v1 17 | { 18 | 19 | 20 | CMw::CMw() : 21 | m_nRef( 1 ) 22 | { 23 | m_BindResult.pfnSucceeded = NULL; 24 | m_BindResult.pfnFailed = NULL; 25 | 26 | m_InvalidateResult.pfnSucceeded = NULL; 27 | m_InvalidateResult.pfnFailed = NULL; 28 | } 29 | 30 | 31 | CMw::~CMw() 32 | { 33 | } 34 | 35 | 36 | int 37 | CMw::Init( 38 | CAdapter* pAdapter 39 | ) 40 | { 41 | HRESULT hr = pAdapter->IAdapter()->CreateMemoryWindow( 42 | &m_InvalidateResult, 43 | &m_pIMw.ref() 44 | ); 45 | if( FAILED( hr ) ) 46 | return MPIU_E_ERR( "**ch3|nd|create_mw %x", hr ); 47 | 48 | return MPI_SUCCESS; 49 | } 50 | 51 | 52 | MPI_RESULT 53 | CMw::Create( 54 | _In_ CAdapter* pAdapter, 55 | _Outptr_ CMw** ppMw 56 | ) 57 | { 58 | StackGuardRef pMw( new CMw() ); 59 | if( pMw.get() == NULL ) 60 | return MPIU_ERR_NOMEM(); 61 | 62 | int mpi_errno = pMw->Init( pAdapter ); 63 | if( mpi_errno != MPI_SUCCESS ) 64 | return MPIU_ERR_FAIL( mpi_errno ); 65 | 66 | *ppMw = pMw.detach(); 67 | return MPI_SUCCESS; 68 | } 69 | 70 | 71 | void 72 | CMw::Release() 73 | { 74 | MPIU_Assert( m_nRef > 0 ); 75 | 76 | long value = ::InterlockedDecrement(&m_nRef); 77 | if( value != 0 ) 78 | { 79 | return; 80 | } 81 | 82 | delete this; 83 | } 84 | 85 | 86 | void 87 | CMw::Bind( 88 | __in CEndpoint* pEp, 89 | __in CMr* pMr, 90 | __in nd_result_t::CompletionRoutine pfnBindSucceeded, 91 | __in nd_result_t::CompletionRoutine pfnBindFailed, 92 | __in nd_result_t::CompletionRoutine pfnInvalidateSucceeded, 93 | __in nd_result_t::CompletionRoutine pfnInvalidateFailed 94 | ) 95 | { 96 | MPIU_Assert( m_pEp.get() == NULL ); 97 | pEp->AddRef(); 98 | m_pEp.attach( pEp ); 99 | 100 | pMr->AddRef(); 101 | m_pMr.attach( pMr ); 102 | 103 | m_BindResult.pfnSucceeded = pfnBindSucceeded; 104 | m_BindResult.pfnFailed = pfnBindFailed; 105 | m_InvalidateResult.pfnSucceeded = pfnInvalidateSucceeded; 106 | m_InvalidateResult.pfnFailed = pfnInvalidateFailed; 107 | } 108 | 109 | 110 | void 111 | CMw::Unbind() 112 | { 113 | MPIU_Assert( m_pEp.get() != NULL ); 114 | m_pEp.free(); 115 | 116 | m_pMr.free(); 117 | 118 | m_BindResult.pfnSucceeded = NULL; 119 | m_BindResult.pfnFailed = NULL; 120 | m_InvalidateResult.pfnSucceeded = NULL; 121 | m_InvalidateResult.pfnFailed = NULL; 122 | } 123 | 124 | } // namespace v1 125 | } // namespace CH3_ND 126 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/collutil.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #ifndef _COLLUTIL_H_ 7 | #define _COLLUTIL_H_ 8 | 9 | struct CollectiveSwitchover 10 | { 11 | unsigned int MPIR_bcast_short_msg; 12 | unsigned int MPIR_bcast_long_msg; 13 | unsigned int MPIR_bcast_min_procs; 14 | unsigned int MPIR_alltoall_short_msg; 15 | unsigned int MPIR_alltoall_medium_msg; 16 | unsigned int MPIR_alltoallv_short_msg; 17 | unsigned int MPIR_redscat_commutative_long_msg; 18 | unsigned int MPIR_redscat_noncommutative_short_msg; /* inter */ 19 | unsigned int MPIR_allgather_short_msg; 20 | unsigned int MPIR_allgather_long_msg; 21 | unsigned int MPIR_reduce_short_msg; 22 | unsigned int MPIR_allreduce_short_msg; 23 | unsigned int MPIR_gather_vsmall_msg; 24 | unsigned int MPIR_gather_short_msg; /* inter */ 25 | unsigned int MPIR_scatter_vsmall_msg; 26 | unsigned int MPIR_scatter_short_msg; /* inter */ 27 | unsigned int MPIR_bcast_smp_threshold; 28 | unsigned int MPIR_bcast_smp_ceiling; 29 | unsigned int MPIR_reduce_smp_threshold; 30 | unsigned int MPIR_reduce_smp_ceiling; 31 | unsigned int MPIR_allreduce_smp_threshold; 32 | unsigned int MPIR_allreduce_smp_ceiling; 33 | unsigned int MPIR_alltoall_pair_algo_msg_threshold; 34 | unsigned int MPIR_alltoall_pair_algo_procs_threshold; 35 | }; 36 | 37 | enum CollectiveSwitchoverKind 38 | { 39 | COLL_SWITCHOVER_FLAT, 40 | COLL_SWITCHOVER_INTER_NODE, 41 | COLL_SWITCHOVER_INTRA_NODE, 42 | COLL_SWITCHOVER_COUNT 43 | }; 44 | 45 | class CollectiveSwitchoverSettings 46 | { 47 | 48 | public: 49 | bool SmpBcastEnabled; 50 | bool SmpBarrierEnabled; 51 | bool SmpReduceEnabled; 52 | bool SmpAllreduceEnabled; 53 | bool SmpCollectiveEnabled; 54 | 55 | unsigned int RequestGroupSize; 56 | 57 | private: 58 | CollectiveSwitchover Table[COLL_SWITCHOVER_COUNT]; 59 | 60 | public: 61 | CollectiveSwitchoverSettings() 62 | : SmpBcastEnabled(false) 63 | , SmpBarrierEnabled(false) 64 | , SmpReduceEnabled(false) 65 | , SmpAllreduceEnabled(false) 66 | , SmpCollectiveEnabled(false) 67 | , RequestGroupSize(1) 68 | { 69 | RtlZeroMemory(Table, sizeof(Table)); 70 | } 71 | 72 | ~CollectiveSwitchoverSettings() 73 | { 74 | } 75 | 76 | MPI_RESULT Initialize(); 77 | 78 | const CollectiveSwitchover& operator[](int i) const 79 | { 80 | return Table[i]; 81 | } 82 | 83 | CollectiveSwitchover& operator[](int i) 84 | { 85 | return Table[i]; 86 | } 87 | 88 | private: 89 | void InitializeSwitchPointsTable(); 90 | 91 | private: 92 | CollectiveSwitchoverSettings(const CollectiveSwitchoverSettings& other); 93 | CollectiveSwitchoverSettings& operator = (const CollectiveSwitchoverSettings& other); 94 | }; 95 | 96 | 97 | #endif // _COLLUTIL_H_ 98 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/colltunersettings.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #define TUNER_SWITCHPOINT_SET_SIZE 3 7 | #define TUNER_MINIMUM_ITERATION_SIZE 5 8 | #define TUNER_MINIMUM_CHANGE_THRESHOLD .1 9 | #define TUNER_MINIMUM_CHANGE_BACK_THRESHOLD .3 10 | 11 | #define TUNER_VERBOSE_DEFAULT false 12 | #define TUNER_PRINT_SETTINGS_DEFAULT false 13 | 14 | #define TUNER_SIZE_LIMIT_DEFAULT 16777216 15 | #define TUNER_SIZE_LIMIT_MIN 1 16 | #define TUNER_SIZE_LIMIT_MAX INT_MAX 17 | 18 | #define TUNER_TIME_LIMIT_DEFAULT 60 19 | #define TUNER_TIME_LIMIT_MIN 0 20 | #define TUNER_TIME_LIMIT_MAX INT_MAX 21 | 22 | #define TUNER_ITERATION_LIMIT_DEFAULT 100000 23 | #define TUNER_ITERATION_LIMIT_MIN TUNER_MINIMUM_ITERATION_SIZE 24 | #define TUNER_ITERATION_LIMIT_MAX INT_MAX 25 | 26 | #define TUNER_VERBOSE_MIN 0 27 | #define TUNER_VERBOSE_LOW 1 28 | #define TUNER_VERBOSE_HIGH 2 29 | #define TUNER_VERBOSE_MAX TUNER_VERBOSE_HIGH 30 | 31 | #define COLLECTIVE_HAS_THREE_ALGORITHMS 3 32 | #define COLLECTIVE_HAS_TWO_ALGORITHMS 2 33 | 34 | enum TunerPrintFormat 35 | { 36 | Off = 0, 37 | Cluscfg, 38 | Mpiexec, 39 | OptionFile, 40 | TunerPrintFormatEnd 41 | }; 42 | 43 | 44 | enum MPIR_Collective 45 | { 46 | Broadcast = 0, 47 | Reduce, 48 | AllReduce, 49 | ReduceScatter, 50 | Alltoall, 51 | Gather, 52 | Allgather, 53 | CollectiveEnd 54 | }; 55 | 56 | 57 | 58 | class CollectiveTunerSettings 59 | { 60 | 61 | public: 62 | bool TuneBcast; 63 | bool TuneReduce; 64 | bool TuneAllreduce; 65 | bool TuneGather; 66 | bool TuneAllgather; 67 | bool TuneAlltoall; 68 | bool TuneRedscat; 69 | 70 | unsigned int PrintSettings; 71 | unsigned int Verbose; 72 | unsigned int SizeLimit; 73 | unsigned int TimeLimit; 74 | unsigned int IterationLimit; 75 | wchar_t OutputFile[MAX_PATH]; 76 | 77 | public: 78 | CollectiveTunerSettings() 79 | : TuneBcast(false) 80 | , TuneReduce(false) 81 | , TuneAllreduce(false) 82 | , TuneGather(false) 83 | , TuneAllgather(false) 84 | , TuneAlltoall(false) 85 | , TuneRedscat(false) 86 | , PrintSettings(TUNER_PRINT_SETTINGS_DEFAULT) 87 | , Verbose(TUNER_VERBOSE_DEFAULT) 88 | , SizeLimit(TUNER_SIZE_LIMIT_DEFAULT) 89 | , TimeLimit(TUNER_TIME_LIMIT_DEFAULT) 90 | , IterationLimit(TUNER_ITERATION_LIMIT_DEFAULT) 91 | { 92 | RtlZeroMemory(OutputFile, sizeof(OutputFile)); 93 | } 94 | 95 | ~CollectiveTunerSettings() 96 | { 97 | } 98 | 99 | MPI_RESULT Initialize(); 100 | 101 | private: 102 | CollectiveTunerSettings(const CollectiveTunerSettings& other); 103 | CollectiveTunerSettings& operator = (const CollectiveTunerSettings& other); 104 | }; 105 | -------------------------------------------------------------------------------- /src/mpi/msmpi/util/gathertuner.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "precomp.h" 5 | #include "colltuner.h" 6 | 7 | #define SWITCHADEFAULT L"MPICH_DEFAULT_GATHER_VSMALL_MSG" 8 | 9 | GatherTuner::GatherTuner( 10 | unsigned int size, 11 | unsigned int time 12 | ) : CollectiveTuner(size, time, COLLECTIVE_HAS_TWO_ALGORITHMS) 13 | { 14 | } 15 | 16 | 17 | const wchar_t* GatherTuner::Name() const 18 | { 19 | return L"Gather"; 20 | } 21 | 22 | 23 | void GatherTuner::PrintValues(FILE* pOutFile, const wchar_t* pFormat) const 24 | { 25 | fwprintf( 26 | pOutFile, 27 | pFormat, 28 | SWITCHADEFAULT, 29 | Mpi.SwitchoverSettings[COLL_SWITCHOVER_FLAT].MPIR_gather_vsmall_msg 30 | ); 31 | fflush(pOutFile); 32 | } 33 | 34 | 35 | void GatherTuner::SetAlgorithm(unsigned int algorithm, CollectiveSwitchover* s) 36 | { 37 | switch(algorithm) 38 | { 39 | case 0: /* short */ 40 | s->MPIR_gather_vsmall_msg = UINT_MAX; 41 | break; 42 | case 1: /* long */ 43 | s->MPIR_gather_vsmall_msg = 0; 44 | break; 45 | default: 46 | break; 47 | } 48 | } 49 | 50 | 51 | int GatherTuner::SetSwitchPoints( 52 | MPI_Comm comm, 53 | CollectiveSwitchover* pSwitchover, 54 | unsigned int measurementIndex 55 | ) 56 | { 57 | int mpi_errno; 58 | mpi_errno = NMPI_Bcast(&m_pSwitchA[measurementIndex], 1, MPI_INT, 0, comm); 59 | ON_ERROR_FAIL(mpi_errno); 60 | 61 | pSwitchover->MPIR_gather_vsmall_msg = m_pSwitchA[measurementIndex]; 62 | 63 | fn_exit: 64 | return mpi_errno; 65 | fn_fail: 66 | goto fn_exit; 67 | } 68 | 69 | 70 | int GatherTuner::Measure( 71 | unsigned int nElements, 72 | unsigned int root, 73 | LARGE_INTEGER* pStart, 74 | LARGE_INTEGER* pStop, 75 | MPID_Comm* pComm 76 | ) 77 | { 78 | BOOL startMeasurementSucceeded = FALSE; 79 | BOOL stopMeasurementSucceeded = FALSE; 80 | int mpi_errno = MPI_SUCCESS; 81 | unsigned int len = nElements / pComm->remote_size; 82 | startMeasurementSucceeded = QueryPerformanceCounter(pStart); 83 | 84 | MPIU_Assert( pComm->comm_kind != MPID_INTERCOMM ); 85 | 86 | mpi_errno = MPIR_Gather_intra( 87 | m_pSendBuffer, 88 | len, 89 | g_hBuiltinTypes.MPI_Byte, 90 | m_pRecvBuffer, 91 | len, 92 | g_hBuiltinTypes.MPI_Byte, 93 | root, 94 | pComm 95 | ); 96 | stopMeasurementSucceeded = QueryPerformanceCounter(pStop); 97 | if(startMeasurementSucceeded == FALSE || stopMeasurementSucceeded == FALSE) 98 | { 99 | if(mpi_errno == MPI_SUCCESS) 100 | { 101 | mpi_errno = MPIU_ERR_CREATE(MPI_ERR_OTHER, "**measurementfailed"); 102 | } 103 | } 104 | return mpi_errno; 105 | } 106 | 107 | bool GatherTuner::Enabled() const 108 | { 109 | return Mpi.TunerSettings.TuneGather; 110 | } 111 | -------------------------------------------------------------------------------- /src/mpi/msmpi/mpid/mpidrma.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | #if !defined(MPICH_MPIDRMA_H_INCLUDED) 9 | #define MPICH_MPIDRMA_H_INCLUDED 10 | 11 | /* 12 | * RMA Declarations. We should move these into something separate from 13 | * a Request. 14 | */ 15 | /* to send derived datatype across in RMA ops */ 16 | typedef struct MPIDI_RMA_dtype_info 17 | { 18 | MPI_Aint extent; 19 | MPI_Aint ub; 20 | MPI_Aint lb; 21 | MPI_Aint true_ub; 22 | MPI_Aint true_lb; 23 | 24 | /* pointer needed to update pointers within dataloop on remote side */ 25 | void* dataloop; 26 | int dataloop_depth; 27 | 28 | int max_contig_blocks; 29 | int size; 30 | 31 | /* not needed because this info is sent in packet header. remove it after lock/unlock is implemented in the device */ 32 | int dataloop_size; 33 | 34 | MPI_Datatype eltype; 35 | bool is_contig; 36 | bool has_sticky_ub; 37 | bool has_sticky_lb; 38 | 39 | } MPIDI_RMA_dtype_info; 40 | 41 | 42 | typedef enum MPIDI_Rma_op_t 43 | { 44 | MPIDI_RMA_OP_LOCK, 45 | MPIDI_RMA_OP_GET, 46 | MPIDI_RMA_OP_PUT, 47 | MPIDI_RMA_OP_ACCUMULATE, 48 | MPIDI_RMA_OP_GET_ACCUMULATE, 49 | MPIDI_RMA_OP_COMPARE_AND_SWAP, 50 | 51 | } MPIDI_Rma_op_t; 52 | 53 | 54 | /* for keeping track of RMA ops, which will be executed at the next sync call */ 55 | typedef struct MPIDI_RMA_ops 56 | { 57 | /* pointer to next element in list */ 58 | struct MPIDI_RMA_ops *next; 59 | 60 | MPIDI_Rma_op_t type; 61 | void* origin_addr; 62 | int origin_count; 63 | TypeHandle origin_datatype; 64 | void* result_addr; 65 | int result_count; 66 | TypeHandle result_datatype; 67 | int target_rank; 68 | MPI_Aint target_disp; 69 | int target_count; 70 | TypeHandle target_datatype; 71 | 72 | /* for accumulate */ 73 | MPI_Op op; 74 | 75 | /* for win_lock */ 76 | int lock_type; 77 | int assert; 78 | 79 | /* for Rput, Rget and Raccumulate */ 80 | MPID_Request* request; 81 | 82 | } MPIDI_RMA_ops; 83 | 84 | 85 | typedef struct MPIDI_PT_single_op 86 | { 87 | /* put, get, or accum. */ 88 | int type; 89 | int count; 90 | void *addr; 91 | TypeHandle datatype; 92 | MPI_Op op; 93 | 94 | /* for gets */ 95 | MPI_Request request_handle; 96 | 97 | /* to indicate if the data has been received */ 98 | int data_recd; 99 | 100 | /* For queued puts and accumulates, data is copied here. Must be last in struct */ 101 | UINT8 data[1]; 102 | 103 | } MPIDI_PT_single_op; 104 | 105 | 106 | typedef struct MPIDI_Win_lock_queue 107 | { 108 | struct MPIDI_Win_lock_queue *next; 109 | int lock_type; 110 | MPI_Win src_win; 111 | MPIDI_VC_t * vc; 112 | struct MPIDI_PT_single_op *pt_single_op; /* to store info for lock-put-unlock optimization */ 113 | 114 | } MPIDI_Win_lock_queue; 115 | 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /src/mpi/msmpi/include/mpistatus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #ifndef STATUS_H_INCLUDED 5 | #define STATUS_H_INCLUDED 6 | 7 | 8 | // 9 | // Internal struct that overlays MPI_Status. 10 | // 11 | #pragma pack( push, 4 ) 12 | struct MPIR_Status 13 | { 14 | unsigned __int64 count : 63; 15 | unsigned __int64 cancelled : 1; 16 | int MPI_SOURCE; 17 | int MPI_TAG; 18 | int MPI_ERROR; 19 | }; 20 | #pragma pack( pop ) 21 | C_ASSERT( 22 | sizeof( MPIR_Status ) == sizeof( MPI_Status ) && 23 | __alignof( MPIR_Status) == __alignof( MPI_Status ) 24 | ); 25 | 26 | 27 | static inline void 28 | MPIR_Status_set_count( 29 | _Inout_ MPI_Status *status, 30 | _In_range_(>=, 0) MPI_Count count 31 | ) 32 | { 33 | reinterpret_cast( status )->count = count; 34 | } 35 | 36 | 37 | static inline MPI_Count 38 | MPIR_Status_get_count( 39 | _In_ const MPI_Status *status 40 | ) 41 | { 42 | return reinterpret_cast( status )->count; 43 | } 44 | 45 | 46 | static inline void 47 | MPIR_Status_set_cancelled( 48 | _Inout_ MPI_Status *status, 49 | _In_range_(0, 1) int cancelled 50 | ) 51 | { 52 | MPIU_Assert( cancelled == TRUE || cancelled == FALSE ); 53 | reinterpret_cast( status )->cancelled = cancelled; 54 | } 55 | 56 | 57 | static inline int 58 | MPIR_Status_get_cancelled( 59 | _In_ const MPI_Status *status 60 | ) 61 | { 62 | return reinterpret_cast( status )->cancelled; 63 | } 64 | 65 | 66 | static inline void 67 | MPI_Status_clear_with_source( 68 | _Inout_ MPI_Status *status, 69 | _In_ int source 70 | ) 71 | { 72 | if( status != MPI_STATUS_IGNORE ) 73 | { 74 | // 75 | // Do not set MPI_ERROR (only set if MPI_ERR_IN_STATUS is returned). 76 | // According to the MPI 1.1 standard page 22 lines 9-12, the MPI_ERROR 77 | // field may not be modified except by the functions in section 3.7.5 78 | // which return MPI_ERR_IN_STATUS (MPI_Wait{all,some} and MPI_Test{all,some}). 79 | // 80 | MPIR_Status_set_count( status, 0 ); 81 | MPIR_Status_set_cancelled( status, FALSE ); 82 | status->MPI_SOURCE = source; 83 | status->MPI_TAG = MPI_ANY_TAG; 84 | } 85 | } 86 | 87 | 88 | static inline void 89 | MPIR_Status_set_empty( 90 | _Inout_ MPI_Status *status 91 | ) 92 | { 93 | MPI_Status_clear_with_source( status, MPI_ANY_SOURCE ); 94 | } 95 | 96 | 97 | static inline void 98 | MPIR_Status_set_error( 99 | _Inout_ MPI_Status *status, 100 | _In_ int err 101 | ) 102 | { 103 | if( status != MPI_STATUS_IGNORE ) 104 | { 105 | status->MPI_ERROR = err; 106 | } 107 | } 108 | 109 | 110 | // 111 | // See MPI 1.1, section 3.11, Null Processes. 112 | // 113 | static inline void 114 | MPIR_Status_set_procnull( 115 | _Inout_ MPI_Status *status 116 | ) 117 | { 118 | MPI_Status_clear_with_source( status, MPI_PROC_NULL ); 119 | } 120 | 121 | 122 | #endif // STATUS_H_INCLUDED 123 | 124 | -------------------------------------------------------------------------------- /src/mpi/msmpi/channels/mpichannels.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | mpichannels 8 | {d3964fd5-1228-4987-a44b-63d32da75c45} 9 | 10 | 11 | 12 | false 13 | StaticLibrary 14 | 15 | 16 | 17 | 18 | 19 | 20 | Use 21 | precomp.h 22 | $(IntDir)\pch_hdr.src 23 | 24 | %(AdditionalIncludeDirectories); 25 | $(MPI_SRC_ROOT)\msmpi\mpid; 26 | $(O); 27 | 28 | 29 | 30 | 31 | 32 | 33 | Create 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/mpi/pmilib/smpd_read_write.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /* 5 | * (C) 2001 by Argonne National Laboratory. 6 | * See COPYRIGHT in top-level directory. 7 | */ 8 | 9 | #include "precomp.h" 10 | #include "smpd.h" 11 | 12 | static char hexchar(int x) 13 | { 14 | switch (x) 15 | { 16 | case 0: return '0'; 17 | case 1: return '1'; 18 | case 2: return '2'; 19 | case 3: return '3'; 20 | case 4: return '4'; 21 | case 5: return '5'; 22 | case 6: return '6'; 23 | case 7: return '7'; 24 | case 8: return '8'; 25 | case 9: return '9'; 26 | case 10: return 'A'; 27 | case 11: return 'B'; 28 | case 12: return 'C'; 29 | case 13: return 'D'; 30 | case 14: return 'E'; 31 | case 15: return 'F'; 32 | } 33 | return '0'; 34 | } 35 | 36 | static char charhex(char c) 37 | { 38 | switch (c) 39 | { 40 | case '0': return 0; 41 | case '1': return 1; 42 | case '2': return 2; 43 | case '3': return 3; 44 | case '4': return 4; 45 | case '5': return 5; 46 | case '6': return 6; 47 | case '7': return 7; 48 | case '8': return 8; 49 | case '9': return 9; 50 | case 'A': return 10; 51 | case 'B': return 11; 52 | case 'C': return 12; 53 | case 'D': return 13; 54 | case 'E': return 14; 55 | case 'F': return 15; 56 | case 'a': return 10; 57 | case 'b': return 11; 58 | case 'c': return 12; 59 | case 'd': return 13; 60 | case 'e': return 14; 61 | case 'f': return 15; 62 | } 63 | return 0; 64 | } 65 | 66 | 67 | static void char_to_hex(char ch, _Out_cap_(2) char *hex) 68 | { 69 | *hex = hexchar((ch>>4) & 0xF); 70 | hex++; 71 | *hex = hexchar(ch & 0xF); 72 | } 73 | 74 | 75 | static char hex_to_char(const char *hex) 76 | { 77 | unsigned char ch; 78 | ch = charhex(*hex) << 4; 79 | hex++; 80 | ch = ch | charhex(*hex); 81 | return (char)ch; 82 | } 83 | 84 | 85 | 86 | void 87 | smpd_encode_buffer( 88 | _Out_writes_z_(dest_length) char *dest, 89 | _In_ size_t dest_length, 90 | _In_reads_(src_length) PCSTR src, 91 | _In_ UINT32 src_length, 92 | _Out_ UINT32 *num_encoded 93 | ) 94 | { 95 | UINT32 n = 0; 96 | while ((src_length > 0) && (dest_length > 2)) 97 | { 98 | char_to_hex(*src, dest); 99 | src++; 100 | dest += 2; 101 | src_length--; 102 | dest_length -= 2; 103 | n++; 104 | } 105 | *dest = '\0'; 106 | *num_encoded = n; 107 | } 108 | 109 | 110 | void 111 | smpd_decode_buffer( 112 | _In_ PCSTR str, 113 | _Out_writes_z_(dest_length) char *dest, 114 | _In_ UINT32 dest_length, 115 | _Out_ UINT32* num_decoded 116 | ) 117 | { 118 | UINT32 n = 0; 119 | while(dest_length > 1) 120 | { 121 | if(*str == '\0' || *(str+1) == '\0') 122 | { 123 | break; 124 | } 125 | 126 | *dest = hex_to_char(str); 127 | str += 2; 128 | dest++; 129 | dest_length--; 130 | n++; 131 | } 132 | *dest = '\0'; 133 | *num_decoded = n; 134 | } 135 | --------------------------------------------------------------------------------