Metal Shading Language Specification



Yüklə 4,82 Kb.
Pdf görüntüsü
səhifə44/51
tarix25.05.2018
ölçüsü4,82 Kb.
#45967
1   ...   40   41   42   43   44   45   46   47   ...   51

 
 
 
 
    C desired, 
 
 
 
 
    memory_order order) 
C atomic_exchange_explicit(device A* object, 
 
 
 
 
    C desired, 
 
 
 
 
    memory_order order) 
C atomic_exchange_explicit(volatile device A* object, 
 
 
 
 
    C desired, 
 
 
 
 
    memory_order order) 
C atomic_exchange_explicit(device A* object, 
 
 
 
 
    C desired, 
 
 
 
 
    memory_order order, 
 
 
 
 
    memory_scope scope) 
C atomic_exchange_explicit(volatile device A* object, 
 
 
 
 
    C desired, 
 
 
 
 
    memory_order order, 
 
 
 
 
    memory_scope scope) 
For
 ios-metal2.0
, the following atomic exchange functions are also supported. 
memory_order_seq_cst
 is the implied memory order. 
C atomic_exchange(threadgroup A* object, C desired) 
C atomic_exchange(volatile threadgroup A* object, C desired) 
C atomic_exchange(device A* object, C desired) 
C atomic_exchange(volatile device A* object, C desired) 
5.12.5.3 
Atomic Compare and Exchange Functions 
These compare-and-exchange functions atomically compare the value in 
*object
 with the 
value in 
*expected
. If those values are equal, the compare-and-exchange function performs a 
read-modify-write operation to replace 
*object
 with 
desired
. Otherwise if those values are 
not equal, the compare-and-exchange function loads the actual value from 
*object
 into 
*expected
. If the underlying atomic value in 
*object
 was successfully changed, the compare-
and-exchange function returns 
true
; otherwise it returns 
false
.  
Copying is performed in a manner similar to 
std::memcpy.
 The effect of a compare-and- 
exchange function is:  
if(memcmp(object, expected, sizeof(*object) == 0) 
memcpy(object, &desired, sizeof(*object)); 
else 
memcpy(expected, object, sizeof(*object)); 
 
2017-9-12   |  Copyright © 2017 Apple Inc. All Rights Reserved.  
Page  
 of  
142
174


For all versions of Metal, the following atomic exchange functions are supported. If the 
comparison is 
true
, memory access is affected according to the value of 
success
, and if the 
comparison is 
false
, memory access is affected according to the value of 
failure
.  
For all versions of Metal, 
memory_order_relaxed
 is supported for success and failure. For 
ios-metal2.0
, all 
memory_order
 values are available for 
success
 and 
failure
 with the 
following restrictions. The 
failure
 argument cannot be 
memory_order_release
 or 
memory_order_acq_rel
. The 
failure
 argument cannot be stronger than the 
success
 
argument.  
bool atomic_compare_exchange_weak_explicit(threadgroup A* object, 
 
 
 
 
 
 
 
   C *expected, 
 
 
 
 
 
 
 
   C desired, 
 
 
 
 
 
 
 
   memory_order success, 
 
 
 
 
 
 
 
   memory_order failure) 
bool atomic_compare_exchange_weak_explicit(volatile threadgroup A* object, 
 
 
 
 
 
 
 
  C *expected, 
 
 
 
 
 
 
 
  C desired, 
    
  memory_order success, 
    
  memory_order failure) 
bool atomic_compare_exchange_weak_explicit(device A* object, 
 
 
 
 
 
 
 
  C *expected, 
 
 
 
 
 
 
 
  C desired, 
 
 
 
 
 
 
 
  memory_order success, 
 
 
 
 
 
 
 
  memory_order failure) 
bool atomic_compare_exchange_weak_explicit(volatile device A* object, 
 
 
 
 
 
 
 
  C *expected, 
    
  C desired
    
  memory_order success, 
    
  memory_order failure) 
bool atomic_compare_exchange_weak_explicit(device A* object, 
    
  C *expected, 
    
  C desired, 
    
  memory_order success, 
    
  memory_order failure, 
    
  memory_scope scope) 
bool atomic_compare_exchange_weak_explicit(volatile device A* object, 
 
2017-9-12   |  Copyright © 2017 Apple Inc. All Rights Reserved.  
Page  
 of  
143
174


 
 
 
 
 
 
 
  C *expected, 
 
 
 
 
 
 
 
  C desired, 
    
  memory_order success, 
    
  memory_order failure, 
    
  memory_scope scope) 
For
 ios-metal2.0
, the following atomic compare-and-exchange functions are also supported. 
memory_order_seq_cst
 is the implied memory order. 
bool atomic_compare_exchange_weak(threadgroup A* object, C *expected, C 
desired) 
bool atomic_compare_exchange_weak(volatile threadgroup A* object, C 
*expected, C desired) 
bool atomic_compare_exchange_weak(device A* object, C *expected, C desired) 
bool atomic_compare_exchange_weak(volatile device A* object, C *expected, C 
desired) 
5.12.5.4 
Atomic Fetch and Modify Functions 
The following operations perform arithmetic and bitwise computations. All of these operations 
are applicable to an object of any atomic type. The key, operator, and computation 
correspondence is given in Table 33. 
Table 33 Atomic Operation Function 
Atomically replaces the value pointed to by 
object
 with the result of the computation of the 
value specified by 
key
 and 
operator
. These operations are atomic read-modify-write 
operations. For signed integer types, arithmetic is defined to use two’s complement 
representation with silent wrap-around on overflow. There are no undefined results. Returns the 
value that 
object
 held previously. 
key
operator
computation
add
+
addition
and
&
bitwise and
max
max
compute max
min
min
compute min
or
|
bitwise inclusive or
sub
-
subtraction
xor
^
bitwise exclusive or
 
2017-9-12   |  Copyright © 2017 Apple Inc. All Rights Reserved.  
Page  
 of  
144
174


Yüklə 4,82 Kb.

Dostları ilə paylaş:
1   ...   40   41   42   43   44   45   46   47   ...   51




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə