Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
29314 Discussions

openmp creates threads only in one cpu

jose
Beginner
508 Views
I am compiling fortran applications with Ifort 8.0 and openmp in the hope to obtain executables that runs independent threads in every one of my two cpu's. I'm using intel fortran 8.0 for IA32 on a redhat 9.0 smp kernel. I have no problems compiling MPI codes that run on the two cpu's, but when using openmp, I can force the program to create any number of threads with the OMP_NUM_THREADS environment variable, but all the thread created go and run in the cpu 0. ssh I'm using ifort 8.0, kernel 2.40.20-8smp
and the code is as simple as:
C FILE: omp_hello.f
C DESCRIPTION:
C In this simple example, the master thread forks a parallel region.
C All threads in the team obtain their unique thread number and print it.
C The master thread only prints the total number of threads. Two OpenMP
C library routines are used to obtain the number of threads and each
C thread's number.
C SOURCE: Blaise Barney 5/99
C LAST REVISED:
C******************************************************************************
PROGRAM HELLO
real a(100000)
INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS,
+ OMP_GET_THREAD_NUM
isum=0
C Fork a team of threads giving them their own copies of variables
!$OMP PARALLEL PRIVATE(NTHREADS, TID)

C Obtain thread number
TID = OMP_GET_THREAD_NUM()
do 100 j=1,1000
do 100 i=1,100000
a(i)=sin(i*1.)
isum=isum+1
100 continue
PRINT *, 'Hello World from thread = ', TID
C Only master thread does this
IF (TID .EQ. 0) THEN
NTHREADS = OMP_GET_NUM_THREADS()
PRINT *, 'Number of threads = ', NTHREADS,isum
END IF
C All threads join master thread and disband
!$OMP END PARALLEL
END
It reports the right number of threads, but they run all in one cpu.
Also, option -openmp_report 2 gives an internalcompiler error.
Thanks for the help
Jose
0 Kudos
2 Replies
Steven_L_Intel1
Employee
508 Views
What compile switches are you using? What is the complete compiler version? (8.0.???)
0 Kudos
jose
Beginner
508 Views


sblionel wrote:
What compile switches are you using? What is the complete compiler version? (8.0.???)






ifort version is 8.0.055

compiler switches I've tried are -openmp -openmp_report2
(that trigers the internal compiler error) and -openmp, at different levels of optimization.

Thread problem is solved, though! it was my fault in reading top and ps results. Sorry!!. Indeed the threads are running in the two processors.

Thanks
Jose
0 Kudos
Reply