3.3.7.2. Fence Operations
3.3.7.2. 栅栏操作
This section describes how the OpenCL 2.x fence operations contribute to the local- and global-happens-before relations.
本节描述OpenCL2.x栅栏操作如何在关系之前对局部和全局进行贡献。
Earlier, we introduced synchronization primitives called fences. Fences can utilize the acquire memory_order, release memory_order, or both. A fence with acquire semantics is called an acquire fence; a fence with release semantics is called a release fence. The overview of atomic and fence operations section describes the memory orders that result in acquire and release fences.
早些时候,我们介绍了称为fence的同步原语。栅栏可以使用acquire内存顺序、release内存顺序或两者兼有。具有acquire语义的栅栏称为acquire栅栏;具有release语义的fence称为release栅栏。原子和栅栏操作概述部分描述了导致acquire和release栅栏的内存顺序。
A global release fence A global-synchronizes-with a global acquire fence B if there exist atomic operations X and Y, both operating on some global atomic object M, such that A is sequenced-before X, X modifies M, Y is sequenced-before B, Y reads the value written by X or a value written by any side effect in the hypothetical release sequence X would head if it were a release operation, and that the scopes of A, B are inclusive. [C11 standard, Section 7.17.4, paragraph 2, modified.]
如果存在都在某个全局原子对象M上操作的原子操作X和Y,则全局release栅栏A全局同步于全局acquire栅栏B,使得A在X之前排序,X修改M,Y在B之前排序,Y读取X写入的值或假设发布序列中任何副作用写入的值,如果它是一个release操作,则X将前进,并且A、B的范围包括在内。[C11标准,第7.17.4节,第2段,修改。]
A global release fence A global-synchronizes-with an atomic operation B that performs an acquire operation on a global atomic object M if there exists an atomic operation X such that A is sequenced-before X, X modifies M, B reads the value written by X or a value written by any side effect in the hypothetical release sequence X would head if it were a release operation, and the scopes of A and B are inclusive. [C11 standard, Section 7.17.4, paragraph 3, modified.]
全局release栅栏A全局同步于原子操作B,该原子操作B在全局原子对象M上执行acquire操作,如果存在原子操作X,使得A在X、X修改M、B读取由X写入的值或由假设释放序列中的任何副作用写入的值之前被排序,如果X是release操作,并且A和B的范围包括在内。[C11标准,第7.17.4节,第3段,修改。]
An atomic operation A that is a release operation on a global atomic object M global-synchronizes-with a global acquire fence B if there exists some atomic operation X on M such that X is sequenced-before B and reads the value written by A or a value written by any side effect in the release sequence headed by A, and the scopes of A and B are inclusive. [C11 standard, Section 7.17.4, paragraph 4, modified.]
如果在M上存在某个原子操作X,使得X在B之前排序,并且读取由A写入的值或由以A为首的release序列中的任何副作用写入的值,则作为全局原子对象M全局同步的release操作的原子操作A与全局acquire栅栏B全局同步,并且A和B的范围包括在内。[C11标准,第7.17.4节,第4段,修改。]
A local release fence A local-synchronizes-with a local acquire fence B if there exist atomic operations X and Y, both operating on some local atomic object M, such that A is sequenced-before X, X modifies M, Y is sequenced-before B, and Y reads the value written by X or a value written by any side effect in the hypothetical release sequence X would head if it were a release operation, and the scopes of A and B are inclusive. [C11 standard, Section 7.17.4, paragraph 2, modified.]
如果存在都在某个局部原子对象M上操作的原子操作X和Y,则局部release栅栏A局部同步于局部acquire栅栏B,使得A在X之前被排序,X修改M,Y在B之前被排序,Y读取由X写入的值或由假设release序列中的任何副作用写入的值,如果它是release操作,X将前进,并且A和B的范围包括在内。[C11标准,第7.17.4节,第2段,修改。]
A local release fence A local-synchronizes-with an atomic operation B that performs an acquire operation on a local atomic object M if there exists an atomic operation X such that A is sequenced-before X, X modifies M, and B reads the value written by X or a value written by any side effect in the hypothetical release sequence X would head if it were a release operation, and the scopes of A and B are inclusive. [C11 standard, Section 7.17.4, paragraph 3, modified.]
如果存在原子操作X,则本地release栅栏A本地同步于对本地原子对象M执行acquire操作的原子操作B,使得A在X之前排序,X修改M,并且B读取由X写入的值,或者由假设release序列中的任何副作用写入的值(如果它是release操作),并且A和B的范围包括在内。[C11标准,第7.17.4节,第3段,修改。]
An atomic operation A that is a release operation on a local atomic object M local-synchronizes-with a local acquire fence B if there exists some atomic operation X on M such that X is sequenced-before B and reads the value written by A or a value written by any side effect in the release sequence headed by A, and the scopes of A and B are inclusive. [C11 standard, Section 7.17.4, paragraph 4, modified.]
如果在M上存在某个原子操作X,使得X在B之前排序,并且读取由A写入的值或由以A为首的release序列中的任何副作用写入的值,则作为对本地原子对象M的release操作的原子操作A与本地acquire栅栏B本地同步,并且A和B的范围包括在内。[C11标准,第7.17.4节,第4段,修改。]
Let X and Y be two work-item fences that each have both the CLK_GLOBAL_MEM_FENCE
and CLK_LOCAL_MEM_FENCE
flags set. X global-synchronizes-with Y and X local synchronizes with Y if the conditions required for X to global-synchronize with Y are met, the conditions required for X to local-synchronize-with Y are met, or both sets of conditions are met.
设X和Y是两个工作项栅栏,每个栅栏都设置了CLK_GLOBAL_MEM_FENCE和CLK_LOCAL_MEM_FENCE标志。如果满足X与Y全局同步所需的条件,X与Y本地同步所需条件,或者两组条件都满足,则X全局与Y同步,X本地与Y同步。