home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / f90 / omp_lock.z / omp_lock
Encoding:
Text File  |  2002-10-03  |  5.3 KB  |  120 lines

  1. omp_lock(3)                     UNICOS 10.0           Last changed: 1-27-99
  2.  
  3.  
  4. NNAAMMEE
  5.      oommpp__iinniitt__lloocckk, oommpp__ddeessttrrooyy__lloocckk, oommpp__sseett__lloocckk, oommpp__uunnsseett__lloocckk,
  6.      oommpp__tteesstt__lloocckk, OOMMPP__IINNIITT__LLOOCCKK, OOMMPP__DDEESSTTRROOYY__LLOOCCKK, OOMMPP__SSEETT__LLOOCCKK,
  7.      OOMMPP__UUNNSSEETT__LLOOCCKK, OOMMPP__TTEESSTT__LLOOCCKK,  - Set of procedures to manipulate
  8.      locks
  9.  
  10. SSYYNNOOPPSSIISS
  11.      C/C++:
  12.           ##iinntteeggeerr <<oommpp__iinniitt__lloocckk>>
  13.           vvooiidd oommpp__iinniitt__lloocckk((_v_a_r))
  14.  
  15.           ##iinntteeggeerr <<oommpp__ddeessttrrooyy__lloocckk>>
  16.           vvooiidd oommpp__ddeessttoorryy__lloocckk((_v_a_r))
  17.  
  18.           ##iinntteeggeerr <<oommpp__sseett__lloocckk>>
  19.           vvooiidd oommpp__sseett__lloocckk((_v_a_r))
  20.  
  21.           ##iinntteeggeerr <<oommpp__uunnsseett__lloocckk>>
  22.           vvooiidd oommpp__uunnsseett__lloocckk((_v_a_r))
  23.  
  24.           ##iinntteeggeerr <<oommpp__tteesstt__lloocckk>>
  25.           iinntt oommpp__tteesstt__lloocckk((_v_a_r))
  26.  
  27.      Fortran:
  28.           CCAALLLL OOMMPP__IINNIITT__LLOOCCKK((_v_a_r))
  29.  
  30.           CCAALLLL OOMMPP__DDEESSTTRROOYY__LLOOCCKK((_v_a_r))
  31.  
  32.           CCAALLLL OOMMPP__SSEETT__LLOOCCKK((_v_a_r))
  33.  
  34.           CCAALLLL OOMMPP__UUNNSSEETT__LLOOCCKK((_v_a_r))
  35.  
  36.           LLOOGGIICCAALL OOMMPP__TTEESSTT__LLOOCCKK((_v_a_r))
  37.  
  38. IIMMPPLLEEMMEENNTTAATTIIOONN
  39.      UNICOS and IRIX systems
  40.  
  41. SSTTAANNDDAARRDDSS
  42.      OpenMP Fortran API
  43.      OpenMP C/C++ API
  44.  
  45. DDEESSCCRRIIPPTTIIOONN
  46.      The following descriptions contain information for Fortran and C/C++.
  47.  
  48.      oommpp__iinniitt__lloocckk, OOMMPP__IINNIITT__LLOOCCKK
  49.           This subroutine initializes a lock associated with the lock
  50.           variable _v_a_r for use in subsequent calls.
  51.  
  52.           The initial state is unlocked.  The lock variable must only be
  53.           accessed through these routines.  In this and the following lock
  54.           routines, _v_a_r should be a scalar integer variable in C and of
  55.           type integer in Fortran and must have a size large enough to hold
  56.           an address.  For example, for 64-bit addressable systems, the
  57.           variable must at least by declared as IINNTTEEGGEERR**88.
  58.  
  59.      oommpp__ddeessttoorryy__lloocckk, OOMMPP__DDEESSTTRROOYY__LLOOCCKK
  60.           This procedure disassociates the given lock variable _v_a_r from any
  61.           locks.
  62.  
  63.      oommpp__sseett__lloocckk, OOMMPP__SSEETT__LLOOCCKK
  64.           This procedure constrins the executing thread to wait until the
  65.           specified lock is available.  The thread is granted ownership of
  66.           the lock when it is available.
  67.  
  68.      oommpp__uunnsseett__lloocckk, OOMMPP__UUNNSSEETT__LLOOCCKK
  69.           This procedure releases the executing thread from ownership of
  70.           the lock.  The behavior is undefined if the thread does not own
  71.           that lock.
  72.  
  73.      oommpp__tteesstt__lloocckk, OOMMPP__TTEESSTT__LLOOCCKK
  74.           This function tries to set the lock associated with the lock
  75.           variable _v_a_r.  It returns nnoonn--zzeerroo (TTRRUUEE) if the lock is
  76.           successfully set; otherwise, it returns zzeerroo (FFAALLSSEE).
  77.  
  78. EEXXAAMMPPLLEESS
  79.      For the OpenMP directives to be honored by the compiler, you must
  80.      specify --mmpp on your compiler command line explicitly.  In addition,
  81.      --MMPP::ooppeenn__mmpp==OONN, which is the default setting, must be in effect.
  82.  
  83.      In the following Fortran 90 example, the argument to the lock routines
  84.      should be of size PPOOIINNTTEERR:
  85.  
  86.                 PROGRAM LOCK_USAGE
  87.                 EXTERNAL OMP_TEST_LOCK
  88.                 LOGICAL OMP_TEST_LOCK
  89.  
  90.                 INTEGER LCK         ! THIS VARIABLE SHOULD BE POINTER SIZED
  91.  
  92.                 CALL OMP_INIT_LOCK(LCK)
  93.           !$OMP PARALLEL SHARED(LCK) PRIVATE(ID)
  94.                 ID = OMP_GET_THREAD_NUM()
  95.                 CALL OMP_SET_LOCK(LCK)
  96.                 PRINT *, 'MY THREAD ID IS ', ID
  97.                 CALL OMP_UNSET_LOCK(LCK)
  98.  
  99.                 DO WHILE (.NOT. OMP_TEST_LOCK(LCK))
  100.                   CALL SKIP(ID)     ! WE DO NOT YET HAVE THE LOCK
  101.                                     ! SO WE MUST DO SOMETHING ELSE
  102.                 END DO
  103.  
  104.                 CALL WORK(ID)       ! WE NOW HAVE THE LOCK
  105.                                     ! AND CAN DO THE WORK
  106.                 CALL OMP_UNSET_LOCK( LCK )
  107.           !$OMP END PARALLEL
  108.  
  109.                 CALL OMP_DESTROY_LOCK( LCK )
  110.  
  111.                 END
  112.  
  113. SSEEEE AALLSSOO
  114.      oommpp__nneesstteedd(3) to manipulate or report status of nested parallelism,
  115.  
  116.      oommpp__tthhrreeaaddss(3) for runtime library procedures used to set, call or
  117.      return numbers of threads
  118.  
  119.      This man page is available only online.
  120.