1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3
"http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
8
<keyword>Atomic Functions</keyword>
12
<refentrytitle>Atomic Functions</refentrytitle>
15
<year>2007-2011</year>
16
<holder>The Khronos Group Inc.
17
Permission is hereby granted, free of charge, to any person obtaining a
18
copy of this software and/or associated documentation files (the
19
"Materials"), to deal in the Materials without restriction, including
20
without limitation the rights to use, copy, modify, merge, publish,
21
distribute, sublicense, and/or sell copies of the Materials, and to
22
permit persons to whom the Materials are furnished to do so, subject to
23
the condition that this copyright notice and permission notice shall be included
24
in all copies or substantial portions of the Materials.</holder>
27
<manvolnum>3</manvolnum>
30
<refname>Atomic Functions</refname>
32
The atomic functions are shown below.
33
Click an item in the table below for details about that function.
37
<refsect1 id="springboard"><title></title>
39
<informaltable frame="all"><tgroup cols="4" align="left" colsep="1" rowsep="1">
40
<colspec colnum="1" colwidth="1*" colname="col1" />
41
<colspec colnum="2" colwidth="1*" colname="col2" />
42
<colspec colnum="3" colwidth="1*" colname="col3" />
43
<colspec colnum="4" colwidth="1*" colname="col4" />
47
<citerefentry><refentrytitle>atomic_add</refentrytitle></citerefentry>
50
<citerefentry><refentrytitle>atomic_sub</refentrytitle></citerefentry>
53
<citerefentry><refentrytitle>atomic_xchg</refentrytitle></citerefentry>
56
<citerefentry><refentrytitle>atomic_inc</refentrytitle></citerefentry>
62
<citerefentry><refentrytitle>atomic_dec</refentrytitle></citerefentry>
65
<citerefentry><refentrytitle>atomic_cmpxchg</refentrytitle></citerefentry>
68
<citerefentry><refentrytitle>atomic_min</refentrytitle></citerefentry>
71
<citerefentry><refentrytitle>atomic_max</refentrytitle></citerefentry>
77
<citerefentry><refentrytitle>atomic_and</refentrytitle></citerefentry>
80
<citerefentry><refentrytitle>atomic_or</refentrytitle></citerefentry>
83
<citerefentry><refentrytitle>atomic_xor</refentrytitle></citerefentry>
91
</tgroup></informaltable>
94
The <citerefentry><refentrytitle>cl_khr_int64_base_atomics</refentrytitle></citerefentry>
95
extension enables additional atomic functions using types <type>long</type>
96
and <type>unsigned long</type>. An application that wants to use
97
this extension will need to include the <code>#pragma OPENCL EXTENSION
98
<citerefentry><refentrytitle>cl_khr_int64_base_atomics</refentrytitle></citerefentry> :
99
enable</code> in the OpenCL program source.
102
<informaltable frame="all"><tgroup cols="4" align="left" colsep="1" rowsep="1">
103
<colspec colnum="1" colwidth="1*" colname="col1" />
104
<colspec colnum="2" colwidth="1*" colname="col2" />
105
<colspec colnum="3" colwidth="1*" colname="col3" />
106
<colspec colnum="4" colwidth="1*" colname="col4" />
110
<citerefentry><refentrytitle>atom_add</refentrytitle></citerefentry>
113
<citerefentry><refentrytitle>atom_sub</refentrytitle></citerefentry>
116
<citerefentry><refentrytitle>atom_xchg</refentrytitle></citerefentry>
119
<citerefentry><refentrytitle>atom_inc</refentrytitle></citerefentry>
125
<citerefentry><refentrytitle>atom_dec</refentrytitle></citerefentry>
128
<citerefentry><refentrytitle>atom_cmpxchg</refentrytitle></citerefentry>
132
</tgroup></informaltable>
135
The <citerefentry><refentrytitle>cl_khr_int64_extended_atomics</refentrytitle></citerefentry>
136
extension enables additional atomic functions using types <type>long</type>
137
and <type>unsigned long</type>. An application that wants to use
138
this extension will need to include the <code>#pragma OPENCL EXTENSION
139
<citerefentry><refentrytitle>cl_khr_int64_extended_atomics</refentrytitle></citerefentry>
140
: enable</code> in the OpenCL program source.
143
<informaltable frame="all"><tgroup cols="3" align="left" colsep="1" rowsep="1">
144
<colspec colnum="1" colwidth="1*" colname="col1" />
145
<colspec colnum="2" colwidth="1*" colname="col2" />
146
<colspec colnum="3" colwidth="1*" colname="col3" />
150
<citerefentry><refentrytitle>atom_min</refentrytitle></citerefentry>
153
<citerefentry><refentrytitle>atom_max</refentrytitle></citerefentry>
156
<citerefentry><refentrytitle>atom_xor</refentrytitle></citerefentry>
162
<citerefentry><refentrytitle>atom_and</refentrytitle></citerefentry>
165
<citerefentry><refentrytitle>atom_or</refentrytitle></citerefentry>
171
</tgroup></informaltable>
175
<refsect1 id="description"><title>Description</title>
177
These functions provide atomic operations on 32-bit signed, unsigned
178
integers and single precision floating-point to locations in <citerefentry
179
href="global"><refentrytitle>__global</refentrytitle></citerefentry> or <citerefentry
180
href="local"><refentrytitle>__local</refentrytitle></citerefentry> memory. Only the
181
<function>atomic_xchg</function> operation is supported for single precision
182
floating-point data type.
186
The atomic built-in functions that use the <constant>atom_</constant> prefix and are
187
described in the <olink uri="atom_add">OpenCL Extension Specification</olink> and are
188
enabled by: cl_khr_global_int32_base_atomics, cl_khr_global_int32_extended_atomics,
189
cl_khr_local_int32_base_atomics, and cl_khr_local_int32_extended_atomics in sections
190
9.5 and 9.6 of the OpenCL 1.0 specification are also supported. .
194
The 64-bit transactions are atomic for the device executing these atomic functions. There
195
is no guarantee of atomicity if the atomic operations to the same memory location
196
are being performed by kernels executing on multiple devices.
200
<refsect1 id="specification"><title>Specification</title>
203
<imagedata fileref="pdficon_small1.gif" format="gif" />
205
<!-- link to section 9.5 of spec -->
206
<olink uri="atomicFunctions">OpenCL Specification</olink>
210
<!-- ================================ ALSO SEE
211
<refsect1 id="seealso"><title>Also see</title>
213
<citerefentry><refentrytitle>sampler_t</refentrytitle></citerefentry>
217
<!-- ============================== COPYRIGHT -->
218
<!-- Content included from copyright.inc.xsl -->
220
<refsect3 id="Copyright"><title></title>
222
<imagedata fileref="KhronosLogo.jpg" format="jpg" />