gotoHomeFree Source CodeModule fthreadsFact SheetEmail us |
Purple Sage Computing Solutions, Inc. |
|
Home --> Free Source Code --> fthreads --> fthreads Usage -->Critical Operations fthreads Critical OperationsThis page describes the fthreads critical operation routines. Introduction to Critical OperationsA critical operation is simply a single operation which must be performed by several threads. Each operation needs to be atomic, that is, without interferrance by other threads. Each critical operation routine requires a mutex. The mutex is used to block any other thread from proceeding with the critical operation while another thread is. The scope of the blocking is controlled by the mutex, so if two operations may occur simultaneously, they should use different mutexs so they won't mutually block. The programmer wishing to trace the activity of a critical operations routine may do so by using a separate mutex for each routine, and gathering the statistics for that mutex via mutex_status(). critical_add()The critical_add() routine provides an atomic addition functionality for operands of type integer, real and complex.
interface
subroutine critical_add( acc, add, m)
TYPE, intent( inout) :: acc
TYPE, intent( in) :: add
type( mutex_t), intent( in) :: m
end subroutine critical_add
end interface
The critical_add() provides an atomic addition functionality for operands of type integer (any kind supported by the processor), real (any kind supported by the processor) and type complex (any kind supported by the processor). The variable acc acts as an accumulator, the variable add is the addend. They must be scalars of the same type and kind. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. critical_mul()The critical_mul() routine provides an atomic multiplication functionality for operands of type integer, real and complex.
interface
subroutine critical_mul( prod, mul, m)
TYPE, intent( inout) :: prod
TYPE, intent( in) :: mul
type( mutex_t), intent( in) :: m
end subroutine critical_mul
end interface
The critical_mul() provides an atomic multiplication functionality for operands of type integer (any kind supported by the processor), real (any kind supported by the processor) and type complex (any kind supported by the processor). The variable prod acts as a continuing product, the variable mul is the multiplicand. They must be scalars of the same type and kind. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. critical_inc()The critical_inc() routine provides an atomic increment functionality for operands of type integer of kind int_k.
interface
subroutine critical_inc( i)
integer( kind= int_k), &
intent( inout) :: i
end subroutine critical_inc
end interface
The critical_inc() routine provides a fast atomic increment of the integer variable i, which must be of kind int_k. The kind int_k is defined in module standard_types, which is used by module fthreads. critical_dec()The critical_dec() routine provides an atomic decrement functionality for operands of type integer of kind int_k.
interface
subroutine critical_dec( i)
integer( kind= int_k), &
intent( inout) :: i
end subroutine critical_dec
end interface
The critical_dec() routine provides a fast atomic decrement of the integer variable i, which must be of kind int_k. The kind int_k is defined in module standard_types, which is used by module fthreads. critical_and()The critical_and() routine provides an atomic and'ing functionality for operands of type integer and logical.
interface
subroutine critical_and( acc, i, m)
subroutine critical_and( acc, l, m)
TYPE, intent( inout) :: acc
integer, intent( in) :: i
logical, intent( in) :: l
type( mutex_t), intent( in) :: m
end subroutine critical_and
end interface
The critical_and() provides an atomic and'ing functionality for operands of type integer (a bitwise and) and type logical (a logical and). The variable acc acts as an accumulator, the integer variable i or logical variable l is the operand. They must be scalars of the same type and kind. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. critical_or()The critical_or() routine provides an atomic or'ing functionality for operands of type integer and logical.
interface
subroutine critical_or( acc, i, m)
subroutine critical_or( acc, l, m)
TYPE, intent( inout) :: acc
integer, intent( in) :: i
logical, intent( in) :: l
type( mutex_t), intent( in) :: m
end subroutine critical_or
end interface
The critical_or() provides an atomic or'ing functionality for operands of type integer (a bitwise or) and type logical (a logical or). The variable acc acts as an accumulator, the integer variable i or logical variable l is the operand. They must be scalars of the same type and kind. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. critical_eor()The critical_eor() routine provides an atomic exclusive or'ing functionality for operands of type integer and logical.
interface
subroutine critical_eor( acc, i, m)
subroutine critical_eor( acc, l, m)
TYPE, intent( inout) :: acc
integer, intent( in) :: i
logical, intent( in) :: l
type( mutex_t), intent( in) :: m
end subroutine critical_eor
end interface
The critical_eor() provides an atomic exclusive or'ing functionality for operands of type integer (a bitwise eor) and type logical (a logical eor). The variable acc acts as an accumulator, the integer variable i or logical variable l is the operand. They must be scalars of the same type and kind. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. critical_max()The critical_max() routine provides an atomic maximum functionality for operands of type integer and real.
interface
subroutine critical_max( acc, test, m)
TYPE, intent( inout) :: acc
TYPE, intent( in) :: test
type( mutex_t), intent( in) :: m
end subroutine critical_max
end interface
The critical_max() provides an atomic maximum functionality for operands of type integer and type real. The variable acc acts as an accumulator, the variable test is the operand. They must be scalars of the same type and kind. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. critical_min()The critical_min() routine provides an atomic minimum functionality for operands of type integer and real.
interface
subroutine critical_min( acc, test, m)
TYPE, intent( inout) :: acc
TYPE, intent( in) :: test
type( mutex_t), intent( in) :: m
end subroutine critical_min
end interface
The critical_min() provides an atomic minimum functionality for operands of type integer and type real. The variable acc acts as an accumulator, the variable test is the operand. They must be scalars of the same type and kind. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. critical_maxcopy()The critical_maxcopy() routine provides an atomic maximum and copy functionality for operands of type integer and real.
interface
subroutine critical_maxcopy( acc, &
cacc, test, ctest, m)
TYPE, intent( inout) :: acc
integer, intent( inout) :: cacc
TYPE, intent( in) :: test
integer, intent( in) :: ctest
type( mutex_t), intent( in) :: m
end subroutine critical_maxcopy
end interface
The critical_maxcopy() provides an atomic maximum and copy functionality for operands of type integer and type real. The variable acc acts as an accumulator, the variable test is the operand. They must be scalars of the same type and kind. If the variable test replaces acc as the new maximum, the integer ctest also replaces the integer cacc. Thus, for example, an array index may be copied along with the maximum value. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. critical_mincopy()The critical_mincopy() routine provides an atomic minimum and copy functionality for operands of type integer and real.
interface
subroutine critical_mincopy( acc, &
cacc, test, ctest, m)
TYPE, intent( inout) :: acc
integer, intent( inout) :: cacc
TYPE, intent( in) :: test
integer, intent( in) :: ctest
type( mutex_t), intent( in) :: m
end subroutine critical_mincopy
end interface
The critical_mincopy() provides an atomic minimum and copy functionality for operands of type integer and type real. The variable acc acts as an accumulator, the variable test is the operand. They must be scalars of the same type and kind. If the variable test replaces acc as the new minimum, the integer ctest also replaces the integer cacc. Thus, for example, an array index may be copied along with the minimum value. The type mutex_t mutex is provided by the caller to enable caller control of the scope of the locking. Please see our Fact Sheet, or E-mail us for more information. |
|
| Home - Fact Sheet - Free Source Code - Fortran Links - Email us |