| Previous | Contents | Index |
To call the _Otsxxxx or mpc_xxxx routines, use the cDEC$ ALIAS directive (described in the DIGITAL Fortran Language Reference Manual) to handle the mixed-case naming convention and missing trailing underscore. For example, to call the _OtsGetThreadNum routine with an alias of OtsGetThreadNum, use the following code:
integer a(10)
INTERFACE
INTEGER FUNCTION OtsGetThreadNum ()
!DEC$ ALIAS OtsGetThreadNum, '_OtsGetThreadNum'
END FUNCTION OtsGetThreadNum
END INTERFACE
!$par parallel do
do i = 1,10
print *, "i=",i, " thread=", OtsGetThreadNum ()
enddo
end
|
Alternatively, to use the compatiblity naming convention of mpc_my_threadnum:
integer a(10)
INTERFACE
INTEGER FUNCTION mpc_my_threadnum ()
!DEC$ ALIAS mpc_my_threadnum, 'mpc_my_threadnum'
END FUNCTION mpc_my_threadnum
END INTERFACE
!$par parallel do
do i = 1,10
print *, "i=",i, " thread=", mpc_my_threadnum ()
enddo
end
|
Syntax:
INTERFACE
SUBROUTINE otsinitparallel (nthreads, attr)
!DEC$ ALIAS otsinitparallel, '_OtsInitParallel'
INTEGER nthreads
INTEGER (KIND=8) attr
!DEC$ ATRRIBUTES, VALUE :: nthreads, attr
END SUBROUTINE otsinitparallel
END INTERFACE
|
Description:
Starts slave threads for parallel processing if they have not yet been started implicitly. Use this routine if you want to:
The arguments are:
Syntax:
INTERFACE
SUBROUTINE otsstopworkers ()
!DEC$ ALIAS otsstopworkers, '_OtsStopWorkers'
END SUBROUTINE otsstopworkers
END INTERFACE
CALL otsstopworkers ()
|
Description:
Stop any slave threads created by parallel library support. Use this
routine if you need to perform some operation (such as a call to fork()) that cannot tolerate extra threads
running in the process. This routine cannot be called from within a
parallel region. After this call, new slave threads will be implicitly
created the next time a parallel region is encountered, or can be
created explicitly by calling otsinitparallel.
E.2.4 otsgetnumthreads or mpc_numthreads
Returns the number of threads being used (in a parallel region) or created so far (if not in a parallel region).
Syntax:
INTERFACE
INTEGER FUNCTION otsgetnumthreads ()
!DEC$ ALIAS otsgetnumthreads, '_OtsGetNumThreads'
END FUNCTION otsgetnumthreads
END INTERFACE
INTEGER result
result = otsgetnumthreads ()
|
Description:
Returns the number of threads that are being used in the current parallel region (if running within one), or the number of threads that have been created so far (if not currently within a parallel region). You can use this call to decide how to partition a parallel loop. For example:
nt = otsgetnumthreads ()
c$par parallel do
do i = a,nt-1
work(i) = 0
k0 = 1+(i*n)/nt
k1 = ((i+1)+n)/nt
do j = 1,m
do k = k0,k1
! use work(i)
enddo
enddo
enddo
|
Returns the maximum number of threads for the current environment.
Syntax:
INTERFACE
INTEGER FUNCTION otsgetmaxthreads ()
!DEC$ ALIAS otsgetmaxthreads, '_OtsGetMaxThreads'
END FUNCTION otsgetmaxthreads
END INTERFACE
INTEGER result
result = otsgetmaxthreads ()
|
Description:
Returns the number of threads that would normally be used for parallel
processing in the current environment. This is affected by the
environment variable MP_THREAD_COUNT, by the number of processes in the
current process's processor set, and by any call to otsinitparallel.
E.2.6 otsgetthreadnum or mpc_my_threadnum
Returns the number of the current thread.
Syntax:
INTERFACE
INTEGER FUNCTION otsgetthreadnum ()
!DEC$ ALIAS otsgetthreadnum, '_OtsGetThreadNum'
END FUNCTION otsgetthreadnum
END INTERFACE
INTEGER result
result = otsgetthreadnum ()
|
Description:
Returns a number that identifies the current thread. The main thread is
0, and slave threads are numbered densely from 1.
E.2.7 otsinparallel or mpc_in_parallel_region
Returns the current status of processing activity in a parallel region.
Syntax:
INTERFACE
INTEGER FUNCTION otsinparallel ()
!DEC$ ALIAS otsinparallel, '_OtsInParallel'
END FUNCTION OtsInParallel
END INTERFACE
INTEGER result
result = otsinparallel ()
|
Description:
The routine returns 1 if the program is currently running within a parallel region, otherwise it returns 0. )
| Index | Contents |