Interesting issue with OpenMP in a DLL, with gfortran on Windows

  • Follow


I have some code using OpenMP that I build as a DLL with gfortran, then call 
from a C++ main program.  There are two ways I can link the library, either at 
compile-time, or at run-time, in which case the library is loaded during program 
execution.  I have found that on Windows the compile-time linking disables 
OpenMP procedures, while the run-time linking functions as expected.  On Linux 
both work fine.

The Windows compile-time version crashes when I invoke the first OpenMP 
function, which is omp_get_num_procs().  If I specify that the DLL should 
execute using only a single thread, in which case the OpenMP functions are not 
invoked, the code executes correctly.

This isn't a critical issue for me, since I can use run-time loading, but it 
does provoke my curiosity.
0
Reply Gib 9/26/2010 1:52:49 AM

On 9/25/2010 6:52 PM, Gib Bogle wrote:
> I have some code using OpenMP that I build as a DLL with gfortran, then
> call from a C++ main program. There are two ways I can link the library,
> either at compile-time, or at run-time, in which case the library is
> loaded during program execution. I have found that on Windows the
> compile-time linking disables OpenMP procedures, while the run-time
> linking functions as expected. On Linux both work fine.
>
> The Windows compile-time version crashes when I invoke the first OpenMP
> function, which is omp_get_num_procs(). If I specify that the DLL should
> execute using only a single thread, in which case the OpenMP functions
> are not invoked, the code executes correctly.
>
> This isn't a critical issue for me, since I can use run-time loading,
> but it does provoke my curiosity.
You don't get OpenMP library support for gfortran on Windows by magic.
Besides, there are several implementations of C++ and gfortran for 
Windows.  No intelligent comment can be made without some details from 
you, including the result of gfortran -v, which will show whether 
libgomp was enabled in the configuration, and perhaps which type of 
gfortran it is.  As far as I know, gfortran doesn't work with any OpenMP 
library which doesn't at least act like libgomp,
nor is there any interface that I know of between gfortran and vcomp, 
the Microsoft OpenMP library, in case you are using MSVC++.  Intel 
libiomp for linux implements the libgomp function calls, but Intel 
libiomp for Windows instead implements vcomp functions.
While libgomp builds and passes some tests with certain Windows versions 
of gfortran, and doesn't normally "crash," I haven't had any success 
with it on Windows (for example, I'd like to see some cases where 2 
threads improve performance over 1).  On linux, libgomp is among the 
best OpenMP implementations.

-- 
Tim Prince
0
Reply Tim 9/26/2010 3:12:24 AM


On 9/25/2010 6:52 PM, Gib Bogle wrote:
> I have some code using OpenMP that I build as a DLL with gfortran, then
> call from a C++ main program. There are two ways I can link the library,
> either at compile-time, or at run-time, in which case the library is
> loaded during program execution. I have found that on Windows the
> compile-time linking disables OpenMP procedures, while the run-time
> linking functions as expected. On Linux both work fine.
>
> The Windows compile-time version crashes when I invoke the first OpenMP
> function, which is omp_get_num_procs(). If I specify that the DLL should
> execute using only a single thread, in which case the OpenMP functions
> are not invoked, the code executes correctly.
>
> This isn't a critical issue for me, since I can use run-time loading,
> but it does provoke my curiosity.
You don't get OpenMP library support for gfortran on Windows by magic.
Besides, there are several implementations of C++ and gfortran for 
Windows.  No intelligent comment can be made without some details from 
you, including the result of gfortran -v, which will show whether 
libgomp was enabled in the configuration, and perhaps which type of 
gfortran it is.  As far as I know, gfortran doesn't work with any OpenMP 
library which doesn't at least act like libgomp,
nor is there any interface that I know of between gfortran and vcomp, 
the Microsoft OpenMP library, in case you are using MSVC++.  Intel 
libiomp for linux implements the libgomp function calls, but Intel 
libiomp for Windows instead implements vcomp functions.
While libgomp builds and passes some tests with certain Windows versions 
of gfortran, and doesn't normally "crash," I haven't had any success 
with it on Windows (for example, I'd like to see some cases where 2 
threads improve performance over 1).  On linux, libgomp is among the 
best OpenMP implementations.

-- 
Tim Prince
0
Reply Tim 9/26/2010 3:12:51 AM

On 9/25/2010 6:52 PM, Gib Bogle wrote:
> I have some code using OpenMP that I build as a DLL with gfortran, then
> call from a C++ main program. There are two ways I can link the library,
> either at compile-time, or at run-time, in which case the library is
> loaded during program execution. I have found that on Windows the
> compile-time linking disables OpenMP procedures, while the run-time
> linking functions as expected. On Linux both work fine.
>
> The Windows compile-time version crashes when I invoke the first OpenMP
> function, which is omp_get_num_procs(). If I specify that the DLL should
> execute using only a single thread, in which case the OpenMP functions
> are not invoked, the code executes correctly.
>
> This isn't a critical issue for me, since I can use run-time loading,
> but it does provoke my curiosity.
You don't get OpenMP library support for gfortran on Windows by magic.
Besides, there are several implementations of C++ and gfortran for 
Windows.  No intelligent comment can be made without some details from 
you, including the result of gfortran -v, which will show whether 
libgomp was enabled in the configuration, and perhaps which type of 
gfortran it is.  As far as I know, gfortran doesn't work with any OpenMP 
library which doesn't at least act like libgomp,
nor is there any interface that I know of between gfortran and vcomp, 
the Microsoft OpenMP library, in case you are using MSVC++.  Intel 
libiomp for linux implements the libgomp function calls, but Intel 
libiomp for Windows instead implements vcomp functions.
While libgomp builds and passes some tests with certain Windows versions 
of gfortran, and doesn't normally "crash," I haven't had any success 
with it on Windows (for example, I'd like to see some cases where 2 
threads improve performance over 1).  On linux, libgomp is among the 
best OpenMP implementations.

-- 
Tim Prince
0
Reply Tim 9/26/2010 3:13:17 AM

On 26/09/2010 4:13 p.m., Tim Prince wrote:
> On 9/25/2010 6:52 PM, Gib Bogle wrote:
>> I have some code using OpenMP that I build as a DLL with gfortran, then
>> call from a C++ main program. There are two ways I can link the library,
>> either at compile-time, or at run-time, in which case the library is
>> loaded during program execution. I have found that on Windows the
>> compile-time linking disables OpenMP procedures, while the run-time
>> linking functions as expected. On Linux both work fine.
>>
>> The Windows compile-time version crashes when I invoke the first OpenMP
>> function, which is omp_get_num_procs(). If I specify that the DLL should
>> execute using only a single thread, in which case the OpenMP functions
>> are not invoked, the code executes correctly.
>>
>> This isn't a critical issue for me, since I can use run-time loading,
>> but it does provoke my curiosity.
> You don't get OpenMP library support for gfortran on Windows by magic.
> Besides, there are several implementations of C++ and gfortran for Windows. No
> intelligent comment can be made without some details from you, including the
> result of gfortran -v, which will show whether libgomp was enabled in the
> configuration, and perhaps which type of gfortran it is. As far as I know,
> gfortran doesn't work with any OpenMP library which doesn't at least act like
> libgomp,
> nor is there any interface that I know of between gfortran and vcomp, the
> Microsoft OpenMP library, in case you are using MSVC++. Intel libiomp for linux
> implements the libgomp function calls, but Intel libiomp for Windows instead
> implements vcomp functions.
> While libgomp builds and passes some tests with certain Windows versions of
> gfortran, and doesn't normally "crash," I haven't had any success with it on
> Windows (for example, I'd like to see some cases where 2 threads improve
> performance over 1). On linux, libgomp is among the best OpenMP implementations.
>

Tim, OpenMP is working on my Windows system, calling my gfortran-built DLL from 
a gcc-built C++ program.  It works when the library is loaded at run-time.  In 
this case it performs as you'd expect OpenMP to perform.  The speedup on my code 
is about 2x going from one to three threads, which is roughly the same as what I 
see on Linux.  The only difference between the case that works and the case that 
doesn't is how the linking is done.  The DLL is the same in both cases.

I'm using mingw-4.4.4.  Here is the output of gfortran -v:

Built by Equation Solution <http://www.Equation.com>.
Using built-in specs.
Target: i686-pc-mingw32
Configured with: ../gcc-4.4.4-mingw/configure --host=i686-pc-mingw32 
--build=x86_64-unknown-linux-gnu --target=i686-pc-mingw32 
--prefix=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/gcc/4.4.4 
--with-gcc --with-gnu-ld --with-gnu-as --disable-shared --disable-nls 
--disable-tls 
--with-gmp=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/gmp 
--with-mpfr=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/mpfr 
--with-mpc=/home/gfortran/gcc-home/binary/mingw32/native/x86_32/mpc 
--enable-languages=c,fortran,c++ 
--with-sysroot=/home/gfortran/gcc-home/binary/mingw32/cross/x86_32/gcc/4.4.4 
--enable-libgomp --enable-threads=win32 --disable-win32-registry
Thread model: win32
gcc version 4.4.4 (GCC)


0
Reply g.bogle (180) 9/26/2010 3:58:20 AM

On Sep 25, 8:58=A0pm, Gib Bogle <g.bo...@auckland.no.spam.ac.nz> wrote:

> Built by Equation Solution <http://www.Equation.com>.

This is not a gcc or gfortran issue.  Equation.com has
replaced the GCC implementation of libgomp with their
own version.  Furthermore, equation.com may have made
local source code changes to their gcc tree, but no
one knows because equation.com refuses to answer email
request for the source code to the compiler they
distribute.

--
steve
0
Reply kargls (354) 9/26/2010 4:30:23 AM

Tim Prince wrote:
> On 9/25/2010 6:52 PM, Gib Bogle wrote:
>> I have some code using OpenMP that I build as a DLL with gfortran, then
>> call from a C++ main program. There are two ways I can link the library,
>> either at compile-time, or at run-time, in which case the library is
>> loaded during program execution. I have found that on Windows the
>> compile-time linking disables OpenMP procedures, while the run-time
>> linking functions as expected. On Linux both work fine.
>>
>> The Windows compile-time version crashes when I invoke the first OpenMP
>> function, which is omp_get_num_procs(). If I specify that the DLL should
>> execute using only a single thread, in which case the OpenMP functions
>> are not invoked, the code executes correctly.
>>
>> This isn't a critical issue for me, since I can use run-time loading,
>> but it does provoke my curiosity.
> You don't get OpenMP library support for gfortran on Windows by magic.
> Besides, there are several implementations of C++ and gfortran for 
> Windows.  No intelligent comment can be made without some details from 
> you, including the result of gfortran -v, which will show whether 
> libgomp was enabled in the configuration, and perhaps which type of 
> gfortran it is.  As far as I know, gfortran doesn't work with any OpenMP 
> library which doesn't at least act like libgomp,
> nor is there any interface that I know of between gfortran and vcomp, 
> the Microsoft OpenMP library, in case you are using MSVC++.  Intel 
> libiomp for linux implements the libgomp function calls, but Intel 
> libiomp for Windows instead implements vcomp functions.
> While libgomp builds and passes some tests with certain Windows versions 
> of gfortran, and doesn't normally "crash," I haven't had any success 
> with it on Windows (for example, I'd like to see some cases where 2 
> threads improve performance over 1).  On linux, libgomp is among the 
> best OpenMP implementations.
> 

Well I've been walking around as a representative of timothy today, 
which I used to associate with my russian professor at BGSU, Tim Pogacar.

Tim,

I've never achieved a functioning OpenMp install, but I can express that 
failure in several languages.

If you think you have a robust mingw install, I would be very curious to 
see what the ls * yields or the windows equivalent.
-- 
Uno
0
Reply Uno 9/26/2010 4:38:28 AM

steve wrote:
> On Sep 25, 8:58 pm, Gib Bogle <g.bo...@auckland.no.spam.ac.nz> wrote:
> 
>> Built by Equation Solution <http://www.Equation.com>.
> 
> This is not a gcc or gfortran issue.  Equation.com has
> replaced the GCC implementation of libgomp with their
> own version.  Furthermore, equation.com may have made
> local source code changes to their gcc tree, but no
> one knows because equation.com refuses to answer email
> request for the source code to the compiler they
> distribute.

My feeling is that english isn't their first language.

Maybe they don't pick up on you being glib.
-- 
Uno
0
Reply Uno 9/26/2010 5:50:07 AM

On 26/09/2010 5:30 p.m., steve wrote:
> On Sep 25, 8:58 pm, Gib Bogle<g.bo...@auckland.no.spam.ac.nz>  wrote:
>
>> Built by Equation Solution<http://www.Equation.com>.
>
> This is not a gcc or gfortran issue.  Equation.com has
> replaced the GCC implementation of libgomp with their
> own version.  Furthermore, equation.com may have made
> local source code changes to their gcc tree, but no
> one knows because equation.com refuses to answer email
> request for the source code to the compiler they
> distribute.
>
> --
> steve

That's interesting.  Where would recommend that I download gcc with gfortran, 
for Windows?
0
Reply g.bogle (180) 9/26/2010 7:03:08 AM

> My feeling is that english isn't their first language.

Well, it isn't the first language of many of us here either. Same goes
for many GCC and gfortran developers. Yet, somehow, we try our best.

-- 
FX
0
Reply FX 9/26/2010 10:11:58 AM

On 9/26/2010 12:03 AM, Gib Bogle wrote:
> On 26/09/2010 5:30 p.m., steve wrote:
>> On Sep 25, 8:58 pm, Gib Bogle<g.bo...@auckland.no.spam.ac.nz> wrote:
>>
>>> Built by Equation Solution<http://www.Equation.com>.
>>
>> This is not a gcc or gfortran issue. Equation.com has
>> replaced the GCC implementation of libgomp with their
>> own version. Furthermore, equation.com may have made
>> local source code changes to their gcc tree, but no
>> one knows because equation.com refuses to answer email
>> request for the source code to the compiler they
>> distribute.
>>
>> --
>> steve
>
> That's interesting. Where would recommend that I download gcc with
> gfortran, for Windows?
gfortran wiki or sourceforge, but I don't count on OpenMP of the same 
quality as for linux, which I took to be your original question

-- 
Tim Prince
0
Reply tprince8714 (291) 9/26/2010 2:12:49 PM

On 27/09/2010 3:12 a.m., Tim Prince wrote:
> On 9/26/2010 12:03 AM, Gib Bogle wrote:
>> On 26/09/2010 5:30 p.m., steve wrote:
>>> On Sep 25, 8:58 pm, Gib Bogle<g.bo...@auckland.no.spam.ac.nz> wrote:
>>>
>>>> Built by Equation Solution<http://www.Equation.com>.
>>>
>>> This is not a gcc or gfortran issue. Equation.com has
>>> replaced the GCC implementation of libgomp with their
>>> own version. Furthermore, equation.com may have made
>>> local source code changes to their gcc tree, but no
>>> one knows because equation.com refuses to answer email
>>> request for the source code to the compiler they
>>> distribute.
>>>
>>> --
>>> steve
>>
>> That's interesting. Where would recommend that I download gcc with
>> gfortran, for Windows?
> gfortran wiki or sourceforge, but I don't count on OpenMP of the same quality as
> for linux, which I took to be your original question
>

I've found searching for gfortran on sourceforge to be a fruitless exercise, 
since it just suggests that you visit the gfortran wiki.  The gfortran wiki 
directs you to the MinGW site.  The mingw-4.4.0 that I installed, I think from 
sourceforge, did not include gfortran.  I want to use gcc-4.4, but I couldn't 
find it on the MinGW site (the download version there is 4.5).  An official 
download for gfortran-4.4 presumably exists somewhere, but I don't know where.
0
Reply g.bogle (180) 9/26/2010 8:45:39 PM

Gib Bogle wrote:
> 
> I've found searching for gfortran on sourceforge to be a fruitless exercise,
> since it just suggests that you visit the gfortran wiki.  The gfortran wiki
> directs you to the MinGW site.  The mingw-4.4.0 that I installed, I think from
> sourceforge, did not include gfortran.  I want to use gcc-4.4, but I couldn't
> find it on the MinGW site (the download version there is 4.5).  An official
> download for gfortran-4.4 presumably exists somewhere, but I don't know where.

The official source for gfortran is a GCC release bundle from
gcc.gnu.org.  Gfortran is a companion development with the GNU C
Compiler.  They now say that GCC stands for the "GNU Compiler
Collection", rather than the former meaning "GNU C Compiler".  IMO both
meanings apply, depending on context.

A full GCC download bundle, either source or precompiled binaries, will
include gcc, gfortran, C++ and other languages.  Separate components of
each release bundle, e.g. gfortran separately, as well as the full
bundles, can be downloaded from the many mirror sites as well as the
main GNU FTP server.  Current and historical releases are available. 
Here is the best reference for the many download sites:

  http://gcc.gnu.org/mirrors.html

The best index to *on-line* gcc and gfortran documentation is here:

  http://gcc.gnu.org/onlinedocs/

You may be wondering about version numbers.  I believe that gfortran
version numbers track gcc version numbers, e.g. get bundle GCC 4.4.4 if
you want gfortran 4.4.4.  HTH.

--Dave
0
Reply nospom (125) 9/27/2010 4:43:20 AM

On 27/09/2010 5:43 p.m., Dave Allured wrote:
> Gib Bogle wrote:
>>
>> I've found searching for gfortran on sourceforge to be a fruitless exercise,
>> since it just suggests that you visit the gfortran wiki.  The gfortran wiki
>> directs you to the MinGW site.  The mingw-4.4.0 that I installed, I think from
>> sourceforge, did not include gfortran.  I want to use gcc-4.4, but I couldn't
>> find it on the MinGW site (the download version there is 4.5).  An official
>> download for gfortran-4.4 presumably exists somewhere, but I don't know where.
>
> The official source for gfortran is a GCC release bundle from
> gcc.gnu.org.  Gfortran is a companion development with the GNU C
> Compiler.  They now say that GCC stands for the "GNU Compiler
> Collection", rather than the former meaning "GNU C Compiler".  IMO both
> meanings apply, depending on context.
>
> A full GCC download bundle, either source or precompiled binaries, will
> include gcc, gfortran, C++ and other languages.  Separate components of
> each release bundle, e.g. gfortran separately, as well as the full
> bundles, can be downloaded from the many mirror sites as well as the
> main GNU FTP server.  Current and historical releases are available.
> Here is the best reference for the many download sites:
>
>    http://gcc.gnu.org/mirrors.html
>
> The best index to *on-line* gcc and gfortran documentation is here:
>
>    http://gcc.gnu.org/onlinedocs/
>
> You may be wondering about version numbers.  I believe that gfortran
> version numbers track gcc version numbers, e.g. get bundle GCC 4.4.4 if
> you want gfortran 4.4.4.  HTH.
>
> --Dave

Hi Dave, as far as I can see the gfortran bundles are source code, and very much 
Unix oriented.  I downloaded the bundle for gfortran-4.4.4, but I am not able to 
build it (without considerable effort, and probably several mistakes).  What I 
really want is the gfortran-4.4 binaries for Windows.  This seems to require one 
to go elsewhere than the Gnu site, or sourceforge.  I'll be happy to be corrected.
0
Reply g.bogle (180) 9/27/2010 7:12:25 AM

On 9/27/2010 12:12 AM, Gib Bogle wrote:

>  What I
> really want is the gfortran-4.4 binaries for Windows.  This seems to require one
> to go elsewhere than the Gnu site, or sourceforge.  I'll be happy to be corrected.

did you try mingw?  I just installed it the other day, one click is all 
I had to do.


$ gfortran -v
Using built-in specs.
COLLECT_GCC=C:\MinGW\bin\gfortran.exe
Thread model: win32
gcc version 4.5.0 (GCC)


I download the installer and it did everything. I Click on the shell, it 
opens, and I type gfortran. It is all there.

Installer I used is mingw-get-inst-20100909.exe  , here is the link

http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/mingw-get-inst-20100909/

Just double click on it when it is finished downloading, and it will do 
the rest.


I also have cygwin, but gfortran there is a little behind mingw:

$ gfortran -v
Using built-in specs.
Target: i686-pc-cygwin
Thread model: posix
gcc version 4.3.4 20090804 (release) 1 (GCC)

--Nasser
0
Reply Nasser 9/27/2010 7:23:09 AM

On 27/09/2010 8:23 p.m., Nasser M. Abbasi wrote:
> On 9/27/2010 12:12 AM, Gib Bogle wrote:
>
>> What I
>> really want is the gfortran-4.4 binaries for Windows. This seems to require one
>> to go elsewhere than the Gnu site, or sourceforge. I'll be happy to be corrected.
>
> did you try mingw? I just installed it the other day, one click is all I had to do.
>
>
> $ gfortran -v
> Using built-in specs.
> COLLECT_GCC=C:\MinGW\bin\gfortran.exe
> Thread model: win32
> gcc version 4.5.0 (GCC)

I have mingw-4.5.0. I also have mingw-4.4.4.  If you read the whole thread 
you'll understand why the issue of obtaining gfortran-4.4 came up.
0
Reply Gib 9/27/2010 8:26:22 AM

On Sep 27, 5:26=A0am, Gib Bogle <g.bo...@auckland.no.spam.ac.nz> wrote:
> On 27/09/2010 8:23 p.m., Nasser M. Abbasi wrote:
>
> > On 9/27/2010 12:12 AM, Gib Bogle wrote:
>
> >> What I
> >> really want is the gfortran-4.4 binaries for Windows. This seems to re=
quire one
> >> to go elsewhere than the Gnu site, or sourceforge. I'll be happy to be=
 corrected.
>
> > did you try mingw? I just installed it the other day, one click is all =
I had to do.
>
> > $ gfortran -v
> > Using built-in specs.
> > COLLECT_GCC=3DC:\MinGW\bin\gfortran.exe
> > Thread model: win32
> > gcc version 4.5.0 (GCC)
>
> I have mingw-4.5.0. I also have mingw-4.4.4. =A0If you read the whole thr=
ead
> you'll understand why the issue of obtaining gfortran-4.4 came up.

Interesting... I installed gfortran from tdm some time ago,

D:\fernando\OPENMP~1\code>gfortran -v
Using built-in specs.
Target: mingw32
Configured with: ../../gcc-4.4.1/configure --prefix=3D/mingw --
build=3Dmingw32 --ena
ble-languages=3Dc,ada,c++,fortran,objc,obj-c++ --disable-nls --disable-
win32-regis
try --enable-libgomp --enable-cxx-flags=3D'-fno-function-sections -fno-
data-sectio
ns' --disable-werror --enable-threads --disable-symvers --enable-
version-specifi
c-runtime-libs --enable-fully-dynamic-string --with-pkgversion=3D'TDM-2
mingw32' -
-enable-sjlj-exceptions --with-bugurl=3Dhttp://www.tdragon.net/recentgcc/
bugs.php
Thread model: win32
gcc version 4.4.1 (TDM-2 mingw32)

which does not link except when I include the -static option:

D:\fernando\OpenMP-related\code>gfortran -fopenmp matmul.f90
d:/fernando/mingw/bin/../lib/gcc/mingw32/4.4.1/crtbegin.o:cygming-
crtbegin.c:(.
ext+0x7): undefined reference to `__cmshared_create_or_grab'
collect2: ld returned 1 exit status

D:\fernando\OpenMP-related\code>gfortran -static -fopenmp matmul.f90

And OpenMP seems to work as expected:

D:\fernando\OPENMP~1\code>a.exe
 calculating A matrix...
 there are            1  threads
 A matrix finished in   37.552999973297119      seconds

D:\fernando\OpenMP-related\code>a.exe
 calculating A matrix...
 there are            2  threads
 A matrix finished in   24.812999963760376      seconds

(CPU: P4 HT, my code is far from being optimized).

I didn't know about
> This is not a gcc or gfortran issue.  Equation.com has
> replaced the GCC implementation of libgomp with their
> own version.  Furthermore, equation.com may have made
> local source code changes to their gcc tree, but no
> one knows because equation.com refuses to answer email
> request for the source code to the compiler they
> distribute.
since I didn't use equation.com packages... and now I think I'll try
to avoid using those...

Maybe every "source" of packages has their own version numbers? I get
lost easily when developing in the Windows environment, I don't have
much code for Windows...

Fernando.





0
Reply ftinetti (148) 9/27/2010 12:56:46 PM

Gib Bogle wrote:
> 
> On 27/09/2010 5:43 p.m., Dave Allured wrote:
> > Gib Bogle wrote:
> >>
> >> I've found searching for gfortran on sourceforge to be a fruitless exercise,
> >> since it just suggests that you visit the gfortran wiki.  The gfortran wiki
> >> directs you to the MinGW site.  The mingw-4.4.0 that I installed, I think from
> >> sourceforge, did not include gfortran.  I want to use gcc-4.4, but I couldn't
> >> find it on the MinGW site (the download version there is 4.5).  An official
> >> download for gfortran-4.4 presumably exists somewhere, but I don't know where.
> >
> > The official source for gfortran is a GCC release bundle from
> > gcc.gnu.org.  Gfortran is a companion development with the GNU C
> > Compiler.  They now say that GCC stands for the "GNU Compiler
> > Collection", rather than the former meaning "GNU C Compiler".  IMO both
> > meanings apply, depending on context.
> >
> > A full GCC download bundle, either source or precompiled binaries, will
> > include gcc, gfortran, C++ and other languages.  Separate components of
> > each release bundle, e.g. gfortran separately, as well as the full
> > bundles, can be downloaded from the many mirror sites as well as the
> > main GNU FTP server.  Current and historical releases are available.
> > Here is the best reference for the many download sites:
> >
> >    http://gcc.gnu.org/mirrors.html
> >
> > The best index to *on-line* gcc and gfortran documentation is here:
> >
> >    http://gcc.gnu.org/onlinedocs/
> >
> > You may be wondering about version numbers.  I believe that gfortran
> > version numbers track gcc version numbers, e.g. get bundle GCC 4.4.4 if
> > you want gfortran 4.4.4.  HTH.
> >
> > --Dave
> 
> Hi Dave, as far as I can see the gfortran bundles are source code, and very much
> Unix oriented.  I downloaded the bundle for gfortran-4.4.4, but I am not able to
> build it (without considerable effort, and probably several mistakes).  What I
> really want is the gfortran-4.4 binaries for Windows.  This seems to require one
> to go elsewhere than the Gnu site, or sourceforge.  I'll be happy to be corrected.

Gib, you are right, the primary bundles are source code only.  I do not
have experience with binaries for Windows or compiling for Windows;
please get advice from others.  The discussion about mingw seems
encouraging.

--Dave
0
Reply nospom (125) 9/27/2010 3:55:46 PM

On 28/09/2010 4:55 a.m., Dave Allured wrote:
> Gib Bogle wrote:
>>
>> On 27/09/2010 5:43 p.m., Dave Allured wrote:
>>> Gib Bogle wrote:
>>>>
>>>> I've found searching for gfortran on sourceforge to be a fruitless exercise,
>>>> since it just suggests that you visit the gfortran wiki.  The gfortran wiki
>>>> directs you to the MinGW site.  The mingw-4.4.0 that I installed, I think from
>>>> sourceforge, did not include gfortran.  I want to use gcc-4.4, but I couldn't
>>>> find it on the MinGW site (the download version there is 4.5).  An official
>>>> download for gfortran-4.4 presumably exists somewhere, but I don't know where.
>>>
>>> The official source for gfortran is a GCC release bundle from
>>> gcc.gnu.org.  Gfortran is a companion development with the GNU C
>>> Compiler.  They now say that GCC stands for the "GNU Compiler
>>> Collection", rather than the former meaning "GNU C Compiler".  IMO both
>>> meanings apply, depending on context.
>>>
>>> A full GCC download bundle, either source or precompiled binaries, will
>>> include gcc, gfortran, C++ and other languages.  Separate components of
>>> each release bundle, e.g. gfortran separately, as well as the full
>>> bundles, can be downloaded from the many mirror sites as well as the
>>> main GNU FTP server.  Current and historical releases are available.
>>> Here is the best reference for the many download sites:
>>>
>>>     http://gcc.gnu.org/mirrors.html
>>>
>>> The best index to *on-line* gcc and gfortran documentation is here:
>>>
>>>     http://gcc.gnu.org/onlinedocs/
>>>
>>> You may be wondering about version numbers.  I believe that gfortran
>>> version numbers track gcc version numbers, e.g. get bundle GCC 4.4.4 if
>>> you want gfortran 4.4.4.  HTH.
>>>
>>> --Dave
>>
>> Hi Dave, as far as I can see the gfortran bundles are source code, and very much
>> Unix oriented.  I downloaded the bundle for gfortran-4.4.4, but I am not able to
>> build it (without considerable effort, and probably several mistakes).  What I
>> really want is the gfortran-4.4 binaries for Windows.  This seems to require one
>> to go elsewhere than the Gnu site, or sourceforge.  I'll be happy to be corrected.
>
> Gib, you are right, the primary bundles are source code only.  I do not
> have experience with binaries for Windows or compiling for Windows;
> please get advice from others.  The discussion about mingw seems
> encouraging.
>
> --Dave

I do have a couple of mingw versions, but the one I have for gcc-4.4 that 
includes gfortran is from equation.com, and this whole discussion was triggered 
by a remark that cast some doubt on equation.com.  In fact equation.com's build 
of gfortran may be perfectly OK.  It has seemed to work fine in every respect, 
except for the curious situation described in my original post, and for all I 
know this behaviour may be shared by the 'kosher' gfortran/gomp.

In any case there is no obvious way to obtain any mingw package before the 
current one (5.6.1, I think).
0
Reply g.bogle (180) 9/27/2010 8:21:31 PM

On 9/27/2010 1:26 AM, Gib Bogle wrote:
> On 27/09/2010 8:23 p.m., Nasser M. Abbasi wrote:
>> On 9/27/2010 12:12 AM, Gib Bogle wrote:
>>
>>> What I
>>> really want is the gfortran-4.4 binaries for Windows. This seems to
>>> require one
>>> to go elsewhere than the Gnu site, or sourceforge. I'll be happy to
>>> be corrected.
>>
>> did you try mingw? I just installed it the other day, one click is all
>> I had to do.
>>
>>
>> $ gfortran -v
>> Using built-in specs.
>> COLLECT_GCC=C:\MinGW\bin\gfortran.exe
>> Thread model: win32
>> gcc version 4.5.0 (GCC)
>
> I have mingw-4.5.0. I also have mingw-4.4.4. If you read the whole
> thread you'll understand why the issue of obtaining gfortran-4.4 came up.

I can tell you that compiling gfortran for mingw is not a trivial task 
to get set up.  Even with a good set of build scripts from FX, it still 
took me several days of trial and error to sort out version issues.

I did read the entire thread and I don't understand why you are tied to 
gfortran 4.4 other than that is what the equation.com folks have.  Why 
not try the version on the gfortran wiki (version 4.6), which has whole 
file optimization available?

0
Reply baf 9/28/2010 3:41:24 AM

On 28/09/2010 4:41 p.m., baf wrote:
> On 9/27/2010 1:26 AM, Gib Bogle wrote:
>> On 27/09/2010 8:23 p.m., Nasser M. Abbasi wrote:
>>> On 9/27/2010 12:12 AM, Gib Bogle wrote:
>>>
>>>> What I
>>>> really want is the gfortran-4.4 binaries for Windows. This seems to
>>>> require one
>>>> to go elsewhere than the Gnu site, or sourceforge. I'll be happy to
>>>> be corrected.
>>>
>>> did you try mingw? I just installed it the other day, one click is all
>>> I had to do.
>>>
>>>
>>> $ gfortran -v
>>> Using built-in specs.
>>> COLLECT_GCC=C:\MinGW\bin\gfortran.exe
>>> Thread model: win32
>>> gcc version 4.5.0 (GCC)
>>
>> I have mingw-4.5.0. I also have mingw-4.4.4. If you read the whole
>> thread you'll understand why the issue of obtaining gfortran-4.4 came up.
>
> I can tell you that compiling gfortran for mingw is not a trivial task to get
> set up. Even with a good set of build scripts from FX, it still took me several
> days of trial and error to sort out version issues.
>
> I did read the entire thread and I don't understand why you are tied to gfortran
> 4.4 other than that is what the equation.com folks have. Why not try the version
> on the gfortran wiki (version 4.6), which has whole file optimization available?
>

I've been using 4.4 because gcc-4.4 is the version that has been tested with 
some other C++ components of my project.  It may well be that I can upgrade 
everything to gcc-4.5.1, for example.  I haven't got around to this yet.  My 
initial post was about the odd issue I encountered using OpenMP in a library 
that can be linked in two different ways.  I thought it was worth mentioning 
because it might interest someone, not because I am dependent on solving it. 
Somehow the thread has wandered some distance from the starting point.
0
Reply Gib 9/28/2010 4:27:17 AM

On 9/27/2010 9:27 PM, Gib Bogle wrote:
> On 28/09/2010 4:41 p.m., baf wrote:
>> On 9/27/2010 1:26 AM, Gib Bogle wrote:
>>> On 27/09/2010 8:23 p.m., Nasser M. Abbasi wrote:
>>>> On 9/27/2010 12:12 AM, Gib Bogle wrote:
>>>>
>>>>> What I
>>>>> really want is the gfortran-4.4 binaries for Windows. This seems to
>>>>> require one
>>>>> to go elsewhere than the Gnu site, or sourceforge. I'll be happy to
>>>>> be corrected.
>>>>
>>>> did you try mingw? I just installed it the other day, one click is all
>>>> I had to do.
>>>>
>>>>
>>>> $ gfortran -v
>>>> Using built-in specs.
>>>> COLLECT_GCC=C:\MinGW\bin\gfortran.exe
>>>> Thread model: win32
>>>> gcc version 4.5.0 (GCC)
>>>
>>> I have mingw-4.5.0. I also have mingw-4.4.4. If you read the whole
>>> thread you'll understand why the issue of obtaining gfortran-4.4 came
>>> up.
>>
>> I can tell you that compiling gfortran for mingw is not a trivial task
>> to get
>> set up. Even with a good set of build scripts from FX, it still took
>> me several
>> days of trial and error to sort out version issues.
>>
>> I did read the entire thread and I don't understand why you are tied
>> to gfortran
>> 4.4 other than that is what the equation.com folks have. Why not try
>> the version
>> on the gfortran wiki (version 4.6), which has whole file optimization
>> available?
>>
>
> I've been using 4.4 because gcc-4.4 is the version that has been tested
> with some other C++ components of my project. It may well be that I can
> upgrade everything to gcc-4.5.1, for example. I haven't got around to
> this yet. My initial post was about the odd issue I encountered using
> OpenMP in a library that can be linked in two different ways. I thought
> it was worth mentioning because it might interest someone, not because I
> am dependent on solving it. Somehow the thread has wandered some
> distance from the starting point.


OK, then see the TDM-GCC 4.4 series at

http://sourceforge.net/projects/tdm-gcc/files_beta/

This site has 32 and 64 bit mingw versions of gcc and friends (including 
gfortran) packaged and ready to install.

0
Reply baf 9/28/2010 5:22:08 AM

> The Windows compile-time version crashes when I invoke the first OpenMP
> function, which is omp_get_num_procs().

Trying to help you actually solve your problem: what are the command
lines you use for compiling and linking?

-- 
FX
0
Reply FX 9/28/2010 7:15:25 AM

On Sep 28, 1:27=A0am, Gib Bogle <g.bo...@auckland.no.spam.ac.nz> wrote:
> On 28/09/2010 4:41 p.m., baf wrote:
>
>
>
>
>
> > On 9/27/2010 1:26 AM, Gib Bogle wrote:
> >> On 27/09/2010 8:23 p.m., Nasser M. Abbasi wrote:
> >>> On 9/27/2010 12:12 AM, Gib Bogle wrote:
>
> >>>> What I
> >>>> really want is the gfortran-4.4 binaries for Windows. This seems to
> >>>> require one
> >>>> to go elsewhere than the Gnu site, or sourceforge. I'll be happy to
> >>>> be corrected.
>
> >>> did you try mingw? I just installed it the other day, one click is al=
l
> >>> I had to do.
>
> >>> $ gfortran -v
> >>> Using built-in specs.
> >>> COLLECT_GCC=3DC:\MinGW\bin\gfortran.exe
> >>> Thread model: win32
> >>> gcc version 4.5.0 (GCC)
>
> >> I have mingw-4.5.0. I also have mingw-4.4.4. If you read the whole
> >> thread you'll understand why the issue of obtaining gfortran-4.4 came =
up.
>
> > I can tell you that compiling gfortran for mingw is not a trivial task =
to get
> > set up. Even with a good set of build scripts from FX, it still took me=
 several
> > days of trial and error to sort out version issues.
>
> > I did read the entire thread and I don't understand why you are tied to=
 gfortran
> > 4.4 other than that is what the equation.com folks have. Why not try th=
e version
> > on the gfortran wiki (version 4.6), which has whole file optimization a=
vailable?
>
> I've been using 4.4 because gcc-4.4 is the version that has been tested w=
ith
> some other C++ components of my project. =A0It may well be that I can upg=
rade
> everything to gcc-4.5.1, for example. =A0I haven't got around to this yet=
.. =A0My
> initial post was about the odd issue I encountered using OpenMP in a libr=
ary
> that can be linked in two different ways. =A0I thought it was worth menti=
oning
> because it might interest someone, not because I am dependent on solving =
it.
> Somehow the thread has wandered some distance from the starting point.

Well, this is neither the first thread nor the last one, I think,
ending at a different point relative to the starting one. And in this
specific thread is not bad at all, I think. I've learned a lot:
1) You report some issues with static linking with the gfortran
version you are using.
2) I have some issues with dynamic linking with the gfortran version
I'm using. Well... this is not a huge problem for me, I usually avoid
dynamic linking...
3) We (or some of us, including me) have some trouble to find and
install gfortran on Windows... Again not a huge problem for me, but
it's good to know in general.
4) People from equation.com may have changed gcc and libgomp. And they
don't answer e-mails...
And this is the kind of knowledge I expect to learn from a forum, by
the way.

Fernando.

0
Reply gmail 9/28/2010 11:15:08 AM

> Well, this is neither the first thread nor the last one, I think,
> ending at a different point relative to the starting one. And in this
> specific thread is not bad at all, I think. I've learned a lot:
> 1) You report some issues with static linking with the gfortran
> version you are using.
> 2) I have some issues with dynamic linking with the gfortran version
> I'm using. Well... this is not a huge problem for me, I usually avoid
> dynamic linking...
> 3) We (or some of us, including me) have some trouble to find and
> install gfortran on Windows... Again not a huge problem for me, but
> it's good to know in general.
> 4) People from equation.com may have changed gcc and libgomp. And they
> don't answer e-mails...
> And this is the kind of knowledge I expect to learn from a forum, by
> the way.
>
> Fernando.

This is a particularly good forum.
0
Reply Gib 9/29/2010 4:53:14 AM

On 28/09/2010 8:15 p.m., FX wrote:
>> The Windows compile-time version crashes when I invoke the first OpenMP
>> function, which is omp_get_num_procs().
>
> Trying to help you actually solve your problem: what are the command
> lines you use for compiling and linking?
>

The library compile lines are like this:

gfortran.exe -Wall  -Wtabs -cpp -O3 -fopenmp -m32 -DWINDOWS -DGFORTRAN 
-Wfatal-errors -D_OPENMP    -c C:\Users\Gib\ABM\omp_global.f90 -o 
obj\Release\omp_global.o

The library libpara32.dll is built like this:

gfortran.exe -shared -Wl,--output-def=Release\libpara32.dll.def 
-Wl,--out-implib=Release\libpara32.dll.a -Wl,--dll  obj\Release\par_zig_mod.o 
obj\Release\omp_rkf45.o obj\Release\Winsock_c.o obj\Release\omp_IL.o 
obj\Release\omp_global.o obj\Release\omp_motility.o obj\Release\omp_behaviour.o 
obj\Release\omp_diffuse.o obj\Release\omp_para.o obj\Release\tcpc.o 
obj\Release\clientc.o   -o Release\libpara32.dll -fopenmp --export-symbols -m32 
  ..\..\..\..\mingw-4.4.4\i686-pc-mingw32\lib\libws2_32.a

The C++ files are compiled like this:

g++ -c -Wno-deprecated -Wno-write-strings -O2 -frtti -fno-exceptions -Wall 
-DUNICODE -DQT_LARGEFILE_SUPPORT -D__GFORTRAN_DLL__ -D__COMPILETIME_LOADING__ 
-DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB 
-DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\Qt\4.7.0\include\QtCore" 
-I"..\..\..\Qt\4.7.0\include\QtNetwork" -I"..\..\..\Qt\4.7.0\include\QtGui" 
-I"..\..\..\Qt\4.7.0\include" -I"..\..\..\VTK-build-4.4.0-static" 
-I"..\..\..\VTK-build-4.4.0-static\rendering" -I"..\..\..\VTK-src\GUISupport\Qt" 
-I"..\..\..\VTK-src\common" -I"..\..\..\VTK-src\rendering" 
-I"..\..\..\VTK-src\graphics" -I"..\..\..\VTK-src\filtering" 
-I"..\..\..\VTK-src\IO" -I"..\..\..\VTK-src\imaging" -I"INCLUDEPATH" -I"+=" 
-I"..\..\..\qt\qwt-5.2.1\src" -I"..\..\..\Qt\4.7.0\include\ActiveQt" -I"release" 
-I"." -I"..\ABM_GUI" -I"." -I"..\..\..\Qt\4.7.0\mkspecs\win32-g++" -o 
release\misc.o ..\ABM_GUI\misc.cpp

and the C++ main program is built thus:

g++ -enable-stdcall-fixup -Wl,-enable-auto-import 
-Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,windows -o 
release\ABM_GUI-static.exe object_script.ABM_GUI-static.Release 
-L"c:\Qt\4.7.0\lib" -lmingw32 -lqtmain -Lc:\VTK-build-4.4.0-static\bin -lQVTK 
-lvtkRendering -lvtkGraphics -lvtkImaging -lvtkIO -lvtkFiltering -lvtkCommon 
-lvtkpng -lvtktiff -lvtkjpeg -lvtkexpat -lvfw32 -lopengl32 -lVPIC -lCosmo 
-lwsock32 -lvtksys -lws2_32 -lvtkexoIIc -lvtkNetCDF -lvtklibxml2 -lvtkzlib 
-lpthread -lvtkalglib -lgdi32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 
-lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 
-LC:\users\gib\abm\build32\release -lpara32 -LC:\qt\qwt-5.2.1\lib -lqwt5 
-lQtGui4 -lQtNetwork4 -lQtCore4

When I invoke the DLL I pass the number of threads, and if this exceeds one the 
OpenMP functions are executed, causing a crash.  Otherwise it runs fine, as it 
does with multiple threads when the DLL is loaded at run-time using a Qt function.


0
Reply g.bogle (180) 9/29/2010 8:49:43 AM

> gfortran.exe -Wall  -Wtabs -cpp -O3 -fopenmp -m32 -DWINDOWS -DGFORTRAN 
> -Wfatal-errors -D_OPENMP    -c C:\Users\Gib\ABM\omp_global.f90 -o 
> obj\Release\omp_global.o

Lokking through your options, I see nothing shocking. I don't know why
you build some files with -m32 and others without, but I suppose if that
were the issue, it'd simply refuse to link rather than crash, so that's
probably not it (maybe worth checking, though).

> gfortran.exe -shared -Wl,--output-def=Release\libpara32.dll.def 
> -Wl,--out-implib=Release\libpara32.dll.a -Wl,--dll

Why do you need --dll here? My own code doesn't seem to use --dll
(I'm no expert win32 developer, but it seems to work fine).

> -enable-stdcall-fixup -Wl,-enable-auto-import 
> -Wl,-enable-runtime-pseudo-reloc

Do you have to use -enable-stdcall-fixup? It's not a foolproof solution,
as far as I understand, and can lead to problems in some cases.

> When I invoke the DLL I pass the number of threads, and if this exceeds
> one the OpenMP functions are executed, causing a crash.  Otherwise it
> runs fine, as it does with multiple threads when the DLL is loaded at
> run-time using a Qt function.

If you can reduce this to a simple reproducable example (2 or 3
routines), you can get some help on gcc-help, or the mingw list, or even
a good generic site like stackoverflow.com  Sorry I cannot be of more
help...

-- 
FX
0
Reply coudert (470) 9/29/2010 8:03:51 PM

FX wrote:
>> My feeling is that english isn't their first language.
> 
> Well, it isn't the first language of many of us here either. Same goes
> for many GCC and gfortran developers. Yet, somehow, we try our best.
> 

Right, but I've "butted heads" with these folks, and I sensed a 
frustration as opposed to a malevolence.
-- 
Uno
0
Reply Uno 9/30/2010 3:13:55 AM

> Right, but I've "butted heads" with these folks, and I sensed a
> frustration as opposed to a malevolence.

Then, your perception was different than mine.

I believe that compliance with a license that you use for your business
should rank high (to put it delicately) on your list of priorities. If
you don't manage to do it in the course of two years, after being asked
to do it multiple times, it is hard to assume good faith, isn't it?

-- 
FX
0
Reply FX 9/30/2010 7:03:23 AM

On 30/09/2010 9:03 a.m., FX wrote:
>> gfortran.exe -Wall  -Wtabs -cpp -O3 -fopenmp -m32 -DWINDOWS -DGFORTRAN
>> -Wfatal-errors -D_OPENMP    -c C:\Users\Gib\ABM\omp_global.f90 -o
>> obj\Release\omp_global.o
>
> Lokking through your options, I see nothing shocking. I don't know why
> you build some files with -m32 and others without, but I suppose if that
> were the issue, it'd simply refuse to link rather than crash, so that's
> probably not it (maybe worth checking, though).
>
>> gfortran.exe -shared -Wl,--output-def=Release\libpara32.dll.def
>> -Wl,--out-implib=Release\libpara32.dll.a -Wl,--dll
>
> Why do you need --dll here? My own code doesn't seem to use --dll
> (I'm no expert win32 developer, but it seems to work fine).
>
>> -enable-stdcall-fixup -Wl,-enable-auto-import
>> -Wl,-enable-runtime-pseudo-reloc
>
> Do you have to use -enable-stdcall-fixup? It's not a foolproof solution,
> as far as I understand, and can lead to problems in some cases.
>
>> When I invoke the DLL I pass the number of threads, and if this exceeds
>> one the OpenMP functions are executed, causing a crash.  Otherwise it
>> runs fine, as it does with multiple threads when the DLL is loaded at
>> run-time using a Qt function.
>
> If you can reduce this to a simple reproducable example (2 or 3
> routines), you can get some help on gcc-help, or the mingw list, or even
> a good generic site like stackoverflow.com  Sorry I cannot be of more
> help...
>

Hi.  I'm use Code::Blocks, and the link flags are its idea.  The -m32 I added 
when I was getting things sorted out, and it seems to be redundant.  In any 
case, since the DLL works perfectly well when loaded at run-time by the Qt 
program, this is not holding me up at all.

I now have some more info.  The problem with OpenMP in conjunction with 
compile-time linking to a Qt app also occurs when the DLL was build with ifort, 
i.e. it's nothing to do with gfortran.  Also, the usual compile-time linking 
works fine when I call the DLL from a Fortran main program.  The problem seems 
to be an interaction between Qt and Fortran with OpenMP.  As I said at the 
start, my post was motivated more by curiosity than anything else.  I've 
considered the idea of creating a tiny example, and may do it when I get sick of 
doing what I should be doing.
0
Reply g.bogle (180) 9/30/2010 11:14:10 PM

FX wrote:
>> Right, but I've "butted heads" with these folks, and I sensed a
>> frustration as opposed to a malevolence.
> 
> Then, your perception was different than mine.
> 
> I believe that compliance with a license that you use for your business
> should rank high (to put it delicately) on your list of priorities. If
> you don't manage to do it in the course of two years, after being asked
> to do it multiple times, it is hard to assume good faith, isn't it?
> 

I guess when you say it, it sounds more reasonable.  And yes.

I think I may have been Wade Ward back then, and I was trying to get the 
product to work for me on windows, and I couldn't get it to work.

The equation.com guy just kept on jumping up and down saying "user 
error."  I looked for differing development tools.  I was gonna work up 
a segment on the wiki about how to make these things work on windows. 
(lost steam)

A lot of people blow through c.l.f. asking about it.
-- 
Uno
0
Reply Uno 10/1/2010 4:06:12 AM

30 Replies
489 Views

(page loaded in 0.311 seconds)

Similiar Articles:


















7/13/2012 7:56:44 PM


Reply: