(j3.2006) Lock variables
Bill Long
longb
Tue Mar 10 13:39:53 EDT 2009
Andy Vaught wrote:
> On Tue, 10 Mar 2009, Bill Long wrote:
>
>
>
> A compare and swap works for single threads, multiple threads, coarrays
> implemented as shared memory and coarrays implemented as messages over
> networks.
>
> Instead of a two new statments, a new intrinsic derived type and half a
> dozen new intrinsic procedures, all that is needed is a single intrinsic
> procedure:
>
> -----------------------------------------------------
> COMPARE_AND_SWAP(VAR, OLD, NEW, SUCCESS)
>
In the current draft f08 we have a new class of intrinsics - atomic
subroutines. There are only two defined (atomic_define and atomic_ref),
but it would be a clear extension of this class (for f13) to add
atomic_cas, atomic_add, and atomic_fadd. (I would also suggest
atomic_or, atomic_and, atomic_xor, and the fetch versions of these.) I
agree that atomic_cas can be effectively used to implement locks in a
threaded environment within an image. This relies mainly on the
characteristics of shared local memory, and local atomic memory
operations are widely available. Locks across images (LOCK / UNLOCK
statements) additionally rely on properties of the network, which is a
lot more variable between systems. With proper hardware support,
atomic_cas would work fine for cross-image locks, but other hardware
environments might have some better method. Given this variability, I
think having more abstracted locks for coarrays is better. Vendors can
then implement the optimal algorithm for their hardware.
Cheers,
Bill
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
More information about the J3
mailing list