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

Compiler supports omp_set_num_threads() ?

stydofe1
Beginner
1,058 Views

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 Replies
Steven_L_Intel1
Employee
1,058 Views
The first version works for me. Is there more to the program you're using than what you showed here?
0 Kudos
stydofe1
Beginner
1,058 Views
That is all codes in the program. Could the problem do anything with compiler options, systemenvironment variables?
0 Kudos
Steven_L_Intel1
Employee
1,058 Views
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]
0 Kudos
stydofe1
Beginner
1,058 Views
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?

0 Kudos
Steven_L_Intel1
Employee
1,058 Views
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?
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,058 Views

What happens if you keep /iface:cvf

Replace

external OMP_set_num_threads

with

USE omp_lib

Jim Dempsey

0 Kudos
stydofe1
Beginner
1,058 Views
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.
0 Kudos
Steven_L_Intel1
Employee
1,058 Views
That works, since it's the C mechanism OMP routine that is called then.
0 Kudos
stydofe1
Beginner
1,058 Views
The problem is resolved byUSE OMP_LIB.
0 Kudos
Steven_L_Intel1
Employee
1,058 Views
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.
0 Kudos
Reply