MPI with ifort on windows with visual studio

Dear friends,

I’m desperately trying to run this simple code.

program Hello_World
implicit none

integer :: i
character(len=20) :: name[*]

if (this_image() == 1) then
write(,‘(a)’,advance=‘no’) 'Enter your name: ’
read(
,‘(a)’) name

do i = 2, num_images()
name[i] = name
end do
end if

sync all

write(*,‘(3a,i0)’) 'Hello ‘,trim(name),’ from image ', this_image()

read(,)

end program Hello_World

I installed the mpi libraries and added /Qcorray to the ifort.cfg

Now the the code compiles without errors but it doesn’t run.

It closes immediately with following error:

‘hellompi.exe’ (Win32): Loaded ‘C:\Windows\System32\sechost.dll’.
The thread 0x3818 has exited with code 4294967295 (0xffffffff).
The thread 0x58b8 has exited with code 4294967295 (0xffffffff).
The thread 0x4b4c has exited with code 4294967295 (0xffffffff).
The program ‘[7844] hellompi.exe’ has exited with code 4294967295 (0xffffffff).

I need this mpi support because I am studying the wonderfull book ‘Modern Fortran’ by Milan Curcic.

Kind Regards

Roger

1 Like

Hi, just a few remarks:

  • Please use the </> button to format code. I copied your sample program and ended up correcting the “helpful” markup: two asterisks indicate italic text, so your read and write statements are mangled and some of the quotes turned out to be “smart”.
  • I compiled (using -Qcoarrray) and ran it on Windows with a plain installation of Intel Fortran oneAPI and got the “hello” text the expected 24 times.
  • I did NOT add the option to ifort.cfg, but I do not think that was the essential difference.
  • If I inspect the executable, there is no sign of a dependency on sechost.dll.

Thank you.
I did a fresh install of visual studio and the intel software but now I get
fatal error LNK1181: cannot open input file 'impi.lib
I checked: impi.lib is where it should be.
I suppose that ‘cannot open’ means that the program found the lib but cannot open it for some reason.
I suppose that you compile from the command line. I build from within visual studio 2022.

Kind regards,
Roger

Roger

Yes, I did use the command-line :slight_smile: I prefer that over setting up a VS solution for small programs.

But it is the linker that complains about the missing library. Can you try to build the program via the command-line? From the Start menu open the “Intel oneAPI command prompt” (I used the 64-bits environment) and simply build it with -Qcoarray as the option.

1 Like

Oh, I just saw the reason for these problems on the Intel Fortran forum: you need to use the 64-bits environment!

1 Like

Well no, I compiled as a 64 bits project.
Here is the build log:

inking...
Link /OUT:"x64\Release\hellompi.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"\include" /MANIFEST /MANIFESTFILE:"x64\Release\hellompi.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:CONSOLE /IMPLIB:"D:\FORTRAN\Projecten\hellompi\x64\Release\hellompi.lib" impi.lib -qnextgen -qm64 "x64\Release\Source1.obj"
LINK : fatal error LNK1181: cannot open input file 'impi.lib'


hellompi - 1 error(s), 0 warning(s)

Roger

I give up.
Try my luck on Linux.

Roger

1 Like

Maybe this is relevant

Thank you all for your comments.
Compiling works now but the program does not execute.

I get a system error.
Execution can not be continued because libicaf.dll is not found.
So frustrating. I already wasted two days of my life with this.
Back to my Manjaro distro I suppose.
Roger

I had something similar experience with MPI with Ifort. Very unfriendly documentation and no basic instructions. Even finding the required information proved to be a daunting task. I quit too!

Hi @rmoortgat ,

Do you get this error by runnig the executable from the Intel oneAPI command prompt, as @Arjen suggested ?
Because reading this

to me it looks like you don’t have such paths to the runtime libraries in the Windows PATH environment variable (which you’d strictly need when using dynamic linking)

Could you post the VS solution (including the code of course)? I am curious about the /IMPLIB option - that seems to belong to DLLs.

hellompi.f90 (802 Bytes)

solution file:
Don’t know where the Win32 comes from. I did the build as x64.

type oMicrosoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "hellompi", "hellompi.vfproj", "{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}.Debug|x64.ActiveCfg = Debug|x64
		{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}.Debug|x64.Build.0 = Debug|x64
		{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}.Debug|x86.ActiveCfg = Debug|Win32
		{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}.Debug|x86.Build.0 = Debug|Win32
		{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}.Release|x64.ActiveCfg = Release|x64
		{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}.Release|x64.Build.0 = Release|x64
		{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}.Release|x86.ActiveCfg = Release|Win32
		{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}.Release|x86.Build.0 = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {96A4B36B-CFE5-4953-AA7A-A3B0FA3945C1}
	EndGlobalSection
EndGlobalr paste code here

@rmoortgat , with this VS solution .sln file, it is needed the project file (.vfprog) as well. It is the one containing both compilation and linking (VS specific) instructions :slight_smile:

Those are the configurations that VS creates by default whenever you create a new VS solution file. You could remove all unwanted configurations via the VS GUI (or by hand if you wish).

Thank you for your support.
I’m old in age but a beginner with fortran.
Excuse my ignorance.

  • where do i find the .vfprog file
  • how do i remove unwanted configurations

Roger

No need to be sorry at all @rmoortgat !!!
I went through your same struggles when I firstly approached these things as well.
They might appear very foggy at first.
And everyone here is there to help anyone.

The project file is named hellompi.vfproj, you can see it is mentioned in the solution file you attached.
Usually, it is placed in the same directory where you find the solution .sln file, as in your case as well, since the relative path to "hellompi.vfproj is not preceded by anything. meaning that it is found in the same directory of the solution file.

Let’s keep this task for a later step, after you have solved the first issue. In any case, what matters is which target platform you build (which you made it clear is x64).

1 Like

OK. Here it is:

<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject ProjectCreator="Intel Fortran" Keyword="Console Application" Version="11.0" ProjectIdGuid="{7945F7FA-ADDF-400A-B7C7-1DBBC5D7F92C}">
	<Platforms>
		<Platform Name="Win32"/>
		<Platform Name="x64"/>
	</Platforms>
	<Configurations>
		<Configuration Name="Debug|Win32" UseCompiler="ifortCompiler">
			<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" WarnInterfaces="true" Traceback="true" BoundsCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDebugDLL"/>
			<Tool Name="VFLinkerTool" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" GenerateDebugInformation="true" SubSystem="subSystemConsole"/>
			<Tool Name="VFResourceCompilerTool"/>
			<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
			<Tool Name="VFCustomBuildTool"/>
			<Tool Name="VFPreLinkEventTool"/>
			<Tool Name="VFPreBuildEventTool"/>
			<Tool Name="VFPostBuildEventTool"/>
			<Tool Name="VFManifestTool" SuppressStartupBanner="true"/>
		</Configuration>
		<Configuration Name="Debug|x64" UseCompiler="ifortCompiler">
			<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="$(I_MPI_ONEAPI_ROOT)\include" EnableCoarrays="CoarrayShared" WarnInterfaces="true" Traceback="true" BoundsCheck="true" StackFrameCheck="true" RuntimeLibrary="rtMultiThreadedDebugDLL"/>
			<Tool Name="VFLinkerTool" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" GenerateDebugInformation="true" SubSystem="subSystemConsole"/>
			<Tool Name="VFResourceCompilerTool"/>
			<Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
			<Tool Name="VFCustomBuildTool"/>
			<Tool Name="VFPreLinkEventTool"/>
			<Tool Name="VFPreBuildEventTool"/>
			<Tool Name="VFPostBuildEventTool"/>
			<Tool Name="VFManifestTool" SuppressStartupBanner="true"/>
		</Configuration>
		<Configuration Name="Release|Win32" UseCompiler="ifortCompiler">
			<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" RuntimeLibrary="rtMultiThreadedDLL"/>
			<Tool Name="VFLinkerTool" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" SubSystem="subSystemConsole"/>
			<Tool Name="VFResourceCompilerTool"/>
			<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
			<Tool Name="VFCustomBuildTool"/>
			<Tool Name="VFPreLinkEventTool"/>
			<Tool Name="VFPreBuildEventTool"/>
			<Tool Name="VFPostBuildEventTool"/>
			<Tool Name="VFManifestTool" SuppressStartupBanner="true"/>
		</Configuration>
		<Configuration Name="Release|x64" UseCompiler="ifxCompiler">
			<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" RuntimeLibrary="rtMultiThreadedDLL"/>
			<Tool Name="VFLinkerTool" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" SubSystem="subSystemConsole"/>
			<Tool Name="VFResourceCompilerTool"/>
			<Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
			<Tool Name="VFCustomBuildTool"/>
			<Tool Name="VFPreLinkEventTool"/>
			<Tool Name="VFPreBuildEventTool"/>
			<Tool Name="VFPostBuildEventTool"/>
			<Tool Name="VFManifestTool" SuppressStartupBanner="true"/>
		</Configuration>
	</Configurations>
	<Files>
		<Filter Name="Header Files" Filter="fi;fd"/>
		<Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"/>
		<Filter Name="Source Files" Filter="f90;for;f;fpp;ftn;def;odl;idl">
		<File RelativePath=".\hellompi.f90"/></Filter>
		<File RelativePath=".\ReadMe.txt"/>
	</Files>
	<Globals/>
</VisualStudioProject>

I dicovered that the coarray programs run from within the intel command line and not from the Powershell.

c:\FORTRAN\hellompi>hello
Enter your name: roger
Hello roger from image 1
Hello roger from image 6
Hello roger from image 5
Hello roger from image 10
Hello roger from image 2
Hello roger from image 9
Hello roger from image 12
Hello roger from image 11
Hello roger from image 8
Hello roger from image 3
Hello roger from image 7
Hello roger from image 4

Yes, that would be due to the path - it must include the directory holding the DLLs. I never use PowerShell myself, but I guess adding the right paths will not be a particularly vexing problem, just tedious.

I ran dependency walker. One of the problems seems to be kernel32.dll.

Dependency Walker:       2.2.6000 (64-bit)
Operating System:        Microsoft Windows NT/2000/XP/2003/Vista based Tablet (64-bit)
OS Version:              6.02.9200
Processor:               Intel64 Family 6 Model 165 Stepping 2, GenuineIntel, ~2712MHz
Number of Processors:    12, Mask: 0x0000000000000FFF
Computer Name:           DESKTOP-PMGA9BL
User Name:               roger
Local Date:              20 nov 23
Local Time:              11:42:21 Romance (standaardtijd) (GMT+01:00)
OS Language:             0x0413: Dutch (Netherlands)
Memory Load:             24%
Physical Memory Total:   68.480.770.048 (65309 MB)
Physical Memory Used:    16.467.591.168
Physical Memory Free:    52.013.178.880
Page File Memory Total:  78.681.317.376
Page File Memory Used:   17.150.050.304
Page File Memory Free:   61.531.267.072
Virtual Memory Total:    140.737.488.224.256
Virtual Memory Used:     4.609.490.944
Virtual Memory Free:     140.732.878.733.312
Page Size:               0x00001000 (4.096)
Allocation Granularity:  0x00010000 (65.536)
Min. App. Address:       0x0000000000010000 (65.536)
Max. App. Address:       0x00007FFFFFFEFFFF (140.737.488.289.791)

********************************| Search Order |********************************
*                                                                              *
* Legend: F  File                     E  Error (path not valid)                *
*                                                                              *
********************************************************************************

Side-by-Side components (Windows 2000/XP/2003/Vista/+)
The system's "KnownDLLs" list
   [F ] c:\windows\system32\ADVAPI32.DLL
   [F ] c:\windows\system32\BCRYPTPRIMITIVES.DLL
   [F ] c:\windows\system32\CLBCATQ.DLL
   [F ] c:\windows\system32\COMBASE.DLL
   [F ] c:\windows\system32\COMCTL32.DLL
   [F ] c:\windows\system32\COMDLG32.DLL
   [F ] c:\windows\system32\COML2.DLL
   [F ] c:\windows\system32\CRYPT32.DLL
   [F ] c:\windows\system32\DIFXAPI.DLL
   [F ] c:\windows\system32\GDI32.DLL
   [F ] c:\windows\system32\GDI32FULL.DLL
   [F ] c:\windows\system32\GDIPLUS.DLL
   [F ] c:\windows\system32\IMAGEHLP.DLL
   [F ] c:\windows\system32\IMM32.DLL
   [F ] c:\windows\system32\KERNEL32.DLL
   [F ] c:\windows\system32\KERNELBASE.DLL
   [F ] c:\windows\system32\MSCTF.DLL
   [F ] c:\windows\system32\MSVCP_WIN.DLL
   [F ] c:\windows\system32\MSVCRT.DLL
   [F ] c:\windows\system32\NORMALIZ.DLL
   [F ] c:\windows\system32\NSI.DLL
   [F ] c:\windows\system32\NTDLL.DLL
   [F ] c:\windows\system32\NTDLL.DLL
   [F ] c:\windows\system32\OLE32.DLL
   [F ] c:\windows\system32\OLEAUT32.DLL
   [F ] c:\windows\system32\PSAPI.DLL
   [F ] c:\windows\system32\RPCRT4.DLL
   [F ] c:\windows\system32\SECHOST.DLL
   [F ] c:\windows\system32\SETUPAPI.DLL
   [F ] c:\windows\system32\SHCORE.DLL
   [F ] c:\windows\system32\SHELL32.DLL
   [F ] c:\windows\system32\SHLWAPI.DLL
   [F ] c:\windows\system32\UCRTBASE.DLL
   [F ] c:\windows\system32\USER32.DLL
   [F ] c:\windows\system32\WIN32U.DLL
   [F ] c:\windows\system32\WINTRUST.DLL
   [F ] c:\windows\system32\WLDAP32.DLL
   [F ] c:\windows\system32\WOW64.DLL
   [F ] c:\windows\system32\WOW64BASE.DLL
   [F ] c:\windows\system32\WOW64CON.DLL
   [F ] c:\windows\system32\WOW64CPU.DLL
   [F ] c:\windows\system32\WOW64WIN.DLL
   [F ] c:\windows\system32\WS2_32.DLL
The application directory
   [  ] C:\FORTRAN\hellompi\
The 32-bit system directory
   [  ] C:\WINDOWS\system32\
The 16-bit system directory (Windows NT/2000/XP/2003/Vista/+)
   [  ] C:\WINDOWS\system\
The system's root OS directory
   [  ] C:\WINDOWS\
The application's registered "App Paths" directories
The system's "PATH" environment variable directories
   [  ] C:\Program Files (x86)\Intel\oneAPI\compiler\2024.0\bin\
   [  ] C:\Program Files (x86)\Intel\oneAPI\mpi\2021.11\bin\mpi\debug\
   [  ] C:\Python\Scripts\
   [  ] C:\Python\
   [  ] C:\Users\roger\AppData\Local\Microsoft\WindowsApps\
   [  ] C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.2\bin\
   [  ] C:\Users\roger\AppData\Local\Programs\Microsoft VS Code\bin\
   [  ] C:\MiKTex\miktex\bin\x64\
   [  ] C:\Program Files (x86)\Notepad++\
   [  ] C:\Users\roger\AppData\Local\Programs\Julia-1.9.2\bin\
   [  ] C:\Users\roger\AppData\Local\sfpm\32\bin\
   [  ] C:\Users\roger\AppData\Local\sfpm\64\bin\
   [  ] C:\Program Files (x86)\SF Package Manager\
   [  ] c:\users\roger\appdata\roaming\python\python39\scripts\
   [  ] c:\users\roger\.local\bin\
   [  ] C:\Program Files (x86)\Intel\oneAPI\compiler\2024.0\bin\

***************************| Module Dependency Tree |***************************
*                                                                              *
* Legend: F  Forwarded Module   ?  Missing Module        6  64-bit Module      *
*         D  Delay Load Module  !  Invalid Module                              *
*         *  Dynamic Module     E  Import/Export Mismatch or Load Failure      *
*                               ^  Duplicate Module                            *
*                                                                              *
********************************************************************************

[  6] HELLO.EXE
     [  6] LIBICAF.DLL
          [ ^6] KERNEL32.DLL
               [F^6] NTDLL.DLL
          [  6] IMPI.DLL
               [ ^6] WS2_32.DLL
               [ ^6] DBGHELP.DLL
                    [F^6] DBGCORE.DLL
               [ ^6] KERNEL32.DLL
                    [F^6] NTDLL.DLL
               [ ^6] ADVAPI32.DLL
     [  6] KERNEL32.DLL
          [  6] API-MS-WIN-CORE-RTLSUPPORT-L1-1-0.DLL
               [F^6] NTDLL.DLL
          [ ? ] API-MS-WIN-CORE-RTLSUPPORT-L1-2-2.DLL
          [  6] NTDLL.DLL
          [  6] KERNELBASE.DLL
               [ ^6] NTDLL.DLL

Just part of the file because I can’t upload while too big.
The situation seems to be hopeless but not serious. :slight_smile:

Roger

Another problem emerged:

:: initializing oneAPI environment...
   Initializing Visual Studio command-line environment...
   Visual Studio version 17.8.0 environment configured.
   "C:\Program Files\Microsoft Visual Studio\2022\Community\"
   Visual Studio command-line environment initialized for: 'x64'
:  advisor -- latest
'powershell' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files (x86)\Intel\oneAPI\advisor\latest\env>

powershell not recognised anymore due to latest update of powershell, now the command is pwsh. Where can I change this?

Roger