|
| View previous topic :: View next topic |
| Author |
Message |
Eos Pengwern
Joined: 18 Aug 2010 Posts: 14
|
Posted: Mon Oct 04, 2010 5:16 pm Post subject: |
|
|
Setting the number of threads once at the beginning of the program definitely doesn't work. If, in the initialisation section of the program, I put the code:
| Code: |
nthreads = omp_get_num_procs()
call omp_set_num_threads(nthreads)
open (12, file='threadcount.txt', status='REPLACE')
!$omp parallel
nthreads = omp_get_num_threads()
!$omp end parallel
write (12,*) 'In omp_init, nthreads = ', nthreads
close(12)
|
...then it is clear from the resulting file that the correct number of threads has been set. If, before the first parallelised loop, I then put the code:
| Code: |
open (12, file='threadcount.txt', status='REPLACE')
write (12,*) 'In Make_Incident_Image...'
close(12)
!$omp parallel
nthreads = omp_get_num_threads()
!$omp end parallel
open (12, file='threadcount.txt', status='REPLACE')
write (12,*) 'In Make_Incident_Image, nthreads = ', nthreads
close(12)
|
...then the application crashes, and the file contents indicate that it was at the "omp_get_num_threads" that it crashed.
Furthermore, if I then try to insert:
| Code: |
nthreads = omp_get_num_procs()
call omp_set_num_threads(nthreads)
|
...into the routine before the open(12...), then it becomes clear that that the file is never even opened. In other words, any OpenMP command at all, following the first initialisation, causes a crash.
Could this behvaiour be connected with the fact that the Fortran code here is all in a DLL called from a C++ GUI, and each execution of a Fortran routine is in a discrete call from C++? [/code] |
|
| Back to top |
|
 |
hongyon
Joined: 19 Jul 2004 Posts: 551
|
Posted: Mon Oct 04, 2010 8:00 pm Post subject: |
|
|
Hi,
You are correct that the crash is due to the fact that Fortran is called from C++. Currently it is required that you call pghpf_init from your main program if you are going to use it with Fortran. It is required only on windows.
Here is example:
main.c:
extern "C" void foo_ ( int * );
extern "C" void pghpf_init(int *);
static int zz = 0;
main(int argc, char **argv)
{
int i;
pghpf_init(&zz);
i = 19;
foo_(&i);
}
foo.f90:
subroutine foo (i)
integer i
print *, i
end subroutine foo
Let me know if this helps.
Hongyon |
|
| Back to top |
|
 |
Eos Pengwern
Joined: 18 Aug 2010 Posts: 14
|
Posted: Mon Oct 04, 2010 11:04 pm Post subject: |
|
|
Thanks Hongyon;
However, I already have a call to pghpf_init at the beginning of my program; the C++ program calls it from its 'main' routine, immediately before the first call to the Fortran routine where the OpenMP settings are initialised.
Stephen. |
|
| Back to top |
|
 |
hongyon
Joined: 19 Jul 2004 Posts: 551
|
Posted: Tue Oct 05, 2010 7:15 am Post subject: |
|
|
Which version of PGI you are using?
Which C++ compiler do you use?
How do you link with openmp library?
What is the command line? What is your OS?
Here is example with pgcpp and pgf90:
%pgf90 foo.f90 -mp -c
%pgcpp myproc.cpp foo.obj -mp -pgf90libs
Hongyon |
|
| Back to top |
|
 |
Eos Pengwern
Joined: 18 Aug 2010 Posts: 14
|
Posted: Wed Oct 06, 2010 4:54 pm Post subject: |
|
|
Thanks Hongyon;
I'm using PGU Visual Fortran V10.8 with Microsoft VC++ 2008. I link with the OpenMP library just by selecting the "Process OpenMP directives" option in the Project property menu. The complete command line is:
(compiler)
-Mpreprocess -DPGI -DUSE_MKL -Bdynamic -Mbackslash -mp -I"C:\Program Files\Intel\MKL\10.2.2.025\include" -I"c:\program files\pgi\win64\10.8\include" -I"C:\Program Files\PGI\Microsoft Open Tools 10\include" -I"C:\Program Files\PGI\Microsoft Open Tools 10\PlatformSDK\include" -fastsse -tp=nehalem-64 -Minform=warn
(linker)
-Mmakedll -Bdynamic -mp -o "D:\Documents\Visual Studio 2008\Builds\Release_x86-64\nCore_PGI_x86-64.dll" -Wl,/libpath:"C:\Program Files\Intel\MKL\10.2.2.025\em64t\lib" mkl_solver_lp64_sequential.lib mkl_intel_lp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib
All this is in indows & Ultimate 64-bit on a Lenovo W510 with an Intel i7 processor.
Stephen. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|