Nope...still hangs...
C***************************************************************************
***
C FILE: omp_workshare1.f
C DESCRIPTION:
C   OpenMP Example - Loop Work-sharing - Fortran Version
C   In this example, the iterations of a loop are scheduled dynamically
C   across the team of threads.  A thread will perform CHUNK iterations
C   at a time before being scheduled for the next CHUNK of work.
C AUTHOR: Blaise Barney  5/99
C LAST REVISED: 01/09/04
C***************************************************************************
***
 
      PROGRAM WORKSHARE1

      INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS,
     +  OMP_GET_THREAD_NUM, N, CHUNKSIZE, CHUNK, I
      PARAMETER (N=100)
      PARAMETER (CHUNKSIZE=10) 
      REAL A(N), B(N), C(N)

!     Some initializations
      DO I = 1, N
        A(I) = I * 1.0
        B(I) = A(I)
      ENDDO
      CHUNK = CHUNKSIZE

!$OMP PARALLEL SHARED(A,B,C,NTHREADS,CHUNK) PRIVATE(I,TID)

      TID = OMP_GET_THREAD_NUM()
      IF (TID .EQ. 0) THEN
        NTHREADS = OMP_GET_NUM_THREADS()
        PRINT *, 'Number of threads =', NTHREADS
      END IF
      PRINT *, 'Thread',TID,' starting...'

!$OMP DO SCHEDULE(DYNAMIC,CHUNK)
      DO I = 1, N
        C(I) = A(I) + B(I)
!$OMP CRITICAL(io)
        WRITE(*,100) TID,I,C(I)
!$OMP END CRITICAL(io)
 100    FORMAT(' Thread',I2,': C(',I3,')=',F8.2)
      ENDDO
!$OMP END DO NOWAIT

      PRINT *, 'Thread',TID,' done.'

!$OMP END PARALLEL

      END

-----Original Message-----
From: Bill Somerville [mailto:g4...@classdesign.com] 
Sent: Tuesday, February 03, 2015 4:10 PM
To: wsjt-devel@lists.sourceforge.net
Subject: Re: [wsjt-devel] WSJT-X Decoder Performance

On 03/02/2015 21:48, Michael Black wrote:

Hi Mike,
> I ran a test using a sample program.
> Compiled with
> gfortran -g -fopenmp -o omp1 omp1.f
>
> Every few runs it hangs after all threads have completed.
That program is not thread safe. All I/O statements need serializing to make
it safe. Try adding:

!$omp critical(io)

immediately before each print or write and:

!$omp end critical(io)

immediately after each print or write.

It also is not a good example for another reason as it doesn't conditionally
compile some OpenMP code so it will not compile without OpenMP support. This
is bad practice because one usually wants a program to give identical
results (as possible) when run with and without multi-threading.
> I haven't let them run to completion...I tried the jt9_omp and let it 
> run and eventually it dies without an intelligent message after quite 
> a few minutes.
jt9 is not yet suitable for multi-threaded decoding, I will be posting some
amendments to deal with this when another unrelated issue has been tracked
down.
> Running this program under gdb never hangs.
GDB will interfere with the thread scheduling, that is one of the gotchas of
multi-threaded testing in that programs often run a different path when
debugged or even when output statements are added to try and locate issues.

73
Bill
G4WJS.
>
>
>
C***************************************************************************
> ***
> C FILE: omp_workshare1.f
> C DESCRIPTION:
> C   OpenMP Example - Loop Work-sharing - Fortran Version
> C   In this example, the iterations of a loop are scheduled dynamically
> C   across the team of threads.  A thread will perform CHUNK iterations
> C   at a time before being scheduled for the next CHUNK of work.
> C AUTHOR: Blaise Barney  5/99
> C LAST REVISED: 01/09/04
>
C***************************************************************************
> ***
>   
>        PROGRAM WORKSHARE1
>
>        INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS,
>       +  OMP_GET_THREAD_NUM, N, CHUNKSIZE, CHUNK, I
>        PARAMETER (N=100)
>        PARAMETER (CHUNKSIZE=10)
>        REAL A(N), B(N), C(N)
>
> !     Some initializations
>        DO I = 1, N
>          A(I) = I * 1.0
>          B(I) = A(I)
>        ENDDO
>        CHUNK = CHUNKSIZE
>
> !$OMP PARALLEL SHARED(A,B,C,NTHREADS,CHUNK) PRIVATE(I,TID)
>
>        TID = OMP_GET_THREAD_NUM()
>        IF (TID .EQ. 0) THEN
>          NTHREADS = OMP_GET_NUM_THREADS()
>          PRINT *, 'Number of threads =', NTHREADS
>        END IF
>        PRINT *, 'Thread',TID,' starting...'
>
> !$OMP DO SCHEDULE(DYNAMIC,CHUNK)
>        DO I = 1, N
>          C(I) = A(I) + B(I)
>          WRITE(*,100) TID,I,C(I)
>   100    FORMAT(' Thread',I2,': C(',I3,')=',F8.2)
>        ENDDO
> !$OMP END DO NOWAIT
>
>        PRINT *, 'Thread',TID,' done.'
>
> !$OMP END PARALLEL
>
>        END
>
> Mike W9MDB
>
> -----Original Message-----
> From: Bill Somerville [mailto:g4...@classdesign.com]
> Sent: Tuesday, February 03, 2015 3:17 PM
> To: wsjt-devel@lists.sourceforge.net
> Subject: Re: [wsjt-devel] WSJT-X Decoder Performance
>
> On 03/02/2015 21:04, Joe Taylor wrote:
>> Hi Greg,
> Hi Greg & Joe,
>> Yes, we need the "-fopenmp" flag to be set.  I think that's being done
>> appropriately now in CMakeLists.txt, although I confess I'm not always
>> confident that I've understood its syntax fully.  Bill should be able
>> to give the definitive answer.
> Yes that is correct.
>
> The CMake script uses the package finder for OpenMP (part of the CMake
> distribution) to find the OpenMP capabilities of the compilers on the
build
> platform. That sets the variable OPENMP_FOUND (or OPENMP-NOTFOUND if it's
> not available) along with the result variables OpenMP_C_FLAGS,
> OpenMP_CXX_FLAGS and, OpenMP_Fortran_FLAGS (actually this last one is only
> set by CMake v3.1 and later so I have substituted the C compiler flag as
it
> is the same for the compilers we use at present). These flags are added to
> '*_omp' source compiles.
>
> The CMake script builds two versions of the internal static library target
> 'wsjt', the second target is 'wsjt_omp'. It also builds two versions of
the
> 'jt9' target, the second being 'jt9_omp' which itself depends on the
> 'wsjt_omp' library.
>
> The 'wsjt' library is basically all the Fortran and C modules that are
used
> by jt9, jt9code, jt9sim, jt65code and wsjt-x.
>>      -- Joe
> 73
> Bill
> G4WJS.
>> On 2/3/2015 3:36 PM, ki...@yahoo.com wrote:
>>> Hi Joe,
>>>
>>> I'm not 100% certain on this, but for openmp on Windows, don't you
>>> have to enable that as a C flag with something l-ke: -fopenmp
>>>
>>> I would assume that's to be done in the CMakeLists.txt file. I'm not
>>> sure about linking the libraries.
>>>
>>> The Qt5 Tool chain has winpthreads and gcc -v has --enable-libgomp so
>>> the tool chain looks to be OpenMP capable.
>>>
>>> 73's
>>> Greg, KI7MT
>>>
>>>
>>> On 2/3/2015 1:06 PM, Joe Taylor wrote:
>>>> Hi Bill and all,
>>>>
>>>> Perhaps you already tried jt9_omp in Linux, but I had not.  I tried
>>>> it today, and it seems to work OK, as is.
>>>>
>>>> Here are some timing tests made on my rather elderly 2-core Linux
>>>> machine.  This time all tests were made with the "Deepest" setting,
>>>> ndepth=3, and all resulted in 17 good decodes of the sample file
>>>> 130610_2343.wav.  To get the times I measured "real" time to execute
>>>> jt9 or jt9_omp from the command-prompt.
>>>>
>>>> Program Version     Params    Time
>>>>                                     (s)
>>>> ------------------------------------
>>>> jt9     v1.3 r3673            2.467
>>>> jt9     v1.4.0-rc2, r4400     2.658
>>>> jt9     v1.5 r4926 -w 1 -m 1  1.243
>>>> jt9     v1.5 r4926 -w 2 -m 1  1.202
>>>> jt9     v1.5 r4926 -w 2 -m 2  1.140
>>>> jt9_omp v1.5 r4926 -w 2 -m 1  0.834
>>>> jt9_omp v1.5 r4926 -w 2 -m 2  0.843
>>>>
>>>> When jt9_omp is used it's better *not* to use the multi-threaded
>>>> FFTW plans, at least on this 2-core machine.  The two cores are
>>>> already being used effectively by running the two big FFTs
concurrently.
>>>>
>>>>
>>>> For interest, here are the actual outputs of a pair of timing runs
>>>> with
>>>> jt9 and jt9_omp.  Note that the decoded lines are the same, but JT65
>>>> lines are intermingled with JT9 lines.  (I like the original
>>>> ordering better -- first the one at the decode frequency; then
>>>> others in the same mode in order of increasing frequancy; then thos
>>>> in the other mode, again in order of increasing frequancy.  With
>>>> effort, I guess we could have it both ways by letting the GUI insert
>>>> decodes (after the first
>>>> one) in the "proper" place in the sequence.)
>>>>
>>>> ####################################################################
>>>> ##### $ time jt9 -p 1 -d 3 -w 2 -m 1 130610_2343.wav>  junk
>>>> 2343  -9  0.3 3196 @ WB8QPG IZ0MIT -11
>>>> 2343 -18  1.0 3372 @ KK4HEG KE0CO CN87
>>>> 2343  14  0.1 3490 @ CQ AG4M EM75
>>>> 2343 -20 -1.3 3567 @ CQ TA4A KM37
>>>> 2343 -15  0.1 3627 @ CT1FBK IK5YZT R+02
>>>> 2343 -23  0.3 3721 @ KF5SLN KB1SUA FN42
>>>> 2343 -16  0.2 3774 @ CQ M0ABA JO01
>>>> 2343  -2  0.2 3843 @ EI3HGB DD2EE JO31
>>>> 2343 -20  0.3  718 # VE6WQ SQ2NIJ -14
>>>> 2343  -7  0.3  815 # KK4DSD W7VP -16
>>>> 2343 -10  0.5  975 # CQ DL7ACA JO40
>>>> 2343  -9  0.8 1089 # N2SU W0JMW R-14
>>>> 2343 -11  0.8 1259 # YV6BFE F6GUU R-08
>>>> 2343  -9  1.7 1471 # VA3UG F1HMR 73
>>>> 2343  -1  0.6 1718 # BG THX JOE 73
>>>> 2343 -15  1.3 1951 # RA3Y VE3NLS 73
>>>> 2343 -20  0.4 2065 # K2OI AJ4UU R-20
>>>> <DecodeFinished>    0   1
>>>>
>>>> real    0m1.196s
>>>> user    0m1.157s
>>>> sys     0m0.037s
>>>>
>>>>
>>>> $ time jt9_omp -p 1 -d 3 -w 2 -m 1 130610_2343.wav>  junk
>>>> 2343 -20  0.3  718 # VE6WQ SQ2NIJ -14
>>>> 2343  -9  0.3 3196 @ WB8QPG IZ0MIT -11
>>>> 2343  -7  0.3  815 # KK4DSD W7VP -16
>>>> 2343 -18  1.0 3372 @ KK4HEG KE0CO CN87
>>>> 2343 -10  0.5  975 # CQ DL7ACA JO40
>>>> 2343  -9  0.8 1089 # N2SU W0JMW R-14
>>>> 2343 -11  0.8 1259 # YV6BFE F6GUU R-08
>>>> 2343  -9  1.7 1471 # VA3UG F1HMR 73
>>>> 2343  14  0.1 3490 @ CQ AG4M EM75
>>>> 2343 -20 -1.3 3567 @ CQ TA4A KM37
>>>> 2343 -15  0.1 3627 @ CT1FBK IK5YZT R+02
>>>> 2343 -23  0.3 3721 @ KF5SLN KB1SUA FN42
>>>> 2343 -16  0.2 3774 @ CQ M0ABA JO01
>>>> 2343  -1  0.6 1718 # BG THX JOE 73
>>>> 2343 -15  1.3 1951 # RA3Y VE3NLS 73
>>>> 2343  -2  0.2 3843 @ EI3HGB DD2EE JO31
>>>> 2343 -20  0.4 2065 # K2OI AJ4UU R-20
>>>> <DecodeFinished>    0   1
>>>>
>>>> real    0m0.806s
>>>> user    0m1.260s
>>>> sys     0m0.055s
>>>>
>>>> ####################################################################
>>>> #####
>>>>
>>>> In its present state the jt9_omp code does not run in Windows.  I
>>>> haven't yet determined why.
>>>>
>>>>    -- Joe, K1JT
>>>>
>>>> --------------------------------------------------------------------
>>>> ---------- Dive into the World of Parallel Programming. The Go
>>>> Parallel Website, sponsored by Intel and developed in partnership
>>>> with Slashdot Media, is your hub for all things parallel software
>>>> development, from weekly thought leadership blogs to news, videos,
>>>> case studies, tutorials and more. Take a look and join the
>>>> conversation now. http://goparallel.sourceforge.net/
>>>> _______________________________________________
>>>> wsjt-devel mailing list
>>>> wsjt-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/wsjt-devel
>>>>
>>> ---------------------------------------------------------------------
>>> --------- Dive into the World of Parallel Programming. The Go
>>> Parallel Website, sponsored by Intel and developed in partnership
>>> with Slashdot Media, is your hub for all things parallel software
>>> development, from weekly thought leadership blogs to news, videos,
>>> case studies, tutorials and more. Take a look and join the
>>> conversation now. http://goparallel.sourceforge.net/
>>> _______________________________________________
>>> wsjt-devel mailing list
>>> wsjt-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/wsjt-devel
>> ----------------------------------------------------------------------
>> -------- Dive into the World of Parallel Programming. The Go Parallel
>> Website, sponsored by Intel and developed in partnership with Slashdot
>> Media, is your hub for all things parallel software development, from
>> weekly thought leadership blogs to news, videos, case studies,
>> tutorials and more. Take a look and join the conversation now.
>> http://goparallel.sourceforge.net/
>> _______________________________________________
>> wsjt-devel mailing list
>> wsjt-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wsjt-devel
>
>
----------------------------------------------------------------------------
> --
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is
your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> wsjt-devel mailing list
> wsjt-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wsjt-devel
>
>
>
----------------------------------------------------------------------------
--
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is
your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> wsjt-devel mailing list
> wsjt-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wsjt-devel


----------------------------------------------------------------------------
--
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
wsjt-devel mailing list
wsjt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wsjt-devel


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
wsjt-devel mailing list
wsjt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wsjt-devel

Reply via email to