Damian Rouson <
dam...@rouson.net> schrieb:
> On Monday, August 27, 2018 at 8:19:31 AM UTC-7, Stefano Zaghi wrote:
>> Il giorno domenica 26 agosto 2018 20:57:27 UTC+2, Thomas Koenig ha scritto:
>> >
>> > the development version of gfortran (aka trunk) now has real
>> > asynchronous I/O.
>
> Thanks for this great news.
>
>> >
>> > In order to use it, the pthread library has to be linked in.
>
> Could you explain how to ensure this?
You need to add the pthread library during the linking step of your program.
This is valid for Linux. On systems like MacOS or Solaris, this is not
needed because pthreads is part of the normal libc. On systems which
lack POSIX condition variables, like AIX, async I/O does not work
for gfortran.
Examples, with separate compilation and linking:
$ gfortran -c hi.f90
$ gfortran -pthread hi.o
or
$ gfortran -c hi.f90
$ gfortran hi.o -lpthread
or
$ gfortran -fopenmp -c hi.f90
$ gfortran -fopenmp hi.o
The last version is only recommended when you want to use OpenMP
anyway, because of the other things that -fopenmp does, like
enabling -frecursive by default. If you use -fopenmp anyway and
have asynchronous I/O statements in your code, you will also get
real asynchronous I/O.
Compilation and linking in one step is
>> > $ gfortran hi.f90
>
> Given that there's no indication of linking in the pthread library above,
It doesn't. If you don't link in pthreads, your code is still
accepted, but the behavior is the same as before the patch -
I/O will then be done sequentially.
You can check if this works by using the example program I posted
before. If you are on a multiprocessor system and time reports
something like
real 0m5.669s
user 0m16.484s
sys 0m0.292s
(User time approximately three times real time), then you know that
I/O was indeed done asynchronously. If what you get looks like
real 0m15.003s
user 0m14.826s
sys 0m0.176s
then the I/O ran synchronously.
By the way, remember to put in these WAIT statements - we found a
few bugs in the gfortran test suite where these hat been omitted :-)