Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Windows Static Link libicaf

everythingfunctional
1,510 Views

I'm trying to compile a Fortran program that uses coarray features in such a way to be able to distribute it to users (who will not have oneAPI or Visual Studio installed) and expect to be able to just double click the executable file.

 

When using the `/libs:static` option, programs that don't use coarray features can be run by double clicking on the executable, even if compiled with the `/Qcoarray=single` option, whereas without `/libs:static` you get errors like "libifcoremd.dll was not found".  However, as soon as you use any coarray feature, even something as simple as `this_image()`, it can't be executed that way even still compiling with `/Qcoarray=single`. I have to execute it from a command prompt in which I've run the `setvars.bat` script or else it says that it can't find `libicaf.dll`.

 

Is there a compiler flag to statically link in libicaf? I would think it should be possible, since there is a `libicaf.lib` file in the oneAPI installation directory. Or is that one of those "not actually a static library" static libraries?

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
1,464 Views

The coarray support is supplied only as a DLL on Windows. The solution is to provide the Intel redistributables installer (also known as Standalone Component Runtime) to the end-user, or even install it as part of your own installation procedure. Intel® oneAPI standalone component installation files

View solution in original post

10 Replies
Arjen_Markus
Honored Contributor I
1,480 Views

The existence of libicaf.lib is not a guarantee. On Windows there are two different types of libraries: regular static libraries that contain the actual object code and so-called import libraries that merely contain interfacing information. I am rather certain that the file(s) libicaf.lib in the distribution are import libraries - they are used by the compiler/linker to identify the bits and pieces in the corresponding DLLs it needs.

0 Kudos
Steve_Lionel
Honored Contributor III
1,465 Views

The coarray support is supplied only as a DLL on Windows. The solution is to provide the Intel redistributables installer (also known as Standalone Component Runtime) to the end-user, or even install it as part of your own installation procedure. Intel® oneAPI standalone component installation files

everythingfunctional
1,451 Views

Slightly disappointing, but understandable. Thanks for the solution.

0 Kudos
Steve_Lionel
Honored Contributor III
1,443 Views

OpenMP support is the same - but the static library still exists on Linux. I never understood why there was a difference. If I recall correctly, coarray support was always DLL-only on Windows, but there used to be a static OpenMP library. I know that static libraries can cause problems with mixed library builds, and I generally recommend DLL linking, but sometimes a static library is the right solution.

0 Kudos
ASO
Beginner
1,272 Views

I use some coarray feature as DLL, simple as `this_image()`, but it's show the error in libicaf.Dll when I call from C#. How to slove it ?  Thanks in advanced!

 

corrary.jpg

0 Kudos
Steve_Lionel
Honored Contributor III
1,261 Views

That's an access violation, and it looks like the code jumped to an invalid address. My first guess would be something in your program is corrupting data used by the coarray support. There is no simple solution here and data corruption is one of the hardest problems to analyze. I usually recommend disabling parts of the program, piece by piece, and see if the symptom changes or goes away. You should also enable full run-time checking.

That the error names libicaf.dll does not necessarily mean that the error is in that DLL.

0 Kudos
ASO
Beginner
1,225 Views

Thanks for your reply.

I use the simple coarry feature as dll:

 

module HelloMode
implicit none
contains

subroutine hello()
!DEC$ ATTRIBUTES DLLEXPORT::hello
!DEC$ ATTRIBUTES STDCALL,ALIAS:'hello'::hello
write (*,*) 'Hello from image ',this_image(), "NumImage: ",NUM_IMAGES()

end subroutine
end module

 

 

and call the dll from C#:

 

 

namespace WinFormsApp1
{
public class LoadDll
{
[DllImport("Dll1.dll", EntryPoint = "hello", CallingConvention = CallingConvention.StdCall)]
public static extern void hello();
}
}

 

 

The error:

ASO_0-1642418642993.png

My question: Is the coarry feature support as dll?

0 Kudos
Steve_Lionel
Honored Contributor III
1,198 Views

At the moment, coarray support requires that the main program be in Fortran. Perhaps you can write a jacket program in Fortran that calls into C# and then calls your DLL.

0 Kudos
everythingfunctional
1,196 Views

Unfortunately you can't (at least at present) call coarray Fortran code from another language if the main program isn't in Fortran. The different images (the Fortran term for threads or processes) must be launched at program startup and stopped at program end, but other languages won't know to do this, and there isn't a way to do it manually before and after calling specific procedures. I suspect that's why you're getting an error.

0 Kudos
Steve_Lionel
Honored Contributor III
1,186 Views

Intel Fortan does support an option, /Qcoarray:single, which omits the "launch" code, therefore requiring that you do your own mpirun (or whatever). But I think this still won't do what you want, as there is some setup code in the main program that still has to run, and I'm not aware Intel has published the specs for how to do this yourself.

At some point in the future, I expect compilers will evolve capability to put coarray code in libraries, enabled by the "teams" feature in Fortran 2018.

0 Kudos
Reply