Topic: any lib for multiplateform multithreading / multiprocessing ?

Is there a way to create/manage multiple thread working on both windows and linux ?

if not, what about multiprocessing ? i was thinking of MPI but it seems to be a pain to make it works on both plateform.

Any other idea/solution/possibility ?

I have some code that need to continuously do tons of computation while still responding to command from stdin.

i was even considering unix socket to communicate between multi process but... windows....

The best case scenario would be phtread of course. But i would need to use cygwin on windows to handle it.
I don't even know how to use pthread from fortran actually.

Re: any lib for multiplateform multithreading / multiprocessing ?

it seems there is a windows version of openmpi, no idea yet how to integrate the whole stuff into simply fortran.
And, ultimately, running openmpi application isn't very user friendly big_smile

Re: any lib for multiplateform multithreading / multiprocessing ?

The most "Fortran" way to do this might be to take advantage of coarray support.  You can have one image continue to respond to input while the other images would be performing calculations.  However, coarray support still isn't ideal for what you're discussing.  It's probably not as flexible as you'd like.  Simply Fortran on Windows supports coarrays without needing MPI, but you'd need MPI on other platforms.

Pthreads aren't particularly portable just because you'll need a wrapper on Windows.  We don't currently ship a Fortran-accessible Pthreads library with Windows, though we could make it available if there was interest.   

We ship OpenMP with all our platforms, so that's also an option.   Again, though, OpenMP might not be as flexible as you'd wish.

Jeff Armstrong
Approximatrix, LLC

Re: any lib for multiplateform multithreading / multiprocessing ?

Do you think it would be difficult to do a pthread module ?
I never ever used C library from fortran so i have no idea.

It could be educational for me to do it but pthread isn't an ideal practice target big_smile

I tried to think of a way to use coarray and openmp for my problem but everything feel like a terribly dirty hack

Re: any lib for multiplateform multithreading / multiprocessing ?

i have the feeling that mixing pthread and openmp would be a terrible nightmare so... i'm not sure.

Re: any lib for multiplateform multithreading / multiprocessing ?

There are Fortran pthread wrappers (here, for example) that should make things easier.  Mixing OpenMP and pthread calls shouldn't be problematic in theory, but it probably is in practice.  We can look at packaging a thread wrapping library, though.  I think that would make sense to include with the compiler.

Jeff Armstrong
Approximatrix, LLC

Re: any lib for multiplateform multithreading / multiprocessing ?

Hi, I have a queston related to this thread.

I have Fortran source code which expects an MPI implementation to be available.  But I cannot compile it under Simply Fortran because it cannot find the MPI module. When the compiler finds
USE MPI
that is a fatal error.

The source code in question is FDS, the Fire Dynamic Simulator, and it is distributed to run under Linux, Mac OS, and Windows.  But in their makefile they only give examples of compiling using the Intel Windows compiler, which supports their own MPI implementation.  Now there is an OpenMPI which has a fortran binding, but I don't see how to use it under Windows.  The free OpenMPI appears to be primarily supported in Linux and Mac OS.

So, I am trying to figure out if I can continue to use Windows 10 and Simply Fortran while also compiling this FDS Fotran source to produce a Windows exe.  Any advice or help?  Best I have come up with so far is to explore either Cygwin or Linux Bash shell under Windows. 

Thanks

CR

Re: any lib for multiplateform multithreading / multiprocessing ?

cboardman wrote:

I have Fortran source code which expects an MPI implementation to be available.  But I cannot compile it under Simply Fortran because it cannot find the MPI module. When the compiler finds
USE MPI
that is a fatal error.

CR,

Simply Fortran for Windows does not include an MPI implementation in the standard installation.  You can install Microsoft MPI for Windows, but there is a significant amount of work involved in getting it running with our compiler (Microsoft assumes you'll be using Visual C++).  We offer an older version through the SF Package Manager that should work as-is.  However, the Microsoft MPI packages are only MPI 2.0 compliant.  If you need MPI 3, there really isn't an alternative other than maybe Intel's offering.

If you are on Windows 10, you might want to consider installing the Windows Subsystem for Linux.  It will allow you to install and run native Linux applications under Windows (including Simply Fortran and MPI) with a bit of work involved.

Sorry for the disappointing news.

Jeff Armstrong
Approximatrix, LLC