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

Compiler supports omp_set_num_threads() ?

stydofe1
Einsteiger
2.173Aufrufe

I am using Intel composer XE 2011. I have some simple codes as below to test the function OMP_set_num_threads, the program freezes once entering the parallel region.

call OMP_set_num_threads(4)

!$omp parallel

print *, 'hello parallel'

!$omp end parallel

It works fine if I use clause instead.

!$omp parallel num_threads(4)

print *, 'hello parallel'

!$omp end parallel

What am I missing in using the routine OMP_set_num_threads?

0 Kudos
10 Antworten
Steven_L_Intel1
Mitarbeiter
2.173Aufrufe
The first version works for me. Is there more to the program you're using than what you showed here?
stydofe1
Einsteiger
2.173Aufrufe
That is all codes in the program. Could the problem do anything with compiler options, systemenvironment variables?
Steven_L_Intel1
Mitarbeiter
2.173Aufrufe
I assume there is an END statement in there somewhere? I just compiled with /Qopenmp and ran it. Nothing special needed.

[plain]C:Projects>ifort /Qopenmp U85077.f90
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 1
2.0.5.221 Build 20110719
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

Microsoft  Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:U85077.exe
-subsystem:console
-nodefaultlib:libiompprof5mt.lib
-nodefaultlib:libiompprof5md.lib
-defaultlib:libiomp5md.lib
-nodefaultlib:vcomp.lib
-nodefaultlib:vcompd.lib
U85077.obj

C:Projects>u85077.exe
 hello parallel
 hello parallel
 hello parallel
 hello parallel
[/plain]
stydofe1
Einsteiger
2.173Aufrufe
Below are the complete codes:

PROGRAM ACCTEST

external OMP_set_num_threads

call OMP_set_num_threads(4)

!$omp parallel

print *, 'hello parallel'

!$omp end parallel

END


The commands for compile and link are:

ifort set_num_th.for /nologo /extend_source:132 /Qopenmp /iface:cvf /Fd"vc100.pdb" /threads /c

link /OUT:"para.exe" /INCREMENTAL:NO /NOLOGO /SUBSYSTEM:CONSOLE set_num_th.obj

Running the program will lead to an error of out of heap memory. The same problem happens on several machine.

Do you need more information to figure out the problem?

Steven_L_Intel1
Mitarbeiter
2.173Aufrufe
Interesting. It's the /iface:cvf that triggers the problem. If you remove that, it works. I'll have to ask the developers why this is. It is finding a STDCALL routine in the OpenMP library.

Do you need /iface:cvf?
jimdempseyatthecove
Geehrter Beitragender III
2.173Aufrufe

What happens if you keep /iface:cvf

Replace

external OMP_set_num_threads

with

USE omp_lib

Jim Dempsey

stydofe1
Einsteiger
2.173Aufrufe
Yes, I need /iface:cvf, since in the programs I am trying to parallelize, some fortran codes are calling C programs or called by C programs.
Steven_L_Intel1
Mitarbeiter
2.173Aufrufe
That works, since it's the C mechanism OMP routine that is called then.
stydofe1
Einsteiger
2.173Aufrufe
The problem is resolved byUSE OMP_LIB.
Steven_L_Intel1
Mitarbeiter
2.173Aufrufe
The developers tell me that they are removing the STDCALL entry points. USE OMP_LIB is the best approach whether or not you use /iface:CVF.
Antworten