- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I have some problems in compiling the following prototype. I execute the attached simple program using multiple cores. Problem is that I am all the time getting just one instead of multiple 'Hello World's.I have used -openmp -Qparallel -fpp settings.
Thanks in advance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try something like:
[fortran]program main
implicit none
integer*4 omp_get_thread_num
integer*4 i
write ( *, * ) 'A sequential hello to you!'
!$omp parallel do
do i = 1,15
write ( *, * ) ' Parallel hello''s to you!', i, omp_get_thread_num ()
end do
!$omp end parallel do
stop
end[/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear John,
I tried your code. But as can br seen, just 'thread 0' is working. what about the other threads? I'm using an intel core i5-2400 CPU.
thanks.
A sequential hello to you!
Parallel hello's to you! 1 0
Parallel hello's to you! 2 0
Parallel hello's to you! 3 0
Parallel hello's to you! 4 0
Parallel hello's to you! 5 0
Parallel hello's to you! 6 0
Parallel hello's to you! 7 0
Parallel hello's to you! 8 0
Parallel hello's to you! 9 0
Parallel hello's to you! 10 0
Parallel hello's to you! 11 0
Parallel hello's to you! 12 0
Parallel hello's to you! 13 0
Parallel hello's to you! 14 0
Parallel hello's to you! 15 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not an expert on openmp but I thought you had to associate the parallel directive with do, workspace or section. Since you're not doing any of these you're not asking it to do anything in parallel. If you were expecting the outpout to appear once for each core then you'll still need to use a loop limited to the number of threads (which you can get with an OMP call). I tried the following variation on my machine which might be of help:
[fortran]
program main
use omp_lib
implicit none
integer :: i, nt
write ( *, * ) 'A sequential hello to you!'
!$omp parallel
nt = omp_get_num_threads()
!$omp do
do i=1,nt
write ( *, '(a,i0)' ) ' Parallel hello''s to you from ',i
end do
!$omp end do
!$omp end parallel
stop
end
[/fortran]
A sequential hello to you!
Parallel hello's to you from 1
Parallel hello's to you from 4
Parallel hello's to you from 2
Parallel hello's to you from 5
Parallel hello's to you from 3
Parallel hello's to you from 8
Parallel hello's to you from 7
Parallel hello's to you from 6
Note the out-of-sequence numbering which is what you shoud expect when executing a lop in parallel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear sgeard
I trired your code. but I get this:
A sequential hello to you!
Parallel hello's to you from 1
why just one thread is recognized?
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are a couple of things I see with your project that was attached in the original posting.
First - while /Qparallel was set, the setting "Language->Generate Parallel Code" was not set (that turns on the /Qopenmp switch).
When I changed that, I saw multiple "Parallel hello's to you" lines.
Also, you're using the DEBUG configuration, which has optimizations turned off. Ultimately, this may have an effect on a "real" program instead of this prototype.
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page