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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [testsuite/] [libgomp.fortran/] [omp_workshare2.f] - Blame information for rev 801

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

Line No. Rev Author Line
1 735 jeremybenn
C******************************************************************************
2
C FILE: omp_workshare2.f
3
C DESCRIPTION:
4
C   OpenMP Example - Sections Work-sharing - Fortran Version
5
C   In this example, the OpenMP SECTION directive is used to assign
6
C   different array operations to threads that execute a SECTION. Each
7
C   thread receives its own copy of the result array to work with.
8
C AUTHOR: Blaise Barney  5/99
9
C LAST REVISED: 01/09/04
10
C******************************************************************************
11
 
12
      PROGRAM WORKSHARE2
13
 
14
      INTEGER N, I, NTHREADS, TID, OMP_GET_NUM_THREADS,
15
     +        OMP_GET_THREAD_NUM
16
      PARAMETER (N=50)
17
      REAL A(N), B(N), C(N)
18
 
19
!     Some initializations
20
      DO I = 1, N
21
        A(I) = I * 1.0
22
        B(I) = A(I)
23
      ENDDO
24
 
25
!$OMP PARALLEL SHARED(A,B,NTHREADS), PRIVATE(C,I,TID)
26
      TID = OMP_GET_THREAD_NUM()
27
      IF (TID .EQ. 0) THEN
28
        NTHREADS = OMP_GET_NUM_THREADS()
29
        PRINT *, 'Number of threads =', NTHREADS
30
      END IF
31
      PRINT *, 'Thread',TID,' starting...'
32
 
33
!$OMP SECTIONS
34
 
35
!$OMP SECTION
36
      PRINT *, 'Thread',TID,' doing section 1'
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(',I2,')=',F8.2)
41
      ENDDO
42
 
43
!$OMP SECTION
44
      PRINT *, 'Thread',TID,' doing section 2'
45
      DO I = 1+N/2, N
46
         C(I) = A(I) * B(I)
47
         WRITE(*,100) TID,I,C(I)
48
      ENDDO
49
 
50
!$OMP END SECTIONS NOWAIT
51
 
52
      PRINT *, 'Thread',TID,' done.'
53
 
54
!$OMP END PARALLEL
55
 
56
      END

powered by: WebSVN 2.1.0

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