OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libgomp/] [testsuite/] [libgomp.fortran/] [omp_workshare1.f] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
C******************************************************************************
2
C FILE: omp_workshare1.f
3
C DESCRIPTION:
4
C   OpenMP Example - Loop Work-sharing - Fortran Version
5
C   In this example, the iterations of a loop are scheduled dynamically
6
C   across the team of threads.  A thread will perform CHUNK iterations
7
C   at a time before being scheduled for the next CHUNK of work.
8
C AUTHOR: Blaise Barney  5/99
9
C LAST REVISED: 01/09/04
10
C******************************************************************************
11
 
12
      PROGRAM WORKSHARE1
13
 
14
      INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS,
15
     +  OMP_GET_THREAD_NUM, N, CHUNKSIZE, CHUNK, I
16
      PARAMETER (N=100)
17
      PARAMETER (CHUNKSIZE=10)
18
      REAL A(N), B(N), C(N)
19
 
20
!     Some initializations
21
      DO I = 1, N
22
        A(I) = I * 1.0
23
        B(I) = A(I)
24
      ENDDO
25
      CHUNK = CHUNKSIZE
26
 
27
!$OMP PARALLEL SHARED(A,B,C,NTHREADS,CHUNK) PRIVATE(I,TID)
28
 
29
      TID = OMP_GET_THREAD_NUM()
30
      IF (TID .EQ. 0) THEN
31
        NTHREADS = OMP_GET_NUM_THREADS()
32
        PRINT *, 'Number of threads =', NTHREADS
33
      END IF
34
      PRINT *, 'Thread',TID,' starting...'
35
 
36
!$OMP DO SCHEDULE(DYNAMIC,CHUNK)
37
      DO I = 1, N
38
        C(I) = A(I) + B(I)
39
        WRITE(*,100) TID,I,C(I)
40
 100    FORMAT(' Thread',I2,': C(',I3,')=',F8.2)
41
      ENDDO
42
!$OMP END DO NOWAIT
43
 
44
      PRINT *, 'Thread',TID,' done.'
45
 
46
!$OMP END PARALLEL
47
 
48
      END

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.