blob: 420a8400637ee8bd996a4156bfddb93995fc0a1b [file]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.23">
<meta name="description" content="OpenCL(TM) is an open, royalty-free standard for cross-platform parallel programming of diverse accelerators. This document describes the OpenCL C language.">
<meta name="author" content="Khronos&#174; OpenCL Working Group">
<title>The OpenCL&#8482; C Specification</title>
<style>
/*! normalize.css v2.1.2 | MIT License | git.io/normalize */
/* ========================================================================== HTML5 display definitions ========================================================================== */
/** Correct `block` display not defined in IE 8/9. */
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; }
/** Correct `inline-block` display not defined in IE 8/9. */
audio, canvas, video { display: inline-block; }
/** Prevent modern browsers from displaying `audio` without controls. Remove excess height in iOS 5 devices. */
audio:not([controls]) { display: none; height: 0; }
/** Address `[hidden]` styling not present in IE 8/9. Hide the `template` element in IE, Safari, and Firefox < 22. */
[hidden], template { display: none; }
script { display: none !important; }
/* ========================================================================== Base ========================================================================== */
/** 1. Set default font family to sans-serif. 2. Prevent iOS text size adjust after orientation change, without disabling user zoom. */
html { font-family: sans-serif; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ }
/** Remove default margin. */
body { margin: 0; }
/* ========================================================================== Links ========================================================================== */
/** Remove the gray background color from active links in IE 10. */
a { background: transparent; }
/** Address `outline` inconsistency between Chrome and other browsers. */
a:focus { outline: thin dotted; }
/** Improve readability when focused and also mouse hovered in all browsers. */
a:active, a:hover { outline: 0; }
/* ========================================================================== Typography ========================================================================== */
/** Address variable `h1` font-size and margin within `section` and `article` contexts in Firefox 4+, Safari 5, and Chrome. */
h1 { font-size: 2em; margin: 0.67em 0; }
/** Address styling not present in IE 8/9, Safari 5, and Chrome. */
abbr[title] { border-bottom: 1px dotted; }
/** Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. */
b, strong { font-weight: bold; }
/** Address styling not present in Safari 5 and Chrome. */
dfn { font-style: italic; }
/** Address differences between Firefox and other browsers. */
hr { -moz-box-sizing: content-box; box-sizing: content-box; height: 0; }
/** Address styling not present in IE 8/9. */
mark { background: #ff0; color: #000; }
/** Correct font family set oddly in Safari 5 and Chrome. */
code, kbd, pre, samp { font-family: monospace, serif; font-size: 1em; }
/** Improve readability of pre-formatted text in all browsers. */
pre { white-space: pre-wrap; }
/** Set consistent quote types. */
q { quotes: "\201C" "\201D" "\2018" "\2019"; }
/** Address inconsistent and variable font size in all browsers. */
small { font-size: 80%; }
/** Prevent `sub` and `sup` affecting `line-height` in all browsers. */
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
/* ========================================================================== Embedded content ========================================================================== */
/** Remove border when inside `a` element in IE 8/9. */
img { border: 0; }
/** Correct overflow displayed oddly in IE 9. */
svg:not(:root) { overflow: hidden; }
/* ========================================================================== Figures ========================================================================== */
/** Address margin not present in IE 8/9 and Safari 5. */
figure { margin: 0; }
/* ========================================================================== Forms ========================================================================== */
/** Define consistent border, margin, and padding. */
fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; }
/** 1. Correct `color` not being inherited in IE 8/9. 2. Remove padding so people aren't caught out if they zero out fieldsets. */
legend { border: 0; /* 1 */ padding: 0; /* 2 */ }
/** 1. Correct font family not being inherited in all browsers. 2. Correct font size not being inherited in all browsers. 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome. */
button, input, select, textarea { font-family: inherit; /* 1 */ font-size: 100%; /* 2 */ margin: 0; /* 3 */ }
/** Address Firefox 4+ setting `line-height` on `input` using `!important` in the UA stylesheet. */
button, input { line-height: normal; }
/** Address inconsistent `text-transform` inheritance for `button` and `select`. All other form control elements do not inherit `text-transform` values. Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+. Correct `select` style inheritance in Firefox 4+ and Opera. */
button, select { text-transform: none; }
/** 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` and `video` controls. 2. Correct inability to style clickable `input` types in iOS. 3. Improve usability and consistency of cursor style between image-type `input` and others. */
button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; /* 2 */ cursor: pointer; /* 3 */ }
/** Re-set default cursor for disabled elements. */
button[disabled], html input[disabled] { cursor: default; }
/** 1. Address box sizing set to `content-box` in IE 8/9. 2. Remove excess padding in IE 8/9. */
input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ }
/** 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome (include `-moz` to future-proof). */
input[type="search"] { -webkit-appearance: textfield; /* 1 */ -moz-box-sizing: content-box; -webkit-box-sizing: content-box; /* 2 */ box-sizing: content-box; }
/** Remove inner padding and search cancel button in Safari 5 and Chrome on OS X. */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
/** Remove inner padding and border in Firefox 4+. */
button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }
/** 1. Remove default vertical scrollbar in IE 8/9. 2. Improve readability and alignment in all browsers. */
textarea { overflow: auto; /* 1 */ vertical-align: top; /* 2 */ }
/* ========================================================================== Tables ========================================================================== */
/** Remove most spacing between table cells. */
table { border-collapse: collapse; border-spacing: 0; }
meta.foundation-mq-small { font-family: "only screen and (min-width: 768px)"; width: 768px; }
meta.foundation-mq-medium { font-family: "only screen and (min-width:1280px)"; width: 1280px; }
meta.foundation-mq-large { font-family: "only screen and (min-width:1440px)"; width: 1440px; }
*, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
html, body { font-size: 100%; }
body { background: #fff; color: #222; padding: 0; margin: 0; font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; font-weight: normal; font-style: normal; line-height: 1; position: relative; cursor: auto; }
a:hover { cursor: pointer; }
img, object, embed { max-width: 100%; height: auto; }
object, embed { height: 100%; }
img { -ms-interpolation-mode: bicubic; }
#map_canvas img, #map_canvas embed, #map_canvas object, .map_canvas img, .map_canvas embed, .map_canvas object { max-width: none !important; }
.left { float: left !important; }
.right { float: right !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-justify { text-align: justify !important; }
.hide { display: none; }
.antialiased { -webkit-font-smoothing: antialiased; }
img { display: inline-block; vertical-align: middle; }
textarea { height: auto; min-height: 50px; }
select { width: 100%; }
object, svg { display: inline-block; vertical-align: middle; }
.center { margin-left: auto; margin-right: auto; }
.spread { width: 100%; }
p.lead, .paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { font-size: 1.21875em; line-height: 1.6; }
.subheader, .admonitionblock td.content > .title, .audioblock > .title, .exampleblock > .title, .imageblock > .title, .listingblock > .title, .literalblock > .title, .stemblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, table.tableblock > .title, .verseblock > .title, .videoblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { line-height: 1.4; color: black; font-weight: 300; margin-top: 0.2em; margin-bottom: 0.5em; }
/* Typography resets */
div, dl, dt, dd, ul, ol, li, h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6, pre, form, p, blockquote, th, td { margin: 0; padding: 0; direction: ltr; }
/* Default Link Styles */
a { color: #0068b0; text-decoration: none; line-height: inherit; }
a:hover, a:focus { color: #333; }
a img { border: none; }
/* Default paragraph styles */
p { font-family: Noto, sans-serif; font-weight: normal; font-size: 1em; line-height: 1.6; margin-bottom: 0.75em; text-rendering: optimizeLegibility; }
p aside { font-size: 0.875em; line-height: 1.35; font-style: italic; }
/* Default header styles */
h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { font-family: Noto, sans-serif; font-weight: normal; font-style: normal; color: black; text-rendering: optimizeLegibility; margin-top: 0.5em; margin-bottom: 0.5em; line-height: 1.2125em; }
h1 small, h2 small, h3 small, #toctitle small, .sidebarblock > .content > .title small, h4 small, h5 small, h6 small { font-size: 60%; color: #4d4d4d; line-height: 0; }
h1 { font-size: 2.125em; }
h2 { font-size: 1.6875em; }
h3, #toctitle, .sidebarblock > .content > .title { font-size: 1.375em; }
h4 { font-size: 1.125em; }
h5 { font-size: 1.125em; }
h6 { font-size: 1em; }
hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 1.25em 0 1.1875em; height: 0; }
/* Helpful Typography Defaults */
em, i { font-style: italic; line-height: inherit; }
strong, b { font-weight: bold; line-height: inherit; }
small { font-size: 60%; line-height: inherit; }
code { font-family: Consolas, "Liberation Mono", Courier, monospace; font-weight: normal; color: #264357; }
/* Lists */
ul, ol, dl { font-size: 1em; line-height: 1.6; margin-bottom: 0.75em; list-style-position: outside; font-family: Noto, sans-serif; }
ul, ol { margin-left: 1.5em; }
ul.no-bullet, ol.no-bullet { margin-left: 1.5em; }
/* Unordered Lists */
ul li ul, ul li ol { margin-left: 1.25em; margin-bottom: 0; font-size: 1em; /* Override nested font-size change */ }
ul.square li ul, ul.circle li ul, ul.disc li ul { list-style: inherit; }
ul.square { list-style-type: square; }
ul.circle { list-style-type: circle; }
ul.disc { list-style-type: disc; }
ul.no-bullet { list-style: none; }
/* Ordered Lists */
ol li ul, ol li ol { margin-left: 1.25em; margin-bottom: 0; }
/* Definition Lists */
dl dt { margin-bottom: 0.3em; font-weight: bold; }
dl dd { margin-bottom: 0.75em; }
/* Abbreviations */
abbr, acronym { text-transform: uppercase; font-size: 90%; color: black; border-bottom: 1px dotted #ddd; cursor: help; }
abbr { text-transform: none; }
/* Blockquotes */
blockquote { margin: 0 0 0.75em; padding: 0.5625em 1.25em 0 1.1875em; border-left: 1px solid #ddd; }
blockquote cite { display: block; font-size: 0.8125em; color: #365E7A; }
blockquote cite:before { content: "\2014 \0020"; }
blockquote cite a, blockquote cite a:visited { color: #365E7A; }
blockquote, blockquote p { line-height: 1.6; color: #333; }
/* Microformats */
.vcard { display: inline-block; margin: 0 0 1.25em 0; border: 1px solid #ddd; padding: 0.625em 0.75em; }
.vcard li { margin: 0; display: block; }
.vcard .fn { font-weight: bold; font-size: 0.9375em; }
.vevent .summary { font-weight: bold; }
.vevent abbr { cursor: auto; text-decoration: none; font-weight: bold; border: none; padding: 0 0.0625em; }
@media only screen and (min-width: 768px) { h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { line-height: 1.4; }
h1 { font-size: 2.75em; }
h2 { font-size: 2.3125em; }
h3, #toctitle, .sidebarblock > .content > .title { font-size: 1.6875em; }
h4 { font-size: 1.4375em; } }
/* Tables */
table { background: #fff; margin-bottom: 1.25em; border: solid 1px #d8d8ce; }
table thead, table tfoot { background: #eee; font-weight: bold; }
table thead tr th, table thead tr td, table tfoot tr th, table tfoot tr td { padding: 0.5em 0.625em 0.625em; font-size: inherit; color: #222; text-align: left; }
table tr th, table tr td { padding: 0.5625em 0.625em; font-size: inherit; color: #6d6e71; }
table tr.even, table tr.alt, table tr:nth-of-type(even) { background: #f8f8f8; }
table thead tr th, table tfoot tr th, table tbody tr td, table tr td, table tfoot tr td { display: table-cell; line-height: 1.4; }
body { -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; tab-size: 4; }
h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { line-height: 1.4; }
a:hover, a:focus { text-decoration: underline; }
.clearfix:before, .clearfix:after, .float-group:before, .float-group:after { content: " "; display: table; }
.clearfix:after, .float-group:after { clear: both; }
*:not(pre) > code { font-size: inherit; font-style: normal !important; letter-spacing: 0; padding: 0; background-color: transparent; -webkit-border-radius: 0; border-radius: 0; line-height: inherit; word-wrap: break-word; }
*:not(pre) > code.nobreak { word-wrap: normal; }
*:not(pre) > code.nowrap { white-space: nowrap; }
pre, pre > code { line-height: 1.6; color: #264357; font-family: Consolas, "Liberation Mono", Courier, monospace; font-weight: normal; }
em em { font-style: normal; }
strong strong { font-weight: normal; }
.keyseq { color: #333333; }
kbd { font-family: Consolas, "Liberation Mono", Courier, monospace; display: inline-block; color: black; font-size: 0.65em; line-height: 1.45; background-color: #f7f7f7; border: 1px solid #ccc; -webkit-border-radius: 3px; border-radius: 3px; -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 0.1em white inset; -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 0.1em white inset; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 0 0.1em white inset; margin: 0 0.15em; padding: 0.2em 0.5em; vertical-align: middle; position: relative; top: -0.1em; white-space: nowrap; }
.keyseq kbd:first-child { margin-left: 0; }
.keyseq kbd:last-child { margin-right: 0; }
.menuseq, .menuref { color: #000; }
.menuseq b:not(.caret), .menuref { font-weight: inherit; }
.menuseq { word-spacing: -0.02em; }
.menuseq b.caret { font-size: 1.25em; line-height: 0.8; }
.menuseq i.caret { font-weight: bold; text-align: center; width: 0.45em; }
b.button:before, b.button:after { position: relative; top: -1px; font-weight: normal; }
b.button:before { content: "["; padding: 0 3px 0 2px; }
b.button:after { content: "]"; padding: 0 2px 0 3px; }
#header, #content, #footnotes, #footer { width: 100%; margin-left: auto; margin-right: auto; margin-top: 0; margin-bottom: 0; max-width: 62.5em; *zoom: 1; position: relative; padding-left: 1.5em; padding-right: 1.5em; }
#header:before, #header:after, #content:before, #content:after, #footnotes:before, #footnotes:after, #footer:before, #footer:after { content: " "; display: table; }
#header:after, #content:after, #footnotes:after, #footer:after { clear: both; }
#content { margin-top: 1.25em; }
#content:before { content: none; }
#header > h1:first-child { color: black; margin-top: 2.25rem; margin-bottom: 0; }
#header > h1:first-child + #toc { margin-top: 8px; border-top: 1px solid #ddd; }
#header > h1:only-child, body.toc2 #header > h1:nth-last-child(2) { border-bottom: 1px solid #ddd; padding-bottom: 8px; }
#header .details { border-bottom: 1px solid #ddd; line-height: 1.45; padding-top: 0.25em; padding-bottom: 0.25em; padding-left: 0.25em; color: #365E7A; display: -ms-flexbox; display: -webkit-flex; display: flex; -ms-flex-flow: row wrap; -webkit-flex-flow: row wrap; flex-flow: row wrap; }
#header .details span:first-child { margin-left: -0.125em; }
#header .details span.email a { color: #333; }
#header .details br { display: none; }
#header .details br + span:before { content: "\00a0\2013\00a0"; }
#header .details br + span.author:before { content: "\00a0\22c5\00a0"; color: #333; }
#header .details br + span#revremark:before { content: "\00a0|\00a0"; }
#header #revnumber { text-transform: capitalize; }
#header #revnumber:after { content: "\00a0"; }
#content > h1:first-child:not([class]) { color: black; border-bottom: 1px solid #ddd; padding-bottom: 8px; margin-top: 0; padding-top: 1rem; margin-bottom: 1.25rem; }
#toc { border-bottom: 0 solid #ddd; padding-bottom: 0.5em; }
#toc > ul { margin-left: 0.125em; }
#toc ul.sectlevel0 > li > a { font-style: italic; }
#toc ul.sectlevel0 ul.sectlevel1 { margin: 0.5em 0; }
#toc ul { font-family: Noto, sans-serif; list-style-type: none; }
#toc li { line-height: 1.3334; margin-top: 0.3334em; }
#toc a { text-decoration: none; }
#toc a:active { text-decoration: underline; }
#toctitle { color: black; font-size: 1.2em; }
@media only screen and (min-width: 768px) { #toctitle { font-size: 1.375em; }
body.toc2 { padding-left: 15em; padding-right: 0; }
#toc.toc2 { margin-top: 0 !important; background-color: #fff; position: fixed; width: 15em; left: 0; top: 0; border-right: 1px solid #ddd; border-top-width: 0 !important; border-bottom-width: 0 !important; z-index: 1000; padding: 1.25em 1em; height: 100%; overflow: auto; }
#toc.toc2 #toctitle { margin-top: 0; margin-bottom: 0.8rem; font-size: 1.2em; }
#toc.toc2 > ul { font-size: 0.9em; margin-bottom: 0; }
#toc.toc2 ul ul { margin-left: 0; padding-left: 1em; }
#toc.toc2 ul.sectlevel0 ul.sectlevel1 { padding-left: 0; margin-top: 0.5em; margin-bottom: 0.5em; }
body.toc2.toc-right { padding-left: 0; padding-right: 15em; }
body.toc2.toc-right #toc.toc2 { border-right-width: 0; border-left: 1px solid #ddd; left: auto; right: 0; } }
@media only screen and (min-width: 1280px) { body.toc2 { padding-left: 20em; padding-right: 0; }
#toc.toc2 { width: 20em; }
#toc.toc2 #toctitle { font-size: 1.375em; }
#toc.toc2 > ul { font-size: 0.95em; }
#toc.toc2 ul ul { padding-left: 1.25em; }
body.toc2.toc-right { padding-left: 0; padding-right: 20em; } }
#content #toc { border-style: solid; border-width: 1px; border-color: #e6e6e6; margin-bottom: 1.25em; padding: 1.25em; background: #fff; -webkit-border-radius: 0; border-radius: 0; }
#content #toc > :first-child { margin-top: 0; }
#content #toc > :last-child { margin-bottom: 0; }
#footer { max-width: 100%; background: none; padding: 1.25em; }
#footer-text { color: black; line-height: 1.44; }
#content { margin-bottom: 0.625em; }
.sect1 { padding-bottom: 0.625em; }
@media only screen and (min-width: 768px) { #content { margin-bottom: 1.25em; }
.sect1 { padding-bottom: 1.25em; } }
.sect1:last-child { padding-bottom: 0; }
.sect1 + .sect1 { border-top: 0 solid #ddd; }
#content h1 > a.anchor, h2 > a.anchor, h3 > a.anchor, #toctitle > a.anchor, .sidebarblock > .content > .title > a.anchor, h4 > a.anchor, h5 > a.anchor, h6 > a.anchor { position: absolute; z-index: 1001; width: 1.5ex; margin-left: -1.5ex; display: block; text-decoration: none !important; visibility: hidden; text-align: center; font-weight: normal; }
#content h1 > a.anchor:before, h2 > a.anchor:before, h3 > a.anchor:before, #toctitle > a.anchor:before, .sidebarblock > .content > .title > a.anchor:before, h4 > a.anchor:before, h5 > a.anchor:before, h6 > a.anchor:before { content: "\00A7"; font-size: 0.85em; display: block; padding-top: 0.1em; }
#content h1:hover > a.anchor, #content h1 > a.anchor:hover, h2:hover > a.anchor, h2 > a.anchor:hover, h3:hover > a.anchor, #toctitle:hover > a.anchor, .sidebarblock > .content > .title:hover > a.anchor, h3 > a.anchor:hover, #toctitle > a.anchor:hover, .sidebarblock > .content > .title > a.anchor:hover, h4:hover > a.anchor, h4 > a.anchor:hover, h5:hover > a.anchor, h5 > a.anchor:hover, h6:hover > a.anchor, h6 > a.anchor:hover { visibility: visible; }
#content h1 > a.link, h2 > a.link, h3 > a.link, #toctitle > a.link, .sidebarblock > .content > .title > a.link, h4 > a.link, h5 > a.link, h6 > a.link { color: black; text-decoration: none; }
#content h1 > a.link:hover, h2 > a.link:hover, h3 > a.link:hover, #toctitle > a.link:hover, .sidebarblock > .content > .title > a.link:hover, h4 > a.link:hover, h5 > a.link:hover, h6 > a.link:hover { color: black; }
.audioblock, .imageblock, .literalblock, .listingblock, .stemblock, .videoblock { margin-bottom: 1.25em; }
.admonitionblock td.content > .title, .audioblock > .title, .exampleblock > .title, .imageblock > .title, .listingblock > .title, .literalblock > .title, .stemblock > .title, .openblock > .title, .paragraph > .title, .quoteblock > .title, table.tableblock > .title, .verseblock > .title, .videoblock > .title, .dlist > .title, .olist > .title, .ulist > .title, .qlist > .title, .hdlist > .title { text-rendering: optimizeLegibility; text-align: left; }
table.tableblock > caption.title { white-space: nowrap; overflow: visible; max-width: 0; }
.paragraph.lead > p, #preamble > .sectionbody > .paragraph:first-of-type p { color: black; }
table.tableblock #preamble > .sectionbody > .paragraph:first-of-type p { font-size: inherit; }
.admonitionblock > table { border-collapse: separate; border: 0; background: none; width: 100%; }
.admonitionblock > table td.icon { text-align: center; width: 80px; }
.admonitionblock > table td.icon img { max-width: initial; }
.admonitionblock > table td.icon .title { font-weight: bold; font-family: Noto, sans-serif; text-transform: uppercase; }
.admonitionblock > table td.content { padding-left: 1.125em; padding-right: 1.25em; border-left: 1px solid #ddd; color: #365E7A; }
.admonitionblock > table td.content > :last-child > :last-child { margin-bottom: 0; }
.exampleblock > .content { border-style: solid; border-width: 1px; border-color: #e6e6e6; margin-bottom: 1.25em; padding: 1.25em; background: #fff; -webkit-border-radius: 0; border-radius: 0; }
.exampleblock > .content > :first-child { margin-top: 0; }
.exampleblock > .content > :last-child { margin-bottom: 0; }
.sidebarblock { border-style: solid; border-width: 1px; border-color: #e6e6e6; margin-bottom: 1.25em; padding: 1.25em; background: #fff; -webkit-border-radius: 0; border-radius: 0; }
.sidebarblock > :first-child { margin-top: 0; }
.sidebarblock > :last-child { margin-bottom: 0; }
.sidebarblock > .content > .title { color: black; margin-top: 0; }
.exampleblock > .content > :last-child > :last-child, .exampleblock > .content .olist > ol > li:last-child > :last-child, .exampleblock > .content .ulist > ul > li:last-child > :last-child, .exampleblock > .content .qlist > ol > li:last-child > :last-child, .sidebarblock > .content > :last-child > :last-child, .sidebarblock > .content .olist > ol > li:last-child > :last-child, .sidebarblock > .content .ulist > ul > li:last-child > :last-child, .sidebarblock > .content .qlist > ol > li:last-child > :last-child { margin-bottom: 0; }
.literalblock pre, .listingblock pre:not(.highlight), .listingblock pre[class="highlight"], .listingblock pre[class^="highlight "], .listingblock pre.CodeRay, .listingblock pre.prettyprint { background: #eee; }
.sidebarblock .literalblock pre, .sidebarblock .listingblock pre:not(.highlight), .sidebarblock .listingblock pre[class="highlight"], .sidebarblock .listingblock pre[class^="highlight "], .sidebarblock .listingblock pre.CodeRay, .sidebarblock .listingblock pre.prettyprint { background: #f2f1f1; }
.literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { border: 1px hidden #666; -webkit-border-radius: 0; border-radius: 0; word-wrap: break-word; padding: 1.25em 1.5625em 1.125em 1.5625em; font-size: 0.8125em; }
.literalblock pre.nowrap, .literalblock pre[class].nowrap, .listingblock pre.nowrap, .listingblock pre[class].nowrap { overflow-x: auto; white-space: pre; word-wrap: normal; }
@media only screen and (min-width: 768px) { .literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { font-size: 0.90625em; } }
@media only screen and (min-width: 1280px) { .literalblock pre, .literalblock pre[class], .listingblock pre, .listingblock pre[class] { font-size: 1em; } }
.literalblock.output pre { color: #eee; background-color: #264357; }
.listingblock pre.highlightjs { padding: 0; }
.listingblock pre.highlightjs > code { padding: 1.25em 1.5625em 1.125em 1.5625em; -webkit-border-radius: 0; border-radius: 0; }
.listingblock > .content { position: relative; }
.listingblock code[data-lang]:before { display: none; content: attr(data-lang); position: absolute; font-size: 0.75em; top: 0.425rem; right: 0.5rem; line-height: 1; text-transform: uppercase; color: #999; }
.listingblock:hover code[data-lang]:before { display: block; }
.listingblock.terminal pre .command:before { content: attr(data-prompt); padding-right: 0.5em; color: #999; }
.listingblock.terminal pre .command:not([data-prompt]):before { content: "$"; }
table.pyhltable { border-collapse: separate; border: 0; margin-bottom: 0; background: none; }
table.pyhltable td { vertical-align: top; padding-top: 0; padding-bottom: 0; line-height: 1.6; }
table.pyhltable td.code { padding-left: .75em; padding-right: 0; }
pre.pygments .lineno, table.pyhltable td:not(.code) { color: #999; padding-left: 0; padding-right: .5em; border-right: 1px solid #ddd; }
pre.pygments .lineno { display: inline-block; margin-right: .25em; }
table.pyhltable .linenodiv { background: none !important; padding-right: 0 !important; }
.quoteblock { margin: 0 1em 0.75em 1.5em; display: table; }
.quoteblock > .title { margin-left: -1.5em; margin-bottom: 0.75em; }
.quoteblock blockquote, .quoteblock blockquote p { color: #333; font-size: 1.15rem; line-height: 1.75; word-spacing: 0.1em; letter-spacing: 0; font-style: italic; text-align: justify; }
.quoteblock blockquote { margin: 0; padding: 0; border: 0; }
.quoteblock blockquote:before { content: "\201c"; float: left; font-size: 2.75em; font-weight: bold; line-height: 0.6em; margin-left: -0.6em; color: black; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.quoteblock blockquote > .paragraph:last-child p { margin-bottom: 0; }
.quoteblock .attribution { margin-top: 0.5em; margin-right: 0.5ex; text-align: right; }
.quoteblock .quoteblock { margin-left: 0; margin-right: 0; padding: 0.5em 0; border-left: 3px solid #365E7A; }
.quoteblock .quoteblock blockquote { padding: 0 0 0 0.75em; }
.quoteblock .quoteblock blockquote:before { display: none; }
.verseblock { margin: 0 1em 0.75em 1em; }
.verseblock pre { font-family: "Open Sans", "DejaVu Sans", sans; font-size: 1.15rem; color: #333; font-weight: 300; text-rendering: optimizeLegibility; }
.verseblock pre strong { font-weight: 400; }
.verseblock .attribution { margin-top: 1.25rem; margin-left: 0.5ex; }
.quoteblock .attribution, .verseblock .attribution { font-size: 0.8125em; line-height: 1.45; font-style: italic; }
.quoteblock .attribution br, .verseblock .attribution br { display: none; }
.quoteblock .attribution cite, .verseblock .attribution cite { display: block; letter-spacing: -0.025em; color: #365E7A; }
.quoteblock.abstract { margin: 0 0 0.75em 0; display: block; }
.quoteblock.abstract blockquote, .quoteblock.abstract blockquote p { text-align: left; word-spacing: 0; }
.quoteblock.abstract blockquote:before, .quoteblock.abstract blockquote p:first-of-type:before { display: none; }
table.tableblock { max-width: 100%; border-collapse: separate; }
table.tableblock td > .paragraph:last-child p > p:last-child, table.tableblock th > p:last-child, table.tableblock td > p:last-child { margin-bottom: 0; }
table.tableblock, th.tableblock, td.tableblock { border: 0 solid #d8d8ce; }
table.grid-all > thead > tr > .tableblock, table.grid-all > tbody > tr > .tableblock { border-width: 0 1px 1px 0; }
table.grid-all > tfoot > tr > .tableblock { border-width: 1px 1px 0 0; }
table.grid-cols > * > tr > .tableblock { border-width: 0 1px 0 0; }
table.grid-rows > thead > tr > .tableblock, table.grid-rows > tbody > tr > .tableblock { border-width: 0 0 1px 0; }
table.grid-rows > tfoot > tr > .tableblock { border-width: 1px 0 0 0; }
table.grid-all > * > tr > .tableblock:last-child, table.grid-cols > * > tr > .tableblock:last-child { border-right-width: 0; }
table.grid-all > tbody > tr:last-child > .tableblock, table.grid-all > thead:last-child > tr > .tableblock, table.grid-rows > tbody > tr:last-child > .tableblock, table.grid-rows > thead:last-child > tr > .tableblock { border-bottom-width: 0; }
table.frame-all { border-width: 1px; }
table.frame-sides { border-width: 0 1px; }
table.frame-topbot { border-width: 1px 0; }
th.halign-left, td.halign-left { text-align: left; }
th.halign-right, td.halign-right { text-align: right; }
th.halign-center, td.halign-center { text-align: center; }
th.valign-top, td.valign-top { vertical-align: top; }
th.valign-bottom, td.valign-bottom { vertical-align: bottom; }
th.valign-middle, td.valign-middle { vertical-align: middle; }
table thead th, table tfoot th { font-weight: bold; }
tbody tr th { display: table-cell; line-height: 1.4; background: #eee; }
tbody tr th, tbody tr th p, tfoot tr th, tfoot tr th p { color: #222; font-weight: bold; }
p.tableblock > code:only-child { background: none; padding: 0; }
p.tableblock { font-size: 1em; }
td > div.verse { white-space: pre; }
ol { margin-left: 1.75em; }
ul li ol { margin-left: 1.5em; }
dl dd { margin-left: 1.125em; }
dl dd:last-child, dl dd:last-child > :last-child { margin-bottom: 0; }
ol > li p, ul > li p, ul dd, ol dd, .olist .olist, .ulist .ulist, .ulist .olist, .olist .ulist { margin-bottom: 0.375em; }
ul.checklist, ul.none, ol.none, ul.no-bullet, ol.no-bullet, ol.unnumbered, ul.unstyled, ol.unstyled { list-style-type: none; }
ul.no-bullet, ol.no-bullet, ol.unnumbered { margin-left: 0.625em; }
ul.unstyled, ol.unstyled { margin-left: 0; }
ul.checklist { margin-left: 0.625em; }
ul.checklist li > p:first-child > .fa-square-o:first-child, ul.checklist li > p:first-child > .fa-check-square-o:first-child { width: 1.25em; font-size: 0.8em; position: relative; bottom: 0.125em; }
ul.checklist li > p:first-child > input[type="checkbox"]:first-child { margin-right: 0.25em; }
ul.inline { display: -ms-flexbox; display: -webkit-box; display: flex; -ms-flex-flow: row wrap; -webkit-flex-flow: row wrap; flex-flow: row wrap; list-style: none; margin: 0 0 0.375em -0.75em; }
ul.inline > li { margin-left: 0.75em; }
.unstyled dl dt { font-weight: normal; font-style: normal; }
ol.arabic { list-style-type: decimal; }
ol.decimal { list-style-type: decimal-leading-zero; }
ol.loweralpha { list-style-type: lower-alpha; }
ol.upperalpha { list-style-type: upper-alpha; }
ol.lowerroman { list-style-type: lower-roman; }
ol.upperroman { list-style-type: upper-roman; }
ol.lowergreek { list-style-type: lower-greek; }
.hdlist > table, .colist > table { border: 0; background: none; }
.hdlist > table > tbody > tr, .colist > table > tbody > tr { background: none; }
td.hdlist1, td.hdlist2 { vertical-align: top; padding: 0 0.625em; }
td.hdlist1 { font-weight: bold; padding-bottom: 0.75em; }
.literalblock + .colist, .listingblock + .colist { margin-top: -0.5em; }
.colist > table tr > td:first-of-type { padding: 0.4em 0.75em 0 0.75em; line-height: 1; vertical-align: top; }
.colist > table tr > td:first-of-type img { max-width: initial; }
.colist > table tr > td:last-of-type { padding: 0.25em 0; }
.thumb, .th { line-height: 0; display: inline-block; border: solid 4px #fff; -webkit-box-shadow: 0 0 0 1px #ddd; box-shadow: 0 0 0 1px #ddd; }
.imageblock.left, .imageblock[style*="float: left"] { margin: 0.25em 0.625em 1.25em 0; }
.imageblock.right, .imageblock[style*="float: right"] { margin: 0.25em 0 1.25em 0.625em; }
.imageblock > .title { margin-bottom: 0; }
.imageblock.thumb, .imageblock.th { border-width: 6px; }
.imageblock.thumb > .title, .imageblock.th > .title { padding: 0 0.125em; }
.image.left, .image.right { margin-top: 0.25em; margin-bottom: 0.25em; display: inline-block; line-height: 0; }
.image.left { margin-right: 0.625em; }
.image.right { margin-left: 0.625em; }
a.image { text-decoration: none; display: inline-block; }
a.image object { pointer-events: none; }
sup.footnote, sup.footnoteref { font-size: 0.875em; position: static; vertical-align: super; }
sup.footnote a, sup.footnoteref a { text-decoration: none; }
sup.footnote a:active, sup.footnoteref a:active { text-decoration: underline; }
#footnotes { padding-top: 0.75em; padding-bottom: 0.75em; margin-bottom: 0.625em; }
#footnotes hr { width: 20%; min-width: 6.25em; margin: -0.25em 0 0.75em 0; border-width: 1px 0 0 0; }
#footnotes .footnote { padding: 0 0.375em 0 0.225em; line-height: 1.3334; font-size: 0.875em; margin-left: 1.2em; margin-bottom: 0.2em; }
#footnotes .footnote a:first-of-type { font-weight: bold; text-decoration: none; margin-left: -1.05em; }
#footnotes .footnote:last-of-type { margin-bottom: 0; }
#content #footnotes { margin-top: -0.625em; margin-bottom: 0; padding: 0.75em 0; }
.gist .file-data > table { border: 0; background: #fff; width: 100%; margin-bottom: 0; }
.gist .file-data > table td.line-data { width: 99%; }
div.unbreakable { page-break-inside: avoid; }
.big { font-size: larger; }
.small { font-size: smaller; }
.underline { text-decoration: underline; }
.overline { text-decoration: overline; }
.line-through { text-decoration: line-through; }
.aqua { color: #00bfbf; }
.aqua-background { background-color: #00fafa; }
.black { color: black; }
.black-background { background-color: black; }
.blue { color: #0000bf; }
.blue-background { background-color: #0000fa; }
.fuchsia { color: #bf00bf; }
.fuchsia-background { background-color: #fa00fa; }
.gray { color: #606060; }
.gray-background { background-color: #7d7d7d; }
.green { color: #006000; }
.green-background { background-color: #007d00; }
.lime { color: #00bf00; }
.lime-background { background-color: #00fa00; }
.maroon { color: #600000; }
.maroon-background { background-color: #7d0000; }
.navy { color: #000060; }
.navy-background { background-color: #00007d; }
.olive { color: #606000; }
.olive-background { background-color: #7d7d00; }
.purple { color: #600060; }
.purple-background { background-color: #7d007d; }
.red { color: #bf0000; }
.red-background { background-color: #fa0000; }
.silver { color: #909090; }
.silver-background { background-color: #bcbcbc; }
.teal { color: #006060; }
.teal-background { background-color: #007d7d; }
.white { color: #bfbfbf; }
.white-background { background-color: #fafafa; }
.yellow { color: #bfbf00; }
.yellow-background { background-color: #fafa00; }
span.icon > .fa { cursor: default; }
a span.icon > .fa { cursor: inherit; }
.admonitionblock td.icon [class^="fa icon-"] { font-size: 2.5em; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); cursor: default; }
.admonitionblock td.icon .icon-note:before { content: "\f05a"; color: #29475c; }
.admonitionblock td.icon .icon-tip:before { content: "\f0eb"; text-shadow: 1px 1px 2px rgba(155, 155, 0, 0.8); color: #111; }
.admonitionblock td.icon .icon-warning:before { content: "\f071"; color: #bf6900; }
.admonitionblock td.icon .icon-caution:before { content: "\f06d"; color: #bf3400; }
.admonitionblock td.icon .icon-important:before { content: "\f06a"; color: #bf0000; }
.conum[data-value] { display: inline-block; color: #fff !important; background-color: black; -webkit-border-radius: 100px; border-radius: 100px; text-align: center; font-size: 0.75em; width: 1.67em; height: 1.67em; line-height: 1.67em; font-family: "Open Sans", "DejaVu Sans", sans-serif; font-style: normal; font-weight: bold; }
.conum[data-value] * { color: #fff !important; }
.conum[data-value] + b { display: none; }
.conum[data-value]:after { content: attr(data-value); }
pre .conum[data-value] { position: relative; top: -0.125em; }
b.conum * { color: inherit !important; }
.conum:not([data-value]):empty { display: none; }
h1, h2, h3, #toctitle, .sidebarblock > .content > .title, h4, h5, h6 { border-bottom: 1px solid #ddd; }
.sect1 { padding-bottom: 0; }
#toctitle { color: #00406F; font-weight: normal; margin-top: 1.5em; }
.sidebarblock { border-color: #aaa; }
code { -webkit-border-radius: 4px; border-radius: 4px; }
p.tableblock.header { color: #6d6e71; }
.literalblock pre, .listingblock pre { background: #eee; }
/* From https://github.com/KhronosGroup/Vulkan-Docs/pull/901 */
a code { color: inherit; }
/* From https://github.com/KhronosGroup/Vulkan-Docs/pull/1157 */
/* Make VUID anchor handles*/
li > p > a[id^="VUID-"] { visibility: hidden; position: absolute; z-index: 1001; width: 2.2ex; margin-left: -2.2ex; display: block; text-decoration: none !important; text-align: center; font-weight: normal; }
li > p > a[id^="VUID-"]:before { content: "\00A7"; font-size: 1em; display: block; padding-top: 0em; background: #fff; }
li > p:hover > a[id^="VUID-"], li > p > a[id^="VUID-"]:hover { visibility: visible; }
li > p > a[id^="VUID-"].link { color: black; text-decoration: none; }
/* TODO: not quite sure what these two do */
li > p > a[id^="VUID-"].link:hover { color: black; }
.vuid { color: #4d4d4d; font-family: monospace; }
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
pre.rouge table td { padding: 5px; }
pre.rouge table pre { margin: 0; }
pre.rouge .kp {
color: #445588;
font-weight: bold;
font-style: italic;
}
pre.rouge .fm {
color: #00c5cd;
font-weight: bold;
}
pre.rouge .nx {
color: #ff4500;
font-weight: bold;
}
pre.rouge .vm {
color: #ffa500;
font-weight: bold;
}
pre.rouge .cm {
color: #555544;
font-style: italic;
}
pre.rouge .cp {
color: #555555;
font-weight: bold;
}
pre.rouge .c1 {
color: #555544;
font-style: italic;
}
pre.rouge .cs {
color: #555555;
font-weight: bold;
font-style: italic;
}
pre.rouge .c, pre.rouge .ch, pre.rouge .cd, pre.rouge .cpf {
color: #555544;
font-style: italic;
}
pre.rouge, pre.rouge .w {
color: #24292f;
background-color: #f6f8fa;
}
pre.rouge .k, pre.rouge .kd, pre.rouge .kn, pre.rouge .kr, pre.rouge .kt, pre.rouge .kv {
color: #cf222e;
}
pre.rouge .gr {
color: #f6f8fa;
}
pre.rouge .gd {
color: #82071e;
background-color: #ffebe9;
}
pre.rouge .nb {
color: #953800;
}
pre.rouge .nc {
color: #953800;
}
pre.rouge .no {
color: #953800;
}
pre.rouge .nn {
color: #953800;
}
pre.rouge .sr {
color: #116329;
}
pre.rouge .na {
color: #116329;
}
pre.rouge .nt {
color: #116329;
}
pre.rouge .gi {
color: #116329;
background-color: #dafbe1;
}
pre.rouge .ges {
font-weight: bold;
font-style: italic;
}
pre.rouge .kc {
color: #0550ae;
}
pre.rouge .l, pre.rouge .ld, pre.rouge .m, pre.rouge .mb, pre.rouge .mf, pre.rouge .mh, pre.rouge .mi, pre.rouge .il, pre.rouge .mo, pre.rouge .mx {
color: #0550ae;
}
pre.rouge .sb {
color: #0550ae;
}
pre.rouge .bp {
color: #0550ae;
}
pre.rouge .ne {
color: #0550ae;
}
pre.rouge .nl {
color: #0550ae;
}
pre.rouge .py {
color: #0550ae;
}
pre.rouge .nv, pre.rouge .vc, pre.rouge .vg, pre.rouge .vi {
color: #0550ae;
}
pre.rouge .o, pre.rouge .ow {
color: #0550ae;
}
pre.rouge .gh {
color: #0550ae;
font-weight: bold;
}
pre.rouge .gu {
color: #0550ae;
font-weight: bold;
}
pre.rouge .s, pre.rouge .sa, pre.rouge .sc, pre.rouge .dl, pre.rouge .sd, pre.rouge .s2, pre.rouge .se, pre.rouge .sh, pre.rouge .sx, pre.rouge .s1, pre.rouge .ss {
color: #0a3069;
}
pre.rouge .nd {
color: #8250df;
}
pre.rouge .nf {
color: #8250df;
}
pre.rouge .err {
color: #f6f8fa;
background-color: #82071e;
}
pre.rouge .gl {
color: #6e7781;
}
pre.rouge .gt {
color: #6e7781;
}
pre.rouge .ni {
color: #24292f;
}
pre.rouge .si {
color: #24292f;
}
pre.rouge .ge {
color: #24292f;
font-style: italic;
}
pre.rouge .gs {
color: #24292f;
font-weight: bold;
}
</style>
<link rel="stylesheet" href="../katex/katex.min.css">
<script src="../katex/katex.min.js"></script>
<script src="../katex/contrib/auto-render.min.js"></script>
<!-- Use KaTeX to render math once document is loaded, see
https://github.com/Khan/KaTeX/tree/master/contrib/auto-render -->
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(
document.body,
{
delimiters: [
{ left: "$$", right: "$$", display: true},
{ left: "\\[", right: "\\]", display: true},
{ left: "$", right: "$", display: false},
{ left: "\\(", right: "\\)", display: false}
]
}
);
});
</script></head>
<body class="book toc2 toc-left">
<div style="text-align: left;">
<span class="image"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiYAAAD6CAYAAACVrYw7AAAMSHpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZhrciS5DYT/8xQ+AkkQJHEcPiN8Ax/fH6pbGo1mdr0TYXWoq1QPPpCJRELh/OffN/yLH0mth6KtV6s18lOsWB6c9Pj6sec7xfJ8Pz+5xvy++tP1cMf7pcwl4SivP9v7ehpc1x8vfMyR5s/XQ3/fyf09UPoc+PkRn9nP99dFcj2/rqfyHsjO66Rab1+XOt8DrfeDz1Lev+VzWa+D/x1+utCI0lYmkpyPJInPd3+tQPw3y+BofCdhUXy350oLHEQ+VkJAftrexzHGrwH6KcgfZ+F79Fv5ffDzeD8h32JZ3zHi5Lc3kn67Lp/z568Ty+eK8rcbEucv23n/3rv7vee1u1EqEa1vRj3BTh/D8CCDFHleq3wav8p5ez7Gp8cRF5DvuJhwcm4pg8oNqaSdRrrpPMeVFkss+eTGMeeV5bnWpWXLSxyn4p90cwO9LR0kVz7BMZP8uZb0zGvPfCt1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2g+7CwTw7Nlc+OMnRO1LSNqQmWzy7AT+wT52HsVF9pFYuTSdtHEL9LoZ9MUP0+UKBBXyARCCCGEkDARQgghhJAwEUIIIYSEiRBCCCGEhIkQQgghJEyEEEIIISRMhBBCCCFhIoQQQgghYSKEEEIICRMhhBBCCAkTIYQQQkiYCCGEEEJImAghhBBCwkQIIYQQQsJECCGEEBImQgghhBASJkIIIYQQEiZCCCGEkDARQgghhJAwEUIIIYSEiRBCCCGEhIkQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEI0OP8fG27L2aBIXd8AAAAASUVORK5CYII=" alt="OpenCL Logo" width="550" height="250">
</span>
</div>
<div id="header" style="max-width: 100%;">
<h1>The OpenCL<sup>&#8482;</sup> C Specification</h1>
<div class="details">
<span id="author" class="author">Khronos<sup>&#174;</sup> OpenCL Working Group</span><br>
<span id="revnumber">version v3.1.1,</span>
<span id="revdate">Fri, 22 May 2026 12:00:00 +0000</span>
<br><span id="revremark">from git branch: main commit: 9f68efb5d80e77a4e437c5b8ee67d581666d044c</span>
</div>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
<li><a href="#the-opencl-c-programming-language">6. The OpenCL C Programming Language</a>
<ul class="sectlevel2">
<li><a href="#unified-spec">6.1. Unified Specification</a></li>
<li><a href="#optional-functionality">6.2. Optional functionality</a>
<ul class="sectlevel3">
<li><a href="#features">6.2.1. Features</a></li>
<li><a href="#extensions">6.2.2. Extensions</a></li>
</ul>
</li>
<li><a href="#supported-data-types">6.3. Supported Data Types</a>
<ul class="sectlevel3">
<li><a href="#built-in-scalar-data-types">6.3.1. Built-in Scalar Data Types</a></li>
<li><a href="#built-in-vector-data-types">6.3.2. Built-in Vector Data Types</a></li>
<li><a href="#other-built-in-data-types">6.3.3. Other Built-in Data Types</a></li>
<li><a href="#reserved-data-types">6.3.4. Reserved Data Types</a></li>
<li><a href="#alignment-of-types">6.3.5. Alignment of Types</a></li>
<li><a href="#vector-literals">6.3.6. Vector Literals</a></li>
<li><a href="#vector-components">6.3.7. Vector Components</a></li>
<li><a href="#aliasing-rules">6.3.8. Aliasing Rules</a></li>
<li><a href="#keywords">6.3.9. Keywords</a></li>
</ul>
</li>
<li><a href="#conversions-and-type-casting">6.4. Conversions and Type Casting</a>
<ul class="sectlevel3">
<li><a href="#implicit-conversions">6.4.1. Implicit Conversions</a></li>
<li><a href="#explicit-casts">6.4.2. Explicit Casts</a></li>
<li><a href="#explicit-conversions">6.4.3. Explicit Conversions</a></li>
<li><a href="#reinterpreting-data-as-another-type">6.4.4. Reinterpreting Data as Another Type</a></li>
<li><a href="#pointer-casting">6.4.5. Pointer Casting</a></li>
<li><a href="#usual-arithmetic-conversions">6.4.6. Usual Arithmetic Conversions</a></li>
</ul>
</li>
<li><a href="#operators">6.5. Operators</a>
<ul class="sectlevel3">
<li><a href="#operators-arithmetic">6.5.1. Arithmetic Operators</a></li>
<li><a href="#operators-unary">6.5.2. Unary Operators</a></li>
<li><a href="#operators-prepost">6.5.3. Pre- and Post-Operators</a></li>
<li><a href="#operators-relational">6.5.4. Relational Operators</a></li>
<li><a href="#operators-equality">6.5.5. Equality Operators</a></li>
<li><a href="#operators-bitwise">6.5.6. Bitwise Operators</a></li>
<li><a href="#operators-logical">6.5.7. Logical Operators</a></li>
<li><a href="#operators-logical-unary">6.5.8. Unary Logical Operator</a></li>
<li><a href="#operators-ternary-selection">6.5.9. Ternary Selection Operator</a></li>
<li><a href="#operators-shift">6.5.10. Shift Operators</a></li>
<li><a href="#operators-sizeof">6.5.11. Sizeof Operator</a></li>
<li><a href="#operators-comma">6.5.12. Comma Operator</a></li>
<li><a href="#operators-indirection">6.5.13. Indirection Operator</a></li>
<li><a href="#operators-address">6.5.14. Address Operator</a></li>
<li><a href="#operators-assignment">6.5.15. Assignment Operator</a></li>
</ul>
</li>
<li><a href="#vector-operations">6.6. Vector Operations</a></li>
<li><a href="#address-space-qualifiers">6.7. Address Space Qualifiers</a>
<ul class="sectlevel3">
<li><a href="#global-or-global">6.7.1. <code>__global</code> (or <code>global</code>)</a></li>
<li><a href="#local-or-local">6.7.2. <code>__local</code> (or <code>local</code>)</a></li>
<li><a href="#constant-or-constant">6.7.3. <code>__constant</code> (or <code>constant</code>)</a></li>
<li><a href="#private-or-private">6.7.4. <code>__private</code> (or <code>private</code>)</a></li>
<li><a href="#the-generic-address-space">6.7.5. The Generic Address Space</a></li>
<li><a href="#_usage_for_declaration_scopes_and_variable_types">6.7.6. Usage for Declaration Scopes and Variable Types</a></li>
<li><a href="#_initialization">6.7.7. Initialization</a></li>
<li><a href="#addr-spaces-inference">6.7.8. Inference</a></li>
<li><a href="#addr-spaces-conversions">6.7.9. Address Space Conversions</a></li>
</ul>
</li>
<li><a href="#access-qualifiers">6.8. Access Qualifiers</a></li>
<li><a href="#function-qualifiers">6.9. Function Qualifiers</a>
<ul class="sectlevel3">
<li><a href="#kernel-or-kernel">6.9.1. <code>__kernel</code> (or <code>kernel</code>)</a></li>
<li><a href="#optional-attribute-qualifiers">6.9.2. Optional Attribute Qualifiers</a></li>
</ul>
</li>
<li><a href="#storage-class-specifiers">6.10. Storage-Class Specifiers</a></li>
<li><a href="#restrictions">6.11. Restrictions</a></li>
<li><a href="#preprocessor-directives-and-macros">6.12. Preprocessor Directives and Macros</a>
<ul class="sectlevel3">
<li><a href="#preprocessor-directives-for-optional-extensions">6.12.1. Preprocessor Directives for Optional Extensions</a></li>
</ul>
</li>
<li><a href="#attribute-qualifiers">6.13. Attribute Qualifiers</a>
<ul class="sectlevel3">
<li><a href="#specifying-attributes-of-types">6.13.1. Specifying Attributes of Types</a></li>
<li><a href="#specifying-attributes-of-functions">6.13.2. Specifying Attributes of Functions</a></li>
<li><a href="#specifying-attributes-of-variables">6.13.3. Specifying Attributes of Variables</a></li>
<li><a href="#specifying-attributes-of-blocks-and-control-flow-statements">6.13.4. Specifying Attributes of Blocks and Control-Flow-Statements</a></li>
<li><a href="#specifying-attribute-for-unrolling-loops">6.13.5. Specifying Attribute for Unrolling Loops</a></li>
</ul>
</li>
<li><a href="#blocks">6.14. Blocks</a>
<ul class="sectlevel3">
<li><a href="#declaring-and-using-a-block">6.14.1. Declaring and Using a Block</a></li>
<li><a href="#declaring-a-block-reference">6.14.2. Declaring a Block Reference</a></li>
<li><a href="#block-literal-expressions">6.14.3. Block Literal Expressions</a></li>
<li><a href="#control-flow">6.14.4. Control Flow</a></li>
<li><a href="#restrictions-1">6.14.5. Restrictions</a></li>
</ul>
</li>
<li><a href="#built-in-functions">6.15. Built-in Functions</a>
<ul class="sectlevel3">
<li><a href="#work-item-functions">6.15.1. Work-Item Functions</a></li>
<li><a href="#math-functions">6.15.2. Math Functions</a></li>
<li><a href="#integer-functions">6.15.3. Integer Functions</a></li>
<li><a href="#common-functions">6.15.4. Common Functions</a></li>
<li><a href="#geometric-functions">6.15.5. Geometric Functions</a></li>
<li><a href="#relational-functions">6.15.6. Relational Functions</a></li>
<li><a href="#vector-data-load-and-store-functions">6.15.7. Vector Data Load and Store Functions</a></li>
<li><a href="#synchronization-functions">6.15.8. Synchronization Functions</a></li>
<li><a href="#legacy-mem-fence-functions">6.15.9. Legacy Explicit Memory Fence Functions</a></li>
<li><a href="#address-space-qualifier-functions">6.15.10. Address Space Qualifier Functions</a></li>
<li><a href="#async-copies">6.15.11. Async Copies From Global to Local Memory, Local to Global Memory, and Prefetch</a></li>
<li><a href="#atomic-functions">6.15.12. Atomic Functions</a></li>
<li><a href="#miscellaneous-vector-functions">6.15.13. Miscellaneous Vector Functions</a></li>
<li><a href="#printf">6.15.14. printf</a></li>
<li><a href="#image-read-and-write-functions">6.15.15. Image Read and Write Functions</a></li>
<li><a href="#work-group-functions">6.15.16. Work-group Collective Functions</a></li>
<li><a href="#work-group-collective-uniform-arithmetic-functions">6.15.17. Work-group Collective Uniform Arithmetic Functions</a></li>
<li><a href="#pipe-functions">6.15.18. Pipe Functions</a></li>
<li><a href="#enqueuing-kernels">6.15.19. Enqueuing Kernels</a></li>
<li><a href="#sub-group-functions">6.15.20. Sub-Group Functions</a></li>
<li><a href="#kernel-clock-functions">6.15.21. Kernel Clock Functions</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#opencl-numerical-compliance">7. OpenCL Numerical Compliance</a>
<ul class="sectlevel2">
<li><a href="#rounding-modes-1">7.1. Rounding Modes</a></li>
<li><a href="#inf-nan-and-denormalized-numbers">7.2. INF, NaN and Denormalized Numbers</a></li>
<li><a href="#floating-point-exceptions">7.3. Floating-Point Exceptions</a></li>
<li><a href="#relative-error-as-ulps">7.4. Relative Error as ULPs</a></li>
<li><a href="#edge-case-behavior">7.5. Edge Case Behavior</a>
<ul class="sectlevel3">
<li><a href="#additional-requirements-beyond-c99-tc2">7.5.1. Additional Requirements Beyond C99 TC2</a></li>
<li><a href="#changes-to-c99-tc2-behavior">7.5.2. Changes to C99 TC2 Behavior</a></li>
<li><a href="#edge-case-behavior-in-flush-to-zero-mode">7.5.3. Edge Case Behavior in Flush to Zero Mode</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#image-addressing-and-filtering">8. Image Addressing and Filtering</a>
<ul class="sectlevel2">
<li><a href="#image-coordinates">8.1. Image Coordinates</a></li>
<li><a href="#addressing-and-filter-modes">8.2. Addressing and Filter Modes</a></li>
<li><a href="#conversion-rules">8.3. Conversion Rules</a>
<ul class="sectlevel3">
<li><a href="#conversion-rules-for-normalized-integer-channel-data-types">8.3.1. Conversion Rules for Normalized Integer Channel Data Types</a></li>
<li><a href="#conversion-rules-for-half-precision-floating-point-channel-data-type">8.3.2. Conversion Rules for Half-Precision Floating-Point Channel Data Type</a></li>
<li><a href="#conversion-rules-for-floating-point-channel-data-type">8.3.3. Conversion Rules for Floating-Point Channel Data Type</a></li>
<li><a href="#conversion-rules-for-signed-and-unsigned-integer-channel-data-types">8.3.4. Conversion Rules for Signed and Unsigned Integer Channel Data Types</a></li>
<li><a href="#conversion-rules-for-srgba-and-sbgra-images">8.3.5. Conversion Rules for sRGBA and sBGRA Images</a></li>
</ul>
</li>
<li><a href="#selecting-an-image-from-an-image-array">8.4. Selecting an Image From an Image Array</a></li>
</ul>
</li>
<li><a href="#references">9. Normative References</a></li>
<li><a href="#changes_to_opencl">Appendix A: Changes to OpenCL</a>
<ul class="sectlevel2">
<li><a href="#_summary_of_changes_to_opencl_3_0">Summary of Changes to OpenCL 3.0</a></li>
<li><a href="#_summary_of_changes_from_opencl_3_0_to_opencl_3_1">Summary of Changes from OpenCL 3.0 to OpenCL 3.1</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content" style="max-width: 100%;">
<div id="preamble">
<div class="sectionbody">
<div style="page-break-after: always;"></div>
<div class="paragraph">
<p>Copyright 2008-2026 The Khronos Group Inc.</p>
</div>
<div class="paragraph">
<p>This Specification is protected by copyright laws and contains material proprietary to Khronos.
Except as described by these terms, it or any components may not be reproduced, republished,
distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without the
express prior written permission of Khronos.</p>
</div>
<div class="paragraph">
<p>This Specification has been created under the Khronos Intellectual Property Rights
Policy, which is Attachment A of the Khronos Group Membership Agreement available at
www.khronos.org/files/member_agreement.pdf and defines the terms 'Scope', 'Compliant Portion',
and 'Necessary Patent Claims'.</p>
</div>
<div class="paragraph">
<p>Khronos grants a conditional copyright license to use and reproduce the
unmodified Specification for any purpose, without fee or royalty, EXCEPT no licenses
to any patent, trademark or other intellectual property rights are granted under these
terms. Parties desiring to implement the Specification and make use of Khronos trademarks
in relation to that implementation, and receive reciprocal patent license protection under
the Khronos Intellectual Property Rights Policy must become Adopters and confirm the
implementation as conformant under the process defined by Khronos for this Specification;
see <a href="https://www.khronos.org/adopters" class="bare">https://www.khronos.org/adopters</a>.</p>
</div>
<div class="paragraph">
<p>Khronos makes no, and expressly disclaims any, representations or warranties,
express or implied, regarding this Specification, including, without limitation:
merchantability, fitness for a particular purpose, non-infringement of any
intellectual property, correctness, accuracy, completeness, timeliness, and
reliability. Under no circumstances will Khronos, or any of its Promoters,
Contributors or Members, or their respective partners, officers, directors,
employees, agents or representatives be liable for any damages, whether direct,
indirect, special or consequential damages for lost revenues, lost profits, or
otherwise, arising from or in connection with these materials.</p>
</div>
<div class="paragraph">
<p>Where this Specification identifies specific sections of external references, only those
specifically identified sections define normative functionality. The Khronos Intellectual
Property Rights Policy excludes external references to materials and associated enabling
technology not created by Khronos from the Scope of this specification, and any licenses
that may be required to implement such referenced materials and associated technologies
must be obtained separately and may involve royalty payments.</p>
</div>
<div class="paragraph">
<p>Khronos® and Vulkan® are registered trademarks, and SPIR™, SPIR-V™, and SYCL™ are trademarks
of The Khronos Group Inc. OpenCLâ„¢ is a trademark of Apple Inc. used under license by Khronos.
OpenGL® is a registered trademark and the OpenGL ES™ and OpenGL SC™ logos
are trademarks of Hewlett Packard Enterprise used under license by Khronos.
All other product names, trademarks, and/or company names are used solely for identification
and belong to their respective owners.</p>
</div>
<div style="page-break-after: always;"></div>
</div>
</div>
<div class="sect1">
<h2 id="the-opencl-c-programming-language"><a class="anchor" href="#the-opencl-c-programming-language"></a>6. The OpenCL C Programming Language</h2>
<div class="sectionbody">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>This document starts at chapter 6 to keep the section numbers historically
consistent with previous versions of the OpenCL and OpenCL C Programming
Language specifications.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>This section describes the OpenCL C programming language.
The OpenCL C programming language may be used to write kernels that execute
on an OpenCL device.</p>
</div>
<div class="paragraph">
<p>The OpenCL C programming language (also referred to as OpenCL C) is based
on the <a href="#C99-spec">ISO/IEC 9899:1999 Programming languages - C</a> specification
(also referred to as the C99 specification, or just C99), with extensions
and restrictions to support parallel kernels.
In addition, some features of OpenCL C are based on the <a href="#C11-spec">ISO/IEC
9899:2011 Information technology - Programming languages - C</a> specification
(also referred to as the C11 specification, or just C11).</p>
</div>
<div class="paragraph">
<p>This document describes the modifications and restrictions to C99 and C11
in OpenCL C.
Please refer to the C99 specification for a detailed description of the
language grammar.</p>
</div>
<div class="sect2">
<h3 id="unified-spec"><a class="anchor" href="#unified-spec"></a>6.1. Unified Specification</h3>
<div class="paragraph">
<p>This document specifies all versions of OpenCL C.</p>
</div>
<div class="paragraph">
<p>There are several ways that an OpenCL C feature may be described in terms of
what versions of OpenCL C specify that feature.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Requires support for OpenCL C <em>major.minor</em> or newer: Features that were
introduced in version <em>major.minor</em>.
Compilers for an earlier version of OpenCL C will not provide these
features.</p>
<div class="ulist">
<ul>
<li>
<p>In some instances the variation of "For OpenCL C <em>major.minor</em> or newer"
is used, it has the identical meaning.</p>
</li>
</ul>
</div>
</li>
<li>
<p>Requires support for OpenCL C 2.0, or OpenCL C 3.0 or newer and the
<code>__opencl_c_<wbr>&lt;feature_<wbr>name&gt;</code> feature:
Features that were introduced in OpenCL C 2.0 as mandatory, but are
<a href="#optional-functionality">optional</a> in OpenCL C 3.0 or newer.
Compilers for versions of OpenCL C 1.2 or below will not provide these
features, compilers for OpenCL C 2.0 will provide these features,
compilers for OpenCL C 3.0 or newer may provide these features.</p>
</li>
<li>
<p>Requires support for OpenCL C 3.0 or newer and the
<code>__opencl_c_<wbr>&lt;feature_<wbr>name&gt;</code> feature: <a href="#optional-functionality">Optional</a> features that were introduced in OpenCL C 3.0.
Compilers for an earlier version of OpenCL C will not provide these
features, compilers for OpenCL C 3.0 or newer may provide these features.</p>
</li>
<li>
<p>Deprecated by OpenCL C <em>major.minor</em>: Features that were deprecated
in version <em>major.minor</em>, see the definition of deprecation in the
glossary of the main OpenCL specification.</p>
</li>
<li>
<p>Universal: Features that have no mention of what version they are missing
before or deprecated by are specified for all versions of OpenCL C.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="optional-functionality"><a class="anchor" href="#optional-functionality"></a>6.2. Optional functionality</h3>
<div class="paragraph">
<p>Some language functionality is optional and will not be supported by all
devices. Such functionality is represented by optional language features or
language extensions. Support of optional functionality in OpenCL C is indicated
by the presence of special predefined macros.</p>
</div>
<div class="sect3">
<h4 id="features"><a class="anchor" href="#features"></a>6.2.1. Features</h4>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
Feature test macros <a href="#unified-spec">require</a> support for OpenCL C
3.0 or newer.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Optional core language features are described in this document. They are
optional from OpenCL C 3.0 onwards and therefore are not supported by all
implementations.
When an optional OpenCL C 3.0 or newer feature is supported, an associated
<em>feature test macro</em> will be predefined.</p>
</div>
<div class="paragraph">
<p>The following table describes OpenCL C 3.0 or newer features and their
meaning. The naming convention for the feature macros is
<code>__opencl_c_<wbr>&lt;feature_<wbr>name&gt;</code>.</p>
</div>
<div class="paragraph">
<p>Feature macro identifiers are used as names of features in this document.</p>
</div>
<table id="table-optional-lang-features" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 1. Optional features in OpenCL C 3.0 or newer and their predefined macros.</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Feature Macro/Name</th>
<th class="tableblock halign-left valign-top">Brief Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>3d_<wbr>image_<wbr>writes</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions for writing to 3D image
objects.</p>
<p class="tableblock">OpenCL C compilers that define the feature macro <code>__opencl_c_<wbr>3d_<wbr>image_<wbr>writes</code>
must also define the feature macro <code>__opencl_c_<wbr>images</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>acq_<wbr>rel</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports enumerations and built-in functions for atomic
operations with acquire and release memory consistency orders.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports enumerations and built-in functions for atomic
operations and fences with sequentially consistent memory consistency order.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports enumerations and built-in functions for atomic
operations and fences with device memory scope.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>all_<wbr>devices</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports enumerations and built-in functions for atomic
operations and fences with all with memory scope across all devices that can
share SVM memory with each other and the host process.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>device_<wbr>enqueue</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions to enqueue additional work
from the device.</p>
<p class="tableblock">OpenCL C compilers that define the feature macro <code>__opencl_c_<wbr>device_<wbr>enqueue</code> must also
define <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> and <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code>
feature macros.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports the unnamed generic address space.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>fp64</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports types and built-in functions with 64-bit
floating-point types.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>images</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports types and built-in functions for images.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>int64</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports types and built-in functions with 64-bit
integers.</p>
<p class="tableblock">OpenCL C compilers for FULL profile devices or devices with 64-bit pointers
must always define the <code>__opencl_c_<wbr>int64</code> feature macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>pipes</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports the pipe specifier and built-in functions
to read and write from a pipe.</p>
<p class="tableblock">OpenCL C compilers that define the feature macro <code>__opencl_c_<wbr>pipes</code> must
also define the feature macro <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports program scope variables in the global address
space.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>read_<wbr>write_<wbr>images</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports reading from and writing to the same image
object in a kernel.</p>
<p class="tableblock">OpenCL C compilers that define the feature macro
<code>__opencl_c_<wbr>read_<wbr>write_<wbr>images</code> must also define the feature macro
<code>__opencl_c_<wbr>images</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>subgroups</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions operating on sub-groupings
of work-items.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>work_<wbr>group_<wbr>collective_<wbr>functions</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions that perform collective
operations across a work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>integer_<wbr>dot_<wbr>product_<wbr>input_<wbr>4x8bit_<wbr>packed</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions that perform dot
products on 4x8 bit packed integer vectors.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>integer_<wbr>dot_<wbr>product_<wbr>input_<wbr>4x8bit</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions that perform dot
products on 4x8 bit integer vectors.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>kernel_<wbr>clock_<wbr>scope_<wbr>device</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions that sample the value from a
clock shared by all work-items executing on the device.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>kernel_<wbr>clock_<wbr>scope_<wbr>work_<wbr>group</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions that sample the value from a
clock shared by all work-items executing in the same work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>kernel_<wbr>clock_<wbr>scope_<wbr>sub_<wbr>group</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports built-in functions that sample the value from a
clock shared by all work-items executing in the same sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>ext_<wbr>image_<wbr>unorm_<wbr>int_<wbr>2_<wbr>101010</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports <code>CLK_UNORM_INT_2_101010_EXT</code> and returning it
from <code>get_image_channel_data_type</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__opencl_c_<wbr>ext_<wbr>image_<wbr>unsigned_<wbr>10x6_<wbr>12x4_<wbr>14x2</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The OpenCL C compiler supports returning <code>CLK_UNSIGNED_INT10X6_EXT</code>,
<code>CLK_UNSIGNED_INT12X4_EXT</code>, <code>CLK_UNSIGNED_INT14X2_EXT</code>, <code>CLK_UNORM_10X6_EXT</code>,
<code>CLK_UNORM_12X4_EXT</code>, or <code>CLK_UNORM_14X2_EXT</code> from <code>get_image_channel_data_type</code>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>In OpenCL C 3.0 or newer, feature macros must expand to the value <code>1</code> if the
feature macro is defined by the OpenCL C compiler. A feature macro must not be
defined if the feature is not supported by the OpenCL C compiler. A feature
macro may expand to a different value in the future, but if this occurs the
value of the feature macro must compare greater than the prior value of the
feature macro.</p>
</div>
<div class="paragraph">
<p>As specified in <a href="#C99-spec">section 7.1.3 of the C99 Specification</a> double
underscore identifiers are reserved and therefore implementations
for earlier OpenCL C versions are allowed to define feature test macros
but they are not required to do so. This means that applications which
target earlier OpenCL C versions should not rely on the presence of
feature test macros because there is no guarantee that feature test macros
will be defined and that if defined they will indicate the presence of the
corresponding optional functionality.</p>
</div>
</div>
<div class="sect3">
<h4 id="extensions"><a class="anchor" href="#extensions"></a>6.2.2. Extensions</h4>
<div class="paragraph">
<p>Other optional functionality may be described by language extensions to OpenCL
C.
Extensions to OpenCL C are described in the OpenCL C specification or in
vendor-provided documentation.
When an OpenCL C extension is supported an associated extension macro will be
predefined.
Please refer to <a href="#preprocessor-directives-for-optional-extensions">Preprocessor
Directives for Optional Extensions</a> for more information about predefined
extension macros.</p>
</div>
<div class="paragraph">
<p>When an optional core language feature began as an extension it may have both an
associated feature macro and an associated extension macro. If an optional core
language feature was an optional extension to an earlier version of OpenCL C it
can still be used as an extension, i.e. the same predefined extension macros are
still valid in OpenCL C 3.0 or newer, however the use of feature macros is
preferred whenever possible.</p>
</div>
<div class="sect4">
<h5 id="cl_khr_3d_image_writes"><a class="anchor" href="#cl_khr_3d_image_writes"></a>6.2.2.1. 3D Image Writes</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>3d_<wbr>image_<wbr>writes</code> extension was promoted to OpenCL C 2.0, and to
OpenCL C 3.0 and newer as the <code>__opencl_c_<wbr>3d_<wbr>image_<wbr>writes</code> feature.
The extension adds <a href="#built-in-image-write-functions">Built-in Image Write
Functions</a> that allow a kernel to write to 3D image objects in addition to
2D image objects.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_async_work_group_copy_fence"><a class="anchor" href="#cl_khr_async_work_group_copy_fence"></a>6.2.2.2. Async Work-group Copy Fence</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>async_<wbr>work_<wbr>group_<wbr>copy_<wbr>fence</code> extension supports establishing a
memory synchronization ordering of asynchronous copies.
The extension provides the <code>async_work_group_copy_fence</code> function, as
described in the <a href="#table-builtin-async-copy">Built-in Async Copy and
Prefetch Functions</a> table</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_byte_addressable_store"><a class="anchor" href="#cl_khr_byte_addressable_store"></a>6.2.2.3. Byte-Addressable Storage</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>byte_<wbr>addressable_<wbr>store</code> extension was promoted to OpenCL C 1.1.
The extension relaxes <a href="#restrictions">Restrictions</a> on pointers to <code>char</code>, <code>uchar</code>,
<code>char2</code>, <code>uchar2</code>, <code>short</code>, <code>ushort</code> and <code>half</code>, allowing applications to
read from and write to pointers to these types.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_depth_images"><a class="anchor" href="#cl_khr_depth_images"></a>6.2.2.4. Depth Images</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>depth_<wbr>images</code> extension was promoted to OpenCL 2.0.
The extension provides new <a href="#table-other-builtin-types">built-in depth image
types</a>, as well as <a href="#table-image-read">read functions</a>,
<a href="#table-image-samplerless-read">sampler-less read functions</a>,
<a href="#table-image-write">write functions</a>, and <a href="#table-image-query">image
queries</a> operating on those types.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_device_enqueue_local_arg_types"><a class="anchor" href="#cl_khr_device_enqueue_local_arg_types"></a>6.2.2.5. Device Enqueue Local Argument Types</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>device_<wbr>enqueue_<wbr>local_<wbr>arg_<wbr>types</code> extension allows arguments to
blocks that are passed to the <a href="#table-builtin-kernel-enqueue">Built-in
Kernel Enqueue Functions</a> and to the <a href="#table-builtin-kernel-query">Built-in
Kernel Query Functions</a> to be pointers to any type (built-in or
user-defined) in local memory, instead of requiring arguments to blocks to
be pointers to <code>void</code> in local memory.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_extended_async_copies"><a class="anchor" href="#cl_khr_extended_async_copies"></a>6.2.2.6. Extended Async Copy Functions</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>extended_<wbr>async_<wbr>copies</code> extension provides additional
<a href="#extended-async-copies">Extended Async Copy Functions</a> which interpret the
source and destination as 2D or 3D images.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_extended_bit_ops"><a class="anchor" href="#cl_khr_extended_bit_ops"></a>6.2.2.7. Extended Bit Operations</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>extended_<wbr>bit_<wbr>ops</code> extension was promoted to OpenCL C 3.1.
The extension provides additional <a href="#extended-bit-operations">Extended Bit
Operations</a> including bitfield insert, bitfield extract, and bit reverse.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16"><a class="anchor" href="#cl_khr_fp16"></a>6.2.2.8. Half-Precision Floating-Point</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>fp16</code> extension provides 16-bit half-precision scalar and vector
floating-point data types and extends many functions to accept these types.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_fp64"><a class="anchor" href="#cl_khr_fp64"></a>6.2.2.9. Double-Precision Floating-Point</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>fp64</code> extension was promoted to OpenCL C 1.2 as an optional
feature.
It provides double-precision scalar and vector floating-point data types and
extends many functions to accept these types.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_gl_msaa_sharing"><a class="anchor" href="#cl_khr_gl_msaa_sharing"></a>6.2.2.10. Multi-Sample Shared OpenCL/OpenGL Images</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension adds support for multi-sample images
shared with OpenGL multi-sample textures.
The extension provides new <a href="#table-other-builtin-types">built-in multisample
image types</a>, as well as <a href="#table-image-samplerless-read">sampler-less read
functions</a> and <a href="#table-image-query">image queries</a> operating on those
types.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_global_int32_base_atomics"><a class="anchor" href="#cl_khr_global_int32_base_atomics"></a>6.2.2.11. Global 32-Bit Base Atomics</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>global_<wbr>int32_<wbr>base_<wbr>atomics</code> extension was promoted to OpenCL C
1.1, with the supported functions renamed to use the <strong>atomic_</strong> prefix
rather than the <strong>atom_</strong> prefix.
The extension provides base atomic functions for __global variables, as
described in the <a href="#table-atomic-function-extensions">Atomic Function
Extensions</a> table.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_global_int32_extended_atomics"><a class="anchor" href="#cl_khr_global_int32_extended_atomics"></a>6.2.2.12. Global 32-Bit Extended Atomics</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>global_<wbr>int32_<wbr>extended_<wbr>atomics</code> extension was promoted to OpenCL
C 1.1, with the supported functions renamed to use the <strong>atomic_</strong> prefix
rather than the <strong>atom_</strong> prefix.
The extension provides extended atomic functions for __global variables, as
described in the <a href="#table-atomic-function-extensions">Atomic Function
Extensions</a> table.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_initialize_memory"><a class="anchor" href="#cl_khr_initialize_memory"></a>6.2.2.13. Initializing Memory</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>initialize_<wbr>memory</code> extension allows creating a context which
initializes specified types (local or private) of memory prior to the start
of kernel execution.</p>
</div>
<div class="paragraph">
<p>There is one <a href="#restrictions-initialize-memory">restriction</a> on the timing
of this initialization discussed in this document, although most of the
extension is defined by the OpenCL API Specification.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_int64_base_atomics"><a class="anchor" href="#cl_khr_int64_base_atomics"></a>6.2.2.14. 64-Bit Base Atomics</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>int64_<wbr>base_<wbr>atomics</code> extension provides base atomic functions for
__global and __local 64-bit signed and unsigned integer variables, as
described in the <a href="#table-atomic-int64-base">Built-in 64-Bit Base Atomic
Functions</a> table.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_int64_extended_atomics"><a class="anchor" href="#cl_khr_int64_extended_atomics"></a>6.2.2.15. 64-Bit Extended Atomics</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>int64_<wbr>extended_<wbr>atomics</code> extension provides extended atomic functions for
__global and __local 64-bit signed and unsigned integer variables, as
described in the <a href="#table-atomic-int64-extended">Built-in 64-Bit Extended Atomic
Functions</a> table.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_integer_dot_product"><a class="anchor" href="#cl_khr_integer_dot_product"></a>6.2.2.16. Integer Dot Product</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>integer_<wbr>dot_<wbr>product</code> extension was promoted to OpenCL C 3.1.
The extension adds support for OpenCL C built-in functions to compute the dot
product of vectors of integers, as described in the <a href="#table-builtin-functions">built-in vector integer argument functions</a> table.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_kernel_clock"><a class="anchor" href="#cl_khr_kernel_clock"></a>6.2.2.17. Kernel Clock</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>kernel_<wbr>clock</code> extension adds OpenCL C built-in functions to sample
the value from one of three clocks provided by compute units.
The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-kernel-clock-functions">Built-in Kernel Clock Functions</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_local_int32_base_atomics"><a class="anchor" href="#cl_khr_local_int32_base_atomics"></a>6.2.2.18. Local 32-Bit Base Atomics</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>local_<wbr>int32_<wbr>base_<wbr>atomics</code> extension was promoted to OpenCL C
1.1, with the supported functions renamed to use the <strong>atomic_</strong> prefix
rather than the <strong>atom_</strong> prefix.
The extension provides base atomic functions for __local variables, as
described in the <a href="#table-atomic-function-extensions">Atomic Function
Extensions</a> table.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_local_int32_extended_atomics"><a class="anchor" href="#cl_khr_local_int32_extended_atomics"></a>6.2.2.19. Local 32-Bit Extended Atomics</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>local_<wbr>int32_<wbr>extended_<wbr>atomics</code> extension was promoted to OpenCL
C 1.1, with the supported functions renamed to use the <strong>atomic_</strong> prefix
rather than the <strong>atom_</strong> prefix.
The extension provides extended atomic functions for __local variables, as
described in the <a href="#table-atomic-function-extensions">Atomic Function
Extensions</a> table.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_mipmap_image"><a class="anchor" href="#cl_khr_mipmap_image"></a>6.2.2.20. Mipmapped Image Reads and Queries</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>mipmap_<wbr>image</code> extension adds support for mipmap images.
The extension provides built-in <a href="#built-in-image-read-functions">image
read</a> and <a href="#built-in-image-query-functions">image query</a> functions
operating on these images.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_mipmap_image_writes"><a class="anchor" href="#cl_khr_mipmap_image_writes"></a>6.2.2.21. Mipmapped Image Writes</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>mipmap_<wbr>image_<wbr>writes</code> extension adds support for writing to
mipmap images, and requires support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.
The extension provides built-in <a href="#built-in-image-write-functions">image
write</a> functions operating on these images.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_select_fprounding_mode"><a class="anchor" href="#cl_khr_select_fprounding_mode"></a>6.2.2.22. Select Floating-Point Rounding Mode</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>select_<wbr>fprounding_<wbr>mode</code> extension allows <a href="#select-rounding-mode">specifying the floating-point rounding mode</a> for an instruction or group of
instructions in the program source by use of a <strong>#pragma</strong>.</p>
</div>
<div class="paragraph">
<p>The extension was deprecated in OpenCL 1.1 and its use is not recommended.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_srgb_image_writes"><a class="anchor" href="#cl_khr_srgb_image_writes"></a>6.2.2.23. sRGB Image Write Functions</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>srgb_<wbr>image_<wbr>writes</code> extension adds support for writing to sRGB
images using the <a href="#built-in-image-write-functions"><strong>write_imagef</strong></a>
functions. Color space conversion is performed by the function.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroups"><a class="anchor" href="#cl_khr_subgroups"></a>6.2.2.24. Sub-Groups</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroups</code> extension was promoted to OpenCL C 2.1 as the
<code>__opencl_c_<wbr>subgroups</code> feature.
The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-subgroup-work-item-functions">Built-in Work-Item Functions for
Sub-Groups</a></p>
</li>
<li>
<p><a href="#table-synchronization-functions">Built-in Synchronization Functions
for Sub-Groups</a></p>
</li>
<li>
<p><a href="#table-collective-functions">Built-in Collective Functions for
Sub-Groups</a></p>
</li>
<li>
<p><a href="#table-pipe-functions">Built-in Pipe Functions for Sub-Groups</a></p>
</li>
<li>
<p><a href="#table-kernel-query-functions">Built-in Kernel Query Functions for
Sub-Groups</a></p>
</li>
<li>
<p>The <a href="#table-memory-scopes"><code>memory_scope_sub_group</code></a> type and
<a href="#atomic-restrictions">associated restrictions</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroup_ballot"><a class="anchor" href="#cl_khr_subgroup_ballot"></a>6.2.2.25. Sub-Group Ballots</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroup_<wbr>ballot</code> extension adds the ability to collect and
operate on ballots from work items in a sub-group.
The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-ballot-functions">Built-in Ballot Functions for Sub-Groups</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroup_clustered_reduce"><a class="anchor" href="#cl_khr_subgroup_clustered_reduce"></a>6.2.2.26. Sub-Group Clustered Reductions</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroup_<wbr>clustered_<wbr>reduce</code> extension adds support for clustered
reductions that operate on a subset of work items in the sub-group.
The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-clustered-reduce-math-functions">Built-in Arithmetic Functions
for Sub-Groups</a></p>
</li>
<li>
<p><a href="#table-clustered-reduce-bitwise-functions">Built-in Bitwise Functions
for Sub-Groups</a></p>
</li>
<li>
<p><a href="#table-clustered-reduce-logical-functions">Built-in Logical Functions
for Sub-Groups</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroup_extended_types"><a class="anchor" href="#cl_khr_subgroup_extended_types"></a>6.2.2.27. Sub-Group Extended Types</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroup_<wbr>extended_<wbr>types</code> extension was promoted to OpenCL C 3.1.
The extension adds <a href="#sub-group-functions">additional supported data types</a> to
the existing <a href="#table-collective-functions">sub-group broadcast, scan, and
reduction functions</a>.</p>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroup_non_uniform_arithmetic"><a class="anchor" href="#cl_khr_subgroup_non_uniform_arithmetic"></a>6.2.2.28. Sub-Group Non-Uniform Arithmetic</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroup_<wbr>non_<wbr>uniform_<wbr>arithmetic</code> extension adds the ability to
use some sub-group functions within non-uniform flow control, including
additional scan and reduction operators.</p>
</div>
<div class="paragraph">
<p>The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-non-uniform-math-functions">Built-in Non-Uniform Arithmetic
Functions for Sub-Groups</a></p>
</li>
<li>
<p><a href="#table-non-uniform-bitwise-functions">Built-in Non-Uniform Bitwise
Functions for Sub-Groups</a></p>
</li>
<li>
<p><a href="#table-non-uniform-logical-functions">Built-in Non-Uniform Logical
Functions for Sub-Groups</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroup_non_uniform_vote"><a class="anchor" href="#cl_khr_subgroup_non_uniform_vote"></a>6.2.2.29. Sub-Group Non-Uniform Vote and Election Functions</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroup_<wbr>non_<wbr>uniform_<wbr>vote</code> extension adds the ability to elect a
single work item from a sub-group to perform a task and to hold votes among
work items in a sub-group.</p>
</div>
<div class="paragraph">
<p>The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-non-uniform-vote-functions">Built-in Non-Uniform Vote Functions
for Sub-Groups</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroup_rotate"><a class="anchor" href="#cl_khr_subgroup_rotate"></a>6.2.2.30. Sub-Group Rotation</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroup_<wbr>rotate</code> extension was promoted to OpenCL C 3.1.
The extension adds support for a new sub-group data exchange operation that
makes it possible to rotate values through the work items in a sub-group.</p>
</div>
<div class="paragraph">
<p>The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-rotate-functions">Built-in Rotation Functions for Sub-Groups</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroup_shuffle"><a class="anchor" href="#cl_khr_subgroup_shuffle"></a>6.2.2.31. Sub-Group General Purpose Shuffles</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroup_<wbr>shuffle</code> extension was promoted to OpenCL C 3.1.
The extension adds support for flexibly exchanging data among work items in a
sub-group.</p>
</div>
<div class="paragraph">
<p>The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-shuffle-functions">Built-in Shuffle Functions for Sub-Groups</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_subgroup_shuffle_relative"><a class="anchor" href="#cl_khr_subgroup_shuffle_relative"></a>6.2.2.32. Sub-Group Relative Shuffles</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>subgroup_<wbr>shuffle_<wbr>relative</code> was promoted to OpenCL C 3.1.
The extension adds specialized ways to exchange data among work items
in a sub-group that may perform better on some implementations.</p>
</div>
<div class="paragraph">
<p>The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-shuffle-relative-functions">Built-in Relative Shuffle Functions
for Sub-Groups</a></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="cl_khr_work_group_uniform_arithmetic"><a class="anchor" href="#cl_khr_work_group_uniform_arithmetic"></a>6.2.2.33. Work-group Collective Uniform Arithmetic Functions</h5>
<div class="paragraph">
<p>The <code>cl_khr_<wbr>work_<wbr>group_<wbr>uniform_<wbr>arithmetic</code> extension adds additional
work-group collective functions, including work-group scans and reductions
for the following operators:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Logical operations (<code>and</code>, <code>or</code>, and <code>xor</code>).</p>
</li>
<li>
<p>Bitwise operations (<code>and</code>, <code>or</code>, and <code>xor</code>).</p>
</li>
<li>
<p>Integer multiplication (<code>mul</code>).</p>
</li>
<li>
<p>Floating-point multiplication (<code>mul</code>).</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The extension provides the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#table-builtin-work-group-logical">Built-in Work-group Logical
Arithmetic Functions</a></p>
</li>
<li>
<p><a href="#table-builtin-work-group-bitwise-integer">Built-in Work-group Bitwise
Integer Functions</a></p>
</li>
<li>
<p><a href="#table-builtin-work-group-multiplicative">Built-in Work-group
Multiplicative Functions</a></p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="supported-data-types"><a class="anchor" href="#supported-data-types"></a>6.3. Supported Data Types</h3>
<div class="paragraph">
<p>The following data types are supported.</p>
</div>
<div class="sect3">
<h4 id="built-in-scalar-data-types"><a class="anchor" href="#built-in-scalar-data-types"></a>6.3.1. Built-in Scalar Data Types</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following table describes the list of built-in scalar data types.</p>
</div>
<table id="table-builtin-scalar-types" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 2. Built-in Scalar Data Types</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>bool</code> <sup class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A conditional data type which is either <em>true</em> or <em>false</em>.
The value <em>true</em> expands to the integer constant 1 and the value
<em>false</em> expands to the integer constant 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>char</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A signed two&#8217;s complement 8-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned char</code>, <code>uchar</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An unsigned 8-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>short</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A signed two&#8217;s complement 16-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned short</code>, <code>ushort</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An unsigned 16-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A signed two&#8217;s complement 32-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned int</code>, <code>uint</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An unsigned 32-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>long</code> <sup class="footnote" id="_footnote_long">[<a id="_footnoteref_2" class="footnote" href="#_footnotedef_2" title="View footnote.">2</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A signed two&#8217;s complement 64-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned long</code>, <code>ulong</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_2" title="View footnote.">2</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An unsigned 64-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>float</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 32-bit floating-point number.
The <code>float</code> data type must conform to the IEEE 754 single precision
storage format.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>double</code> <sup class="footnote">[<a id="_footnoteref_3" class="footnote" href="#_footnotedef_3" title="View footnote.">3</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 64-bit floating-point number.
The <code>double</code> data type must conform to the IEEE 754 double-precision
storage format.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for <a href="#double-precision-support">double-precision</a>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>half</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 16-bit floating-point number.
The <code>half</code> data type must conform to the IEEE 754-2008 half-precision
storage format.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>size_t</code> <sup class="footnote" id="_footnote_size_t">[<a id="_footnoteref_4" class="footnote" href="#_footnotedef_4" title="View footnote.">4</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The unsigned integer type of the result of the <code>sizeof</code> operator.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ptrdiff_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_4" title="View footnote.">4</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A signed integer type that is the result of subtracting two
pointers.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>intptr_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_4" title="View footnote.">4</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A signed integer type with the property that any valid pointer to
<code>void</code> can be converted to this type, then converted back to pointer
to <code>void</code>, and the result will compare equal to the original pointer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>uintptr_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_4" title="View footnote.">4</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An unsigned integer type with the property that any valid pointer
to <code>void</code> can be converted to this type, then converted back to
pointer to <code>void</code>, and the result will compare equal to the original
pointer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>void</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>void</code> type comprises an empty set of values; it is an incomplete
type that cannot be completed.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Most built-in scalar data types are also declared as appropriate types in
the OpenCL API (and header files) that can be used by an application.
The following table describes the built-in scalar data type in the OpenCL C
programming language and the corresponding data type available to the
application:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type in OpenCL Language</th>
<th class="tableblock halign-left valign-top">API type for application</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>bool</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">n/a</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>char</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_char</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned char</code>, <code>uchar</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_uchar</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>short</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_short</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned short</code>, <code>ushort</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_ushort</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_int</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned int</code>, <code>uint</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_uint</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>long</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_long</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned long</code>, <code>ulong</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_ulong</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>float</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_float</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>double</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_double</code> <sup class="footnote">[<a id="_footnoteref_5" class="footnote" href="#_footnotedef_5" title="View footnote.">5</a>]</sup></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>half</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_half</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>size_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">n/a</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ptrdiff_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">n/a</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>intptr_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">n/a</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>uintptr_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">n/a</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>void</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>void</code></p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect4">
<h5 id="double-precision-support"><a class="anchor" href="#double-precision-support"></a>6.3.1.1. Double-Precision Floating-Point Support</h5>
<div class="paragraph">
<p>Double-precision floating-point is supported if
the <code>cl_khr_<wbr>fp64</code> extension is supported, or if
OpenCL 3.0 or newer and the <code>__opencl_c_<wbr>fp64</code> feature is supported.</p>
</div>
<div class="paragraph">
<p>If double-precision is not supported, implementations may
implicitly cast double-precision floating-point literals to
single-precision literals. The use of double-precision literals without
double-precision support should result in a diagnostic.</p>
</div>
</div>
<div class="sect4">
<h5 id="the-half-data-type"><a class="anchor" href="#the-half-data-type"></a>6.3.1.2. The <code>half</code> Data Type</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>half</code> data type must be IEEE 754-2008 compliant.
<code>half</code> numbers have 1 sign bit, 5 exponent bits, and 10 mantissa bits.
The interpretation of the sign, exponent and mantissa is analogous to IEEE
754 floating-point numbers.
The exponent bias is 15.
The <code>half</code> data type must represent finite and normal numbers, denormalized
numbers, infinities and NaN.
Denormalized numbers for the <code>half</code> data type which may be generated when
converting a <code>float</code> to a <code>half</code> using <strong>vstore_half</strong> and converting a <code>half</code>
to a <code>float</code> using <strong>vload_half</strong> cannot be flushed to zero.
Conversions from <code>float</code> to <code>half</code> correctly round the mantissa to 11 bits
of precision.
Conversions from <code>half</code> to <code>float</code> are lossless; all <code>half</code> numbers are
exactly representable as <code>float</code> values.
Conversions from <code>double</code> to <code>half</code> are correctly rounded.
Conversions from <code>half</code> to <code>double</code> are lossless.</p>
</div>
<div class="paragraph">
<p>The <code>half</code> data type can only be used to declare a pointer to a buffer that
contains <code>half</code> values.
A few valid examples are given below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span>
<span class="nf">bar</span> <span class="p">(</span><span class="nx">__global</span> <span class="kt">half</span> <span class="o">*</span><span class="n">p</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="nx">__kernel</span> <span class="kt">void</span>
<span class="nf">foo</span> <span class="p">(</span><span class="nx">__global</span> <span class="kt">half</span> <span class="o">*</span><span class="n">pg</span><span class="p">,</span> <span class="nx">__local</span> <span class="kt">half</span> <span class="o">*</span><span class="n">pl</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">__global</span> <span class="kt">half</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">offset</span><span class="p">;</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="n">pg</span> <span class="o">+</span> <span class="n">offset</span><span class="p">;</span>
<span class="n">bar</span><span class="p">(</span><span class="n">ptr</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Below are some examples that are not valid usage of the <code>half</code> type:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">half</span> <span class="n">a</span><span class="p">;</span>
<span class="kt">half</span> <span class="n">b</span><span class="p">[</span><span class="mi">100</span><span class="p">];</span>
<span class="kt">half</span> <span class="o">*</span><span class="n">p</span><span class="p">;</span>
<span class="n">a</span> <span class="o">=</span> <span class="o">*</span><span class="n">p</span><span class="p">;</span> <span class="c1">// not allowed. must use *vload_half* function</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Loads from a pointer to a <code>half</code> and stores to a pointer to a <code>half</code> can be
performed using the <a href="#vector-data-load-and-store-functions">vector data load
and store functions</a> <strong>vload_half</strong>, <strong>vload_half<em>n</em></strong>, <strong>vloada_halfn</strong> and
<strong>vstore_half</strong>, <strong>vstore_half<em>n</em></strong>, and <strong>vstorea_halfn</strong>.
The load functions read scalar or vector <code>half</code> values from memory and
convert them to a scalar or vector <code>float</code> value.
The store functions take a scalar or vector <code>float</code> value as input, convert
it to a <code>half</code> scalar or vector value (with appropriate rounding mode) and
write the <code>half</code> scalar or vector value to memory.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="built-in-vector-data-types"><a class="anchor" href="#built-in-vector-data-types"></a>6.3.2. Built-in Vector Data Types</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>char</code>, <code>unsigned char</code>, <code>short</code>, <code>unsigned short</code>, <code>int</code>, <code>unsigned int</code>,
<code>long</code>, <code>unsigned long</code>, <code>float</code> and <code>double</code> vector data types are supported.
<sup class="footnote">[<a id="_footnoteref_6" class="footnote" href="#_footnotedef_6" title="View footnote.">6</a>]</sup>
The vector data type is defined with the type name, i.e. <code>char</code>, <code>uchar</code>,
<code>short</code>, <code>ushort</code>, <code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, or <code>double</code>
followed by a literal value <em>n</em> that defines the number of elements in the
vector.
Supported values of <em>n</em> are 2, 3, 4, 8, and 16 for all vector data types.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Vector types with three elements, i.e. where <em>n</em> is 3, <a href="#unified-spec">require</a> support for OpenCL C 1.1 or newer.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The following table describes the list of built-in vector data types.</p>
</div>
<table id="table-builtin-vector-types" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 3. Built-in Vector Data Types</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>char<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 8-bit signed two&#8217;s complement integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>uchar<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 8-bit unsigned integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>short<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 16-bit signed two&#8217;s complement integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ushort<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 16-bit unsigned integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 32-bit signed two&#8217;s complement integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>uint<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 32-bit unsigned integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>long<em>n</em></code> <sup class="footnote" id="_footnote_long-vec">[<a id="_footnoteref_7" class="footnote" href="#_footnotedef_7" title="View footnote.">7</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 64-bit signed two&#8217;s complement integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ulong<em>n</em></code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_7" title="View footnote.">7</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 64-bit unsigned integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>half<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_8" class="footnote" href="#_footnotedef_8" title="View footnote.">8</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 16-bit floating-point values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>float<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 32-bit floating-point values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>double<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_9" class="footnote" href="#_footnotedef_9" title="View footnote.">9</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A vector of <em>n</em> 64-bit floating-point values.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for <a href="#double-precision-support">double-precision</a>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The built-in vector data types are also declared as appropriate types in the
OpenCL API (and header files) that can be used by an application.
The following table describes the built-in vector data type in the OpenCL C
programming language and the corresponding data type available to the
application:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type in OpenCL Language</th>
<th class="tableblock halign-left valign-top">API type for application</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>char<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_char<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>uchar<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_uchar<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>short<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_short<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ushort<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_ushort<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>int<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_int<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>uint<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_uint<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>long<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_long<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ulong<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_ulong<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>half<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_half<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>float<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_float<em>n</em></code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>double<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_double<em>n</em></code></p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="other-built-in-data-types"><a class="anchor" href="#other-built-in-data-types"></a>6.3.3. Other Built-in Data Types</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following table describes the list of additional data types supported by
OpenCL.</p>
</div>
<table id="table-other-builtin-types" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 4. Other Built-in Data Types</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_t</code> <sup class="footnote" id="_footnote_image-functions">[<a id="_footnoteref_10" class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 2D image.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image3d_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 3D image.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_array_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 2D image array.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image1d_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 1D image.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image1d_buffer_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 1D image created from a buffer object.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image1d_array_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 1D image array.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_depth_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 2D depth image.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_array_depth_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 2D depth image array.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sampler_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_10" title="View footnote.">10</a>]</sup></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A sampler type.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>queue_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A device command-queue.
This queue can only be used to enqueue commands from kernels executing
on the device.</p>
<p class="tableblock"> <a href="#unifed-spec">Requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>device_<wbr>enqueue</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ndrange_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The N-dimensional range over which a kernel executes.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>device_<wbr>enqueue</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>clk_event_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A device-side event that identifies a command enqueued to
a device command-queue.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>device_<wbr>enqueue</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>reserve_id_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A reservation ID.
This opaque type is used to identify the reservation for
<a href="#pipe-functions">reading and writing a pipe</a>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>pipes</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>event_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An event.
This can be used to identify <a href="#async-copies">async copies</a> from
<code>global</code> to <code>local</code> memory and vice-versa.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem_fence_flags</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">This is a bitfield and can be 0 or a combination of the following
values ORed together:</p>
<p class="tableblock"> <code>CLK_GLOBAL_MEM_FENCE</code><br>
<code>CLK_LOCAL_MEM_FENCE</code><br>
<code>CLK_IMAGE_MEM_FENCE</code></p>
<p class="tableblock"> These flags are described in detail in the
<a href="#synchronization-functions">synchronization functions</a> section.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_msaa_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 2D multi-sample color image.
Refer to the <a href="#built-in-image-sampler-less-read-functions">Built-in
Image Sampler-less Read Functions</a> section for a detailed description
of the built-in functions that use this type.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_array_msaa_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 2D multi-sample color image array.
Refer to the <a href="#built-in-image-sampler-less-read-functions">Built-in
Image Sampler-less Read Functions</a> section for a detailed description
of the built-in functions that use this type.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_msaa_depth_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 2D multi-sample depth image.
Refer to the <a href="#built-in-image-sampler-less-read-functions">Built-in
Image Sampler-less Read Functions</a> section for a detailed description
of the built-in functions that use this type.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_array_msaa_depth_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 2D multi-sample depth image array.
Refer to the <a href="#built-in-image-sampler-less-read-functions">Built-in
Image Sampler-less Read Functions</a> section for a detailed description
of the built-in functions that use this type.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The <code>image2d_t</code>, <code>image3d_t</code>, <code>image2d_array_t</code>, <code>image1d_t</code>,
<code>image1d_buffer_t</code>, <code>image1d_array_t</code>, <code>image2d_depth_t</code>,
<code>image2d_array_depth_t</code> and <code>sampler_t</code> types are only defined if the device
supports images, i.e. the value of the <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>IMAGE_<wbr>SUPPORT</code> device query</a>) is <code>CL_TRUE</code>.
If this is the case then an OpenCL C 3.0 or newer compiler must also define
the <code>__opencl_c_<wbr>images</code> feature macro.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The C99 derived types (arrays, structs, unions, functions, and pointers),
constructed from the built-in <a href="#built-in-scalar-data-types">scalar</a>,
<a href="#built-in-vector-data-types">vector</a>, and
<a href="#other-built-in-data-types">other</a> data types are supported, with specified
<a href="#restrictions">restrictions</a>.</p>
</div>
<div class="paragraph">
<p>The following tables describe the other built-in data types in OpenCL described
in <a href="#table-other-builtin-types">Other Built-in Data Types</a> and the corresponding
data type available to the application:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type in OpenCL C</th>
<th class="tableblock halign-left valign-top">API type for application</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image3d_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_array_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image1d_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image1d_buffer_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image1d_array_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_depth_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>image2d_array_depth_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sampler_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_sampler</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>queue_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_command_queue</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ndrange_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">N/A</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>clk_event_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">N/A</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>reserve_id_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">N/A</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>event_t</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">N/A</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_mem_fence_flags</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">N/A</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="reserved-data-types"><a class="anchor" href="#reserved-data-types"></a>6.3.4. Reserved Data Types</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The data type names described in the following table are reserved and cannot
be used by applications as type names.
The vector data type names defined in <a href="#table-builtin-vector-types">Built-in
Vector Data Types</a>, but where <em>n</em> is any value other than 2, 3, 4, 8 and 16,
are also reserved.</p>
</div>
<table id="table-reserved-types" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 5. Reserved Data Types</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Type</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>bool<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A boolean vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>quad</code>, <code>quad<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 128-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>complex half</code>, <code>complex half<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A complex 16-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>imaginary half</code>, <code>imaginary half<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An imaginary 16-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>complex float</code>, <code>complex float<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A complex 32-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>imaginary float</code>, <code>imaginary float<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An imaginary 32-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>complex double</code>, <code>complex double<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A complex 64-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>imaginary double</code>, <code>imaginary double<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An imaginary 64-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>complex quad</code>, <code>complex quad<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A complex 128-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>imaginary quad</code>, <code>imaginary quad<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An imaginary 128-bit floating-point scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>float<em>n</em>x<em>m</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An <em>n</em> × <em>m</em> matrix of single precision floating-point values
stored in column-major order.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>double<em>n</em>x<em>m</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An <em>n</em> × <em>m</em> matrix of double-precision floating-point values
stored in column-major order.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>long double</code>, <code>long double<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A floating-point scalar and vector type with at least as much
precision and range as a <code>double</code> and no more precision and range than
a quad.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>long long, long long<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 128-bit signed integer scalar and vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>unsigned long long</code>,
<code>ulong long</code>,
<code>ulong long<em>n</em></code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A 128-bit unsigned integer scalar and vector.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="alignment-of-types"><a class="anchor" href="#alignment-of-types"></a>6.3.5. Alignment of Types</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>A data item declared to be a data type in memory is always aligned to the
size of the data type in bytes.
For example, a <code>float4</code> variable will be aligned to a 16-byte boundary, a
<code>char2</code> variable will be aligned to a 2-byte boundary.</p>
</div>
<div class="paragraph">
<p>For 3-component vector data types, the size of the data type is <code>4 *
sizeof(component)</code>.
This means that a 3-component vector data type will be aligned to a <code>4 *
sizeof(component)</code> boundary.
The <strong>vload3</strong> and <strong>vstore3</strong> built-in functions can be used to read and write,
respectively, 3-component vector data types from an array of packed scalar
data type.</p>
</div>
<div class="paragraph">
<p>A built-in data type that is not a power of two bytes in size must be
aligned to the next larger power of two.
This rule applies to built-in types only, not structs or unions.</p>
</div>
<div class="paragraph">
<p>The OpenCL compiler is responsible for aligning data items to the
appropriate alignment as required by the data type.
For arguments to a <code>__kernel</code> function declared to be a pointer to a data
type, the OpenCL compiler can assume that the pointee is always
appropriately aligned as required by the data type.
The behavior of an unaligned load or store is undefined, except for the
<a href="#vector-data-load-and-store-functions">vector data load and store
functions</a> <strong>vload<em>n</em></strong>, <strong>vload_half<em>n</em></strong>, <strong>vstore<em>n</em></strong>, and
<strong>vstore_half<em>n</em></strong>.
The vector load functions can read a vector from an address aligned to the
element type of the vector.
The vector store functions can write a vector to an address aligned to the
element type of the vector.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="vector-literals"><a class="anchor" href="#vector-literals"></a>6.3.6. Vector Literals</h4>
<div class="paragraph">
<p>Vector literals can be used to create vectors from a list of scalars,
vectors or a mixture thereof.
A vector literal can be used either as a vector initializer or as a primary
expression.
Whether a vector literal can be used as an l-value is implementation-defined.</p>
</div>
<div class="paragraph">
<p>A vector literal is written as a parenthesized vector type followed by a
parenthesized comma delimited list of parameters.
A vector literal operates as an overloaded function.
The forms of the function that are available is the set of possible argument
lists for which all arguments have the same element type as the result
vector, and the total number of elements is equal to the number of elements
in the result vector.
In addition, a form with a single scalar of the same type as the element
type of the vector is available.
For example, the following forms are available for <code>float4</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="p">(</span><span class="kt">float4</span><span class="p">)(</span> <span class="kt">float</span><span class="p">,</span> <span class="kt">float</span><span class="p">,</span> <span class="kt">float</span><span class="p">,</span> <span class="kt">float</span> <span class="p">)</span>
<span class="p">(</span><span class="kt">float4</span><span class="p">)(</span> <span class="kt">float2</span><span class="p">,</span> <span class="kt">float</span><span class="p">,</span> <span class="kt">float</span> <span class="p">)</span>
<span class="p">(</span><span class="kt">float4</span><span class="p">)(</span> <span class="kt">float</span><span class="p">,</span> <span class="kt">float2</span><span class="p">,</span> <span class="kt">float</span> <span class="p">)</span>
<span class="p">(</span><span class="kt">float4</span><span class="p">)(</span> <span class="kt">float</span><span class="p">,</span> <span class="kt">float</span><span class="p">,</span> <span class="kt">float2</span> <span class="p">)</span>
<span class="p">(</span><span class="kt">float4</span><span class="p">)(</span> <span class="kt">float2</span><span class="p">,</span> <span class="kt">float2</span> <span class="p">)</span>
<span class="p">(</span><span class="kt">float4</span><span class="p">)(</span> <span class="kt">float3</span><span class="p">,</span> <span class="kt">float</span> <span class="p">)</span>
<span class="p">(</span><span class="kt">float4</span><span class="p">)(</span> <span class="kt">float</span><span class="p">,</span> <span class="kt">float3</span> <span class="p">)</span>
<span class="p">(</span><span class="kt">float4</span><span class="p">)(</span> <span class="kt">float</span> <span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Operands are evaluated by standard rules for function evaluation, except
that implicit scalar widening shall not occur.
The order in which the operands are evaluated is undefined.
The operands are assigned to their respective positions in the result vector
as they appear in memory order.
That is, the first element of the first operand is assigned to <code>result.x</code>,
the second element of the first operand (or the first element of the second
operand if the first operand was a scalar) is assigned to <code>result.y</code>, etc.
In the case of the form that has a single scalar operand, the operand is
replicated across all lanes of the vector.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="kt">uint4</span> <span class="n">u</span> <span class="o">=</span> <span class="p">(</span><span class="kt">uint4</span><span class="p">)(</span><span class="mi">1</span><span class="p">);</span> <span class="c1">// u will be (1, 1, 1, 1).</span>
<span class="kt">float4</span> <span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)((</span><span class="kt">float2</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">),</span> <span class="p">(</span><span class="kt">float2</span><span class="p">)(</span><span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">));</span>
<span class="kt">float4</span> <span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="p">(</span><span class="kt">float2</span><span class="p">)(</span><span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">),</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">);</span> <span class="c1">// error</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="vector-components"><a class="anchor" href="#vector-components"></a>6.3.7. Vector Components</h4>
<div class="paragraph">
<p>The components of vector data types can be addressed as
<code>&lt;vector_data_type&gt;.xyzw</code>.
Vector data types with two or more components, such as <code>char2</code>, can access <code>.xy</code> elements.
Vector data types with three or more components, such as <code>uint3</code>, can access <code>.xyz</code> elements.
Vector data types with four or more components, such as <code>ulong4</code> or <code>float8</code>, can access <code>.xyzw</code> elements.</p>
</div>
<div class="paragraph">
<p>In OpenCL C 3.0 or newer, the components of vector data types can also be
addressed as <code>&lt;vector_data_type&gt;.rgba</code>.
Vector data types with two or more components can access <code>.rg</code> elements.
Vector data types with three or more components can access <code>.rgb</code> elements.
Vector data types with four or more components can access <code>.rgba</code> elements.</p>
</div>
<div class="paragraph">
<p>Accessing components beyond those declared for the vector type is an error
so, for example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float2</span> <span class="n">coord</span><span class="p">;</span>
<span class="n">coord</span><span class="p">.</span><span class="n">x</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span> <span class="c1">// is legal</span>
<span class="n">coord</span><span class="p">.</span><span class="n">r</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span> <span class="c1">// is legal in OpenCL C 3.0 or newer</span>
<span class="n">coord</span><span class="p">.</span><span class="n">z</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span> <span class="c1">// is illegal, since coord only has two components</span>
<span class="kt">float3</span> <span class="n">pos</span><span class="p">;</span>
<span class="n">pos</span><span class="p">.</span><span class="n">z</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span> <span class="c1">// is legal</span>
<span class="n">pos</span><span class="p">.</span><span class="n">b</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span> <span class="c1">// is legal in OpenCL C 3.0 or newer</span>
<span class="n">pos</span><span class="p">.</span><span class="n">w</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span> <span class="c1">// is illegal, since pos only has three components</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The component selection syntax allows multiple components to be selected by
appending their names after the period (<strong>.</strong>).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">c</span><span class="p">;</span>
<span class="n">c</span><span class="p">.</span><span class="n">xyzw</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="n">c</span><span class="p">.</span><span class="n">z</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span>
<span class="n">c</span><span class="p">.</span><span class="n">xy</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float2</span><span class="p">)(</span><span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="n">c</span><span class="p">.</span><span class="n">xyz</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float3</span><span class="p">)(</span><span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">,</span> <span class="mf">5.0f</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The component selection syntax also allows components to be permuted or
replicated.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">pos</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">swiz</span><span class="o">=</span> <span class="n">pos</span><span class="p">.</span><span class="n">wzyx</span><span class="p">;</span> <span class="c1">// swiz = (4.0f, 3.0f, 2.0f, 1.0f)</span>
<span class="kt">float4</span> <span class="n">dup</span> <span class="o">=</span> <span class="n">pos</span><span class="p">.</span><span class="n">xxyy</span><span class="p">;</span> <span class="c1">// dup = (1.0f, 1.0f, 2.0f, 2.0f)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The component group notation can occur on the left hand side of an
expression.
To form an l-value, swizzling must be applied to an l-value of vector type,
contain no duplicate components, and it results in an l-value of scalar or
vector type, depending on number of components specified.
Each component must be a supported scalar or vector type.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">pos</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="n">pos</span><span class="p">.</span><span class="n">xw</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float2</span><span class="p">)(</span><span class="mf">5.0f</span><span class="p">,</span> <span class="mf">6.0f</span><span class="p">);</span><span class="c1">// pos = (5.0f, 2.0f, 3.0f, 6.0f)</span>
<span class="n">pos</span><span class="p">.</span><span class="n">wx</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float2</span><span class="p">)(</span><span class="mf">7.0f</span><span class="p">,</span> <span class="mf">8.0f</span><span class="p">);</span><span class="c1">// pos = (8.0f, 2.0f, 3.0f, 7.0f)</span>
<span class="n">pos</span><span class="p">.</span><span class="n">xyz</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float3</span><span class="p">)(</span><span class="mf">3.0f</span><span class="p">,</span> <span class="mf">5.0f</span><span class="p">,</span> <span class="mf">9.0f</span><span class="p">);</span> <span class="c1">// pos = (3.0f, 5.0f, 9.0f, 4.0f)</span>
<span class="n">pos</span><span class="p">.</span><span class="n">xx</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float2</span><span class="p">)(</span><span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span><span class="c1">// illegal - 'x' used twice</span>
<span class="c1">// illegal - mismatch between float2 and float4</span>
<span class="n">pos</span><span class="p">.</span><span class="n">xy</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">d</span><span class="p">;</span>
<span class="kt">float16</span> <span class="n">x</span><span class="p">;</span>
<span class="n">x</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float16</span><span class="p">)(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">d</span><span class="p">);</span>
<span class="n">x</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float16</span><span class="p">)(</span><span class="n">a</span><span class="p">.</span><span class="n">xxxx</span><span class="p">,</span> <span class="n">b</span><span class="p">.</span><span class="n">xyz</span><span class="p">,</span> <span class="n">c</span><span class="p">.</span><span class="n">xyz</span><span class="p">,</span> <span class="n">d</span><span class="p">.</span><span class="n">xyz</span><span class="p">,</span> <span class="n">a</span><span class="p">.</span><span class="n">yzw</span><span class="p">);</span>
<span class="c1">// illegal - component a.xxxxxxx is not a valid vector type</span>
<span class="n">x</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float16</span><span class="p">)(</span><span class="n">a</span><span class="p">.</span><span class="n">xxxxxxx</span><span class="p">,</span> <span class="n">b</span><span class="p">.</span><span class="n">xyz</span><span class="p">,</span> <span class="n">c</span><span class="p">.</span><span class="n">xyz</span><span class="p">,</span> <span class="n">d</span><span class="p">.</span><span class="n">xyz</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Elements of vector data types can also be accessed using a numeric index to
refer to the appropriate element in the vector.
The numeric indices that can be used are given in the table below:</p>
</div>
<table id="table-vector-indices" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 6. Numeric indices for built-in vector data types</caption>
<colgroup>
<col style="width: 34%;">
<col style="width: 66%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Vector Components</th>
<th class="tableblock halign-left valign-top">Numeric indices that can be used</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2-component</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0, 1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3-component</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0, 1, 2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">4-component</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0, 1, 2, 3</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">8-component</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0, 1, 2, 3, 4, 5, 6, 7</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">16-component</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
a, A, b, B, c, C, d, D, e, E, f, F</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The numeric indices must be preceded by the letter <code>s</code> or <code>S</code>.</p>
</div>
<div class="paragraph">
<p>In the following example</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float8</span> <span class="n">f</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>f.s0</code> refers to the 1<sup>st</sup> element of the <code>float8</code> variable <code>f</code> and <code>f.s7</code>
refers to the 8<sup>th</sup> element of the <code>float8</code> variable <code>f</code>.</p>
</div>
<div class="paragraph">
<p>In the following example</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float16</span> <span class="n">x</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>x.sa</code> (or <code>x.sA</code>) refers to the 11<sup>th</sup> element of the <code>float16</code> variable
<code>x</code> and <code>x.sf</code> (or <code>x.sF</code>) refers to the 16<sup>th</sup> element of the <code>float16</code>
variable <code>x</code>.</p>
</div>
<div class="paragraph">
<p>The numeric indices used to refer to an appropriate element in the vector
cannot be intermixed with <code>.xyzw</code> notation used to access elements of a 1 ..
4 component vector.</p>
</div>
<div class="paragraph">
<p>For example</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">f</span><span class="p">,</span> <span class="n">a</span><span class="p">;</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">f</span><span class="p">.</span><span class="n">x12w</span><span class="p">;</span> <span class="c1">// illegal use of numeric indices with .xyzw</span>
<span class="n">a</span><span class="p">.</span><span class="n">xyzw</span> <span class="o">=</span> <span class="n">f</span><span class="p">.</span><span class="n">s0123</span><span class="p">;</span> <span class="c1">// valid</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Vector data types can use the <code>.lo</code> (or <code>.even</code>) and <code>.hi</code> (or <code>.odd</code>)
suffixes to get smaller vector types or to combine smaller vector types to a
larger vector type.
Multiple levels of <code>.lo</code> (or <code>.even</code>) and <code>.hi</code> (or <code>.odd</code>) suffixes can be
used until they refer to a scalar term.</p>
</div>
<div class="paragraph">
<p>The <code>.lo</code> suffix refers to the lower half of a given vector.
The <code>.hi</code> suffix refers to the upper half of a given vector.</p>
</div>
<div class="paragraph">
<p>The <code>.even</code> suffix refers to the even elements of a vector.
The <code>.odd</code> suffix refers to the odd elements of a vector.</p>
</div>
<div class="paragraph">
<p>Some examples to help illustrate this are given below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">vf</span><span class="p">;</span>
<span class="kt">float2</span> <span class="n">low</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">lo</span><span class="p">;</span> <span class="c1">// returns vf.xy</span>
<span class="kt">float2</span> <span class="n">high</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">hi</span><span class="p">;</span> <span class="c1">// returns vf.zw</span>
<span class="kt">float2</span> <span class="n">even</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">even</span><span class="p">;</span> <span class="c1">// returns vf.xz</span>
<span class="kt">float2</span> <span class="n">odd</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">odd</span><span class="p">;</span> <span class="c1">// returns vf.yw</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The suffixes <code>.lo</code> (or <code>.even</code>) and <code>.hi</code> (or <code>.odd</code>) for a 3-component
vector type operate as if the 3-component vector type is a 4-component
vector type with the value in the <code>w</code> component undefined.</p>
</div>
<div class="paragraph">
<p>Some examples are given below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float8</span> <span class="n">vf</span><span class="p">;</span>
<span class="kt">float4</span> <span class="n">odd</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">odd</span><span class="p">;</span>
<span class="kt">float4</span> <span class="n">even</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">even</span><span class="p">;</span>
<span class="kt">float2</span> <span class="n">high</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">even</span><span class="p">.</span><span class="n">hi</span><span class="p">;</span>
<span class="kt">float2</span> <span class="n">low</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">odd</span><span class="p">.</span><span class="n">lo</span><span class="p">;</span>
<span class="c1">// interleave LR stereo stream</span>
<span class="kt">float4</span> <span class="n">left</span><span class="p">,</span> <span class="n">right</span><span class="p">;</span>
<span class="kt">float8</span> <span class="n">interleaved</span><span class="p">;</span>
<span class="n">interleaved</span><span class="p">.</span><span class="n">even</span> <span class="o">=</span> <span class="n">left</span><span class="p">;</span>
<span class="n">interleaved</span><span class="p">.</span><span class="n">odd</span> <span class="o">=</span> <span class="n">right</span><span class="p">;</span>
<span class="c1">// deinterleave</span>
<span class="n">left</span> <span class="o">=</span> <span class="n">interleaved</span><span class="p">.</span><span class="n">even</span><span class="p">;</span>
<span class="n">right</span> <span class="o">=</span> <span class="n">interleaved</span><span class="p">.</span><span class="n">odd</span><span class="p">;</span>
<span class="c1">// transpose a 4x4 matrix</span>
<span class="kt">void</span> <span class="nf">transpose</span><span class="p">(</span> <span class="kt">float4</span> <span class="n">m</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="p">)</span>
<span class="p">{</span>
<span class="c1">// read matrix into a float16 vector</span>
<span class="kt">float16</span> <span class="n">x</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float16</span><span class="p">)(</span> <span class="n">m</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">m</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">m</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">m</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="p">);</span>
<span class="kt">float16</span> <span class="n">t</span><span class="p">;</span>
<span class="c1">// transpose</span>
<span class="n">t</span><span class="p">.</span><span class="n">even</span> <span class="o">=</span> <span class="n">x</span><span class="p">.</span><span class="n">lo</span><span class="p">;</span>
<span class="n">t</span><span class="p">.</span><span class="n">odd</span> <span class="o">=</span> <span class="n">x</span><span class="p">.</span><span class="n">hi</span><span class="p">;</span>
<span class="n">x</span><span class="p">.</span><span class="n">even</span> <span class="o">=</span> <span class="n">t</span><span class="p">.</span><span class="n">lo</span><span class="p">;</span>
<span class="n">x</span><span class="p">.</span><span class="n">odd</span> <span class="o">=</span> <span class="n">t</span><span class="p">.</span><span class="n">hi</span><span class="p">;</span>
<span class="c1">// write back</span>
<span class="n">m</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span><span class="p">.</span><span class="n">lo</span><span class="p">.</span><span class="n">lo</span><span class="p">;</span> <span class="c1">// { m[0][0], m[1][0], m[2][0], m[3][0] }</span>
<span class="n">m</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span><span class="p">.</span><span class="n">lo</span><span class="p">.</span><span class="n">hi</span><span class="p">;</span> <span class="c1">// { m[0][1], m[1][1], m[2][1], m[3][1] }</span>
<span class="n">m</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span><span class="p">.</span><span class="n">hi</span><span class="p">.</span><span class="n">lo</span><span class="p">;</span> <span class="c1">// { m[0][2], m[1][2], m[2][2], m[3][2] }</span>
<span class="n">m</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span><span class="p">.</span><span class="n">hi</span><span class="p">.</span><span class="n">hi</span><span class="p">;</span> <span class="c1">// { m[0][3], m[1][3], m[2][3], m[3][3] }</span>
<span class="p">}</span>
<span class="kt">float3</span> <span class="n">vf</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float3</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">);</span>
<span class="kt">float2</span> <span class="n">low</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">lo</span><span class="p">;</span> <span class="c1">// (1.0f, 2.0f);</span>
<span class="kt">float2</span> <span class="n">high</span> <span class="o">=</span> <span class="n">vf</span><span class="p">.</span><span class="n">hi</span><span class="p">;</span> <span class="c1">// (3.0f, _undefined_);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>It is illegal to take the address of a vector element and will result in a
compilation error.
For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float8</span> <span class="n">vf</span><span class="p">;</span>
<span class="kt">float</span> <span class="o">*</span><span class="n">f</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">vf</span><span class="p">.</span><span class="n">x</span><span class="p">;</span> <span class="c1">// is illegal</span>
<span class="kt">float2</span> <span class="o">*</span><span class="n">f2</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">vf</span><span class="p">.</span><span class="n">s07</span><span class="p">;</span> <span class="c1">// is illegal</span>
<span class="kt">float4</span> <span class="o">*</span><span class="n">odd</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">vf</span><span class="p">.</span><span class="n">odd</span><span class="p">;</span> <span class="c1">// is illegal</span>
<span class="kt">float4</span> <span class="o">*</span><span class="n">even</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">vf</span><span class="p">.</span><span class="n">even</span><span class="p">;</span> <span class="c1">// is illegal</span>
<span class="kt">float2</span> <span class="o">*</span><span class="n">high</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">vf</span><span class="p">.</span><span class="n">even</span><span class="p">.</span><span class="n">hi</span><span class="p">;</span> <span class="c1">// is illegal</span>
<span class="kt">float2</span> <span class="o">*</span><span class="n">low</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">vf</span><span class="p">.</span><span class="n">odd</span><span class="p">.</span><span class="n">lo</span><span class="p">;</span> <span class="c1">// is illegal</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="aliasing-rules"><a class="anchor" href="#aliasing-rules"></a>6.3.8. Aliasing Rules</h4>
<div class="paragraph">
<p>OpenCL C programs shall comply with the C99 type-based aliasing rules
defined in <a href="#C99-spec">section 6.5, item 7 of the C99 Specification</a>.
The OpenCL C built-in vector data types are considered aggregate types
<sup class="footnote">[<a id="_footnoteref_11" class="footnote" href="#_footnotedef_11" title="View footnote.">11</a>]</sup> for the purpose of applying these
aliasing rules.</p>
</div>
</div>
<div class="sect3">
<h4 id="keywords"><a class="anchor" href="#keywords"></a>6.3.9. Keywords</h4>
<div class="paragraph">
<p>The following names are reserved for use as keywords in OpenCL C and shall
not be used otherwise.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Names reserved as keywords by C99.</p>
</li>
<li>
<p>OpenCL C data types defined in <a href="#table-builtin-vector-types">Built-in Vector
Data Types</a>,
<a href="#table-other-builtin-types">Other Built-in Data Types</a>, and
<a href="#table-reserved-types">Reserved Data Types</a>.</p>
</li>
<li>
<p>Address space qualifiers: <code>__global</code>, <code>global</code>, <code>__local</code>, <code>local</code>,
<code>__constant</code>, <code>constant</code>, <code>__private</code>, and <code>private</code>.
<code>__generic</code> and <code>generic</code> are reserved for future use.</p>
</li>
<li>
<p>Function qualifiers: <code>__kernel</code> and <code>kernel</code>.</p>
</li>
<li>
<p>Access qualifiers: <code>__read_only</code>, <code>read_only</code>, <code>__write_only</code>,
<code>write_only</code>, <code>__read_write</code> and <code>read_write</code>.</p>
</li>
<li>
<p><code>uniform</code>, <code>pipe</code>.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect2">
<h3 id="conversions-and-type-casting"><a class="anchor" href="#conversions-and-type-casting"></a>6.4. Conversions and Type Casting</h3>
<div class="sect3">
<h4 id="implicit-conversions"><a class="anchor" href="#implicit-conversions"></a>6.4.1. Implicit Conversions</h4>
<div class="paragraph">
<p>Implicit conversions between scalar built-in types defined in
<a href="#table-builtin-scalar-types">Built-in Scalar Data Types</a> (except <code>void</code> and
<code>half</code> <sup class="footnote">[<a id="_footnoteref_12" class="footnote" href="#_footnotedef_12" title="View footnote.">12</a>]</sup>) are supported.
When an implicit conversion is done, it is not just a re-interpretation of
the expression&#8217;s value but a conversion of that value to an equivalent value
in the new type.
For example, the integer value 5 will be converted to the floating-point
value 5.0.</p>
</div>
<div class="paragraph">
<p>Implicit conversions from a scalar type to a vector type are allowed.
In this case, the scalar may be subject to the usual arithmetic conversion
to the element type used by the vector.
The scalar type is then widened to the vector.</p>
</div>
<div class="paragraph">
<p>Implicit conversions between built-in vector data types are disallowed.</p>
</div>
<div class="paragraph">
<p>Implicit conversions for pointer types follow the rules described in the
<a href="#C99-spec">C99 Specification</a>.</p>
</div>
</div>
<div class="sect3">
<h4 id="explicit-casts"><a class="anchor" href="#explicit-casts"></a>6.4.2. Explicit Casts</h4>
<div class="paragraph">
<p>Standard typecasts for built-in scalar data types defined in
<a href="#table-builtin-scalar-types">Built-in Scalar Data Types</a> will perform
appropriate conversion (except <code>void</code> and <code>half</code> <sup class="footnote">[<a id="_footnoteref_13" class="footnote" href="#_footnotedef_13" title="View footnote.">13</a>]</sup>).
In the example below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float</span> <span class="n">f</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">f</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>f</code> stores <code>0x3F800000</code> and <code>i</code> stores <code>0x1</code> which is the floating-point
value <code>1.0f</code> in <code>f</code> converted to an integer value.</p>
</div>
<div class="paragraph">
<p>Explicit casts between vector types are not legal.
The examples below will generate a compilation error.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int4</span> <span class="n">i</span><span class="p">;</span>
<span class="kt">uint4</span> <span class="n">u</span> <span class="o">=</span> <span class="p">(</span><span class="kt">uint4</span><span class="p">)</span> <span class="n">i</span><span class="p">;</span> <span class="c1">// not allowed</span>
<span class="kt">float4</span> <span class="n">f</span><span class="p">;</span>
<span class="kt">int4</span> <span class="n">i</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int4</span><span class="p">)</span> <span class="n">f</span><span class="p">;</span> <span class="c1">// not allowed</span>
<span class="kt">float4</span> <span class="n">f</span><span class="p">;</span>
<span class="kt">int8</span> <span class="n">i</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int8</span><span class="p">)</span> <span class="n">f</span><span class="p">;</span> <span class="c1">// not allowed</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Scalar to vector conversions may be performed by casting the scalar to the
desired vector data type.
Type casting will also perform appropriate arithmetic conversion.
The round to zero rounding mode will be used for conversions to built-in
integer vector types.
The default rounding mode will be used for conversions to floating-point
vector types.
When casting a <code>bool</code> to a vector integer data type, the vector components
will be set to -1 (i.e. all bits set) if the bool value is <em>true</em> and 0
otherwise.</p>
</div>
<div class="paragraph">
<p>Below are some correct examples of explicit casts.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float</span> <span class="n">f</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span>
<span class="kt">float4</span> <span class="n">va</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)</span><span class="n">f</span><span class="p">;</span>
<span class="c1">// va is a float4 vector with elements (f, f, f, f).</span>
<span class="kt">uchar</span> <span class="n">u</span> <span class="o">=</span> <span class="mh">0xFF</span><span class="p">;</span>
<span class="kt">float4</span> <span class="n">vb</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)</span><span class="n">u</span><span class="p">;</span>
<span class="c1">// vb is a float4 vector with elements</span>
<span class="c1">// ((float)u, (float)u, (float)u, (float)u).</span>
<span class="kt">float</span> <span class="n">f</span> <span class="o">=</span> <span class="mf">2.0f</span><span class="p">;</span>
<span class="kt">int2</span> <span class="n">vc</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int2</span><span class="p">)</span><span class="n">f</span><span class="p">;</span>
<span class="c1">// vc is an int2 vector with elements ((int)f, (int)f).</span>
<span class="kt">uchar4</span> <span class="n">vtrue</span> <span class="o">=</span> <span class="p">(</span><span class="kt">uchar4</span><span class="p">)</span><span class="nb">true</span><span class="p">;</span>
<span class="c1">// vtrue is a uchar4 vector with elements (0xff, 0xff,</span>
<span class="c1">// 0xff, 0xff).</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="explicit-conversions"><a class="anchor" href="#explicit-conversions"></a>6.4.3. Explicit Conversions</h4>
<div class="paragraph">
<p>Explicit conversions may be performed using the</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">convert_destType</span><span class="p">(</span><span class="n">sourceType</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>suite of functions.
These provide a full set of type conversions between supported
<a href="#built-in-scalar-data-types">scalar</a> and
<a href="#built-in-vector-data-types">vector</a> data types:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>char</code>, <code>char<em>n</em></code>, <code>uchar</code>, <code>uchar<em>n</em></code></p>
</li>
<li>
<p><code>short</code>, <code>short<em>n</em></code>, <code>ushort</code>, <code>ushort<em>n</em></code></p>
</li>
<li>
<p><code>int</code>, <code>int<em>n</em></code>, <code>uint</code>, <code>uint<em>n</em></code></p>
</li>
<li>
<p><code>long</code> <sup class="footnote">[<a id="_footnoteref_14" class="footnote" href="#_footnotedef_14" title="View footnote.">14</a>]</sup>, <code>long<em>n</em></code>, <code>ulong</code>, <code>ulong<em>n</em></code></p>
</li>
<li>
<p><code>float</code>, <code>float<em>n</em></code></p>
</li>
<li>
<p><code>half</code> <sup class="footnote">[<a id="_footnoteref_15" class="footnote" href="#_footnotedef_15" title="View footnote.">15</a>]</sup>, <code>half<em>n</em></code></p>
</li>
<li>
<p><code>double</code> <sup class="footnote">[<a id="_footnoteref_16" class="footnote" href="#_footnotedef_16" title="View footnote.">16</a>]</sup>, <code>double<em>n</em></code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The number of elements in the source and destination vectors must match.</p>
</div>
<div class="paragraph">
<p>In the example below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uchar4</span> <span class="n">u</span><span class="p">;</span>
<span class="kt">int4</span> <span class="n">c</span> <span class="o">=</span> <span class="fm">convert_int4</span><span class="p">(</span><span class="n">u</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>convert_int4</code> converts a <code>uchar4</code> vector <code>u</code> to an <code>int4</code> vector <code>c</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float</span> <span class="n">f</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="n">convert_int</span><span class="p">(</span><span class="n">f</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>convert_int</code> converts a <code>float</code> scalar <code>f</code> to an int scalar <code>i</code>.</p>
</div>
<div class="paragraph">
<p>The behavior of the conversion may be modified by one or two optional
modifiers that specify saturation for out-of-range inputs and rounding
behavior.</p>
</div>
<div class="paragraph">
<p>The full form of the scalar convert function is:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">destType</span> <span class="n">convert_destType</span><span class="o">&lt;</span><span class="n">_sat</span><span class="o">&gt;&lt;</span><span class="n">_roundingMode</span><span class="o">&gt;</span><span class="p">(</span><span class="n">sourceType</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>dstType</code> is the destination scalar type and <code>sourceType</code> is the source scalar type.</p>
</div>
<div class="paragraph">
<p>The full form of the vector convert function is:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">destTypen</span> <span class="n">convert_destTypen</span><span class="o">&lt;</span><span class="n">_sat</span><span class="o">&gt;&lt;</span><span class="n">_roundingMode</span><span class="o">&gt;</span><span class="p">(</span><span class="n">sourceTypen</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>destTypen</code> is the n-element destination vector type and <code>sourceTypen</code> is the n-element source vector type.</p>
</div>
<div class="sect4">
<h5 id="data-types"><a class="anchor" href="#data-types"></a>6.4.3.1. Data Types</h5>
<div class="paragraph">
<p>Conversions are available for the following scalar types: <code>char</code>, <code>uchar</code>,
<code>short</code>, <code>ushort</code>, <code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, and built-in
vector types derived therefrom.
The operand and result type must have the same number of elements.
The operand and result type may be the same type in which case the
conversion has no effect on the type or value of an expression.</p>
</div>
<div class="paragraph">
<p>Conversions between integer types follow the conversion rules specified in
<a href="#C99-spec">sections 6.3.1.1 and 6.3.1.3 of the C99 Specification</a> except
for <a href="#out-of-range-behavior">out-of-range behavior and saturated
conversions</a>.</p>
</div>
</div>
<div class="sect4">
<h5 id="rounding-modes"><a class="anchor" href="#rounding-modes"></a>6.4.3.2. Rounding Modes</h5>
<div class="paragraph">
<p>Conversions to and from floating-point type shall conform to IEEE-754
rounding rules.
Conversions may have an optional rounding mode modifier described in the
following table.</p>
</div>
<table id="table-rounding-mode" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 7. Rounding Modes</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Modifier</th>
<th class="tableblock halign-left valign-top">Rounding Mode Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>_rte</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round to nearest even</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>_rtz</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round toward zero</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>_rtp</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round toward positive infinity</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>_rtn</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round toward negative infinity</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">no modifier specified</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the default rounding mode for this destination
type, <code>_rtz</code> for conversion to integers or the
default rounding mode for conversion to
floating-point types.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>By default, conversions to integer type use the <code>_rtz</code> (round toward zero)
rounding mode and conversions to floating-point type
<sup class="footnote">[<a id="_footnoteref_17" class="footnote" href="#_footnotedef_17" title="View footnote.">17</a>]</sup> use the default rounding mode.
The only default floating-point rounding mode supported is round to nearest
even i.e the default rounding mode will be <code>_rte</code> for floating-point types.</p>
</div>
</div>
<div class="sect4">
<h5 id="out-of-range-behavior"><a class="anchor" href="#out-of-range-behavior"></a>6.4.3.3. Out-of-Range Behavior and Saturated Conversions</h5>
<div class="paragraph">
<p>When the conversion operand is either greater than the greatest
representable destination value or less than the least representable
destination value, it is said to be out-of-range.
The result of out-of-range conversion is determined by the conversion rules
specified by <a href="#C99-spec">section 6.3 of the C99 Specification</a>.
When converting from a floating-point type to integer type, the behavior is
implementation-defined.</p>
</div>
<div class="paragraph">
<p>Conversions to integer types may opt to convert using the optional saturated
mode by appending the <code>_sat</code> modifier to the conversion function name.
When in saturated mode, values that are outside the representable range
are clamped to the nearest representable value in the destination format,
and NaN is converted to zero.</p>
</div>
<div class="paragraph">
<p>Conversions to floating-point types conform to IEEE-754 rounding rules.
The <code>_sat</code> modifier may not be used for conversions to floating-point
formats.</p>
</div>
</div>
<div class="sect4">
<h5 id="explicit-conversion-examples"><a class="anchor" href="#explicit-conversion-examples"></a>6.4.3.4. Explicit Conversion Examples</h5>
<div class="paragraph">
<p>Example 1:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">short4</span> <span class="n">s</span><span class="p">;</span>
<span class="c1">// negative values clamped to zero</span>
<span class="kt">ushort4</span> <span class="n">u</span> <span class="o">=</span> <span class="fm">convert_ushort4_sat</span><span class="p">(</span> <span class="n">s</span> <span class="p">);</span>
<span class="c1">// values &gt; CHAR_MAX converted to CHAR_MAX</span>
<span class="c1">// values &lt; CHAR_MIN converted to CHAR_MIN</span>
<span class="kt">char4</span> <span class="n">c</span> <span class="o">=</span> <span class="fm">convert_char4_sat</span><span class="p">(</span> <span class="n">s</span> <span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Example 2:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">f</span><span class="p">;</span>
<span class="c1">// values implementation-defined for</span>
<span class="c1">// f &gt; INT_MAX, f &lt; INT_MIN or NaN</span>
<span class="kt">int4</span> <span class="n">i</span> <span class="o">=</span> <span class="fm">convert_int4</span><span class="p">(</span> <span class="n">f</span> <span class="p">);</span>
<span class="c1">// values &gt; INT_MAX clamp to INT_MAX, values &lt; INT_MIN clamp</span>
<span class="c1">// to INT_MIN, and NaN is converted to zero</span>
<span class="c1">// The _rtz_ rounding mode is used to produce the integer values.</span>
<span class="kt">int4</span> <span class="n">i2</span> <span class="o">=</span> <span class="fm">convert_int4_sat</span><span class="p">(</span> <span class="n">f</span> <span class="p">);</span>
<span class="c1">// similar to convert_int4, except that floating-point values</span>
<span class="c1">// are rounded to the nearest integer instead of truncated</span>
<span class="kt">int4</span> <span class="n">i3</span> <span class="o">=</span> <span class="fm">convert_int4_rte</span><span class="p">(</span> <span class="n">f</span> <span class="p">);</span>
<span class="c1">// similar to convert_int4_sat, except that floating-point values</span>
<span class="c1">// are rounded to the nearest integer instead of truncated</span>
<span class="kt">int4</span> <span class="n">i4</span> <span class="o">=</span> <span class="fm">convert_int4_sat_rte</span><span class="p">(</span> <span class="n">f</span> <span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Example 3:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int4</span> <span class="n">i</span><span class="p">;</span>
<span class="c1">// convert ints to floats using the default rounding mode.</span>
<span class="kt">float4</span> <span class="n">f</span> <span class="o">=</span> <span class="fm">convert_float4</span><span class="p">(</span> <span class="n">i</span> <span class="p">);</span>
<span class="c1">// convert ints to floats. integer values that cannot</span>
<span class="c1">// be exactly represented as floats should round up to the</span>
<span class="c1">// next representable float.</span>
<span class="kt">float4</span> <span class="n">f</span> <span class="o">=</span> <span class="fm">convert_float4_rtp</span><span class="p">(</span> <span class="n">i</span> <span class="p">);</span></code></pre>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="reinterpreting-data-as-another-type"><a class="anchor" href="#reinterpreting-data-as-another-type"></a>6.4.4. Reinterpreting Data as Another Type</h4>
<div class="paragraph">
<p>It is frequently necessary to reinterpret bits in a data type as another
data type in OpenCL.
This is typically required when direct access to the bits in a
floating-point type is needed, for example to mask off the sign bit or make
use of the result of a vector <a href="#operators-relational">relational operator</a>
on floating-point data <sup class="footnote">[<a id="_footnoteref_18" class="footnote" href="#_footnotedef_18" title="View footnote.">18</a>]</sup>.
Several methods to achieve this (non-) conversion are frequently practiced
in C, including pointer aliasing, unions and memcpy.
Of these, only memcpy is strictly correct in C99.
Since OpenCL does not provide <strong>memcpy</strong>, other methods are needed.</p>
</div>
<div class="sect4">
<h5 id="reinterpreting-types-using-unions"><a class="anchor" href="#reinterpreting-types-using-unions"></a>6.4.4.1. Reinterpreting Types Using Unions</h5>
<div class="paragraph">
<p>The OpenCL language extends the union to allow the program to access a
member of a union object using a member of a different type.
The relevant bytes of the representation of the object are treated as an
object of the type used for the access.
If the type used for access is larger than the representation of the object,
then the value of the additional bytes is undefined.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// d only if double-precision is supported</span>
<span class="k">union</span> <span class="p">{</span> <span class="kt">float</span> <span class="n">f</span><span class="p">;</span> <span class="kt">uint</span> <span class="n">u</span><span class="p">;</span> <span class="kt">double</span> <span class="n">d</span><span class="p">;</span> <span class="p">}</span> <span class="n">u</span><span class="p">;</span>
<span class="n">u</span><span class="p">.</span><span class="n">u</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="c1">// u.f contains 2**-149. u.d is undefined --</span>
<span class="c1">// depending on endianness the low or high half</span>
<span class="c1">// of d is unknown</span>
<span class="n">u</span><span class="p">.</span><span class="n">f</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span> <span class="c1">// u.u contains 0x3f800000, u.d contains an</span>
<span class="c1">// undefined value -- depending on endianness</span>
<span class="c1">// the low or high half of d is unknown</span>
<span class="n">u</span><span class="p">.</span><span class="n">d</span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">;</span> <span class="c1">// u.u contains 0x3ff00000 (big endian) or 0</span>
<span class="c1">// (little endian). u.f contains either 0x1.ep0f</span>
<span class="c1">// (big endian) or 0.0f (little endian)</span></code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="reinterpreting-types-using-as_type-and-as_typen"><a class="anchor" href="#reinterpreting-types-using-as_type-and-as_typen"></a>6.4.4.2. Reinterpreting Types Using <strong>as_type</strong>() and <strong>as_type<em>n</em></strong>()</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>All data types described in <a href="#table-builtin-scalar-types">Built-in Scalar Data
Types</a> and <a href="#table-builtin-vector-types">Built-in Vector Data Types</a> (except
<code>bool</code>, <code>void</code>, and <code>half</code> <sup class="footnote">[<a id="_footnoteref_19" class="footnote" href="#_footnotedef_19" title="View footnote.">19</a>]</sup>) may be also
reinterpreted as another data type of the same size using the <strong>as_type</strong>()
operator for scalar data types and the <strong>as_type<em>n</em></strong>() operator
<sup class="footnote">[<a id="_footnoteref_20" class="footnote" href="#_footnotedef_20" title="View footnote.">20</a>]</sup> for vector data types.
When the operand and result type contain the same number of elements, the
bits in the operand shall be returned directly without modification as the
new type.
The usual type promotion for function arguments shall not be performed.</p>
</div>
<div class="paragraph">
<p>For example, <code><strong>as_float</strong>(0x3f800000)</code> returns <code>1.0f</code>, which is the value
that the bit pattern <code>0x3f800000</code> has if viewed as an IEEE-754 single
precision value.</p>
</div>
<div class="paragraph">
<p>When the operand and result type contain a different number of elements, the
result shall be implementation-defined except if the operand is a
4-component vector and the result is a 3-component vector.
In this case, the bits in the operand shall be returned directly without
modification as the new type.
That is, a conforming implementation shall explicitly define a behavior, but
two conforming implementations need not have the same behavior when the
number of elements in the result and operand types does not match.
The implementation may define the result to contain all, some or none of the
original bits in whatever order it chooses.
It is an error to use <strong>as_type</strong>() or <strong>as_type<em>n</em></strong>() operator to
reinterpret data to a type of a different number of bytes.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float</span> <span class="n">f</span> <span class="o">=</span> <span class="mf">1.0f</span><span class="p">;</span>
<span class="kt">uint</span> <span class="n">u</span> <span class="o">=</span> <span class="fm">as_uint</span><span class="p">(</span><span class="n">f</span><span class="p">);</span> <span class="c1">// Legal. Contains: 0x3f800000</span>
<span class="kt">float4</span> <span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="c1">// Legal. Contains:</span>
<span class="c1">// (int4)(0x3f800000, 0x40000000, 0x40400000, 0x40800000)</span>
<span class="kt">int4</span> <span class="n">i</span> <span class="o">=</span> <span class="fm">as_int4</span><span class="p">(</span><span class="n">f</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">;</span>
<span class="kt">int4</span> <span class="n">is_less</span> <span class="o">=</span> <span class="n">f</span> <span class="o">&lt;</span> <span class="n">g</span><span class="p">;</span>
<span class="c1">// Legal. f[i] = f[i] &lt; g[i] ? f[i] : 0.0f</span>
<span class="n">f</span> <span class="o">=</span> <span class="fm">as_float4</span><span class="p">(</span><span class="fm">as_int4</span><span class="p">(</span><span class="n">f</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">is_less</span><span class="p">);</span>
<span class="kt">int</span> <span class="n">i</span><span class="p">;</span>
<span class="c1">// Legal. Result is implementation-defined.</span>
<span class="kt">short2</span> <span class="n">j</span> <span class="o">=</span> <span class="fm">as_short2</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
<span class="kt">int4</span> <span class="n">i</span><span class="p">;</span>
<span class="c1">// Legal. Result is implementation-defined.</span>
<span class="kt">short8</span> <span class="n">j</span> <span class="o">=</span> <span class="fm">as_short8</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">f</span><span class="p">;</span>
<span class="c1">// Error. Result and operand have different sizes</span>
<span class="kt">double4</span> <span class="n">g</span> <span class="o">=</span> <span class="fm">as_double4</span><span class="p">(</span><span class="n">f</span><span class="p">);</span> <span class="c1">// Only if double-precision is supported.</span>
<span class="kt">float4</span> <span class="n">f</span><span class="p">;</span>
<span class="c1">// Legal. g.xyz will have same values as f.xyz. g.w is undefined</span>
<span class="kt">float3</span> <span class="n">g</span> <span class="o">=</span> <span class="fm">as_float3</span><span class="p">(</span><span class="n">f</span><span class="p">);</span></code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="pointer-casting"><a class="anchor" href="#pointer-casting"></a>6.4.5. Pointer Casting</h4>
<div class="paragraph">
<p>Pointers to old and new types may be cast back and forth to each other.
Casting a pointer to a new type represents an unchecked assertion that the
address is correctly aligned.
The developer will also need to know the endianness of the OpenCL device and
the endianness of the data to determine how the scalar and vector data
elements are stored in memory.</p>
</div>
</div>
<div class="sect3">
<h4 id="usual-arithmetic-conversions"><a class="anchor" href="#usual-arithmetic-conversions"></a>6.4.6. Usual Arithmetic Conversions</h4>
<div class="paragraph">
<p>Many operators that expect operands of arithmetic type cause conversions and
yield result types in a similar way.
The purpose is to determine a common real type for the operands and result.
For the specified operands, each operand is converted, without change of
type domain, to a type whose corresponding real type is the common real
type.
For this purpose, all vector types shall be considered to have higher
conversion ranks than scalars.
Unless explicitly stated otherwise, the common real type is also the
corresponding real type of the result, whose type domain is the type domain
of the operands if they are the same, and complex otherwise.
This pattern is called the usual arithmetic conversions.
If the operands are of more than one vector type, then an error shall occur.
<a href="#implicit-conversions">Implicit conversions</a> between vector types are not
permitted.</p>
</div>
<div class="paragraph">
<p>Otherwise, if there is only a single vector type, and all other operands are
scalar types, the scalar types are converted to the type of the vector
element, then widened into a new vector containing the same number of
elements as the vector, by duplication of the scalar value across the width
of the new vector.
An error shall occur if any scalar operand has greater rank than the type of
the vector element.
For this purpose, the rank order defined as follows:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The rank of a floating-point type is greater than the rank of another
floating-point type, if the first floating-point type can exactly
represent all numeric values in the second floating-point type.
(For this purpose, the encoding of the floating-point value is used,
rather than the subset of the encoding usable by the device.)</p>
</li>
<li>
<p>The rank of any floating-point type is greater than the rank of any
integer type.</p>
</li>
<li>
<p>The rank of an integer type is greater than the rank of an integer type
with less precision.</p>
</li>
<li>
<p>The rank of an unsigned integer type is <strong>greater than</strong> the rank of a
signed integer type with the same precision
<sup class="footnote">[<a id="_footnoteref_21" class="footnote" href="#_footnotedef_21" title="View footnote.">21</a>]</sup>.</p>
</li>
<li>
<p>The rank of the bool type is less than the rank of any other type.</p>
</li>
<li>
<p>The rank of an enumerated type shall equal the rank of the compatible
integer type.</p>
</li>
<li>
<p>For all types, <code>T1</code>, <code>T2</code> and <code>T3</code>, if <code>T1</code> has greater rank than <code>T2</code>,
and <code>T2</code> has greater rank than <code>T3</code>, then <code>T1</code> has greater rank than
<code>T3</code>.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Otherwise, if all operands are scalar, the usual arithmetic conversions
apply, per <a href="#C99-spec">section 6.3.1.8 of the C99 Specification</a>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Both the standard orderings in <a href="#C99-spec">sections 6.3.1.8 and 6.3.1.1 of
the C99 Specification</a> were examined and rejected.
Had we used integer conversion rank here, <code>int4 + 0U</code> would have been legal
and had <code>int4</code> return type.
Had we used standard C99 usual arithmetic conversion rules for scalars, then
the standard integer promotion would have been performed on vector integer
element types and <code>short8 + char</code> would either have return type of <code>int8</code> or
be illegal.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect2">
<h3 id="operators"><a class="anchor" href="#operators"></a>6.5. Operators</h3>
<div class="sect3">
<h4 id="operators-arithmetic"><a class="anchor" href="#operators-arithmetic"></a>6.5.1. Arithmetic Operators</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The arithmetic operators add (<strong>+</strong>), subtract (<strong>-</strong>), multiply (<strong>*</strong>) and
divide (<strong>/</strong>) operate on built-in integer and floating-point scalar, and
vector data types.
The arithmetic operator remainder (<strong>%</strong>) operates on built-in integer scalar
and integer vector data types.
All arithmetic operators return result of the same built-in type (integer or
floating-point) as the type of the operands, after operand type conversion.
After conversion, the following cases are valid:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The two operands are scalars.
In this case, the operation is applied, resulting in a scalar.</p>
</li>
<li>
<p>One operand is a scalar, and the other is a vector.
In this case, the scalar may be subject to the usual arithmetic
conversion to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of
components as the vector operand.
The operation is done component-wise resulting in the same size vector.</p>
</li>
<li>
<p>The two operands are vectors of the same type.
In this case, the operation is done component-wise resulting in the same
size vector.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>All other cases of implicit conversions are illegal.
Division on integer types which results in a value that lies outside of the
range bounded by the maximum and minimum representable values of the integer
type will not cause an exception but will result in an unspecified value.
A divide by zero with integer types does not cause an exception but will
result in an unspecified value.
Division by zero for floating-point types will result in ±∞ or
NaN as prescribed by the IEEE-754 standard.
Use the built-in functions <strong>dot</strong> and <strong>cross</strong> to get, respectively, the
vector dot product and the vector cross product.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-unary"><a class="anchor" href="#operators-unary"></a>6.5.2. Unary Operators</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The arithmetic unary operators (<strong>+</strong> and <strong>-</strong>) operate on built-in scalar and
vector types.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-prepost"><a class="anchor" href="#operators-prepost"></a>6.5.3. Pre- and Post-Operators</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The arithmetic post- and pre-increment and decrement operators (<strong>--</strong> and
<strong>++</strong>) operate on built-in scalar and vector types except the built-in scalar
and vector <code>float</code> types <sup class="footnote">[<a id="_footnoteref_22" class="footnote" href="#_footnotedef_22" title="View footnote.">22</a>]</sup>.
All unary operators work component-wise on their operands.
These result with the same type they operated on.
For post- and pre-increment and decrement, the expression must be one that
could be assigned to (an l-value).
Pre-increment and pre-decrement add or subtract 1 to the contents of the
expression they operate on, and the value of the pre-increment or
pre-decrement expression is the resulting value of that modification.
Post-increment and post-decrement expressions add or subtract 1 to the
contents of the expression they operate on, but the resulting expression has
the expression&#8217;s value before the post-increment or post-decrement was
executed.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-relational"><a class="anchor" href="#operators-relational"></a>6.5.4. Relational Operators</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The relational operators greater than (<strong>&gt;</strong>), less than (<strong>&lt;</strong>), greater than or
equal (<strong>&gt;=</strong>), and less than or equal (<strong>&lt;=</strong>) operate on scalar and vector types
<sup class="footnote">[<a id="_footnoteref_23" class="footnote" href="#_footnotedef_23" title="View footnote.">23</a>]</sup>.
All relational operators result in an integer type.
After operand type conversion, the following cases are valid:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The two operands are scalars.
In this case, the operation is applied, resulting in an <code>int</code> scalar.</p>
</li>
<li>
<p>One operand is a scalar, and the other is a vector.
In this case, the scalar may be subject to the usual arithmetic
conversion to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of
components as the vector operand.
The operation is done component-wise resulting in the same size vector.</p>
</li>
<li>
<p>The two operands are vectors of the same type.
In this case, the operation is done component-wise resulting in the same
size vector.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>All other cases of implicit conversions are illegal.</p>
</div>
<div class="paragraph">
<p>The result is a scalar signed integer of type <code>int</code> if the source operands
are scalar and a vector signed integer type of the same size as the source
operands if the source operands are vector types.
Vector source operands of type <code>char<em>n</em></code> and <code>uchar<em>n</em></code> return a
<code>char<em>n</em></code> result; vector source operands of type
<code>half<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_24" class="footnote" href="#_footnotedef_24" title="View footnote.">24</a>]</sup>,
<code>short<em>n</em></code> and
<code>ushort<em>n</em></code> return a <code>short<em>n</em></code> result; vector source operands of type
<code>int<em>n</em></code>, <code>uint<em>n</em></code> and <code>float<em>n</em></code> return an <code>int<em>n</em></code> result; vector
source operands of type <code>long<em>n</em></code>, <code>ulong<em>n</em></code> and <code>double<em>n</em></code> return a
<code>long<em>n</em></code> result.</p>
</div>
<div class="paragraph">
<p>For scalar types, the relational operators shall return 0 if the specified
relation is <em>false</em> and return 1 if the specified relation is <em>true</em>.
For vector types, the relational operators shall return 0 if the specified
relation is <em>false</em> and return -1 (i.e. all bits set) if the specified
relation is <em>true</em>.
The relational operators always return 0 if either argument is not a number
(NaN).</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-equality"><a class="anchor" href="#operators-equality"></a>6.5.5. Equality Operators</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The equality operators equal (<strong>==</strong>) and not equal (<strong>!=</strong>) operate on
built-in scalar and vector types <sup class="footnote">[<a id="_footnoteref_25" class="footnote" href="#_footnotedef_25" title="View footnote.">25</a>]</sup>.
All equality operators result in an integer type.
After operand type conversion, the following cases are valid:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The two operands are scalars.
In this case, the operation is applied, resulting in a scalar.</p>
</li>
<li>
<p>One operand is a scalar, and the other is a vector.
In this case, the scalar may be subject to the usual arithmetic
conversion to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of
components as the vector operand.
The operation is done component-wise resulting in the same size vector.</p>
</li>
<li>
<p>The two operands are vectors of the same type.
In this case, the operation is done component-wise resulting in the same
size vector.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>All other cases of implicit conversions are illegal.</p>
</div>
<div class="paragraph">
<p>The result is a scalar signed integer of type <code>int</code> if the source operands
are scalar and a vector signed integer type of the same size as the source
operands if the source operands are vector types.
Vector source operands of type <code>char<em>n</em></code> and <code>uchar<em>n</em></code> return a
<code>char<em>n</em></code> result; vector source operands of type
<code>half<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_26" class="footnote" href="#_footnotedef_26" title="View footnote.">26</a>]</sup>,
<code>short<em>n</em></code> and
<code>ushort<em>n</em></code> return a <code>short<em>n</em></code> result; vector source operands of type
<code>int<em>n</em></code>, <code>uint<em>n</em></code> and <code>float<em>n</em></code> return an <code>int<em>n</em></code> result; vector
source operands of type <code>long<em>n</em></code>, <code>ulong<em>n</em></code> and <code>double<em>n</em></code> return a
<code>long<em>n</em></code> result.</p>
</div>
<div class="paragraph">
<p>For scalar types, the equality operators shall return 0 if the specified
relation is <em>false</em> and return 1 if the specified relation is <em>true</em>.
For vector types, the equality operators shall return 0 if the specified
relation is <em>false</em> and return -1 (i.e. all bits set) if the specified
relation is <em>true</em>.
The equality operator equal (<strong>==</strong>) returns 0 if one or both arguments are
not a number (NaN).
The equality operator not equal (<strong>!=</strong>) returns 1 (for scalar source
operands) or -1 (for vector source operands) if one or both arguments are
not a number (NaN).</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-bitwise"><a class="anchor" href="#operators-bitwise"></a>6.5.6. Bitwise Operators</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The bitwise operators and (<strong>&amp;</strong>), or (<strong>|</strong>), exclusive or (<strong>^</strong>), and not
(<strong>~</strong>) operate on all scalar and vector built-in types except the built-in
scalar and vector <code>float</code> types.
For vector built-in types, the operators are applied component-wise.
If one operand is a scalar and the other is a vector, the scalar may be
subject to the usual arithmetic conversion to the element type used by the
vector operand.
The scalar type is then widened to a vector that has the same number of
components as the vector operand.
The operation is done component-wise resulting in the same size vector.
Vector source operands of type <code>half<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_27" class="footnote" href="#_footnotedef_27" title="View footnote.">27</a>]</sup>
return a <code>short<em>n</em></code> result.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-logical"><a class="anchor" href="#operators-logical"></a>6.5.7. Logical Operators</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The logical operators and (<strong>&amp;&amp;</strong>) and or (<strong>||</strong>) operate on all scalar and
vector built-in types.
For scalar built-in types only, and (<strong>&amp;&amp;</strong>) will only evaluate the right hand
operand if the left hand operand compares unequal to 0.
For scalar built-in types only, or (<strong>||</strong>) will only evaluate the right hand
operand if the left hand operand compares equal to 0.
For built-in vector types, both operands are evaluated and the operators are
applied component-wise.
If one operand is a scalar and the other is a vector, the scalar may be
subject to the usual arithmetic conversion to the element type used by the
vector operand.
The scalar type is then widened to a vector that has the same number of
components as the vector operand.
The operation is done component-wise resulting in the same size vector.</p>
</div>
<div class="paragraph">
<p>The logical operator exclusive or (<strong>^^</strong>) is reserved.</p>
</div>
<div class="paragraph">
<p>The result is a scalar signed integer of type <code>int</code> if the source operands
are scalar and a vector signed integer type of the same size as the source
operands if the source operands are vector types.
Vector source operands of type <code>char<em>n</em></code> and <code>uchar<em>n</em></code> return a
<code>char<em>n</em></code> result; vector source operands of type
<code>half<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_28" class="footnote" href="#_footnotedef_28" title="View footnote.">28</a>]</sup>,
<code>short<em>n</em></code> and
<code>ushort<em>n</em></code> return a <code>short<em>n</em></code> result; vector source operands of type
<code>int<em>n</em></code>, <code>uint<em>n</em></code> and <code>float<em>n</em></code> return an <code>int<em>n</em></code> result; vector
source operands of type <code>long<em>n</em></code>, <code>ulong<em>n</em></code> and <code>double<em>n</em></code> return a
<code>long<em>n</em></code> result.</p>
</div>
<div class="paragraph">
<p>For scalar types, the logical operators shall return 0 if the result of the
operation is <em>false</em> and return 1 if the result is <em>true</em>.
For vector types, the logical operators shall return 0 if the result of the
operation is <em>false</em> and return -1 (i.e. all bits set) if the result is <em>true</em>.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-logical-unary"><a class="anchor" href="#operators-logical-unary"></a>6.5.8. Unary Logical Operator</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The logical unary operator not (<strong>!</strong>) operates on all scalar and vector
built-in types.
For built-in vector types, the operators are applied component-wise.</p>
</div>
<div class="paragraph">
<p>The result is a scalar signed integer of type <code>int</code> if the source operands
are scalar and a vector signed integer type of the same size as the source
operands if the source operands are vector types.
Vector source operands of type <code>char<em>n</em></code> and <code>uchar<em>n</em></code> return a
<code>char<em>n</em></code> result; vector source operands of type
<code>half<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_29" class="footnote" href="#_footnotedef_29" title="View footnote.">29</a>]</sup>,
<code>short<em>n</em></code> and
<code>ushort<em>n</em></code> return a <code>short<em>n</em></code> result; vector source operands of type
<code>int<em>n</em></code>, <code>uint<em>n</em></code> and <code>float<em>n</em></code> return an <code>int<em>n</em></code> result; vector
source operands of type <code>long<em>n</em></code>, <code>ulong<em>n</em></code> and <code>double<em>n</em></code> return a
<code>long<em>n</em></code> result.</p>
</div>
<div class="paragraph">
<p>For scalar types, the logical unary operator shall return 0 if the value of
its operand compares unequal to 0, and return 1 if the value of its operand
compares equal to 0.
For vector types, the unary operator shall return 0 if the value of its
operand compares unequal to 0, and return -1 (i.e. all bits set) if the
value of its operand compares equal to 0.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-ternary-selection"><a class="anchor" href="#operators-ternary-selection"></a>6.5.9. Ternary Selection Operator</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The ternary selection operator (<strong>?:</strong>) operates on three expressions (<em>exp1</em>
<strong>?</strong> <em>exp2</em> <strong>:</strong> <em>exp3</em>).
This operator evaluates the first expression <em>exp1</em>, which can be a scalar
or vector result except <code>float</code>.
If all three expressions are scalar values, the C99 rules for ternary
operator are followed.
If the result is a vector value, then this is equivalent to calling
<strong>select</strong>(<em>exp3</em>, <em>exp2</em>, <em>exp1</em>).
The <strong>select</strong> function is described in <a href="#table-builtin-relational">Built-in Scalar
and Vector Relational Functions</a>.
The second and third expressions can be any type, as long their types match,
or there is an <a href="#implicit-conversions">implicit conversion</a> that can be
applied to one of the expressions to make their types match, or one is a
vector and the other is a scalar and the scalar may be subject to the usual
arithmetic conversion to the element type used by the vector operand and
widened to the same type as the vector type.
This resulting matching type is the type of the entire expression.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-shift"><a class="anchor" href="#operators-shift"></a>6.5.10. Shift Operators</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The operators right-shift (<strong>&gt;&gt;</strong>), left-shift (<strong>&lt;&lt;</strong>) operate on all scalar
and vector built-in types except the built-in scalar and vector <code>float</code>
types.
For built-in vector types, the operators are applied component-wise.
For the right-shift (<strong>&gt;&gt;</strong>), left-shift (<strong>&lt;&lt;</strong>) operators, the rightmost
operand must be a scalar if the first operand is a scalar, and the rightmost
operand can be a vector or scalar if the first operand is a vector.</p>
</div>
<div class="paragraph">
<p>The result of <code>E1</code> <strong>&lt;&lt;</strong> <code>E2</code> is <code>E1</code> left-shifted by log<sub>2</sub>(N) least significant
bits in <code>E2</code> viewed as an unsigned integer value, where N is the number of bits
used to represent the data type of <code>E1</code> after integer promotion
<sup class="footnote">[<a id="_footnoteref_30" class="footnote" href="#_footnotedef_30" title="View footnote.">30</a>]</sup>, if <code>E1</code> is a scalar, or the number of bits
used to represent the type of <code>E1</code> elements, if <code>E1</code> is a vector.
The vacated bits are filled with zeros.</p>
</div>
<div class="paragraph">
<p>The result of <code>E1</code> <strong>&gt;&gt;</strong> <code>E2</code> is <code>E1</code> right-shifted by log<sub>2</sub>(N) least
significant bits in <code>E2</code> viewed as an unsigned integer value, where N is the
number of bits used to represent the data type of <code>E1</code> after integer
promotion, if <code>E1</code> is a scalar, or the number of bits used to represent the
type of <code>E1</code> elements, if <code>E1</code> is a vector.
If <code>E1</code> has an unsigned type or if <code>E1</code> has a signed type and a nonnegative
value, the vacated bits are filled with zeros.
If <code>E1</code> has a signed type and a negative value, the vacated bits are filled
with ones.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-sizeof"><a class="anchor" href="#operators-sizeof"></a>6.5.11. Sizeof Operator</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>sizeof</code> operator yields the size (in bytes) of its operand, including
any <a href="#alignment-of-types">padding bytes needed for alignment</a>, which may be
an expression or the parenthesized name of a type.
The size is determined from the type of the operand.
The result is of type <code>size_t</code>.
If the type of the operand is a variable length array
<sup class="footnote">[<a id="_footnoteref_31" class="footnote" href="#_footnotedef_31" title="View footnote.">31</a>]</sup> type, the operand is
evaluated; otherwise, the operand is not evaluated and the result is an integer
constant.</p>
</div>
<div class="paragraph">
<p>When applied to an operand that has type <code>char</code> or <code>uchar</code>, the result is 1.
When applied to an operand that has type <code>short</code>, <code>ushort</code>, or <code>half</code> the
result is 2.
When applied to an operand that has type <code>int</code>, <code>uint</code> or <code>float</code>, the
result is 4.
When applied to an operand that has type <code>long</code>, <code>ulong</code> or <code>double</code>, the
result is 8.
When applied to an operand that is a vector type, the result is the number of
components times the size of each scalar component <sup class="footnote">[<a id="_footnoteref_32" class="footnote" href="#_footnotedef_32" title="View footnote.">32</a>]</sup>.
When applied to an operand that has array type, the result is the total
number of bytes in the array.
When applied to an operand that has structure or union type, the result is
the total number of bytes in such an object, including internal and trailing
padding.
The <code>sizeof</code> operator shall not be applied to an expression that has
function type or an incomplete type, to the parenthesized name of such a
type, or to an expression that designates a bit-field struct member
<sup class="footnote">[<a id="_footnoteref_33" class="footnote" href="#_footnotedef_33" title="View footnote.">33</a>]</sup>.</p>
</div>
<div class="paragraph">
<p>The behavior of applying the <code>sizeof</code> operator to the <code>bool</code>, <code>image2d_t</code>,
<code>image3d_t</code>, <code>image2d_array_t</code>, <code>image1d_t</code>, <code>image1d_buffer_t</code>,
<code>image1d_array_t</code>, <code>image2d_depth_t</code>, <code>image2d_array_depth_t</code>,
<code>sampler_t</code>, <code>queue_t</code>, <code>ndrange_t</code>, <code>clk_event_t</code>, <code>reserve_id_t</code>, and
<code>event_t</code> types is implementation-defined. Additionally, the behavior of
applying the <code>sizeof</code> operator to a pipe object (a type with the <code>pipe</code> type
specifier keyword) is implementation-defined.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-comma"><a class="anchor" href="#operators-comma"></a>6.5.12. Comma Operator</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The comma (<strong>,</strong>) operator operates on expressions by returning the type and
value of the right-most expression in a comma separated list of expressions.
All expressions are evaluated, in order, from left to right.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-indirection"><a class="anchor" href="#operators-indirection"></a>6.5.13. Indirection Operator</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The unary (<strong>*</strong>) operator denotes indirection.
If the operand points to an object, the result is an l-value designating the
object.
If the operand has type "pointer to <em>type</em>", the result has type
"<em>type</em>".
If an invalid value has been assigned to the pointer, the behavior of the unary
<strong>*</strong> operator is undefined <sup class="footnote">[<a id="_footnoteref_34" class="footnote" href="#_footnotedef_34" title="View footnote.">34</a>]</sup>.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-address"><a class="anchor" href="#operators-address"></a>6.5.14. Address Operator</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The unary (<strong>&amp;</strong>) operator returns the address of its operand.
If the operand has type "<em>type</em>", the result has type "pointer to
<em>type</em>".
If the operand is the result of a unary <strong>*</strong> operator, neither that operator
nor the <strong>&amp;</strong> operator is evaluated and the result is as if both were omitted,
except that the constraints on the operators still apply and the result is
not an l-value.
Similarly, if the operand is the result of a <strong>[]</strong> operator, neither the <strong>&amp;</strong>
operator nor the unary <strong>*</strong> that is implied by the <strong>[]</strong> is evaluated and the
result is as if the <strong>&amp;</strong> operator were removed and the <strong>[]</strong> operator were
changed to a <strong>+</strong> operator.
Otherwise, the result is a pointer to the object designated by its
operand <sup class="footnote">[<a id="_footnoteref_35" class="footnote" href="#_footnotedef_35" title="View footnote.">35</a>]</sup>.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="operators-assignment"><a class="anchor" href="#operators-assignment"></a>6.5.15. Assignment Operator</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>Assignments of values to variable names are done with the assignment
operator (<strong>=</strong>), like</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><em>lvalue</em> = <em>expression</em></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The assignment operator stores the value of <em>expression</em> into <em>lvalue</em>.
The <em>expression</em> and <em>lvalue</em> must have the same type, or the expression must
have a type in <a href="#table-builtin-scalar-types">Built-in Scalar Data Types</a>, in
which case an implicit conversion will be done on the expression before the
assignment is done.</p>
</div>
<div class="paragraph">
<p>If <em>expression</em> is a scalar type and <em>lvalue</em> is a vector type, the scalar
is converted to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of
components as the vector operand.
The operation is done component-wise resulting in the same size vector.</p>
</div>
<div class="paragraph">
<p>Any other desired type-conversions must be specified explicitly.
L-values must be writable.
Variables that are built-in types, entire structures or arrays, structure
fields, l-values with the field selector (<strong>.</strong>) applied to select components
or swizzles without repeated fields, l-values within parentheses, and
l-values dereferenced with the array subscript operator (<strong>[]</strong>) are all
l-values.
Other binary or unary expressions, function names, swizzles with repeated
fields, and constants cannot be l-values.
The ternary operator (<strong>?:</strong>) is also not allowed as an l-value.</p>
</div>
<div class="paragraph">
<p>The order of evaluation of the operands is unspecified.
If an attempt is made to modify the result of an assignment operator or to
access it after the next sequence point, the behavior is undefined.
Other assignment operators are the assignments add into (<strong>+=</strong>), subtract
from (<strong>-=</strong>), multiply into (<strong>=</strong>), divide into (<strong>/=</strong>), modulus into (<strong>%=</strong>),
left shift by (<strong>&lt;&lt;=</strong>), right shift by (<strong>&gt;&gt;=</strong>), and into (<strong>&amp;=</strong>), inclusive
or into (<strong>|=</strong>), and exclusive or into (<strong>^=</strong>).</p>
</div>
<div class="paragraph">
<p>The expression</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><em>lvalue</em> <em>op</em> <strong>=</strong> <em>expression</em></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>is equivalent to</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><em>lvalue</em> = <em>lvalue</em> <em>op</em> <em>expression</em></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>and the <em>lvalue</em> and <em>expression</em> must satisfy the requirements for both
operator <em>op</em> and assignment (<strong>=</strong>).</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Except for the <code>sizeof</code> operator, the <code>half</code> data type cannot be used with
any of the operators described in this section.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="vector-operations"><a class="anchor" href="#vector-operations"></a>6.6. Vector Operations</h3>
<div class="paragraph">
<p>Vector operations are component-wise.
Usually, when an operator operates on a vector, it is operating
independently on each component of the vector, in a component-wise fashion.</p>
</div>
<div class="paragraph">
<p>For example,</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">v</span><span class="p">,</span> <span class="n">u</span><span class="p">;</span>
<span class="kt">float</span> <span class="n">f</span><span class="p">;</span>
<span class="n">v</span> <span class="o">=</span> <span class="n">u</span> <span class="o">+</span> <span class="n">f</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>will be equivalent to</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">v</span><span class="p">.</span><span class="n">x</span> <span class="o">=</span> <span class="n">u</span><span class="p">.</span><span class="n">x</span> <span class="o">+</span> <span class="n">f</span><span class="p">;</span>
<span class="n">v</span><span class="p">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">u</span><span class="p">.</span><span class="n">y</span> <span class="o">+</span> <span class="n">f</span><span class="p">;</span>
<span class="n">v</span><span class="p">.</span><span class="n">z</span> <span class="o">=</span> <span class="n">u</span><span class="p">.</span><span class="n">z</span> <span class="o">+</span> <span class="n">f</span><span class="p">;</span>
<span class="n">v</span><span class="p">.</span><span class="n">w</span> <span class="o">=</span> <span class="n">u</span><span class="p">.</span><span class="n">w</span> <span class="o">+</span> <span class="n">f</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>And</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">v</span><span class="p">,</span> <span class="n">u</span><span class="p">,</span> <span class="n">w</span><span class="p">;</span>
<span class="n">w</span> <span class="o">=</span> <span class="n">v</span> <span class="o">+</span> <span class="n">u</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>will be equivalent to</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">w</span><span class="p">.</span><span class="n">x</span> <span class="o">=</span> <span class="n">v</span><span class="p">.</span><span class="n">x</span> <span class="o">+</span> <span class="n">u</span><span class="p">.</span><span class="n">x</span><span class="p">;</span>
<span class="n">w</span><span class="p">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">v</span><span class="p">.</span><span class="n">y</span> <span class="o">+</span> <span class="n">u</span><span class="p">.</span><span class="n">y</span><span class="p">;</span>
<span class="n">w</span><span class="p">.</span><span class="n">z</span> <span class="o">=</span> <span class="n">v</span><span class="p">.</span><span class="n">z</span> <span class="o">+</span> <span class="n">u</span><span class="p">.</span><span class="n">z</span><span class="p">;</span>
<span class="n">w</span><span class="p">.</span><span class="n">w</span> <span class="o">=</span> <span class="n">v</span><span class="p">.</span><span class="n">w</span> <span class="o">+</span> <span class="n">u</span><span class="p">.</span><span class="n">w</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>and likewise for most operators and all integer and floating-point vector
types.</p>
</div>
</div>
<div class="sect2">
<h3 id="address-space-qualifiers"><a class="anchor" href="#address-space-qualifiers"></a>6.7. Address Space Qualifiers</h3>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>OpenCL C has a hierarchical memory architecture represented by address spaces, as
defined in section 5 of <a href="#embedded-c-spec">the Embedded C Specification</a>. It
extends the C syntax to allow an address space name as a valid type qualifier
(section 5.1.2 of <a href="#embedded-c-spec">the Embedded C Specification</a>).
OpenCL implements disjoint named address spaces with the spelling
<code>__global</code>, <code>__local</code>, <code>__constant</code> and <code>__private</code>.
The address space qualifier may be used in variable declarations to specify
the region where objects are to be allocated. If the type of an
object is qualified by an address space name, the object is allocated in the
specified address space. Similarly, for pointers, the type pointed to can be qualified
by an address space signaling the address space where the object pointed to is located.</p>
</div>
<div class="paragraph">
<p>The address space name spelling without the <code>__</code> prefix, i.e. <code>global</code>,
<code>local</code>, <code>constant</code> and <code>private</code>, are valid and may be substituted for the
corresponding address space names with the <code>__</code> prefix.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// declares a pointer p in the global address space that</span>
<span class="c1">// points to an object in the global address space</span>
<span class="nx">__global</span> <span class="kt">int</span> <span class="o">*</span><span class="nx">__global</span> <span class="n">p</span><span class="p">;</span>
<span class="kt">void</span> <span class="nf">foo</span> <span class="p">(...)</span>
<span class="p">{</span>
<span class="c1">// declares an array of 4 floats in the private address space</span>
<span class="nx">__private</span> <span class="kt">float</span> <span class="n">x</span><span class="p">[</span><span class="mi">4</span><span class="p">];</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature macro, there is an additional unnamed
generic address space.</p>
</div>
<div class="paragraph">
<p>Most of the restrictions from section 5.1.2 and section 5.3 of the
<a href="#embedded-c-spec">Embedded C Specification</a> apply in OpenCL C, e.g. address
spaces can not be used with a return type, a function parameter, or a function
type, and multiple address space qualifiers are not allowed. However, in OpenCL
C it is allowed to qualify local variables with an address space qualifier.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// OK.</span>
<span class="kt">int</span> <span class="nf">f</span><span class="p">()</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}</span>
<span class="c1">// Error. Address space qualifier cannot be used with a non-pointer return type.</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="nf">f</span><span class="p">()</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}</span>
<span class="c1">// OK. Address space qualifier can be used with a pointer return type.</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="nf">f</span><span class="p">()</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}</span>
<span class="c1">// Error. Multiple address spaces specified for a type.</span>
<span class="nx">private</span> <span class="nx">local</span> <span class="kt">int</span> <span class="n">i</span><span class="p">;</span>
<span class="c1">// OK. The first address space qualifies the object pointed to and the second</span>
<span class="c1">// qualifies the pointer.</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="o">*</span><span class="nx">local</span> <span class="n">ptr</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>__global</code>, <code>__constant</code>, <code>__local</code>, <code>__private</code>, <code>global</code>,
<code>constant</code>, <code>local</code>, and <code>private</code> names are reserved for use as address
space qualifiers and shall not be used otherwise.
The <code>__generic</code> and <code>generic</code> names are reserved for future use.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The size of pointers to different address spaces may differ.
It is not correct to assume that, for example, <code>sizeof(__global int *)</code>
always equals <code>sizeof(__local int *)</code>.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="global-or-global"><a class="anchor" href="#global-or-global"></a>6.7.1. <code>__global</code> (or <code>global</code>)</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>__global</code> or <code>global</code> address space name is used to refer to memory
objects (buffer or image objects) allocated from the <code>global</code> memory pool.</p>
</div>
<div class="paragraph">
<p>A buffer memory object can be declared as a pointer to a scalar, vector or
user-defined struct.
This allows the kernel to read and/or write any location in the buffer.</p>
</div>
<div class="paragraph">
<p>The actual size of the memory object is determined when the memory
object is allocated via appropriate API calls in the host code.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">global</span> <span class="kt">float4</span> <span class="o">*</span><span class="n">color</span><span class="p">;</span> <span class="c1">// An array of float4 elements</span>
<span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
<span class="kt">float</span> <span class="n">a</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="kt">int</span> <span class="n">b</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
<span class="p">}</span> <span class="n">foo_t</span><span class="p">;</span>
<span class="nx">global</span> <span class="n">foo_t</span> <span class="o">*</span><span class="n">my_info</span><span class="p">;</span> <span class="c1">// An array of foo_t elements</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>As image objects are always allocated from the <code>global</code> address space, the
<code>__global</code> or <code>global</code> qualifier should not be specified for image types.
The elements of an image object cannot be directly accessed.
Built-in functions to read from and write to an image object are provided.</p>
</div>
<div class="paragraph">
<p>Variables at program scope or <code>static</code> or <code>extern</code> variables inside functions
can be declared in global address space if the
<code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature is supported. These
variables in the <code>global</code> address space have the same lifetime as the program,
and their values persist between calls to any of the kernels in the program.
They are not shared across devices and have distinct storage.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="local-or-local"><a class="anchor" href="#local-or-local"></a>6.7.2. <code>__local</code> (or <code>local</code>)</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>__local</code> or <code>local</code> address space name is used to describe variables that
are allocated in local memory and shared by all work-items in a work-group.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_func</span><span class="p">(...)</span>
<span class="p">{</span>
<span class="nx">local</span> <span class="kt">float</span> <span class="n">a</span><span class="p">;</span> <span class="c1">// A single float allocated</span>
<span class="c1">// in the local address space</span>
<span class="nx">local</span> <span class="kt">float</span> <span class="n">b</span><span class="p">[</span><span class="mi">10</span><span class="p">];</span> <span class="c1">// An array of 10 floats</span>
<span class="c1">// allocated in the local address space</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Variables allocated in the <code>__local</code> address space inside a kernel
function are allocated for each work-group executing the kernel and exist
only for the lifetime of the work-group executing the kernel.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="constant-or-constant"><a class="anchor" href="#constant-or-constant"></a>6.7.3. <code>__constant</code> (or <code>constant</code>)</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>__constant</code> or <code>constant</code> address space name is used to describe
read-only variables that are accessible globally. They may
be declared in program scope or in the outermost kernel scope or inside
functions with a <code>static</code> or <code>extern</code> storage class specifier. Such variables
can be accessed by all work-items or by different kernels during the program execution.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Each argument to a kernel that is a pointer to the <code>__constant</code> address
space is counted separately towards the maximum number of such arguments,
defined as the value of the <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>MAX_<wbr>CONSTANT_<wbr>ARGS</code> device query</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>It is illegal to write to a variable in the constant address space and will
result in a compilation error.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">constant</span> <span class="kt">int</span> <span class="n">a</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span> <span class="c1">// int allocated in the constant address space</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">k1</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">buf</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">buf</span><span class="p">[</span><span class="n">a</span><span class="p">]</span> <span class="o">=</span> <span class="p">...;</span> <span class="c1">// OK. All work items access element with index 3.</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">k2</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">buf</span><span class="p">)</span>
<span class="p">{</span>
<span class="o">*</span><span class="n">buf</span> <span class="o">=</span> <span class="n">a</span><span class="p">;</span> <span class="c1">// OK. All work items store value 3.</span>
<span class="n">a</span> <span class="o">=</span> <span class="mi">42</span><span class="p">;</span> <span class="c1">// Error. a is in constant memory.</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Implementations are not required to aggregate these declarations into the
fewest number of constant arguments. This behavior is implementation-defined.</p>
</div>
<div class="paragraph">
<p>Thus portable code must conservatively assume that each variable declared
inside a function or in program scope allocated in the <code>__constant</code>
address space counts as a separate constant argument.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="private-or-private"><a class="anchor" href="#private-or-private"></a>6.7.4. <code>__private</code> (or <code>private</code>)</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The private address space is a memory segment that can only be accessed by one
work item. Variables that are not shareable among work items are allocated in
the private address space, and it is the default address space for most
variables, in particular variables with automatic storage duration.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">foo</span><span class="p">(...)</span>
<span class="p">{</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="n">i</span><span class="p">;</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="the-generic-address-space"><a class="anchor" href="#the-generic-address-space"></a>6.7.5. The Generic Address Space</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The generic address space requires support for either OpenCL C 2.0, or OpenCL C
3.0 or newer with the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature.
It can be used with pointer types and it represents a placeholder for any of the
named address spaces - <code>global</code>, <code>local</code> or <code>private</code>. It signals that a pointer
points to an object in one of these concrete named address spaces. The exact
address space resolution can occur dynamically during the kernel execution.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="n">a</span><span class="p">)</span>
<span class="p">{</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="n">b</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="n">c</span><span class="p">;</span>
<span class="kt">int</span><span class="o">*</span> <span class="n">p</span> <span class="o">=</span> <span class="n">a</span> <span class="o">?</span> <span class="o">&amp;</span><span class="n">b</span> <span class="o">:</span> <span class="o">&amp;</span><span class="n">c</span><span class="p">;</span> <span class="c1">// p points to the local or private address space.</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_usage_for_declaration_scopes_and_variable_types"><a class="anchor" href="#_usage_for_declaration_scopes_and_variable_types"></a>6.7.6. Usage for Declaration Scopes and Variable Types</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>This section describes use of address space qualifiers with respect to
declaration scopes or variable types.</p>
</div>
<div class="paragraph">
<p>Local variables inside functions can be qualified by the private address space
qualifier.</p>
</div>
<div class="paragraph">
<p>Variables declared in the outermost compound statement inside the body of the
kernel function can be qualified by the local or constant address spaces.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_func</span><span class="p">(...)</span>
<span class="p">{</span>
<span class="nx">private</span> <span class="kt">float</span> <span class="n">a</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="nx">local</span> <span class="kt">float</span> <span class="n">b</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="k">if</span> <span class="p">(...)</span>
<span class="p">{</span>
<span class="c1">// Example of variable in __local address space but not</span>
<span class="c1">// declared at __kernel function scope.</span>
<span class="nx">local</span> <span class="kt">float</span> <span class="n">c</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="p">}</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Program scope variables or variables with a <code>extern</code> or <code>static</code> storage class
specifier:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Must be qualified by <code>__constant</code> prior to OpenCL C 2.0, or for OpenCL C 3.0
or newer without <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature.</p>
</li>
<li>
<p>Can be qualified by either <code>__constant</code> or <code>__global</code> for OpenCL C 2.0, or
OpenCL C 3.0 or newer with <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code>
feature.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_program_scope_global_variables feature macro.</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="n">foo</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="n">baz</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="nx">global</span> <span class="kt">uchar</span> <span class="n">buf</span><span class="p">[</span><span class="mi">512</span><span class="p">];</span> <span class="c1">// OK.</span>
<span class="k">static</span> <span class="nx">global</span> <span class="kt">int</span> <span class="n">bat</span><span class="p">;</span> <span class="c1">// OK. Internal linkage.</span>
<span class="k">extern</span> <span class="nx">constant</span> <span class="kt">int</span> <span class="n">foo</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="kt">void</span> <span class="nf">func</span><span class="p">(...)</span>
<span class="p">{</span>
<span class="nx">constant</span> <span class="k">static</span> <span class="kt">int</span> <span class="n">foo</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="nx">global</span> <span class="k">extern</span> <span class="kt">int</span> <span class="n">foo</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="p">}</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="nx">global</span> <span class="n">ptr</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="o">*</span><span class="nx">global</span> <span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">baz</span><span class="p">;</span> <span class="c1">// Error, baz is in the global address space.</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="nx">constant</span> <span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">baz</span><span class="p">;</span> <span class="c1">// OK.</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Kernel function arguments declared to be a pointer or an array of a type
must point to one of the named address spaces <code>__global</code>, <code>__local</code> or
<code>__constant</code>.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"> <span class="c1">// OK.</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_kernel</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="c1">// Error, ptr must point to the global, local, or constant address space.</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_kernel</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_initialization"><a class="anchor" href="#_initialization"></a>6.7.7. Initialization</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>Program scope and <code>static</code> variables in the <code>__global</code> address space are zero
initialized by default. A constant expression may be given as an initializer.</p>
</div>
<div class="paragraph">
<p>Variables allocated in the <code>__local</code> address space inside a kernel function
cannot be initialized.</p>
</div>
<div class="paragraph">
<p>Variables allocated in the <code>__constant</code> address space are required to be initialized
and the values used to initialize these variables must be a compile time constant.</p>
</div>
<div class="paragraph">
<p>Private address space objects are not initialized by default; any initializer is
allowed to be given.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">global</span> <span class="kt">int</span> <span class="n">a</span> <span class="o">=</span> <span class="mi">12</span><span class="p">;</span> <span class="c1">// Initialization is allowed.</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="n">b</span><span class="p">;</span> <span class="c1">// Zero initialized.</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="n">c</span> <span class="o">=</span> <span class="mi">12</span><span class="p">;</span> <span class="c1">// Initializer is a compile time constant.</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="n">d</span><span class="p">;</span> <span class="c1">// Error. No initializer provided.</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_func</span><span class="p">(...)</span>
<span class="p">{</span>
<span class="nx">local</span> <span class="kt">float</span> <span class="n">e</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="c1">// Error. Initializer is not allowed.</span>
<span class="nx">local</span> <span class="kt">float</span> <span class="n">f</span><span class="p">;</span>
<span class="n">f</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="c1">// Allowed</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="n">g</span><span class="p">;</span> <span class="c1">// Uninitialized.</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="n">h</span> <span class="o">=</span> <span class="n">g</span><span class="p">;</span> <span class="c1">// Error. Initializer is not a constant expression.</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="addr-spaces-inference"><a class="anchor" href="#addr-spaces-inference"></a>6.7.8. Inference</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>Address space qualifiers are not required in many cases. If they are not
specified explicitly the default address space will be inferred depending
on the declaration scope and the object type.</p>
</div>
<div class="paragraph">
<p>There is no syntax to provide address space in the source for some situations,
therefore only the default address space is applicable.</p>
</div>
<div class="paragraph">
<p>For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature, the address space for a
variable at program scope or a <code>static</code> or <code>extern</code> variable inside a function
are inferred to be <code>__global</code>.</p>
</div>
<div class="paragraph">
<p>If the generic address space is supported, pointers that are declared without
pointing to a named address space point to the generic address space.</p>
</div>
<div class="paragraph">
<p>All string literal storage shall be in the <code>__constant</code> address space.</p>
</div>
<div class="paragraph">
<p>For all other cases that are not listed above the address space is inferred to
<code>__private</code>. This includes:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>All function arguments as well as return values are in the private address
space.</p>
</li>
<li>
<p>Pointers that are declared without pointing to a named address space point
to the <code>__private</code> address space if the generic address space is not
supported.</p>
</li>
<li>
<p>Variables inside a function not declared with an address space qualifier
are inferred to be in the private address space.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_program_scope_global_variables feature macro.</span>
<span class="kt">int</span> <span class="n">foo</span><span class="p">;</span> <span class="c1">// Inferred to be in the global address space.</span>
<span class="k">static</span> <span class="kt">int</span> <span class="n">foo</span><span class="p">;</span> <span class="c1">// Inferred to be in the global address space.</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span> <span class="c1">// ptr is inferred to be in the global address space.</span>
<span class="c1">// ptr points to a location in (1) the generic address</span>
<span class="c1">// space for OpenCL C 2.0, or OpenCL C 3.0 or newer with</span>
<span class="c1">// the __opencl_c_generic_address_space feature, or</span>
<span class="c1">// in (2) the private address space otherwise.</span>
<span class="kt">int</span> <span class="o">*</span><span class="nx">global</span> <span class="n">ptr</span><span class="p">;</span> <span class="c1">// ptr is declared to be in the global address space.</span>
<span class="c1">// ptr points to a location in (1) the generic address</span>
<span class="c1">// space for OpenCL C 2.0, or OpenCL C 3.0 or newer with</span>
<span class="c1">// __opencl_c_generic_address_space feature, or</span>
<span class="c1">// in (2) the private address space otherwise.</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span> <span class="o">=</span>
<span class="s">"Hello"</span><span class="p">;</span> <span class="c1">// string literal is in constant address space.</span>
<span class="kt">void</span> <span class="nf">func</span><span class="p">(</span><span class="kt">int</span> <span class="n">param</span><span class="p">)</span> <span class="c1">// param is allocated in the private address space.</span>
<span class="p">{</span>
<span class="kt">int</span> <span class="n">foo</span><span class="p">;</span> <span class="c1">// foo is allocated in the private address space.</span>
<span class="k">static</span> <span class="kt">int</span> <span class="n">foo</span><span class="p">;</span> <span class="c1">// foo is allocated in the global address space.</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span> <span class="c1">// ptr is allocated in the private address space.</span>
<span class="c1">// ptr points to a location in (1) the generic address</span>
<span class="c1">// space for OpenCL C 2.0, or OpenCL C 3.0 or newer with</span>
<span class="c1">// __opencl_c_generic_address_space feature, or</span>
<span class="c1">// in (2) the private address space otherwise.</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Qualifiers must be explicitly specified for:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Program scope variables or variables inside functions with a <code>static</code> or
<code>extern</code> type specifier prior to OpenCL C 2.0, or for OpenCL C 3.0 or newer
without <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature.</p>
</li>
<li>
<p>Pointers used as arguments to kernel functions (the address space pointed
to must be specified explicitly).</p>
</li>
</ul>
</div>
</td>
</tr>
</table>
</div>
<table id="table-addr-spaces-summary" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 8. Address space behavior</caption>
<colgroup>
<col style="width: 14.2857%;">
<col style="width: 28.5714%;">
<col style="width: 28.5714%;">
<col style="width: 28.5715%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Address Space</th>
<th class="tableblock halign-left valign-top">Supported Usage</th>
<th class="tableblock halign-left valign-top">Initialization</th>
<th class="tableblock halign-left valign-top">Inference</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__global</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Program scope variables, for OpenCL C 2.0, or
OpenCL C 3.0 or newer with the <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature,</p>
<p class="tableblock"> <code>static</code> or <code>extern</code> local variables, for OpenCL C 2.0, or
OpenCL C 3.0 or newer with the <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature,</p>
<p class="tableblock"> Pointers.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional constant initializers, 0-initialized by default.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Program scope variables, for OpenCL C 2.0, or
OpenCL C 3.0 or newer with the <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature.</p>
<p class="tableblock"> <code>static</code> or <code>extern</code> local variables, for OpenCL C 2.0, or
OpenCL C 3.0 or newer with the <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__private</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Local scope variables,</p>
<p class="tableblock"> Function arguments and return types,</p>
<p class="tableblock"> Pointers.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional initializers, otherwise no default initialization.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Local scope variables,</p>
<p class="tableblock"> Function arguments and return types,</p>
<p class="tableblock"> Pointers in which the address space they point to is not given explicitly,
prior to OpenCL C 2.0, or for OpenCL C 3.0 or newer without the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__constant</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Program scope variables,</p>
<p class="tableblock"> Kernel scope variables,</p>
<p class="tableblock"> String literals,</p>
<p class="tableblock"> Pointers.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Mandatory initialization with a compile time constant.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String literals.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>__local</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Kernel scope variables,</p>
<p class="tableblock"> Pointers.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Not supported.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Not supported.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Generic</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Pointers, for OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Not applicable.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Pointers in which the address space they point to is not given explicitly,
prior to OpenCL C 2.0, or for OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="addr-spaces-conversions"><a class="anchor" href="#addr-spaces-conversions"></a>6.7.9. Address Space Conversions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>OpenCL implements the address space nesting model for pointers from
<a href="#embedded-c-spec">Embedded C, section 5.1.3</a> as follows:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In OpenCL the named address spaces <code>__global</code>, <code>__local</code>,
<code>__constant</code> and <code>__private</code> are disjoint.</p>
</li>
<li>
<p>The named address spaces <code>__global</code>, <code>__local</code>, and <code>__private</code>
are subsets of the unnamed generic address space.</p>
</li>
<li>
<p>The unnamed generic address space does not overlap the named <code>__constant</code>
address space; the named <code>__constant</code> address space is not in the generic
address space.</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The OpenCL definition of the generic address space is different than the
definition in section 5 of the <a href="#embedded-c-spec">Embedded C Specification</a>. In
OpenCL C, no objects can be allocated in this address space. It can only be used
with pointer types, where a pointer pointing to a location in the generic
address space can be used for objects allocated in any of the concrete named
address spaces <code>private</code>, <code>local</code>, or <code>global</code>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Following section 5.3 of the <a href="#embedded-c-spec">Embedded C Specification</a>, it
is only allowed to convert pointers implicitly, i.e. in assignments, function
parameters, operations, if the original pointer points to an object qualified by
an address space enclosed into the address space pointed by the destination
pointer.</p>
</div>
<div class="paragraph">
<p>In contrast to the <a href="#embedded-c-spec">Embedded C Specification</a>, explicitly
converting i.e. casting between pointers to non-overlapping address spaces is
illegal in OpenCL.</p>
</div>
<div class="paragraph">
<p>Considering the above, the following applies to conversions of pointers pointing
to different address spaces:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A pointer that points to the <code>global</code>, <code>local</code> or <code>private</code> address
space can be implicitly converted to a pointer to the unnamed generic
address space but not vice-versa.</p>
</li>
<li>
<p>Pointer casts can be used to cast a pointer that points to the <code>global</code>,
<code>local</code> or <code>private</code> space to the unnamed generic address space and
vice-versa.</p>
</li>
<li>
<p>A pointer that points to the <code>constant</code> address space cannot be cast or
implicitly converted to the generic address space.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="paragraph">
<p>This is the canonical example.
In this example, function <code>foo</code> is declared with an argument that is a
pointer with the unnamed generic address space address space qualifier.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">)</span>
<span class="p">{</span>
<span class="o">*</span><span class="n">a</span> <span class="o">=</span> <span class="o">*</span><span class="n">a</span> <span class="o">+</span> <span class="mi">2</span><span class="p">;</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">k1</span><span class="p">(</span><span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="n">foo</span><span class="p">(</span><span class="n">a</span><span class="p">);</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">k2</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="n">foo</span><span class="p">(</span><span class="n">a</span><span class="p">);</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>In the example below, <code>var</code> is a pointer to the unnamed generic address space.
A pointer to the <code>global</code> or <code>local</code> address space may be assigned to <code>var</code>
depending on the result of a conditional expression.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">bar</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">g</span><span class="p">,</span> <span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">l</span><span class="p">)</span>
<span class="p">{</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">var</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">is_even</span><span class="p">(</span><span class="fm">get_global_id</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span>
<span class="n">var</span> <span class="o">=</span> <span class="n">g</span><span class="p">;</span>
<span class="k">else</span>
<span class="n">var</span> <span class="o">=</span> <span class="n">l</span><span class="p">;</span>
<span class="o">*</span><span class="n">var</span> <span class="o">=</span> <span class="mi">42</span><span class="p">;</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>In the example below, the same pointer to the unnamed generic address
space is used to point to objects allocated in different named address spaces.
A pointer to the unnamed generic address space may point to
objects in the <code>global</code>, <code>local</code>, and <code>private</code> address spaces,
but it is not legal for a pointer to the unnamed generic address to
point to an object in the <code>constant</code> address space.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="n">g</span><span class="p">;</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">g</span><span class="p">;</span> <span class="c1">// legal</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="n">l</span><span class="p">;</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">l</span><span class="p">;</span> <span class="c1">// legal</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="n">p</span><span class="p">;</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">p</span><span class="p">;</span> <span class="c1">// legal</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="n">c</span><span class="p">;</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">c</span><span class="p">;</span> <span class="c1">// illegal</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>In the example below, pointers to named address spaces are assigned to
a pointer to the unnamed generic address space.
It is legal to assign a pointer to the <code>global</code>, <code>local</code>, and <code>private</code>
address spaces to a pointer to the unnamed generic address space without
an explicit cast.
It is not legal to assign a pointer to the <code>constant</code> address space to
a pointer to the unnamed generic address space.
It is also not legal to assign a pointer to the unnamed generic address
space to a pointer to a named address space without a cast.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">gp</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lp</span><span class="p">;</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="o">*</span><span class="n">pp</span><span class="p">;</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="o">*</span><span class="n">cp</span><span class="p">;</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">p</span><span class="p">;</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">gp</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">lp</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">pp</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">cp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="c1">// it is illegal to convert from a generic pointer</span>
<span class="c1">// to an explicit address space pointer without a cast:</span>
<span class="n">gp</span> <span class="o">=</span> <span class="n">p</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">lp</span> <span class="o">=</span> <span class="n">p</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">pp</span> <span class="o">=</span> <span class="n">p</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">cp</span> <span class="o">=</span> <span class="n">p</span><span class="p">;</span> <span class="c1">// Error.</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The example below illustrates the implicit conversion between named address
spaces.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">gp</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lp</span><span class="p">;</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="o">*</span><span class="n">pp</span><span class="p">;</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="o">*</span><span class="n">cp</span><span class="p">;</span>
<span class="c1">// it is illegal to convert pointers pointing to different</span>
<span class="c1">// named address spaces.</span>
<span class="n">gp</span> <span class="o">=</span> <span class="n">lp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">gp</span> <span class="o">=</span> <span class="n">pp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">gp</span> <span class="o">=</span> <span class="n">cp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">lp</span> <span class="o">=</span> <span class="n">gp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">lp</span> <span class="o">=</span> <span class="n">pp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">lp</span> <span class="o">=</span> <span class="n">cp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">pp</span> <span class="o">=</span> <span class="n">lp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">pp</span> <span class="o">=</span> <span class="n">gp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">pp</span> <span class="o">=</span> <span class="n">cp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">cp</span> <span class="o">=</span> <span class="n">lp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">cp</span> <span class="o">=</span> <span class="n">pp</span><span class="p">;</span> <span class="c1">// Error.</span>
<span class="n">cp</span> <span class="o">=</span> <span class="n">gp</span><span class="p">;</span> <span class="c1">// Error.</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The example below demonstrates explicit conversions for pointers pointing to
different address spaces.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">gp</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lp</span><span class="p">;</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="o">*</span><span class="n">pp</span><span class="p">;</span>
<span class="nx">constant</span> <span class="kt">int</span> <span class="o">*</span><span class="n">cp</span><span class="p">;</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">p</span><span class="p">;</span>
<span class="n">gp</span> <span class="o">=</span> <span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="p">)</span><span class="n">lp</span><span class="p">;</span> <span class="c1">// illegal to cast between named address spaces</span>
<span class="n">p</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span> <span class="o">*</span><span class="p">)</span><span class="n">gp</span><span class="p">;</span> <span class="c1">// legal to cast from global to generic</span>
<span class="n">gp</span> <span class="o">=</span> <span class="p">(</span><span class="nx">global</span> <span class="kt">int</span><span class="o">*</span><span class="p">)</span><span class="n">p</span><span class="p">;</span> <span class="c1">// legal to cast from generic to global</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>For nested pointers, implicit conversions between address spaces are disallowed.
Explicitly casting between different address spaces in nested pointers is
allowed but the use of such pointers can lead to incorrect behavior such as
accessing invalid memory locations.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">mykernel</span><span class="p">(...)</span>
<span class="p">{</span>
<span class="c1">// ll is a pointer to a pointer in the local address space,</span>
<span class="c1">// which points to an integer in the local address space</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="nx">local</span> <span class="o">*</span><span class="n">ll</span><span class="p">;</span>
<span class="c1">// gl is a pointer to a pointer in the local address space,</span>
<span class="c1">// which points to an integer in the global address space</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="nx">local</span> <span class="o">*</span><span class="n">gl</span><span class="p">;</span>
<span class="c1">// nl is a pointer to a pointer in the local address space,</span>
<span class="c1">// which points to an integer via the unnamed generic address space</span>
<span class="kt">int</span> <span class="o">*</span><span class="nx">local</span> <span class="o">*</span> <span class="n">nl</span><span class="p">;</span>
<span class="n">ll</span> <span class="o">=</span> <span class="n">gl</span><span class="p">;</span> <span class="c1">// Error, cannot convert address spaces implicitly</span>
<span class="c1">// for nested pointers.</span>
<span class="n">ll</span> <span class="o">=</span> <span class="n">nl</span><span class="p">;</span> <span class="c1">// Error, cannot convert address spaces implicitly</span>
<span class="c1">// for nested pointers.</span>
<span class="n">ll</span> <span class="o">=</span> <span class="p">(</span><span class="nx">local</span> <span class="kt">int</span><span class="o">*</span> <span class="nx">local</span><span class="o">*</span><span class="p">)</span><span class="n">gl</span><span class="p">;</span> <span class="c1">// OK to convert explicitly,</span>
<span class="c1">// but uses of 'll' can result in</span>
<span class="c1">// in ill-formed program.</span>
<span class="n">ll</span> <span class="o">=</span> <span class="p">(</span><span class="nx">local</span> <span class="kt">int</span><span class="o">*</span> <span class="nx">local</span><span class="o">*</span><span class="p">)</span><span class="n">nl</span><span class="p">;</span> <span class="c1">// OK to convert explicitly,</span>
<span class="c1">// but uses of 'll' can result in</span>
<span class="c1">// in ill-formed program.</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Various clarifications and examples illustrating how changes to ISO/IEC
9899:1999 detailed in <a href="#embedded-c-spec">Embedded C, section 5.3</a> apply
to OpenCL C with the generic address space.</p>
</div>
<div class="paragraph">
<p><strong>Clause 6.2.5 - Types</strong>:</p>
</div>
<div class="paragraph">
<p>If address space qualifier on type T is omitted refer to
<a href="#addr-spaces-inference">Address Space Inference</a>.</p>
</div>
<div class="paragraph">
<p><strong>Clause 6.3.2.3 - Pointers</strong></p>
</div>
<div class="paragraph">
<p>Conversions between disjoint address spaces are disallowed in OpenCL,
refer to <a href="#addr-spaces-conversions">Address Space Conversions</a>.</p>
</div>
<div class="paragraph">
<p><strong>Clause 6.5.8 - Relational operators</strong>:</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">test1</span><span class="p">()</span>
<span class="p">{</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="n">arr</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span> <span class="p">};</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">p</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">arr</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">q</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">arr</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="c1">// q implicitly converted to the generic address space</span>
<span class="c1">// since the generic address space encloses the global</span>
<span class="c1">// address space</span>
<span class="k">if</span> <span class="p">(</span><span class="n">q</span> <span class="o">&gt;=</span> <span class="n">p</span><span class="p">)</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"true</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
<span class="c1">// q implicitly converted to the generic address space</span>
<span class="c1">// since the generic address space encloses the global</span>
<span class="c1">// address space</span>
<span class="k">if</span> <span class="p">(</span><span class="n">p</span> <span class="o">&lt;=</span> <span class="n">q</span><span class="p">)</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"true</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Clause 6.5.9 - Equality operators</strong>:</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="n">lval</span> <span class="o">=</span> <span class="n">SOME_VAL</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">lval</span><span class="p">;</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="n">gval</span> <span class="o">=</span> <span class="n">SOME_OTHER_VAL</span><span class="p">;</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">gptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">gval</span><span class="p">;</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="n">lptr</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">ptr</span> <span class="o">==</span> <span class="n">gptr</span><span class="p">)</span> <span class="c1">// legal</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="n">ptr</span> <span class="o">==</span> <span class="n">lptr</span><span class="p">)</span> <span class="c1">// legal</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="n">lptr</span> <span class="o">==</span> <span class="n">gptr</span><span class="p">)</span> <span class="c1">// illegal, compiler error</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Consider the following example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="kt">bool</span> <span class="nf">callee</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span><span class="n">p1</span><span class="p">,</span> <span class="kt">int</span> <span class="o">*</span><span class="n">p2</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="n">p1</span> <span class="o">==</span> <span class="n">p2</span><span class="p">)</span>
<span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
<span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">caller</span><span class="p">()</span>
<span class="p">{</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">gptr</span> <span class="o">=</span> <span class="mh">0xdeadbeef</span><span class="p">;</span>
<span class="nx">private</span> <span class="kt">int</span> <span class="o">*</span><span class="n">pptr</span> <span class="o">=</span> <span class="mh">0xdeadbeef</span><span class="p">;</span>
<span class="c1">// behavior of callee is undefined</span>
<span class="kt">bool</span> <span class="n">b</span> <span class="o">=</span> <span class="n">callee</span><span class="p">(</span><span class="n">gptr</span><span class="p">,</span> <span class="n">pptr</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The behavior of callee is undefined as gptr and pptr are in different
address spaces.
The example above would have the same undefined behavior if the equality
operator is replaced with a relational operator.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lptr</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">gptr</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">ptr</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span> <span class="c1">// legal</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="n">ptr</span> <span class="o">==</span> <span class="n">lptr</span><span class="p">)</span> <span class="c1">// legal</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="n">lptr</span> <span class="o">==</span> <span class="n">gptr</span><span class="p">)</span> <span class="c1">// compile-time error</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="n">lptr</span><span class="p">;</span> <span class="c1">// legal</span>
<span class="n">intptr</span> <span class="n">l</span> <span class="o">=</span> <span class="p">(</span><span class="kt">intptr_t</span><span class="p">)</span><span class="n">lptr</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">l</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="c1">// legal</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="n">l</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span> <span class="c1">// legal</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Clause 6.5.15 - Conditional operator</strong>:</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">test1</span><span class="p">()</span>
<span class="p">{</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="n">arr</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span> <span class="p">};</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">p</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">arr</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">q</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">arr</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">r</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">val</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="c1">// legal. 2nd and 3rd operands are in address spaces</span>
<span class="c1">// that overlap</span>
<span class="n">val</span> <span class="o">=</span> <span class="p">(</span><span class="n">q</span> <span class="o">&gt;=</span> <span class="n">p</span><span class="p">)</span> <span class="o">?</span> <span class="n">q</span> <span class="o">:</span> <span class="n">p</span><span class="p">;</span>
<span class="c1">// compiler error. 2nd and 3rd operands are in disjoint</span>
<span class="c1">// address spaces</span>
<span class="n">val</span> <span class="o">=</span> <span class="p">(</span><span class="n">q</span> <span class="o">&gt;=</span> <span class="n">p</span><span class="p">)</span> <span class="o">?</span> <span class="n">q</span> <span class="o">:</span> <span class="n">r</span><span class="p">;</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Clause 6.5.16.1 - Simple assignment</strong>:</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Note: these examples assume OpenCL C 2.0 or the</span>
<span class="c1">// __opencl_c_generic_address_space feature support.</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">f</span><span class="p">()</span>
<span class="p">{</span>
<span class="kt">int</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lptr</span><span class="p">;</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">gptr</span><span class="p">;</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="n">val</span> <span class="o">=</span> <span class="mi">55</span><span class="p">;</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">val</span><span class="p">;</span> <span class="c1">// legal: implicit cast to generic, then assign</span>
<span class="n">lptr</span> <span class="o">=</span> <span class="n">ptr</span><span class="p">;</span> <span class="c1">// illegal: no implicit cast from</span>
<span class="c1">// generic to local</span>
<span class="n">lptr</span> <span class="o">=</span> <span class="n">gptr</span><span class="p">;</span> <span class="c1">// illegal: no implicit cast from</span>
<span class="c1">// global to local</span>
<span class="n">ptr</span> <span class="o">=</span> <span class="n">gptr</span><span class="p">;</span> <span class="c1">// legal: implicit cast from global to generic,</span>
<span class="c1">// then assign</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Clause 6.7.3 - Type qualifiers</strong></p>
</div>
<div class="paragraph">
<p>The type of an object with automatic storage duration are in private address
space and therefore can be qualified with <code>private</code>/<code>__private</code>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="access-qualifiers"><a class="anchor" href="#access-qualifiers"></a>6.8. Access Qualifiers</h3>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>Image objects specified as arguments to a kernel can be declared to be
read-only or write-only.</p>
</div>
<div class="paragraph">
<p>For OpenCL C 2.0, or with the <code>__opencl_c_<wbr>read_<wbr>write_<wbr>images</code> feature,
image objects specified as arguments to a kernel can additionally be
declared to be read-write.</p>
</div>
<div class="paragraph">
<p>The <code>__read_only</code> (or <code>read_only</code>) access qualifier specifies that the
image object is only being read by a kernel or function.
The <code>__write_only</code> (or <code>write_only</code>) access qualifier specifies that the
image object is only being written to by a kernel or function.
The <code>__read_write</code> (or <code>read_write</code>) access qualifier specifies that the
image object may be both read from or written to by a kernel or function.</p>
</div>
<div class="paragraph">
<p>The default access qualifier is <code>read_only</code>, if no access qualifier is declared.</p>
</div>
<div class="paragraph">
<p>In the following example</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">foo</span> <span class="p">(</span><span class="nx">read_only</span> <span class="kt">image2d_t</span> <span class="n">imageA</span><span class="p">,</span>
<span class="nx">write_only</span> <span class="kt">image2d_t</span> <span class="n">imageB</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>imageA</code> is a read-only 2D image object, and <code>imageB</code> is a write-only 2D image
object.</p>
</div>
<div class="paragraph">
<p>The sampler-less read image and write image built-ins can be used with image
declared with the <code>__read_write</code> (or <code>read_write</code>) qualifier.
Calls to built-ins that read from an image using a sampler for images
declared with the <code>__read_write</code> (or <code>read_write</code>) qualifier will be a
compilation error.</p>
</div>
<div class="paragraph">
<p>Pipe objects specified as arguments to a kernel also use these access
qualifiers.
See the <a href="#pipe-functions">detailed description on how these access qualifiers
can be used with pipes</a>.</p>
</div>
<div class="paragraph">
<p>The <code>__read_only</code>, <code>__write_only</code>, <code>__read_write</code>, <code>read_only</code>,
<code>write_only</code> and <code>read_write</code> names are reserved for use as access
qualifiers and shall not be used otherwise.</p>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="function-qualifiers"><a class="anchor" href="#function-qualifiers"></a>6.9. Function Qualifiers</h3>
<div class="sect3">
<h4 id="kernel-or-kernel"><a class="anchor" href="#kernel-or-kernel"></a>6.9.1. <code>__kernel</code> (or <code>kernel</code>)</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>__kernel</code> (or <code>kernel</code>) qualifier declares a function to be a kernel
that can be executed by an application on an OpenCL device(s).
The following rules apply to functions that are declared with this
qualifier:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>It can be executed on the device only</p>
</li>
<li>
<p>It can be called by the host</p>
</li>
<li>
<p>It is just a regular function call if a <code>__kernel</code> function is called
by another kernel function.</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Kernel functions with variables declared inside the function with the
<code>__local</code> or <code>local</code> qualifier can be called by the host using appropriate
APIs such as <strong>clEnqueueNDRangeKernel</strong>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <code>__kernel</code> and <code>kernel</code> names are reserved for use as functions
qualifiers and shall not be used otherwise.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="optional-attribute-qualifiers"><a class="anchor" href="#optional-attribute-qualifiers"></a>6.9.2. Optional Attribute Qualifiers</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>__kernel</code> qualifier can be used with the keyword <em>attribute</em> to
declare additional information about the kernel function as described below.</p>
</div>
<div class="paragraph">
<p>The optional <code>__attribute__((vec_type_hint(&lt;type&gt;)))</code>
<sup class="footnote">[<a id="_footnoteref_36" class="footnote" href="#_footnotedef_36" title="View footnote.">36</a>]</sup> is a hint to the compiler and is intended to be a
representation of the computational <em>width</em> of the <code>__kernel</code>, and should
serve as the basis for calculating processor bandwidth utilization when the
compiler is looking to autovectorize the code.
In the <code>__attribute__((vec_type_hint(&lt;type&gt;)))</code> qualifier &lt;type&gt; is one of
the built-in vector types listed in <a href="#table-builtin-vector-types">Built-in Vector Data Types</a> or the
constituent scalar element types.
If <code>vec_type_hint (&lt;type&gt;)</code> is not specified, the kernel is assumed to have
the <code>__attribute__((vec_type_hint(int)))</code> qualifier.</p>
</div>
<div class="paragraph">
<p>For example, where the developer specified a width of <code>float4</code>, the compiler
should assume that the computation usually uses up to 4 lanes of a <code>float</code>
vector, and would decide to merge work-items or possibly even separate one
work-item into many threads to better match the hardware capabilities.
A conforming implementation is not required to autovectorize code, but shall
support the hint.
A compiler may autovectorize, even if no hint is provided.
If an implementation merges N work-items into one thread, it is responsible
for correctly handling cases where the number of <code>global</code> or <code>local</code>
work-items in any dimension modulo N is not zero.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// autovectorize assuming float4 as the</span>
<span class="c1">// basic computation width</span>
<span class="nx">__kernel</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">vec_type_hint</span><span class="p">(</span><span class="kt">float4</span><span class="p">)))</span>
<span class="kt">void</span> <span class="n">foo</span><span class="p">(</span> <span class="nx">__global</span> <span class="kt">float4</span> <span class="o">*</span><span class="n">p</span> <span class="p">)</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}</span>
<span class="c1">// autovectorize assuming double as the</span>
<span class="c1">// basic computation width</span>
<span class="nx">__kernel</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">vec_type_hint</span><span class="p">(</span><span class="kt">double</span><span class="p">)))</span>
<span class="kt">void</span> <span class="n">foo</span><span class="p">(</span> <span class="nx">__global</span> <span class="kt">float4</span> <span class="o">*</span><span class="n">p</span> <span class="p">)</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}</span>
<span class="c1">// autovectorize assuming int (default)</span>
<span class="c1">// as the basic computation width</span>
<span class="nx">__kernel</span>
<span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span> <span class="nx">__global</span> <span class="kt">float4</span> <span class="o">*</span><span class="n">p</span> <span class="p">)</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>If for example, a <code>__kernel</code> function is declared with</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><code>__attribute__(( vec_type_hint (float4)))</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>(meaning that most operations in the <code>__kernel</code> function are explicitly
vectorized using <code>float4</code>) and the kernel is running using Intel<sup>®</sup>
Advanced Vector Instructions (Intel<sup>®</sup> AVX) which implements a
8-float-wide vector unit, the autovectorizer might choose to merge two
work-items to one thread, running a second work-item in the high half of the
256-bit AVX register.</p>
</div>
<div class="paragraph">
<p>As another example, a Power4 machine has two scalar double-precision
floating-point units with an 6-cycle deep pipe.
An autovectorizer for the Power4 machine might choose to interleave six
kernels declared with the <code>__attribute__(( vec_type_hint (double2)))</code>
qualifier into one hardware thread, to ensure that there is always 12-way
parallelism available to saturate the FPUs.
It might also choose to merge 4 or 8 work-items (or some other number) if it
concludes that these are better choices, due to resource utilization
concerns or some preference for divisibility by 2.</p>
</div>
<div class="paragraph">
<p>The optional <code>__attribute__((work_group_size_hint(X, Y, Z)))</code> is a hint to
the compiler and is intended to specify the work-group size that may be used
i.e. value most likely to be specified by the <em>local_work_size</em> argument to
<strong>clEnqueueNDRangeKernel</strong>.
For example, the <code>__attribute__((work_group_size_hint(1, 1, 1)))</code> is a
hint to the compiler that the kernel will most likely be executed with a
work-group size of 1.</p>
</div>
<div class="paragraph">
<p>The optional <code>__attribute__((reqd_work_group_size(X, Y, Z)))</code> is the
work-group size that must be used as the <em>local_work_size</em> argument to
<strong>clEnqueueNDRangeKernel</strong>.
This allows the compiler to optimize the generated code appropriately for
this kernel.</p>
</div>
<div class="paragraph">
<p>If <code>Z</code> is one, the <em>work_dim</em> argument to <strong>clEnqueueNDRangeKernel</strong> can be 2
or 3.
If <code>Y</code> and <code>Z</code> are one, the <em>work_dim</em> argument to <strong>clEnqueueNDRangeKernel</strong>
can be 1, 2 or 3.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="storage-class-specifiers"><a class="anchor" href="#storage-class-specifiers"></a>6.10. Storage-Class Specifiers</h3>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>typedef</code> storage-class specifier is supported.
The <code>extern</code> and <code>static</code> storage-class specifiers are supported but
<a href="#unified-spec">require</a> support for OpenCL C 1.2 or newer.
The <code>auto</code> and <code>register</code> storage-class specifiers are not supported.</p>
</div>
<div class="paragraph">
<p>The <code>extern</code> storage-class specifier can only be used for functions (kernel
and non-kernel functions) and <code>global</code> variables declared in program scope
or variables declared inside a function (kernel and non-kernel functions).
The <code>static</code> storage-class specifier can only be used for non-kernel
functions, <code>global</code> variables declared in program scope and variables inside
a function declared in the <code>global</code> or <code>constant</code> address space.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">extern</span> <span class="nx">constant</span> <span class="kt">float4</span> <span class="n">noise_table</span><span class="p">[</span><span class="mi">256</span><span class="p">];</span>
<span class="k">static</span> <span class="nx">constant</span> <span class="kt">float4</span> <span class="n">color_table</span><span class="p">[</span><span class="mi">256</span><span class="p">];</span>
<span class="k">extern</span> <span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_foo</span><span class="p">(</span><span class="kt">image2d_t</span> <span class="n">img</span><span class="p">);</span>
<span class="k">extern</span> <span class="kt">void</span> <span class="nf">my_bar</span><span class="p">(</span><span class="nx">global</span> <span class="kt">float</span> <span class="o">*</span><span class="n">a</span><span class="p">);</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_func</span><span class="p">(</span><span class="kt">image2d_t</span> <span class="n">img</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">float</span> <span class="o">*</span><span class="n">a</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">extern</span> <span class="nx">constant</span> <span class="kt">float4</span> <span class="n">a</span><span class="p">;</span>
<span class="k">static</span> <span class="nx">constant</span> <span class="kt">float4</span> <span class="n">b</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">);</span> <span class="c1">// OK.</span>
<span class="k">static</span> <span class="kt">float</span> <span class="n">c</span><span class="p">;</span> <span class="c1">// Error: No implicit address space</span>
<span class="nx">global</span> <span class="kt">int</span> <span class="n">hurl</span><span class="p">;</span> <span class="c1">// Error: Must be static</span>
<span class="p">...</span>
<span class="n">my_foo</span><span class="p">(</span><span class="n">img</span><span class="p">);</span>
<span class="p">...</span>
<span class="n">my_bar</span><span class="p">(</span><span class="n">a</span><span class="p">);</span>
<span class="p">...</span>
<span class="k">while</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">static</span> <span class="nx">global</span> <span class="kt">int</span> <span class="n">inside</span><span class="p">;</span> <span class="c1">// OK.</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="restrictions"><a class="anchor" href="#restrictions"></a>6.11. Restrictions</h3>
<div class="openblock">
<div class="content">
<div class="olist loweralpha">
<ol class="loweralpha" type="a">
<li>
<p>The use of pointers is somewhat restricted.
The following rules apply:</p>
<div class="ulist">
<ul>
<li>
<p>Arguments to kernel functions declared in a program that are pointers
must be declared with the <code>__global</code>, <code>__constant</code> or <code>__local</code>
qualifier.</p>
</li>
<li>
<p>A pointer declared with the <code>__constant</code> qualifier can only be
assigned to a pointer declared with the <code>__constant</code> qualifier
respectively.</p>
</li>
<li>
<p>Pointers to functions are not allowed.</p>
</li>
<li>
<p>Arguments to kernel functions in a program cannot be
declared as a pointer to a pointer(s).
Variables inside a function or arguments to non-kernel functions in a
program can be declared as a pointer to a pointer(s).
This restriction only applies to OpenCL C 1.2 or below.</p>
</li>
</ul>
</div>
</li>
<li>
<p>An image type (<code>image2d_t</code>, <code>image3d_t</code>, <code>image2d_array_t</code>, <code>image1d_t</code>,
<code>image1d_buffer_t</code> or <code>image1d_array_t</code>) can only be used as the type of
a function argument.
An image function argument cannot be modified.
Elements of an image can only be accessed using the built-in
<a href="#image-read-and-write-functions">image read and write functions</a>.</p>
<div class="paragraph">
<p>An image type cannot be used to declare a variable, a structure or union
field, an array of images, a pointer to an image, or the return type of a
function.
An image type cannot be used with the <code>__global</code>, <code>__private</code>,
<code>__local</code> and <code>__constant</code> address space qualifiers.</p>
</div>
<div class="paragraph">
<p>The sampler type (<code>sampler_t</code>) can only be used as the type of a function
argument or a variable declared in the program scope or the outermost scope
of a kernel function.
The behavior of a sampler variable declared in a non-outermost scope of a
kernel function is implementation-defined.
A sampler argument or variable cannot be modified.</p>
</div>
<div class="paragraph">
<p>The sampler type cannot be used to declare a structure or union field, an
array of samplers, a pointer to a sampler, or the return type of a function.
The sampler type cannot be used with the <code>__local</code> and <code>__global</code>
address space qualifiers.</p>
</div>
</li>
<li>
<p><a id="restrictions-bitfield"></a> Bit-field struct members are currently not
supported.</p>
</li>
<li>
<p><a id="restrictions-variable-length"></a> Variable length arrays and structures
with flexible (or unsized) arrays are not supported.</p>
</li>
<li>
<p>Variadic functions are not supported, with the exception of <code>printf</code> and
<code>enqueue_kernel</code>.</p>
</li>
<li>
<p>Variadic macros are not supported.
This restriction only applies to OpenCL C 2.0 or below.</p>
</li>
<li>
<p>If a list of parameters in a function declaration is empty, the function
takes no arguments. This is due to the above restriction on variadic
functions.</p>
</li>
<li>
<p>Unless defined in the OpenCL specification, the library functions,
macros, types, and constants defined in the C99 standard headers
<code>assert.h</code>, <code>ctype.h</code>, <code>complex.h</code>, <code>errno.h</code>, <code>fenv.h</code>, <code>float.h</code>,
<code>inttypes.h</code>, <code>limits.h</code>, <code>locale.h</code>, <code>setjmp.h</code>, <code>signal.h</code>,
<code>stdarg.h</code>, <code>stdio.h</code>, <code>stdlib.h</code>, <code>string.h</code>, <code>tgmath.h</code>, <code>time.h</code>,
<code>wchar.h</code> and <code>wctype.h</code> are not available and cannot be included by a
program.</p>
</li>
<li>
<p>The <code>auto</code> and <code>register</code> storage-class specifiers are not supported.</p>
</li>
<li>
<p>Predefined identifiers are not supported.
This restriction only applies to OpenCL C 1.1 or below.</p>
</li>
<li>
<p>Recursion is not supported.</p>
</li>
<li>
<p>The return type of a kernel function must be <code>void</code>.</p>
</li>
<li>
<p>Arguments to kernel functions in a program cannot be declared with the
built-in scalar types <code>bool</code>, <code>size_t</code>, <code>ptrdiff_t</code>, <code>intptr_t</code>, and
<code>uintptr_t</code> or a struct and/or union that contain fields declared to be
one of these built-in scalar types.</p>
</li>
<li>
<p><code>half</code> is not supported as <code>half</code> can be used as a storage format
<sup class="footnote">[<a id="_footnoteref_37" class="footnote" href="#_footnotedef_37" title="View footnote.">37</a>]</sup> only and is not a data type on which
floating-point arithmetic can be performed.</p>
</li>
<li>
<p>Whether or not irreducible control flow is illegal is implementation
defined.</p>
</li>
<li>
<p>The following restriction only applies to
OpenCL C 1.0, and only if the <code>cl_khr_<wbr>byte_<wbr>addressable_<wbr>store</code>
extension macro is not supported:<br>
Built-in types that are less than 32-bits in size, i.e.
<code>char</code>, <code>uchar</code>, <code>char2</code>, <code>uchar2</code>, <code>short</code>, <code>ushort</code>, and <code>half</code>, have
the following restriction:</p>
<div class="ulist">
<ul>
<li>
<p>Writes to a pointer (or arrays) of type <code>char</code>,
<code>uchar</code>, <code>char2</code>, <code>uchar2</code>, <code>short</code>, <code>ushort</code>, and <code>half</code> or to
elements of a struct that are of type <code>char</code>, <code>uchar</code>, <code>char2</code>,
<code>uchar2</code>, <code>short</code> and <code>ushort</code> are not supported.
Refer to <em>section 9.9</em> for additional information.</p>
<div class="paragraph">
<p>The kernel example below shows what memory operations are not supported on
built-in types less than 32-bits in size.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">do_proc</span> <span class="p">(</span><span class="nx">__global</span> <span class="kt">char</span> <span class="o">*</span><span class="n">pA</span><span class="p">,</span> <span class="kt">short</span> <span class="n">b</span><span class="p">,</span>
<span class="nx">__global</span> <span class="kt">short</span> <span class="o">*</span><span class="n">pB</span><span class="p">)</span>
<span class="p">{</span>
<span class="kt">char</span> <span class="n">x</span><span class="p">[</span><span class="mi">100</span><span class="p">];</span>
<span class="nx">__private</span> <span class="kt">char</span> <span class="o">*</span><span class="n">px</span> <span class="o">=</span> <span class="n">x</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">id</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="fm">get_global_id</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="kt">short</span> <span class="n">f</span><span class="p">;</span>
<span class="n">f</span> <span class="o">=</span> <span class="n">pB</span><span class="p">[</span><span class="n">id</span><span class="p">]</span> <span class="o">+</span> <span class="n">b</span><span class="p">;</span> <span class="c1">// is allowed</span>
<span class="n">px</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">pA</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span> <span class="c1">// error. px cannot be written.</span>
<span class="n">pB</span><span class="p">[</span><span class="n">id</span><span class="p">]</span> <span class="o">=</span> <span class="n">b</span><span class="p">;</span> <span class="c1">// error. pB cannot be written</span>
<span class="p">}</span></code></pre>
</div>
</div>
</li>
</ul>
</div>
</li>
<li>
<p>The type qualifiers <code>const</code>, <code>restrict</code> and <code>volatile</code> as defined by the
C99 specification are supported.
These qualifiers cannot be used with <code>image2d_t</code>, <code>image3d_t</code>,
<code>image2d_array_t</code>, <code>image2d_depth_t</code>, <code>image2d_array_depth_t</code>,
<code>image1d_t</code>, <code>image1d_buffer_t</code> and <code>image1d_array_t</code> types.
Types other than pointer types shall not use the <code>restrict</code> qualifier.</p>
</li>
<li>
<p>The event type (<code>event_t</code>) cannot be used as the type of a kernel
function argument.
The event type cannot be used to declare a program scope variable.
The event type cannot be used to declare a structure or union field.
The event type cannot be used with the <code>__local</code>, <code>__constant</code> and
<code>__global</code> address space qualifiers.</p>
</li>
<li>
<p>The <code>clk_event_t</code>, <code>ndrange_t</code> and <code>reserve_id_t</code> types cannot be used
as arguments to kernel functions that get enqueued from the host.
The <code>clk_event_t</code> and <code>reserve_id_t</code> types cannot be declared in program
scope.</p>
</li>
<li>
<p>Kernels enqueued by the host must continue to have their arguments that
are a pointer to a type declared to point to a named address space.</p>
</li>
<li>
<p>A function in an OpenCL program cannot be called <code>main</code>.</p>
</li>
<li>
<p>Implicit function declaration is not supported.</p>
</li>
<li>
<p>Program scope variables can be defined with any valid OpenCL C data type
except for those in <a href="#table-other-builtin-types">Other Built-in Data Types</a>.
Such program scope variables may be of any user-defined type, or a pointer
to a user-defined type.</p>
<div class="paragraph">
<p>In the presence of shared virtual memory, these pointers or pointer
members should work as expected as long as they are shared virtual memory
pointers and the referenced storage has been mapped appropriately.
Program scope variables can be declared with <code>__constant</code> address space
qualifiers or if <code>__opencl_c_<wbr>program_<wbr>scope_<wbr>global_<wbr>variables</code> feature is
supported with <code>__global</code> address space qualifier.</p>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a id="restrictions-initialize-memory"></a> The following restriction only
applies if the <code>cl_khr_<wbr>initialize_<wbr>memory</code> extension is supported:<br>
If the context is created with <code>CL_CONTEXT_<wbr>MEMORY_<wbr>INITIALIZE_<wbr>KHR</code>,
appropriate memory locations as specified by the bit-field are
initialized with zeroes, prior to the start of execution of any kernel.
The driver chooses when, prior to kernel execution, the initialization of
local and/or private memory is performed.
The only requirement is there should be no values set from outside the
context, which can be read during a kernel execution.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="preprocessor-directives-and-macros"><a class="anchor" href="#preprocessor-directives-and-macros"></a>6.12. Preprocessor Directives and Macros</h3>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The preprocessing directives defined by the C99 specification are supported.</p>
</div>
<div class="paragraph">
<p>The <strong>#pragma</strong> directive is described as:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>#pragma</strong> <em>pp-tokens<sub>opt</sub></em> <em>new-line</em></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>A <strong>#pragma</strong> directive where the preprocessing token <code>OPENCL</code> (used instead
of <strong><code>STDC</code></strong>) does not immediately follow <strong>#pragma</strong> in the directive (prior to
any macro replacement) causes the implementation to behave in an
implementation-defined manner.
The behavior might cause translation to fail or cause the translator or the
resulting program to behave in a non-conforming manner.
Any such <strong>#pragma</strong> that is not recognized by the implementation is ignored.
If the preprocessing token <code>OPENCL</code> does immediately follow <strong>#pragma</strong> in the
directive (prior to any macro replacement), then no macro replacement is
performed on the directive, and the directive shall have one of the
following forms whose meanings are described elsewhere:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// on-off-switch is one of ON, OFF, or DEFAULT</span>
<span class="cp">#pragma OPENCL FP_CONTRACT on-off-switch</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The following predefined macro names are available.</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>__FILE__</code> </dt>
<dd>
<p>The presumed name of the current source file (a character string
literal).</p>
</dd>
<dt class="hdlist1"><code>__LINE__</code> </dt>
<dd>
<p>The presumed line number (within the current source file) of the current
source line (an integer constant).</p>
</dd>
<dt class="hdlist1"><code>__OPENCL_VERSION__</code> </dt>
<dd>
<p>For OpenCL devices with OpenCL version less than or equal to OpenCL 2.0,
substitutes an integer value reflecting the OpenCL version supported by the
device.
This predefined macro is <a href="#unified-spec">deprecated by</a> OpenCL 2.1.
For OpenCL devices with OpenCL version greater than OpenCL 2.0, it must be
defined but may substitute any implementation-defined integer value greater
than 200, reflecting OpenCL 2.0. <sup class="footnote">[<a id="_footnoteref_38" class="footnote" href="#_footnotedef_38" title="View footnote.">38</a>]</sup></p>
</dd>
<dt class="hdlist1"><code>CL_VERSION_1_0</code> </dt>
<dd>
<p>Substitutes the integer 100 reflecting the OpenCL 1.0 version.
<a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p>
</dd>
<dt class="hdlist1"><code>CL_VERSION_1_1</code> </dt>
<dd>
<p>Substitutes the integer 110 reflecting the OpenCL 1.1 version.
<a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p>
</dd>
<dt class="hdlist1"><code>CL_VERSION_1_2</code> </dt>
<dd>
<p>Substitutes the integer 120 reflecting the OpenCL 1.2 version.
<a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p>
</dd>
<dt class="hdlist1"><code>CL_VERSION_2_0</code> </dt>
<dd>
<p>Substitutes the integer 200 reflecting the OpenCL 2.0 version.
<a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p>
</dd>
<dt class="hdlist1"><code>CL_VERSION_3_0</code> </dt>
<dd>
<p>Substitutes the integer 300 reflecting the OpenCL 3.0 version.
<a href="#unified-spec">Requires</a> support for OpenCL C 3.0 or newer.</p>
</dd>
<dt class="hdlist1"><code>CL_VERSION_3_1</code> </dt>
<dd>
<p>Substitutes the integer 301 reflecting the OpenCL 3.1 version.
<a href="#unified-spec">Requires</a> support for OpenCL C 3.1 or newer.</p>
</dd>
<dt class="hdlist1"><code>__OPENCL_C_VERSION__</code> </dt>
<dd>
<p>Substitutes an integer reflecting the OpenCL C version specified by the
<code>-cl-std</code> build option (see <a href="#opencl-spec">OpenCL Specification</a>) to
<strong>clBuildProgram</strong> or <strong>clCompileProgram</strong>.
If the <code>-cl-std</code> build option is not specified, the highest OpenCL C 1.x
language version supported by each device is used as the version of
OpenCL C when compiling the program for each device.
<a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p>
</dd>
<dt class="hdlist1"><code>__ROUNDING_MODE__</code> </dt>
<dd>
<p>Used to determine the current rounding mode and is set to rte.
Only affects the rounding mode of conversions to a float type.
<a href="#unified-spec">Deprecated by</a> OpenCL C 1.1, along with the
<code>cl_khr_<wbr>select_<wbr>fprounding_<wbr>mode</code> extension.</p>
</dd>
<dt class="hdlist1"><code>__ENDIAN_LITTLE__</code> </dt>
<dd>
<p>Used to determine if the OpenCL device is a little endian architecture
or a big endian architecture (an integer constant of 1 if device is
little endian and is undefined otherwise).
Also refer to the value of the <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>ENDIAN_<wbr>LITTLE</code> device query</a>.</p>
</dd>
<dt class="hdlist1"><code>__kernel_exec(X, typen)</code> (and <code>kernel_exec(X, typen)</code>) </dt>
<dd>
<p>is defined as:</p>
</dd>
</dl>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">__kernel</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">work_group_size_hint</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)))</span> \
<span class="n">__attribute__</span><span class="p">((</span><span class="n">vec_type_hint</span><span class="p">(</span><span class="n">typen</span><span class="p">)))</span></code></pre>
</div>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>__IMAGE_SUPPORT__</code> </dt>
<dd>
<p>Used to determine if the OpenCL device supports images.
This is an integer constant of 1 if images are supported and is
undefined otherwise.
Also refer to the value of the <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>IMAGE_<wbr>SUPPORT</code> device query</a> and the <code>__opencl_c_<wbr>images</code>
feature.</p>
</dd>
<dt class="hdlist1"><code>__FAST_RELAXED_MATH__</code> </dt>
<dd>
<p>Used to determine if the <code>-cl-fast-relaxed-math</code> optimization option is
specified in build options given to <strong>clBuildProgram</strong> or
<strong>clCompileProgram</strong>.
This is an integer constant of 1 if the <code>-cl-fast-relaxed-math</code> build
option is specified and is undefined otherwise.</p>
</dd>
</dl>
</div>
<div class="paragraph">
<p>The <code>NULL</code> macro expands to a null pointer constant.
An integer constant expression with the value 0, or such an expression cast
to type <code>void *</code> is called a <em>null pointer constant</em>.
<a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p>
</div>
<div class="paragraph">
<p>The macro names defined by the C99 specification but not currently supported
by OpenCL are reserved for future use.</p>
</div>
<div class="paragraph">
<p>The predefined identifier <code>__func__</code> is available.
<a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p>
</div>
<div class="paragraph">
<p>In OpenCL C 3.0 or newer there are a number of optional predefined macros
indicating optional language features. Such macros are listed in the
<a href="#table-optional-lang-features">optional features in OpenCL C 3.0 or newer table</a>.</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="preprocessor-directives-for-optional-extensions"><a class="anchor" href="#preprocessor-directives-for-optional-extensions"></a>6.12.1. Preprocessor Directives for Optional Extensions</h4>
<div class="paragraph">
<p>The <strong>#pragma OPENCL EXTENSION</strong> directive controls the behavior of the OpenCL
compiler with respect to extensions.
The <strong>#pragma OPENCL EXTENSION</strong> directive is defined as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#pragma OPENCL EXTENSION &lt;extension_name&gt; : &lt;behavior&gt;
#pragma OPENCL EXTENSION all : &lt;behavior&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <em>extension_name</em> is the name of the extension.
The token <strong>all</strong> means that the behavior applies to all extensions supported
by the compiler.
The <em>behavior</em> can be set to one of the following values given by the table
below.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"><strong>behavior</strong></th>
<th class="tableblock halign-left valign-top"><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>enable</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Behave as specified by the extension <em>extension_name</em>.</p>
<p class="tableblock"> Report an error on the <strong><code>#pragma OPENCL EXTENSION</code></strong> if the
<em>extension_name</em> is not supported, or if <strong>all</strong> is specified.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>disable</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Behave (including issuing errors and warnings) as if the extension
<em>extension_name</em> is not part of the language definition.</p>
<p class="tableblock"> If <strong>all</strong> is specified, then behavior must revert back to that of the
non-extended core version of the language being compiled to.</p>
<p class="tableblock"> Warn on the <strong><code>#pragma OPENCL EXTENSION</code></strong> if the extension <em>extension_name</em>
is not supported.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <strong><code>#pragma OPENCL EXTENSION</code></strong> directive is a simple, low-level mechanism
to set the behavior for each extension.
It does not define policies such as which combinations are appropriate;
those must be defined elsewhere.
The order of directives matter in setting the behavior for each extension.
Directives that occur later override those seen earlier.
The <strong>all</strong> variant sets the behavior for all extensions, overriding all
previously issued extension directives, but only if the <em>behavior</em> is set to
<strong>disable</strong>.</p>
</div>
<div class="paragraph">
<p>The initial state of the compiler is as if the directive</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#pragma OPENCL EXTENSION all : disable</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>was issued, telling the compiler that all error and warning reporting must
be done according to this specification, ignoring any extensions.</p>
</div>
<div class="paragraph">
<p>Every extension which affects the OpenCL language semantics, syntax or adds
built-in functions to the language must create a preprocessor <code>#define</code> that
matches the extension name string.
This <code>#define</code> would be available in the language if and only if the
extension is supported on a given implementation.</p>
</div>
<div class="paragraph">
<p>For example, compilers that support the <code>cl_khr_<wbr>3d_<wbr>image_<wbr>writes</code> extension
will add a preprocessor <code>#define</code> called <code>cl_khr_<wbr>3d_<wbr>image_<wbr>writes</code>.
A kernel can now use this preprocessor <code>#define</code> to do something like:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#ifdef cl_khr_3d_image_writes
</span> <span class="c1">// do something using the extension</span>
<span class="cp">#else
</span> <span class="c1">// do something else or #error!</span>
<span class="cp">#endif</span></code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="attribute-qualifiers"><a class="anchor" href="#attribute-qualifiers"></a>6.13. Attribute Qualifiers</h3>
<div class="paragraph">
<p>This section describes the syntax with which <code>__attribute__</code> may be used,
and the constructs to which attribute specifiers bind.</p>
</div>
<div class="paragraph">
<p>An attribute specifier is of the form</p>
</div>
<div class="paragraph">
<p><code>__attribute__ ((_attribute-list_))</code>.</p>
</div>
<div class="paragraph">
<p>An attribute list is defined as:</p>
</div>
<div class="openblock bnf">
<div class="content">
<div class="dlist">
<dl>
<dt class="hdlist1"><em>attribute-list</em> : </dt>
<dd>
<p><em>attribute<sub>opt</sub></em><br>
<em>attribute-list</em> , <em>attribute<sub>opt</sub></em></p>
</dd>
<dt class="hdlist1"><em>attribute</em> : </dt>
<dd>
<p><em>attribute-token</em> <em>attribute-argument-clause<sub>opt</sub></em></p>
</dd>
<dt class="hdlist1"><em>attribute-token</em> : </dt>
<dd>
<p><em>identifier</em></p>
</dd>
<dt class="hdlist1"><em>attribute-argument-clause</em> : </dt>
<dd>
<p>( <em>attribute-argument-list</em> )</p>
</dd>
<dt class="hdlist1"><em>attribute-argument-list</em> : </dt>
<dd>
<p><em>attribute-argument</em><br>
<em>attribute-argument-list</em> , <em>attribute-argument</em></p>
</dd>
<dt class="hdlist1"><em>attribute-argument</em> : </dt>
<dd>
<p><em>assignment-expression</em></p>
</dd>
</dl>
</div>
</div>
</div>
<div class="paragraph">
<p>This syntax is taken directly from GCC but unlike GCC, which allows
attributes to be applied only to functions, types, and variables, OpenCL
attributes can be associated with:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>types;</p>
</li>
<li>
<p>functions;</p>
</li>
<li>
<p>variables;</p>
</li>
<li>
<p>blocks; and</p>
</li>
<li>
<p>control-flow statements.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In general, the rules for how an attribute binds, for a given context, are
non-trivial and the reader is pointed to GCC&#8217;s documentation and Maurer and
Wong&#8217;s paper [See 16.
and 17.
in <em>section 11</em> - <strong>References</strong>] for the details.</p>
</div>
<div class="sect3">
<h4 id="specifying-attributes-of-types"><a class="anchor" href="#specifying-attributes-of-types"></a>6.13.1. Specifying Attributes of Types</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The keyword <code>__attribute__</code> allows you to specify special attributes of
enum, struct and union types when you define such types.
This keyword is followed by an attribute specification inside double
parentheses.
Two attributes are currently defined for types: aligned, and packed.</p>
</div>
<div class="paragraph">
<p>You may specify type attributes in an enum, struct or union type declaration
or definition, or for other types in a <code>typedef</code> declaration.</p>
</div>
<div class="paragraph">
<p>For an enum, struct or union type, you may specify attributes either between
the enum, struct or union tag and the name of the type, or just past the
closing curly brace of the <em>definition</em>.
The former syntax is preferred.</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>aligned (<em>alignment</em>)</code> </dt>
<dd>
<p>This attribute specifies a minimum alignment (in bytes) for variables of the
specified type.</p>
</dd>
</dl>
</div>
</div>
</div>
<div class="paragraph">
<p>For example, the declarations:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">struct</span> <span class="nc">S</span> <span class="p">{</span> <span class="kt">short</span> <span class="n">f</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span> <span class="p">}</span> <span class="n">__attribute__</span> <span class="p">((</span><span class="n">aligned</span> <span class="p">(</span><span class="mi">8</span><span class="p">)));</span>
<span class="k">typedef</span> <span class="kt">int</span> <span class="n">more_aligned_int</span> <span class="nf">__attribute__</span> <span class="p">((</span><span class="n">aligned</span> <span class="p">(</span><span class="mi">8</span><span class="p">)));</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>force the compiler to ensure (as far as it can) that each variable whose
type is <code>struct S</code> or <code>more_aligned_int</code> will be allocated and aligned <em>at
least</em> on a 8-byte boundary.</p>
</div>
<div class="paragraph">
<p>Note that the alignment of any given struct or union type is required by the
ISO C standard to be at least a perfect multiple of the lowest common
multiple of the alignments of all of the members of the struct or union in
question and must also be a power of two.
This means that you <em>can</em> effectively adjust the alignment of a struct or
union type by attaching an aligned attribute to any one of the members of
such a type, but the notation illustrated in the example above is a more
obvious, intuitive, and readable way to request the compiler to adjust the
alignment of an entire struct or union type.</p>
</div>
<div class="paragraph">
<p>As in the preceding example, you can explicitly specify the alignment (in
bytes) that you wish the compiler to use for a given struct or union type.
Alternatively, you can leave out the alignment factor and just ask the
compiler to align a type to the maximum useful alignment for the target
machine you are compiling for.
For example, you could write:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">struct</span> <span class="nc">S</span> <span class="p">{</span> <span class="kt">short</span> <span class="n">f</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span> <span class="p">}</span> <span class="n">__attribute__</span> <span class="p">((</span><span class="n">aligned</span><span class="p">));</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Whenever you leave out the alignment factor in an aligned attribute
specification, the compiler automatically sets the alignment for the type to
the largest alignment which is ever used for any data type on the target
machine you are compiling for.
In the example above, the size of each <code>short</code> is 2 bytes, and therefore the
size of the entire <code>struct S</code> type is 6 bytes.
The smallest power of two which is greater than or equal to that is 8, so
the compiler sets the alignment for the entire <code>struct S</code> type to 8 bytes.</p>
</div>
<div class="paragraph">
<p>Note that the effectiveness of aligned attributes may be limited by inherent
limitations of the OpenCL device and compiler.
For some devices, the OpenCL compiler may only be able to arrange for
variables to be aligned up to a certain maximum alignment.
If the OpenCL compiler is only able to align variables up to a maximum of 8
byte alignment, then specifying <code>aligned(16)</code> in an <code>__attribute__</code> will
still only provide you with 8 byte alignment.
See your platform-specific documentation for further information.</p>
</div>
<div class="paragraph">
<p>The aligned attribute can only increase the alignment; but you can decrease
it by specifying packed as well.
See below.</p>
</div>
<div class="openblock">
<div class="content">
<div class="dlist">
<dl>
<dt class="hdlist1"><code>packed</code> </dt>
<dd>
<p>This attribute, attached to struct or union type definition, specifies that
each member of the structure or union is placed to minimize the memory
required.
When attached to an enum definition, it indicates that the smallest integral
type should be used.</p>
</dd>
</dl>
</div>
</div>
</div>
<div class="paragraph">
<p>Specifying this attribute for struct and union types is equivalent to
specifying the packed attribute on each of the structure or union members.</p>
</div>
<div class="paragraph">
<p>In the following example, the members of <code>my_packed_struct</code> are packed
closely together, but the internal layout of its <code>s</code> member is not packed.
To do that, struct <code>my_unpacked_struct</code> would need to be packed, too.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">struct</span> <span class="nc">my_unpacked_struct</span>
<span class="p">{</span>
<span class="kt">char</span> <span class="n">c</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">i</span><span class="p">;</span>
<span class="p">};</span>
<span class="k">struct</span> <span class="nc">__attribute__</span> <span class="p">((</span><span class="n">packed</span><span class="p">))</span> <span class="n">my_packed_struct</span>
<span class="p">{</span>
<span class="kt">char</span> <span class="n">c</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">i</span><span class="p">;</span>
<span class="k">struct</span> <span class="nc">my_unpacked_struct</span> <span class="n">s</span><span class="p">;</span>
<span class="p">};</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>You may only specify this attribute on the definition of a enum, struct or
union, not on a <code>typedef</code> which does not also define the enumerated type,
structure or union.</p>
</div>
<div class="openblock">
<div class="content">
</div>
</div>
</div>
<div class="sect3">
<h4 id="specifying-attributes-of-functions"><a class="anchor" href="#specifying-attributes-of-functions"></a>6.13.2. Specifying Attributes of Functions</h4>
<div class="paragraph">
<p>See <a href="#function-qualifiers">Function Qualifiers</a> for the function attribute
qualifiers currently supported.</p>
</div>
</div>
<div class="sect3">
<h4 id="specifying-attributes-of-variables"><a class="anchor" href="#specifying-attributes-of-variables"></a>6.13.3. Specifying Attributes of Variables</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The keyword <code>__attribute__</code> allows you to specify special attributes of
variables or structure fields.
This keyword is followed by an attribute specification inside double
parentheses.
The following attribute qualifiers are currently defined:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><code>aligned (<em>alignment</em>)</code> </dt>
<dd>
<p>This attribute specifies a minimum alignment for the variable or structure
field, measured in bytes.
For example, the declaration:</p>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">x</span> <span class="n">__attribute__</span> <span class="p">((</span><span class="n">aligned</span> <span class="p">(</span><span class="mi">16</span><span class="p">)))</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>causes the compiler to allocate the global variable <code>x</code> on a 16-byte
boundary.
The alignment value specified must be a power of two.</p>
</div>
<div class="paragraph">
<p>You can also specify the alignment of structure fields.
For example, to create a double-word aligned <code>int</code> pair, you could write:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">struct</span> <span class="nc">foo</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="n">__attribute__</span> <span class="p">((</span><span class="n">aligned</span> <span class="p">(</span><span class="mi">8</span><span class="p">)));</span> <span class="p">};</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>This is an alternative to creating a union with a <code>double</code> member that
forces the union to be double-word aligned.</p>
</div>
<div class="paragraph">
<p>As in the preceding examples, you can explicitly specify the alignment (in
bytes) that you wish the compiler to use for a given variable or structure
field.
Alternatively, you can leave out the alignment factor and just ask the
compiler to align a variable or field to the maximum useful alignment for
the target machine you are compiling for.
For example, you could write:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">short</span> <span class="n">array</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="n">__attribute__</span> <span class="p">((</span><span class="n">aligned</span><span class="p">));</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Whenever you leave out the alignment factor in an aligned attribute
specification, the OpenCL compiler automatically sets the alignment for the
declared variable or field to the largest alignment which is ever used for
any data type on the target device you are compiling for.</p>
</div>
<div class="paragraph">
<p>When used on a struct, or struct member, the aligned attribute can only
increase the alignment; in order to decrease it, the packed attribute must
be specified as well.
When used as part of a <code>typedef</code>, the aligned attribute can both increase
and decrease alignment, and specifying the packed attribute will generate a
warning.</p>
</div>
<div class="paragraph">
<p>Note that the effectiveness of aligned attributes may be limited by inherent
limitations of the OpenCL device and compiler.
For some devices, the OpenCL compiler may only be able to arrange for
variables to be aligned up to a certain maximum alignment.
If the OpenCL compiler is only able to align variables up to a maximum of 8
byte alignment, then specifying <code>aligned(16)</code> in an <code>__attribute__</code> will
still only provide you with 8 byte alignment.
See your platform-specific documentation for further information.</p>
</div>
</dd>
<dt class="hdlist1"><code>packed</code> </dt>
<dd>
<p>The packed attribute specifies that a variable or structure field should
have the smallest possible alignment&#8201;&#8212;&#8201;one byte for a variable, unless you
specify a larger value with the aligned attribute.</p>
<div class="paragraph">
<p>Here is a structure in which the field <code>x</code> is packed, so that it immediately
follows a:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">struct</span> <span class="nc">foo</span>
<span class="p">{</span>
<span class="kt">char</span> <span class="n">a</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="n">__attribute__</span> <span class="p">((</span><span class="n">packed</span><span class="p">));</span>
<span class="p">};</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>An attribute list placed at the beginning of a user-defined type applies to
the variable of that type and not the type, while attributes following the
type body apply to the type.</p>
</div>
<div class="paragraph">
<p>For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cm">/* a has alignment of 128 */</span>
<span class="n">__attribute__</span><span class="p">((</span><span class="n">aligned</span><span class="p">(</span><span class="mi">128</span><span class="p">)))</span> <span class="k">struct</span> <span class="nc">A</span> <span class="p">{</span><span class="kt">int</span> <span class="n">i</span><span class="p">;}</span> <span class="n">a</span><span class="p">;</span>
<span class="cm">/* b has alignment of 16 */</span>
<span class="n">__attribute__</span><span class="p">((</span><span class="n">aligned</span><span class="p">(</span><span class="mi">16</span><span class="p">)))</span> <span class="k">struct</span> <span class="nc">B</span> <span class="p">{</span><span class="kt">double</span> <span class="n">d</span><span class="p">;}</span>
<span class="n">__attribute__</span><span class="p">((</span><span class="n">aligned</span><span class="p">(</span><span class="mi">32</span><span class="p">)))</span> <span class="n">b</span> <span class="p">;</span>
<span class="k">struct</span> <span class="nc">A</span> <span class="n">a1</span><span class="p">;</span> <span class="cm">/* a1 has alignment of 4 */</span>
<span class="k">struct</span> <span class="nc">B</span> <span class="n">b1</span><span class="p">;</span> <span class="cm">/* b1 has alignment of 32 */</span></code></pre>
</div>
</div>
</dd>
<dt class="hdlist1"><code>endian (<em>endiantype</em>)</code> </dt>
<dd>
<p>The endian attribute determines the byte ordering of a variable.
<em>endiantype</em> can be set to <code>host</code> indicating the variable uses the
endianness of the host processor or can be set to <code>device</code> indicating the
variable uses the endianness of the device on which the kernel will be
executed.
The default is <code>device</code>.</p>
<div class="paragraph">
<p>For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">global</span> <span class="kt">float4</span> <span class="o">*</span><span class="n">p</span> <span class="nf">__attribute__</span> <span class="p">((</span><span class="n">endian</span><span class="p">(</span><span class="n">host</span><span class="p">)));</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>specifies that data stored in memory pointed to by p will be in the host
endian format.</p>
</div>
<div class="paragraph">
<p>The endian attribute can only be applied to pointer types that are in the
<code>global</code> or <code>constant</code> address space.
The endian attribute cannot be used for variables that are not a pointer
type.
The endian attribute value for both pointers must be the same when one
pointer is assigned to another.</p>
</div>
</dd>
<dt class="hdlist1"><code>nosvm</code> </dt>
<dd>
<p>The <code>nosvm</code> attribute can be used with a pointer variable to inform the
compiler that the pointer does not refer to a shared virtual memory region.
<a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p>
</dd>
</dl>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The <code>nosvm</code> attribute is deprecated, and the compiler can ignore it.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="specifying-attributes-of-blocks-and-control-flow-statements"><a class="anchor" href="#specifying-attributes-of-blocks-and-control-flow-statements"></a>6.13.4. Specifying Attributes of Blocks and Control-Flow-Statements</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>For basic blocks and control-flow-statements the attribute is placed before
the structure in question, for example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">__attribute__</span><span class="p">((</span><span class="n">attr1</span><span class="p">))</span> <span class="p">{...}</span>
<span class="k">for</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">attr2</span><span class="p">))</span> <span class="p">(...)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">attr3</span><span class="p">))</span> <span class="p">{...}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Here <code>attr1</code> applies to the block in braces and <code>attr2</code> and <code>attr3</code> apply to
the loop&#8217;s control construct and body, respectively.</p>
</div>
<div class="paragraph">
<p>No attribute qualifiers for blocks and control-flow-statements are currently
defined.</p>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="specifying-attribute-for-unrolling-loops"><a class="anchor" href="#specifying-attribute-for-unrolling-loops"></a>6.13.5. Specifying Attribute for Unrolling Loops</h4>
<div class="openblock">
<div class="content">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for OpenCL C 2.0 or newer.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <code>__attribute__((opencl_unroll_hint))</code> and
<code>__attribute__((opencl_unroll_hint(n)))</code> attribute qualifiers can be used
to specify that a loop (for, while and do loops) can be unrolled.
This attribute qualifier can be used to specify full unrolling or partial
unrolling by a specified amount.
This is a compiler hint and the compiler may ignore this directive.</p>
</div>
<div class="paragraph">
<p>n is the loop unrolling factor and must be a positive integral compile time
constant expression.
An unroll factor of 1 disables unrolling.
If n is not specified, the compiler determines the unrolling factor for the
loop.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The <code>__attribute__((opencl_unroll_hint(n)))</code> attribute qualifier must
appear immediately before the loop to be affected.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">__attribute__</span><span class="p">((</span><span class="n">opencl_unroll_hint</span><span class="p">(</span><span class="mi">2</span><span class="p">)))</span>
<span class="k">while</span> <span class="p">(</span><span class="o">*</span><span class="n">s</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span>
<span class="o">*</span><span class="n">p</span><span class="o">++</span> <span class="o">=</span> <span class="o">*</span><span class="n">s</span><span class="o">++</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The tells the compiler to unroll the above while loop by a factor of 2.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">__attribute__</span><span class="p">((</span><span class="n">opencl_unroll_hint</span><span class="p">))</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="n">i</span><span class="o">&lt;</span><span class="mi">2</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>In the example above, the compiler will determine how much to unroll the
loop.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">__attribute__</span><span class="p">((</span><span class="n">opencl_unroll_hint</span><span class="p">(</span><span class="mi">1</span><span class="p">)))</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="n">i</span><span class="o">&lt;</span><span class="mi">32</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The above is an example where the loop should not be unrolled.</p>
</div>
<div class="paragraph">
<p>Below are some examples of invalid usage of
<code>__attribute__((opencl_unroll_hint(n)))</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">__attribute__</span><span class="p">((</span><span class="n">opencl_unroll_hint</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)))</span>
<span class="k">while</span> <span class="p">(...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The above example is an invalid usage of the loop unroll factor as the loop
unroll factor is negative.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">__attribute__</span><span class="p">((</span><span class="n">opencl_unroll_hint</span><span class="p">))</span>
<span class="k">if</span> <span class="p">(...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The above example is invalid because the unroll attribute qualifier is used
on a non-loop construct</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_kernel</span><span class="p">(</span> <span class="p">...</span> <span class="p">)</span>
<span class="p">{</span>
<span class="kt">int</span> <span class="n">x</span><span class="p">;</span>
<span class="n">__attribute__</span><span class="p">((</span><span class="n">opencl_unroll_hint</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="n">i</span><span class="o">&lt;</span><span class="n">x</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The above example is invalid because the loop unroll factor is not a
compile-time constant expression.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="blocks"><a class="anchor" href="#blocks"></a>6.14. Blocks</h3>
<div class="openblock">
<div class="content">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and the
<code>__opencl_c_<wbr>device_<wbr>enqueue</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>This section describes the clang block syntax
<sup class="footnote">[<a id="_footnoteref_39" class="footnote" href="#_footnotedef_39" title="View footnote.">39</a>]</sup>.</p>
</div>
<div class="paragraph">
<p>Like function types, the Block type is a pair consisting of a result value
type and a list of parameter types very similar to a function type.
Blocks are intended to be used much like functions with the key distinction
being that in addition to executable code they also contain various variable
bindings to automatic (stack) or <code>global</code> memory.</p>
</div>
</div>
</div>
<div class="sect3">
<h4 id="declaring-and-using-a-block"><a class="anchor" href="#declaring-and-using-a-block"></a>6.14.1. Declaring and Using a Block</h4>
<div class="paragraph">
<p>You use the ^ operator to declare a Block variable and to indicate the
beginning of a Block literal.
The body of the Block itself is contained within {}, as shown in this
example (as usual with C, ; indicates the end of the statement):</p>
</div>
<div class="paragraph">
<p>The example is explained in the following illustration:</p>
</div>
<div class="paragraph">
<p><span class="image"><img src="data:image/jpg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAUAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAAgICAgICAgICAgMCAgIDBAMCAgMEBQQEBAQEBQYFBQUFBQUGBgcHCAcHBgkJCgoJCQwMDAwMDAwMDAwMDAwMDAEDAwMFBAUJBgYJDQsJCw0PDg4ODg8PDAwMDAwPDwwMDAwMDA8MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgA5AIsAwERAAIRAQMRAf/EAN4AAQACAgMBAQAAAAAAAAAAAAAGBwUIAQMEAgkBAQADAQEBAQAAAAAAAAAAAAABAgMEBQYHEAAABQIEAAcIDAgGDAoIBwABAgMEBQAGERITByFhFNQXVwgxUdEiFZUWGEFxobEyUmIj05RWlpGik1RktCVYgUJjJHY38ILSM1Nzs3W1psZHkkM0RHQ1VYUmZ+KDhGXFNmYocqTERoaHSBEAAgEBBQQGCAUEAgMAAwEAAAECESExEgMEQVGRE2Fx0VIUBYGhscHhIjIWQpJTFQbwcjM08WKi0iOCsiTi/9oADAMBAAIRAxEAPwD9/KAUAoBQCgFAKAUBgLkuSFs+AmbpuR+nFwUA0VfSr9TESpoolExhApQExhHDApSgJjDgAAIiAUBSEfaN6bupluDc+QmLJtF8GeC2fiHasa55KcByKXC/aHI4UcKFEBM2QVIil8A+uYBPQGZL2a+zvlKC2x9jPlAAAM6fQLB4ufD2TruElFDjxmMNAffq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+7EVzegHq19nLqD28+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FPYDkCQVNgEY9gMAADXWBQABAywQNdYFAQIDZBRh9gNsAIUAFiQBFyQBSWYBAAAAAZZsACF2AAJoASN2AAEsECN2AQJkFDpWCwAClmwACnQAAOABE9YwAAAA/wQBAAAAAAD/BAEAAAAAAP8EAQAAAAAA/wQBAAAAAAD/BAEAAAAAAP8EAQAAFPYDkCQVNgEY9gMAADXWBQABAywQNdYFAQIDZBRh9gNsAIUAFiQBFyQBSWYBAAAAAZZsACF2AAJoASN2AAEsECN2AQJkFDpWCwAClmwACnQAAOABE9YwAAAA/wQBAAAAAAD/BAEAAAAAAP8EAQAAAAAA/wQBAAAAAAD/BAEAAAAAAP8EAQAAFPYDkCQVNgE=" alt="block example" title="Block Example"></span></p>
</div>
<div class="paragraph">
<p>Notice that the Block is able to make use of variables from the same scope
in which it was defined.</p>
</div>
<div class="paragraph">
<p>If you declare a Block as a variable, you can then use it just as you would
a function:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span><span class="p">;</span>
<span class="kt">int</span> <span class="p">(</span><span class="o">^</span><span class="n">myBlock</span><span class="p">)(</span><span class="kt">int</span><span class="p">)</span> <span class="o">=</span> <span class="o">^</span><span class="p">(</span><span class="kt">int</span> <span class="n">num</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="n">num</span> <span class="o">*</span> <span class="n">multiplier</span><span class="p">;</span>
<span class="p">};</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"%d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">myBlock</span><span class="p">(</span><span class="mi">3</span><span class="p">));</span>
<span class="c1">// prints 21</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="declaring-a-block-reference"><a class="anchor" href="#declaring-a-block-reference"></a>6.14.2. Declaring a Block Reference</h4>
<div class="paragraph">
<p>Block variables hold references to Blocks.
You declare them using syntax similar to that you use to declare a pointer
to a function, except that you use ^ instead of *.
The Block type fully interoperates with the rest of the C type system.
The following are valid Block variable declarations:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="p">(</span><span class="o">^</span><span class="n">blockReturningVoidWithVoidArgument</span><span class="p">)(</span><span class="kt">void</span><span class="p">);</span>
<span class="kt">int</span> <span class="p">(</span><span class="o">^</span><span class="n">blockReturningIntWithIntAndCharArguments</span><span class="p">)(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">char</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>A Block that takes no arguments must specify <code>void</code> in the argument list.
A Block reference may not be dereferenced via the pointer dereference
operation *, and thus a Block&#8217;s size may not be computed at compile time.</p>
</div>
<div class="paragraph">
<p>Blocks are designed to be fully type safe by giving the compiler a full set
of metadata to use to validate use of Blocks, parameters passed to blocks,
and assignment of the return value.</p>
</div>
<div class="paragraph">
<p>You can also create types for Blocks&#8201;&#8212;&#8201;doing so is generally considered to
be best practice when you use a block with a given signature in multiple
places:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">typedef</span> <span class="nf">float</span> <span class="p">(</span><span class="o">^</span><span class="n">MyBlockType</span><span class="p">)(</span><span class="kt">float</span><span class="p">,</span> <span class="kt">float</span><span class="p">);</span>
<span class="n">MyBlockType</span> <span class="n">myFirstBlock</span> <span class="o">=</span> <span class="c1">// ...;</span>
<span class="n">MyBlockType</span> <span class="n">mySecondBlock</span> <span class="o">=</span> <span class="c1">// ...;</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="block-literal-expressions"><a class="anchor" href="#block-literal-expressions"></a>6.14.3. Block Literal Expressions</h4>
<div class="paragraph">
<p>A Block literal expression produces a reference to a Block.
It is introduced by the use of the <strong>^</strong> token as a unary operator.</p>
</div>
<div class="openblock bnf">
<div class="content">
<div class="dlist">
<dl>
<dt class="hdlist1">Block_literal_expression : </dt>
<dd>
<p>^ <em>block_decl</em> <em>compound_statement_body</em></p>
</dd>
<dt class="hdlist1"><em>block_decl</em> : </dt>
<dd>
<p>empty<br>
<em>parameter_list</em><br>
<em>type_expression</em></p>
</dd>
</dl>
</div>
</div>
</div>
<div class="paragraph">
<p>where <em>type_expression</em> is extended to allow ^ as a Block reference where *
is allowed as a function reference.</p>
</div>
<div class="paragraph">
<p>The following Block literal:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="o">^</span> <span class="kt">void</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span> <span class="fm">printf</span><span class="p">(</span><span class="s">"hello world**</span><span class="se">\n</span><span class="s">**"</span><span class="p">);</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>produces a reference to a Block with no arguments with no return value.</p>
</div>
<div class="paragraph">
<p>The return type is optional and is inferred from the return statements.
If the return statements return a value, they all must return a value of the
same type.
If there is no value returned the inferred type of the Block is <code>void</code>;
otherwise it is the type of the return statement value.
If the return type is omitted and the argument list is <code>( void )</code>, the <code>(
void )</code> argument list may also be omitted.</p>
</div>
<div class="paragraph">
<p>So:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="o">^</span> <span class="p">(</span> <span class="kt">void</span> <span class="p">)</span> <span class="p">{</span> <span class="fm">printf</span><span class="p">(</span><span class="s">"hello world**</span><span class="se">\n</span><span class="s">**"</span><span class="p">);</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>and:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="o">^</span> <span class="p">{</span> <span class="fm">printf</span><span class="p">(</span><span class="s">"hello world**</span><span class="se">\n</span><span class="s">**"</span><span class="p">);</span> <span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>are exactly equivalent constructs for the same expression.</p>
</div>
<div class="paragraph">
<p>The compound statement body establishes a new lexical scope within that of
its parent.
Variables used within the scope of the compound statement are bound to the
Block in the normal manner with the exception of those in automatic (stack)
storage.
Thus one may access functions and global variables as one would expect, as
well as <code>static</code> local variables.</p>
</div>
<div class="paragraph">
<p>Local automatic (stack) variables referenced within the compound statement
of a Block are imported and captured by the Block as const copies.
The capture (binding) is performed at the time of the Block literal
expression evaluation.</p>
</div>
<div class="paragraph">
<p>The compiler is not required to capture a variable if it can prove that no
references to the variable will actually be evaluated.</p>
</div>
<div class="paragraph">
<p>The lifetime of variables declared in a Block is that of a function..</p>
</div>
<div class="paragraph">
<p>Block literal expressions may occur within Block literal expressions
(nested) and all variables captured by any nested blocks are implicitly also
captured in the scopes of their enclosing Blocks.</p>
</div>
<div class="paragraph">
<p>A Block literal expression may be used as the initialization value for Block
variables at global or local <code>static</code> scope.</p>
</div>
<div class="paragraph">
<p>You can also declare a Block as a global literal in program scope.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">GlobalInt</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="kt">int</span> <span class="p">(</span><span class="o">^</span><span class="n">getGlobalInt</span><span class="p">)(</span><span class="kt">void</span><span class="p">)</span> <span class="o">=</span> <span class="o">^</span><span class="p">{</span> <span class="k">return</span> <span class="n">GlobalInt</span><span class="p">;</span> <span class="p">};</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="control-flow"><a class="anchor" href="#control-flow"></a>6.14.4. Control Flow</h4>
<div class="paragraph">
<p>The compound statement of a Block is treated much like a function body with
respect to control flow in that continue, break and goto do not escape the
Block.</p>
</div>
</div>
<div class="sect3">
<h4 id="restrictions-1"><a class="anchor" href="#restrictions-1"></a>6.14.5. Restrictions</h4>
<div class="paragraph">
<p>The following Blocks features are currently not supported in OpenCL C.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The <code>__block</code> storage type.</p>
</li>
<li>
<p>The <strong>Block_copy</strong>() and <strong>Block_release</strong>() functions that copy and release
Blocks.</p>
</li>
<li>
<p>Blocks with variadic arguments.</p>
</li>
<li>
<p>Arrays of Blocks.</p>
</li>
<li>
<p>Blocks as structures and union members.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Block literals are assumed to allocate memory at the point of definition and
to be destroyed at the end of the same scope.
To support these behaviors, additional restrictions
<sup class="footnote">[<a id="_footnoteref_40" class="footnote" href="#_footnotedef_40" title="View footnote.">40</a>]</sup> in addition to the above feature
restrictions are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Block variables must be defined and used in a way that allows them to be
statically determinable at build or &#8220;link to executable&#8221; time.
In particular:</p>
<div class="ulist">
<ul>
<li>
<p>Block variables assigned in one scope must be used only with the same
or any nested scope.</p>
</li>
<li>
<p>The <code>extern</code> storage-class specified cannot be used with program scope
block variables.</p>
</li>
<li>
<p>Block variable declarations are implicitly qualified with const.
Therefore all block variables must be initialized at declaration time
and may not be reassigned.</p>
</li>
<li>
<p>A block cannot be a return value or a parameter of a function.</p>
</li>
<li>
<p>Blocks cannot be used as expressions of the ternary selection operator
(<strong>?:</strong>).</p>
</li>
</ul>
</div>
</li>
<li>
<p>The unary operators (<strong>*</strong>) and (<strong>&amp;</strong>) cannot be used with a Block.</p>
</li>
<li>
<p>Pointers to Blocks are not allowed.</p>
</li>
<li>
<p>A Block cannot capture another Block variable declared in the outer
scope (Example 4).</p>
</li>
<li>
<p>Block capture semantics follows regular C argument passing convention,
i.e. arrays are captured by reference (decayed to pointers) and structs
are captured by value (Example 5).</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Some examples that describe legal and illegal issue of Blocks in OpenCL C
are described below.</p>
</div>
<div class="paragraph">
<p>Example 1:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="p">(</span><span class="o">^</span><span class="n">bar</span><span class="p">)(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">int</span><span class="p">))</span>
<span class="p">{</span>
<span class="o">*</span><span class="n">x</span> <span class="o">=</span> <span class="n">bar</span><span class="p">(</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">x</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">kernel</span>
<span class="kt">void</span> <span class="nf">k</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">z</span><span class="p">)</span>
<span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="n">some</span> <span class="n">expression</span><span class="p">)</span>
<span class="n">foo</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">^</span><span class="kt">int</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">){</span><span class="k">return</span> <span class="n">x</span><span class="o">+</span><span class="n">y</span><span class="o">+*</span><span class="n">z</span><span class="p">;});</span> <span class="c1">// legal</span>
<span class="k">else</span>
<span class="nf">foo</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">^</span><span class="kt">int</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">){</span><span class="k">return</span> <span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span><span class="p">)</span><span class="o">-*</span><span class="n">z</span><span class="p">;});</span> <span class="c1">// legal</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Example 2:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span>
<span class="kt">void</span> <span class="nf">k</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">z</span><span class="p">)</span>
<span class="p">{</span>
<span class="kt">int</span> <span class="o">^</span><span class="p">(</span><span class="n">tmp</span><span class="p">)(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">int</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">some</span> <span class="n">expression</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">tmp</span> <span class="o">=</span> <span class="o">^</span><span class="kt">int</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">){</span><span class="k">return</span> <span class="n">x</span><span class="o">+</span><span class="n">y</span><span class="o">+*</span><span class="n">z</span><span class="p">;});</span> <span class="c1">// illegal</span>
<span class="p">}</span>
<span class="o">*</span><span class="n">x</span> <span class="o">=</span> <span class="n">foo</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">tmp</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Example 3:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">GlobalInt</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="kt">int</span> <span class="p">(</span><span class="o">^</span><span class="n">getGlobalInt</span><span class="p">)(</span><span class="kt">void</span><span class="p">)</span> <span class="o">=</span> <span class="o">^</span><span class="p">{</span> <span class="k">return</span> <span class="n">GlobalInt</span><span class="p">;</span> <span class="p">};</span> <span class="c1">// legal</span>
<span class="kt">int</span> <span class="p">(</span><span class="o">^</span><span class="n">getAnotherGlobalInt</span><span class="p">)(</span><span class="kt">void</span><span class="p">);</span> <span class="c1">// illegal</span>
<span class="k">extern</span> <span class="nf">int</span> <span class="p">(</span><span class="o">^</span><span class="n">getExternGlobalInt</span><span class="p">)(</span><span class="kt">void</span><span class="p">);</span> <span class="c1">// illegal</span>
<span class="kt">void</span> <span class="nf">foo</span><span class="p">()</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="n">getGlobalInt</span> <span class="o">=</span> <span class="o">^</span><span class="p">{</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">};</span> <span class="c1">// illegal - cannot assign to</span>
<span class="c1">// a global block variable</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Example 4:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="p">(</span><span class="o">^</span><span class="n">bl0</span><span class="p">)(</span><span class="kt">void</span><span class="p">)</span> <span class="o">=</span> <span class="o">^</span><span class="p">{</span>
<span class="p">...</span>
<span class="p">};</span>
<span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">k</span><span class="p">()</span>
<span class="p">{</span>
<span class="kt">void</span><span class="p">(</span><span class="o">^</span><span class="n">bl1</span><span class="p">)(</span><span class="kt">void</span><span class="p">)</span> <span class="o">=</span> <span class="o">^</span><span class="p">{</span>
<span class="p">...</span>
<span class="p">};</span>
<span class="kt">void</span><span class="p">(</span><span class="o">^</span><span class="n">bl2</span><span class="p">)(</span><span class="kt">void</span><span class="p">)</span> <span class="o">=</span> <span class="o">^</span><span class="p">{</span>
<span class="n">bl0</span><span class="p">();</span> <span class="c1">// legal because bl0 is a global</span>
<span class="c1">// variable available in this scope</span>
<span class="n">bl1</span><span class="p">();</span> <span class="c1">// illegal because bl1 would have to be captured</span>
<span class="p">};</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Example 5:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">struct</span> <span class="nc">v</span> <span class="p">{</span>
<span class="kt">int</span> <span class="n">arr</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
<span class="p">}</span> <span class="n">s</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">};</span>
<span class="kt">void</span> <span class="p">(</span><span class="o">^</span><span class="n">bl1</span><span class="p">)()</span> <span class="o">=</span> <span class="o">^</span><span class="p">(){</span><span class="fm">printf</span><span class="p">(</span><span class="s">"%d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">s</span><span class="p">.</span><span class="n">arr</span><span class="p">[</span><span class="mi">1</span><span class="p">]);};</span>
<span class="c1">// array content copied into captured struct location</span>
<span class="kt">int</span> <span class="n">arr</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">};</span>
<span class="kt">void</span> <span class="p">(</span><span class="o">^</span><span class="n">bl2</span><span class="p">)()</span> <span class="o">=</span> <span class="o">^</span><span class="p">(){</span><span class="fm">printf</span><span class="p">(</span><span class="s">"%d</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">arr</span><span class="p">[</span><span class="mi">1</span><span class="p">]);};</span>
<span class="c1">// array decayed to pointer while captured</span>
<span class="n">s</span><span class="p">.</span><span class="n">arr</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">arr</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mi">8</span><span class="p">;</span>
<span class="n">bl1</span><span class="p">();</span> <span class="c1">// prints - 1</span>
<span class="n">bl2</span><span class="p">();</span> <span class="c1">// prints - 8</span></code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="built-in-functions"><a class="anchor" href="#built-in-functions"></a>6.15. Built-in Functions</h3>
<div class="paragraph">
<p>The OpenCL C programming language provides a rich set of built-in functions
for scalar and vector operations.
Many of these functions are similar to the function names provided in common
C libraries but they support scalar and vector argument types.
Applications should use the built-in functions wherever possible instead of
writing their own version.</p>
</div>
<div class="paragraph">
<p>User defined OpenCL C functions behave per C standard rules for functions as
defined in <a href="#C99-spec">section 6.9.1 of the C99 Specification</a>.
On entry to the function, the size of each variably modified parameter is
evaluated and the value of each argument expression is converted to the type
of the corresponding parameter as per the
<a href="#usual-arithmetic-conversions">usual arithmetic conversion rules</a>.
Built-in functions described in this section behave similarly, except that
in order to avoid ambiguity between multiple forms of the same built-in
function, implicit scalar widening shall not occur.
Note that some built-in functions described in this section do have forms
that operate on mixed scalar and vector types, however.</p>
</div>
<div class="sect3">
<h4 id="work-item-functions"><a class="anchor" href="#work-item-functions"></a>6.15.1. Work-Item Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following table describes the list of built-in work-item functions that
can be used to query the number of dimensions, the global and local work
size specified to <strong>clEnqueueNDRangeKernel</strong>, and the global and local
identifier of each work-item when this kernel is being executed on a device.</p>
</div>
<table id="table-work-item-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 9. Built-in Work-Item Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>get_work_dim</strong>()</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of dimensions in use.
This is the value given to the <em>work_dim</em> argument specified in
<strong>clEnqueueNDRangeKernel</strong>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_global_size</strong>(uint <em>dimindx</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of global work-items specified for dimension
identified by <em>dimindx</em>.
This value is given by the <em>global_work_size</em> argument to
<strong>clEnqueueNDRangeKernel</strong>.</p>
<p class="tableblock"> Valid values of <em>dimindx</em> are 0 to <strong>get_work_dim</strong>() - 1.
For other values of <em>dimindx</em>, <strong>get_global_size</strong>() returns 1.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_global_id</strong>(uint <em>dimindx</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the unique global work-item ID value for dimension identified
by <em>dimindx</em>.
The global work-item ID specifies the work-item ID based on the number
of global work-items specified to execute the kernel.</p>
<p class="tableblock"> Valid values of <em>dimindx</em> are 0 to <strong>get_work_dim</strong>() - 1.
For other values of <em>dimindx</em>, <strong>get_global_id</strong>() returns 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_local_size</strong>(uint <em>dimindx</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of local work-items specified in dimension
identified by <em>dimindx</em>.
This value is at most the value given by the <em>local_work_size</em>
argument to <strong>clEnqueueNDRangeKernel</strong> if <em>local_work_size</em> is not
<code>NULL</code>; otherwise the OpenCL implementation chooses an appropriate
<em>local_work_size</em> value which is returned by this function.
If the kernel is executed with a non-uniform work-group size
<sup class="footnote">[<a id="_footnoteref_41" class="footnote" href="#_footnotedef_41" title="View footnote.">41</a>]</sup>, calls to this built-in from some
work-groups may return different values than calls to this built-in from
other work-groups.</p>
<p class="tableblock"> Valid values of <em>dimindx</em> are 0 to <strong>get_work_dim</strong>() - 1.
For other values of <em>dimindx</em>, <strong>get_local_size</strong>() returns 1.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_enqueued_local_size</strong>(
uint <em>dimindx</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the same value as that returned by <strong>get_local_size</strong>(<em>dimindx</em>)
if the kernel is executed with a uniform work-group size.</p>
<p class="tableblock"> If the kernel is executed with a non-uniform work-group size, returns
the number of local work-items in each of the work-groups that make up
the uniform region of the global range in the dimension identified by
<em>dimindx</em>.
If the <em>local_work_size</em> argument to <strong>clEnqueueNDRangeKernel</strong> is not
<code>NULL</code>, this value will match the value specified in
<em>local_work_size</em>[<em>dimindx</em>].
If <em>local_work_size</em> is <code>NULL</code>, this value will match the local size
that the implementation determined would be most efficient at
implementing the uniform region of the global range.</p>
<p class="tableblock"> Valid values of <em>dimindx</em> are 0 to <strong>get_work_dim</strong>() - 1.
For other values of <em>dimindx</em>, <strong>get_enqueued_local_size</strong>() returns 1.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_local_id</strong>(uint <em>dimindx</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the unique local work-item ID, i.e. a work-item within a
specific work-group for dimension identified by <em>dimindx</em>.</p>
<p class="tableblock"> Valid values of <em>dimindx</em> are 0 to <strong>get_work_dim</strong>() - 1.
For other values of <em>dimindx</em>, <strong>get_local_id</strong>() returns 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_num_groups</strong>(uint <em>dimindx</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of work-groups that will execute a kernel for
dimension identified by <em>dimindx</em>.</p>
<p class="tableblock"> Valid values of <em>dimindx</em> are 0 to <strong>get_work_dim</strong>() - 1.
For other values of <em>dimindx</em>, <strong>get_num_groups</strong>() returns 1.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_group_id</strong>(uint <em>dimindx</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>get_group_id</strong> returns the work-group ID which is a number from 0 ..
<strong>get_num_groups</strong>(<em>dimindx</em>) - 1.</p>
<p class="tableblock"> Valid values of <em>dimindx</em> are 0 to <strong>get_work_dim</strong>() - 1.
For other values, <strong>get_group_id</strong>() returns 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_global_offset</strong>(uint <em>dimindx</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>get_global_offset</strong> returns the offset values specified in
<em>global_work_offset</em> argument to <strong>clEnqueueNDRangeKernel</strong>.</p>
<p class="tableblock"> Valid values of <em>dimindx</em> are 0 to <strong>get_work_dim</strong>() - 1.
For other values, <strong>get_global_offset</strong>() returns 0.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_global_linear_id</strong>()</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the work-items 1-dimensional global ID.</p>
<p class="tableblock"> For 1D work-groups, it is computed as <strong>get_global_id</strong>(0) -
<strong>get_global_offset</strong>(0).</p>
<p class="tableblock"> For 2D work-groups, it is computed as (<strong>get_global_id</strong>(1) -
<strong>get_global_offset</strong>(1)) * <strong>get_global_size</strong>(0) + (<strong>get_global_id</strong>(0) -
<strong>get_global_offset</strong>(0)).</p>
<p class="tableblock"> For 3D work-groups, it is computed as ((<strong>get_global_id</strong>(2) -
<strong>get_global_offset</strong>(2)) * <strong>get_global_size</strong>(1) * <strong>get_global_size</strong>(0))
+ ((<strong>get_global_id</strong>(1) - <strong>get_global_offset</strong>(1)) * <strong>get_global_size</strong>(0))
+ (<strong>get_global_id</strong>(0) - <strong>get_global_offset</strong>(0)).</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size_t <strong>get_local_linear_id</strong>()</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the work-items 1-dimensional local ID.</p>
<p class="tableblock"> For 1D work-groups, it is the same value as</p>
<p class="tableblock"> <strong>get_local_id</strong>(0).</p>
<p class="tableblock"> For 2D work-groups, it is computed as</p>
<p class="tableblock"> <strong>get_local_id</strong>(1) * <strong>get_local_size</strong>(0) + <strong>get_local_id</strong>(0).</p>
<p class="tableblock"> For 3D work-groups, it is computed as</p>
<p class="tableblock"> (<strong>get_local_id</strong>(2) * <strong>get_local_size</strong>(1) * <strong>get_local_size</strong>(0)) +
(<strong>get_local_id</strong>(1) * <strong>get_local_size</strong>(0)) + <strong>get_local_id</strong>(0).</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in the following table <a href="#unified-spec">requires</a> support for
the <code>cl_khr_<wbr>subgroups</code> extension, or
OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>subgroups</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The following table describes the list of built-in work-item functions that
can be used to query the size of a sub-group, number of sub-groups per work-group,
and identifier of the sub-group within a work-group and work-item within a
sub-group when this kernel is being executed on a device.</p>
</div>
<table id="table-subgroup-work-item-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 10. Built-in Work-Item Functions for Sub-Groups</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>uint <strong>get_sub_group_size</strong>()</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of work-items in the sub-group.
This value is no more than the maximum sub-group size and is
implementation-defined based on a combination of the compiled kernel and
the dispatch dimensions.
This will be a constant value for the lifetime of the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>uint <strong>get_max_sub_group_size</strong>()</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the maximum size of a sub-group within the dispatch.
This value will be invariant for a given set of dispatch dimensions and a
kernel object compiled for a given device.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>uint <strong>get_num_sub_groups</strong>()</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of sub-groups that the current work-group is divided
into.</p>
<p class="tableblock"> This number will be constant for the duration of a work-group&#8217;s execution.
If the kernel is executed with a non-uniform work-group size
(i.e. the global_work_size values specified to <strong>clEnqueueNDRangeKernel</strong>
are not evenly divisible by the local_work_size values for any dimension,
calls to this built-in from some work-groups may return different values
than calls to this built-in from other work-groups.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>uint <strong>get_enqueued_num_sub_groups</strong>()</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the same value as that returned by <strong>get_num_sub_groups</strong> if the
kernel is executed with a uniform work-group size.</p>
<p class="tableblock"> If the kernel is executed with a non-uniform work-group size, returns the
number of sub-groups in each of the work-groups that make up the uniform
region of the global range.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>uint <strong>get_sub_group_id</strong>()</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>get_sub_group_id</strong> returns the sub-group ID which is a number from 0 ..
<strong>get_num_sub_groups</strong>() - 1.</p>
<p class="tableblock"> For <strong>clEnqueueTask</strong>, this returns 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>uint <strong>get_sub_group_local_id</strong>()</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the unique work-item ID within the current sub-group.
The mapping from <strong>get_local_id</strong>(<em>dimindx</em>) to <strong>get_sub_group_local_id</strong>
will be invariant for the lifetime of the work-group.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="math-functions"><a class="anchor" href="#math-functions"></a>6.15.2. Math Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The built-in math functions are categorized into the following:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A list of built-in functions that have scalar or vector argument
versions, and,</p>
</li>
<li>
<p>A list of built-in functions that only take scalar <code>float</code> arguments.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The vector versions of the math functions operate component-wise.
The description is per-component.</p>
</div>
<div class="paragraph">
<p>The built-in math functions are not affected by the prevailing rounding mode
in the calling environment, and always return the same value as they would
if called with the round to nearest even rounding mode.</p>
</div>
<div class="paragraph">
<p>The <a href="#table-builtin-math">Built-in Scalar and Vector Argument Math
Functions</a> table describes the list of built-in math functions that can
take scalar or vector arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentype</code> indicates that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>float</code>, <code>float2</code>, <code>float3</code>, <code>float4</code>, <code>float8</code>, or <code>float16</code></p>
</li>
<li>
<p><code>double</code> <sup class="footnote" id="_footnote_double-supported">[<a id="_footnoteref_42" class="footnote" href="#_footnotedef_42" title="View footnote.">42</a>]</sup>, <code>double2</code>,
<code>double3</code>, <code>double4</code>, <code>double8</code> or <code>double16</code></p>
</li>
<li>
<p><code>half</code> <sup class="footnote">[<a id="_footnoteref_43" class="footnote" href="#_footnotedef_43" title="View footnote.">43</a>]</sup>, <code>half2</code>, <code>half3</code>, <code>half4</code>,
<code>half8</code> or <code>half16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentypef</code> indicates that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>float</code>, <code>float2</code>, <code>float3</code>, <code>float4</code>, <code>float8</code>, or <code>float16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentyped</code> <sup class="footnote">[<a id="_footnoteref_44" class="footnote" href="#_footnotedef_44" title="View footnote.">44</a>]</sup> indicates
that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>double</code>, <code>double2</code>, <code>double3</code>, <code>double4</code>, <code>double8</code> or <code>double16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentypeh</code> <sup class="footnote">[<a id="_footnoteref_45" class="footnote" href="#_footnotedef_45" title="View footnote.">45</a>]</sup> indicates
that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>half</code>, <code>half2</code>, <code>half3</code>, <code>half4</code>, <code>half8</code> or <code>half16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
All functions taking or returning <code>half</code> types are supported only when
the <code>cl_khr_<wbr>fp16</code> extension macro is supported.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>For any specific use of a function with <code>gentype*</code> arguments the actual type
has to be the same for all arguments and the return type, unless they are
explicitly specified as an actual type.</p>
</div>
<table id="table-builtin-math" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 11. Built-in Scalar and Vector Argument Math Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>acos</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Arc cosine function. Returns an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>acosh</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Inverse hyperbolic cosine. Returns an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>acospi</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <strong>acos</strong>(<em>x</em>) / π.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>asin</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Arc sine function. Returns an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>asinh</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Inverse hyperbolic sine. Returns an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>asinpi</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <strong>asin</strong>(<em>x</em>) / π.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>atan</strong>(gentype <em>y_over_x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Arc tangent function. Returns an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>atan2</strong>(gentype <em>y</em>, gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Arc tangent of <em>y</em> / <em>x</em>. Returns an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>atanh</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Hyperbolic arc tangent. Returns an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>atanpi</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <strong>atan</strong>(<em>x</em>) / π.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>atan2pi</strong>(gentype <em>y</em>, gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <strong>atan2</strong>(<em>y</em>, <em>x</em>) / π.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>cbrt</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute cube-root.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>ceil</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round to integral value using the round to positive infinity rounding
mode.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>copysign</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>x</em> with its sign changed to match the sign of <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>cos</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute cosine, where <em>x</em> is an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>cosh</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute hyperbolic cosine, where <em>x</em> is an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>cospi</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <strong>cos</strong>(Ï€ <em>x</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>erfc</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Complementary error function.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>erf</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Error function encountered in integrating the
<a href="https://mathworld.wolfram.com/NormalDistribution.html"><em>normal
distribution</em></a>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>exp</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the base-<em>e</em> exponential of <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>exp2</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Exponential base 2 function.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>exp10</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Exponential base 10 function.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>expm1</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>e<sup>x</sup></em> - 1.0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>fabs</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute absolute value of a floating-point number.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>fdim</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> - <em>y</em> if <em>x</em> &gt; <em>y</em>, +0 if <em>x</em> is less than or equal to <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>floor</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round to integral value using the round to negative infinity rounding
mode.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>fma</strong>(gentype <em>a</em>, gentype <em>b</em>, gentype <em>c</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the correctly rounded floating-point representation of the sum
of <em>c</em> with the infinitely precise product of <em>a</em> and <em>b</em>.
Rounding of intermediate products shall not occur.
Edge case behavior is per the IEEE 754-2008 standard.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>fmax</strong>(gentype <em>x</em>, gentype <em>y</em>)<br>
gentypef <strong>fmax</strong>(gentypef <em>x</em>, float <em>y</em>)<br>
gentyped <strong>fmax</strong>(gentyped <em>x</em>, double <em>y</em>)</p>
<p class="tableblock">gentypeh <strong>fmax</strong>(gentypeh <em>x</em>, half <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>y</em> if <em>x</em> &lt; <em>y</em>, otherwise it returns <em>x</em>.
If one argument is a NaN, <strong>fmax</strong>() returns the other argument.
If both arguments are NaNs, <strong>fmax</strong>() returns a NaN.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>fmin</strong>(gentype <em>x</em>, gentype <em>y</em>)<br>
gentypef <strong>fmin</strong>(gentypef <em>x</em>, float <em>y</em>)<br>
gentyped <strong>fmin</strong>(gentyped <em>x</em>, double <em>y</em>)</p>
<p class="tableblock">gentypeh <strong>fmin</strong>(gentypeh <em>x</em>, half <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>y</em> if <em>y</em> &lt; <em>x</em>, otherwise it returns <em>x</em>.
If one argument is a NaN, <strong>fmin</strong>() returns the other argument.
If both arguments are NaNs, <strong>fmin</strong>() returns a NaN.
<sup class="footnote">[<a id="_footnoteref_46" class="footnote" href="#_footnotedef_46" title="View footnote.">46</a>]</sup></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>fmod</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Modulus.
Returns <em>x</em> - <em>y</em> * <strong>trunc</strong>(<em>x</em>/<em>y</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>fract</strong>(gentype <em>x</em>, __global gentype <em>*iptr</em>)<br>
gentype <strong>fract</strong>(gentype <em>x</em>, __local gentype <em>*iptr</em>)<br>
gentype <strong>fract</strong>(gentype <em>x</em>, __private gentype <em>*iptr</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> gentype <strong>fract</strong>(gentype <em>x</em>, gentype <em>*iptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>fmin</strong>(<em>x</em> - <strong>floor</strong>(<em>x</em>), <code>C</code>), where <code>C</code> is the constant
<code>0x1.fffffep-1f</code> for <code>float</code> aguments, <code>0x1.fffffffffffffp-1</code> for <code>double</code>
arguments, and <code>0x1.ffcp-1h</code> for <code>half</code> arguments.
<strong>floor</strong>(x) is returned in <em>iptr</em>.
<sup class="footnote">[<a id="_footnoteref_47" class="footnote" href="#_footnotedef_47" title="View footnote.">47</a>]</sup></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half<em>n</em> <strong>frexp</strong>(half<em>n</em> <em>x</em>, __global int<em>n</em> *exp)<br>
half <strong>frexp</strong>(half <em>x</em>, __global int *exp)</p>
<p class="tableblock"> half<em>n</em> <strong>frexp</strong>(half<em>n</em> <em>x</em>, __local int<em>n</em> *exp)<br>
half <strong>frexp</strong>(half <em>x</em>, __local int *exp)</p>
<p class="tableblock"> half<em>n</em> <strong>frexp</strong>(half<em>n</em> <em>x</em>, __private int<em>n</em> *exp)<br>
half <strong>frexp</strong>(half <em>x</em>, __private int *exp)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> half<em>n</em> <strong>frexp</strong>(half<em>n</em> <em>x</em>, int<em>n</em> *exp)<br>
half <strong>frexp</strong>(half <em>x</em>, int *exp)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Extract mantissa and exponent from <em>x</em>.
For each component the mantissa returned is a <code>half</code> with magnitude in
the interval [1/2, 1) or 0.
Each component of <em>x</em> equals mantissa returned * 2<em><sup>exp</sup></em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>frexp</strong>(float<em>n</em> <em>x</em>, __global int<em>n</em> *exp)<br>
float <strong>frexp</strong>(float <em>x</em>, __global int *exp)</p>
<p class="tableblock"> float<em>n</em> <strong>frexp</strong>(float<em>n</em> <em>x</em>, __local int<em>n</em> *exp)<br>
float <strong>frexp</strong>(float <em>x</em>, __local int *exp)</p>
<p class="tableblock"> float<em>n</em> <strong>frexp</strong>(float<em>n</em> <em>x</em>, __private int<em>n</em> *exp)<br>
float <strong>frexp</strong>(float <em>x</em>, __private int *exp)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> float<em>n</em> <strong>frexp</strong>(float<em>n</em> <em>x</em>, int<em>n</em> *exp)<br>
float <strong>frexp</strong>(float <em>x</em>, int *exp)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Extract mantissa and exponent from <em>x</em>.
For each component the mantissa returned is a <code>float</code> with magnitude
in the interval [1/2, 1) or 0.
Each component of <em>x</em> equals mantissa returned * 2<em><sup>exp</sup></em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">double<em>n</em> <strong>frexp</strong>(double<em>n</em> <em>x</em>, __global int<em>n</em> *exp)<br>
double <strong>frexp</strong>(double <em>x</em>, __global int *exp)</p>
<p class="tableblock"> double<em>n</em> <strong>frexp</strong>(double<em>n</em> <em>x</em>, __local int<em>n</em> *exp)<br>
double <strong>frexp</strong>(double <em>x</em>, __local int *exp)</p>
<p class="tableblock"> double<em>n</em> <strong>frexp</strong>(double<em>n</em> <em>x</em>, __private int<em>n</em> *exp)<br>
double <strong>frexp</strong>(double <em>x</em>, __private int *exp)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> double<em>n</em> <strong>frexp</strong>(double<em>n</em> <em>x</em>, int<em>n</em> *exp)<br>
double <strong>frexp</strong>(double <em>x</em>, int *exp)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Extract mantissa and exponent from <em>x</em>.
For each component the mantissa returned is a <code>double</code> with magnitude
in the interval [1/2, 1) or 0.
Each component of <em>x</em> equals mantissa returned * 2<em><sup>exp</sup></em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>hypot</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the value of the square root of <em>x</em><sup>2</sup>+ <em>y</em><sup>2</sup> without
undue overflow or underflow.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int<em>n</em> <strong>ilogb</strong>(float<em>n</em> <em>x</em>)<br>
int <strong>ilogb</strong>(float <em>x</em>)<br>
int<em>n</em> <strong>ilogb</strong>(double<em>n</em> <em>x</em>)<br>
int <strong>ilogb</strong>(double <em>x</em>)</p>
<p class="tableblock"> int<em>n</em> <strong>ilogb</strong>(half<em>n</em> <em>x</em>)<br>
int <strong>ilogb</strong>(half <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the exponent as an integer value.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>ldexp</strong>(float<em>n</em> <em>x</em>, int<em>n</em> <em>k</em>)<br>
float<em>n</em> <strong>ldexp</strong>(float<em>n</em> <em>x</em>, int <em>k</em>)<br>
float <strong>ldexp</strong>(float <em>x</em>, int <em>k</em>)<br>
double<em>n</em> <strong>ldexp</strong>(double<em>n</em> <em>x</em>, int<em>n</em> <em>k</em>)<br>
double<em>n</em> <strong>ldexp</strong>(double<em>n</em> <em>x</em>, int <em>k</em>)<br>
double <strong>ldexp</strong>(double <em>x</em>, int <em>k</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>ldexp</strong>(half<em>n</em> <em>x</em>, int<em>n</em> <em>k</em>)<br>
half<em>n</em> <strong>ldexp</strong>(half<em>n</em> <em>x</em>, int <em>k</em>)<br>
half <strong>ldexp</strong>(half <em>x</em>, int <em>k</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Multiply <em>x</em> by 2 to the power <em>k</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>lgamma</strong>(gentype <em>x</em>)<br>
float<em>n</em> <strong>lgamma_r</strong>(float<em>n</em> <em>x</em>, __global int<em>n</em> *<em>signp</em>)<br>
float <strong>lgamma_r</strong>(float <em>x</em>, __global int *<em>signp</em>)<br>
double<em>n</em> <strong>lgamma_r</strong>(double<em>n</em> <em>x</em>, __global int<em>n</em> *<em>signp</em>)<br>
double <strong>lgamma_r</strong>(double <em>x</em>, __global int *<em>signp</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>lgamma_r</strong>(half<em>n</em> <em>x</em>, __global int<em>n</em> *<em>signp</em>)<br>
half <strong>lgamma_r</strong>(half <em>x</em>, __global int *<em>signp</em>)<br></p>
<p class="tableblock"> float<em>n</em> <strong>lgamma_r</strong>(float<em>n</em> <em>x</em>, __local int<em>n</em> *<em>signp</em>)<br>
float <strong>lgamma_r</strong>(float <em>x</em>, __local int *<em>signp</em>)<br>
double<em>n</em> <strong>lgamma_r</strong>(double<em>n</em> <em>x</em>, __local int<em>n</em> *<em>signp</em>)<br>
double <strong>lgamma_r</strong>(double <em>x</em>, __local int *<em>signp</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>lgamma_r</strong>(half<em>n</em> <em>x</em>, __local int<em>n</em> *<em>signp</em>)<br>
half <strong>lgamma_r</strong>(half <em>x</em>, __local int *<em>signp</em>)<br></p>
<p class="tableblock"> float<em>n</em> <strong>lgamma_r</strong>(float<em>n</em> <em>x</em>, __private int<em>n</em> *<em>signp</em>)<br>
float <strong>lgamma_r</strong>(float <em>x</em>, __private int *<em>signp</em>)<br>
double<em>n</em> <strong>lgamma_r</strong>(double<em>n</em> <em>x</em>, __private int<em>n</em> *<em>signp</em>)<br>
double <strong>lgamma_r</strong>(double <em>x</em>, __private int *<em>signp</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>lgamma_r</strong>(half<em>n</em> <em>x</em>, __private int<em>n</em> *<em>signp</em>)<br>
half <strong>lgamma_r</strong>(half <em>x</em>, __private int *<em>signp</em>)<br></p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> float<em>n</em> <strong>lgamma_r</strong>(float<em>n</em> <em>x</em>, int<em>n</em> *<em>signp</em>)<br>
float <strong>lgamma_r</strong>(float <em>x</em>, int *<em>signp</em>)<br>
double<em>n</em> <strong>lgamma_r</strong>(double<em>n</em> <em>x</em>, int<em>n</em> *<em>signp</em>)<br>
double <strong>lgamma_r</strong>(double <em>x</em>, int *<em>signp</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>lgamma_r</strong>(half<em>n</em> <em>x</em>, int<em>n</em> *<em>signp</em>)<br>
half <strong>lgamma_r</strong>(half <em>x</em>, int *<em>signp</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Log gamma function.
Returns the natural logarithm of the absolute value of the gamma
function.
The sign of the gamma function is returned in the <em>signp</em> argument of
<strong>lgamma_r</strong>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>log</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute natural logarithm.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>log2</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute a base 2 logarithm.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>log10</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute a base 10 logarithm.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>log1p</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute log<sub>e</sub>(1.0 + <em>x</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>logb</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the exponent of <em>x</em>, which is the integral part of
log<em><sub>r</sub></em>(|<em>x</em>|).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>mad</strong>(gentype <em>a</em>, gentype <em>b</em>, gentype <em>c</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mad</strong> computes <em>a</em> * <em>b</em> + <em>c</em>.
The function may compute <em>a</em> * <em>b</em> + <em>c</em> with reduced accuracy in the
embedded profile.
On some hardware the mad instruction may provide better performance
than expanded computation of <em>a</em> * <em>b</em> + <em>c</em>.
<sup class="footnote">[<a id="_footnoteref_48" class="footnote" href="#_footnotedef_48" title="View footnote.">48</a>]</sup></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>maxmag</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>x</em> if |<em>x</em>| &gt; |<em>y</em>|, <em>y</em> if |<em>y</em>| &gt; |<em>x</em>|, otherwise
<strong>fmax</strong>(<em>x</em>, <em>y</em>).</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>minmag</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>x</em> if |<em>x</em>| &lt; |<em>y</em>|, <em>y</em> if |<em>y</em>| &lt; |<em>x</em>|, otherwise
<strong>fmin</strong>(<em>x</em>, <em>y</em>).</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>modf</strong>(gentype <em>x</em>, __global gentype <em>*iptr</em>)<br>
gentype <strong>modf</strong>(gentype <em>x</em>, __local gentype <em>*iptr</em>)<br>
gentype <strong>modf</strong>(gentype <em>x</em>, __private gentype <em>*iptr</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> gentype <strong>modf</strong>(gentype <em>x</em>, gentype <em>*iptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Decompose a floating-point number.
The <strong>modf</strong> function breaks the argument <em>x</em> into integral and
fractional parts, each of which has the same sign as the argument.
It stores the integral part in the object pointed to by <em>iptr</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>nan</strong>(uint<em>n</em> <em>nancode</em>)<br>
float <strong>nan</strong>(uint <em>nancode</em>)<br>
double<em>n</em> <strong>nan</strong>(ulong<em>n</em> <em>nancode</em>)<br>
double <strong>nan</strong>(ulong <em>nancode</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>nan</strong>(ushort<em>n</em> <em>nancode</em>)<br>
half <strong>nan</strong>(ushort <em>nancode</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a quiet NaN.
The <em>nancode</em> may be placed in the significand of the resulting NaN.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>nextafter</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Computes the next representable floating-point value
following <em>x</em> in the direction of <em>y</em>.
Thus, if <em>y</em> is less than <em>x</em>, <strong>nextafter</strong>() returns the largest
representable floating-point number less than <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>pow</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>x</em> to the power <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>pown</strong>(float<em>n</em> <em>x</em>, int<em>n</em> <em>y</em>)<br>
float <strong>pown</strong>(float <em>x</em>, int <em>y</em>)<br>
double<em>n</em> <strong>pown</strong>(double<em>n</em> <em>x</em>, int<em>n</em> <em>y</em>)<br>
double <strong>pown</strong>(double <em>x</em>, int <em>y</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>pown</strong>(half<em>n</em> <em>x</em>, int<em>n</em> <em>y</em>)<br>
half <strong>pown</strong>(half <em>x</em>, int <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>x</em> to the power <em>y</em>, where <em>y</em> is an integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>powr</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>x</em> to the power <em>y</em>, where <em>x</em> is &gt;= 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>remainder</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the value <em>r</em> such that <em>r</em> = <em>x</em> - <em>n</em>*<em>y</em>, where <em>n</em> is the
integer nearest the exact value of <em>x</em>/<em>y</em>.
If there are two integers closest to <em>x</em>/<em>y</em>, <em>n</em> shall be the even
one.
If <em>r</em> is zero, it is given the same sign as <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>remquo</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>, __global int<em>n</em> <em>*quo</em>)<br>
float <strong>remquo</strong>(float <em>x</em>, float <em>y</em>, __global int <em>*quo</em>)</p>
<p class="tableblock"> float<em>n</em> <strong>remquo</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>, __local int<em>n</em> <em>*quo</em>)<br>
float <strong>remquo</strong>(float <em>x</em>, float <em>y</em>, __local int <em>*quo</em>)</p>
<p class="tableblock"> float<em>n</em> <strong>remquo</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>, __private int<em>n</em> <em>*quo</em>)<br>
float <strong>remquo</strong>(float <em>x</em>, float <em>y</em>, __private int <em>*quo</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> float<em>n</em> <strong>remquo</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>, int<em>n</em> <em>*quo</em>)<br>
float <strong>remquo</strong>(float <em>x</em>, float <em>y</em>, int <em>*quo</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <strong>remquo</strong> function computes the value r such that <em>r</em> = <em>x</em> -
<em>k</em>*<em>y</em>, where <em>k</em> is the integer nearest the exact value of <em>x</em>/<em>y</em>.
If there are two integers closest to <em>x</em>/<em>y</em>, <em>k</em> shall be the even
one.
If <em>r</em> is zero, it is given the same sign as <em>x</em>.
This is the same value that is returned by the <strong>remainder</strong> function.
<strong>remquo</strong> also calculates the lower seven bits of the integral quotient
<em>x</em>/<em>y</em>, and gives that value the same sign as <em>x</em>/<em>y</em>.
It stores this signed value in the object pointed to by <em>quo</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">double<em>n</em> <strong>remquo</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>, __global int<em>n</em> <em>*quo</em>)<br>
double <strong>remquo</strong>(double <em>x</em>, double <em>y</em>, __global int <em>*quo</em>)</p>
<p class="tableblock"> double<em>n</em> <strong>remquo</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>, __local int<em>n</em> <em>*quo</em>)<br>
double <strong>remquo</strong>(double <em>x</em>, double <em>y</em>, __local int <em>*quo</em>)</p>
<p class="tableblock"> double<em>n</em> <strong>remquo</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>, __private int<em>n</em> <em>*quo</em>)<br>
double <strong>remquo</strong>(double <em>x</em>, double <em>y</em>, __private int <em>*quo</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> double<em>n</em> <strong>remquo</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>, int<em>n</em> <em>*quo</em>)<br>
double <strong>remquo</strong>(double <em>x</em>, double <em>y</em>, int <em>*quo</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <strong>remquo</strong> function computes the value r such that <em>r</em> = <em>x</em> -
<em>k</em>*<em>y</em>, where <em>k</em> is the integer nearest the exact value of <em>x</em>/<em>y</em>.
If there are two integers closest to <em>x</em>/<em>y</em>, <em>k</em> shall be the even
one.
If <em>r</em> is zero, it is given the same sign as <em>x</em>.
This is the same value that is returned by the <strong>remainder</strong> function.
<strong>remquo</strong> also calculates the lower seven bits of the integral quotient
<em>x</em>/<em>y</em>, and gives that value the same sign as <em>x</em>/<em>y</em>.
It stores this signed value in the object pointed to by <em>quo</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half<em>n</em> <strong>remquo</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>, __global int<em>n</em> <em>*quo</em>)<br>
half <strong>remquo</strong>(half <em>x</em>, half <em>y</em>, __global int <em>*quo</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>remquo</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>, __local int<em>n</em> <em>*quo</em>)<br>
half <strong>remquo</strong>(half <em>x</em>, half <em>y</em>, __local int <em>*quo</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>remquo</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>, __private int<em>n</em> <em>*quo</em>)<br>
half <strong>remquo</strong>(half <em>x</em>, half <em>y</em>, __private int <em>*quo</em>)</p>
<p class="tableblock"> For OpenCL C 2.0 or with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> half<em>n</em> <strong>remquo</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>, int<em>n</em> <em>*quo</em>)<br>
half <strong>remquo</strong>(half <em>x</em>, half <em>y</em>, int <em>*quo</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <strong>remquo</strong> function computes the value r such that <em>r</em> = <em>x</em> -
<em>k</em>*<em>y</em>, where <em>k</em> is the integer nearest the exact value of <em>x</em>/<em>y</em>.
If there are two integers closest to <em>x</em>/<em>y</em>, <em>k</em> shall be the even
one.
If <em>r</em> is zero, it is given the same sign as <em>x</em>.
This is the same value that is returned by the <strong>remainder</strong> function.
<strong>remquo</strong> also calculates the lower seven bits of the integral quotient
<em>x</em>/<em>y</em>, and gives that value the same sign as <em>x</em>/<em>y</em>.
It stores this signed value in the object pointed to by <em>quo</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>rint</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round to integral value (using round to nearest even rounding mode) in
floating-point format.
Refer to section 7.1 for description of rounding modes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>rootn</strong>(float<em>n</em> <em>x</em>, int<em>n</em> <em>y</em>)<br>
float <strong>rootn</strong>(float <em>x</em>, int <em>y</em>)<br>
double<em>n</em> <strong>rootn</strong>(double<em>n</em> <em>x</em>, int<em>n</em> <em>y</em>)<br>
double <strong>rootn</strong>(double <em>x</em>, int <em>y</em>)</p>
<p class="tableblock"> half<em>n</em> <strong>rootn</strong>(half<em>n</em> <em>x</em>, int<em>n</em> <em>y</em>)<br>
half <strong>rootn</strong>(half <em>x</em>, int <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>x</em> to the power 1/<em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>round</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the integral value nearest to <em>x</em> rounding halfway cases away
from zero, regardless of the current rounding direction.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>rsqrt</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute inverse square root.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sin</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute sine, where <em>x</em> is an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sincos</strong>(gentype <em>x</em>, __global gentype <em>*cosval</em>)<br>
gentype <strong>sincos</strong>(gentype <em>x</em>, __local gentype <em>*cosval</em>)<br>
gentype <strong>sincos</strong>(gentype <em>x</em>, __private gentype <em>*cosval</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> gentype <strong>sincos</strong>(gentype <em>x</em>, gentype <em>*cosval</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute sine and cosine of <em>x</em>.
The computed sine is the return value and computed cosine is returned
in <em>cosval</em>, where <em>x</em> is an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sinh</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute hyperbolic sine, where <em>x</em> is an angle in radians</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sinpi</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <strong>sin</strong>(Ï€ <em>x</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sqrt</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute square root.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>tan</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute tangent, where <em>x</em> is an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>tanh</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute hyperbolic tangent, where <em>x</em> is an angle in radians.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>tanpi</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <strong>tan</strong>(Ï€ <em>x</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>tgamma</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the gamma function.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>trunc</strong>(gentype)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Round to integral value using the round to zero rounding mode.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following table describes the following functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A subset of functions from <a href="#table-builtin-math">Built-in Scalar and Vector
Argument Math Functions</a> that are defined with the half_ prefix.
These functions are implemented with a minimum of 10-bits of accuracy,
i.e. the maximum error value &lt;= 8192 ulp.</p>
</li>
<li>
<p>A subset of functions from <a href="#table-builtin-math">Built-in Scalar and Vector
Argument Math Functions</a> that are defined with the native_ prefix.
These functions may map to one or more native device instructions and
will typically have better performance compared to the corresponding
functions without the <code>native_</code> prefix).
The accuracy (and in some cases the input range(s)) of these functions
is implementation-defined.</p>
</li>
<li>
<p><code>half_</code> and <code>native_</code> functions for following basic operations:
divide and reciprocal.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>We use the generic type name <code>gentype</code> to indicate that the functions in the
following table can take <code>float</code>, <code>float2</code>, <code>float3</code>, <code>float4</code>, <code>float8</code> or
<code>float16</code> as the type for the arguments.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The use of <code>half</code> in this table does not refer to the argument and
return types, which are 32-bit floating-point values, but to the accuracy
requirements of the function results.
</td>
</tr>
</table>
</div>
<table id="table-builtin-half-native-math" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 12. Built-in Scalar and Vector <em>half</em> and <em>native</em> Math Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_cos</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute cosine.
<em>x</em> is an angle in radians, and must be in the range [-2<sup>16</sup>, +2<sup>16</sup>].</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_divide</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>x</em> / <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_exp</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the base-<em>e</em> exponential of <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_exp2</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the base- 2 exponential of <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_exp10</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the base- 10 exponential of <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_log</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute natural logarithm.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_log2</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute a base 2 logarithm.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_log10</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute a base 10 logarithm.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_powr</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>x</em> to the power <em>y</em>, where <em>x</em> is &gt;= 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_recip</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute reciprocal.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_rsqrt</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute inverse square root.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_sin</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute sine.
<em>x</em> is an angle in radians, and must be in the range [-2<sup>16</sup>, +2<sup>16</sup>].</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_sqrt</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute square root.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>half_tan</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute tangent.
<em>x</em> is an angle in radians, and must be in the range [-2<sup>16</sup>, +2<sup>16</sup>].</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_cos</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute cosine over an implementation-defined range, where <em>x</em> is an
angle in radians.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_divide</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>x</em> / <em>y</em> over an implementation-defined range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_exp</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the base-<em>e</em> exponential of <em>x</em> over an
implementation-defined range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_exp2</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the base-2 exponential of <em>x</em> over an implementation-defined
range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_exp10</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the base-10 exponential of <em>x</em> over an implementation-defined
range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_log</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute natural logarithm over an implementation-defined range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_log2</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute a base 2 logarithm over an
implementation-defined range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_log10</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute a base 10 logarithm over
an implementation-defined range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_powr</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute <em>x</em> to the power <em>y</em>, where <em>x</em> is &gt;= 0.
The range of <em>x</em> and <em>y</em> are implementation-defined.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_recip</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute reciprocal over an implementation-defined range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_rsqrt</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute inverse square root over an implementation-defined range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_sin</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute sine over an implementation-defined range, where <em>x</em> is an
angle in radians.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_sqrt</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute square root over an implementation-defined range.
The maximum error is implementation-defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>native_tan</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute tangent over an implementation-defined range, where <em>x</em> is an
angle in radians.
The maximum error is implementation-defined.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Support for denormal values is optional for <strong>half_</strong> functions.
The <strong>half_</strong> functions may return any result allowed by
<a href="#edge-case-behavior-in-flush-to-zero-mode">Edge Case Behavior</a>, even when
<code>-cl-denorms-are-zero</code> (see <a href="#opencl-spec">section 5.8.4.2 of the OpenCL
Specification</a>) is not in force.
Support for denormal values is implementation-defined for <strong>native_</strong>
functions.</p>
</div>
</div>
</div>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following constants are available.
Their values are of type <code>float</code> and are accurate within the precision of a
single precision floating-point number.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Constant Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>MAXFLOAT</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of maximum non-infinite single-precision floating-point number.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HUGE_VALF</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A positive <code>float</code> constant expression.
<code>HUGE_VALF</code> evaluates to +infinity.
Used as an error value returned by the built-in math functions.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>INFINITY</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A constant expression of type <code>float</code> representing positive or
unsigned infinity.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>NAN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A constant expression of type <code>float</code> representing a quiet NaN.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>If <a href="#double-precision-support">double-precision is supported by the
device</a>, then the following constants are also available:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Constant Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HUGE_VAL</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A positive double constant expression.
<code>HUGE_VAL</code> evaluates to +infinity.
Used as an error value returned by the built-in math functions.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect4">
<h5 id="floating-point-macros-and-pragmas"><a class="anchor" href="#floating-point-macros-and-pragmas"></a>6.15.2.1. Floating-point Macros and Pragmas</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>FP_CONTRACT</code> pragma can be used to allow (if the state is on) or
disallow (if the state is off) the implementation to contract expressions.
Each pragma can occur either outside external declarations or preceding all
explicit declarations and statements inside a compound statement.
When outside external declarations, the pragma takes effect from its
occurrence until another <code>FP_CONTRACT</code> pragma is encountered, or until the
end of the translation unit.
When inside a compound statement, the pragma takes effect from its
occurrence until another <code>FP_CONTRACT</code> pragma is encountered (including
within a nested compound statement), or until the end of the compound
statement; at the end of a compound statement the state for the pragma is
restored to its condition just before the compound statement.
If this pragma is used in any other context, the behavior is undefined.</p>
</div>
<div class="paragraph">
<p>The pragma definition to set <code>FP_CONTRACT</code> is:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// on-off-switch is one of ON, OFF, or DEFAULT.</span>
<span class="c1">// The DEFAULT value is ON.</span>
<span class="cp">#pragma OPENCL FP_CONTRACT on-off-switch</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>FP_FAST_FMAF</code> macro indicates whether the <strong>fma</strong> function is fast
compared with direct code for single precision floating-point.
If defined, the <code>FP_FAST_FMAF</code> macro shall indicate that the <strong>fma</strong> function
generally executes about as fast as, or faster than, a multiply and an add
of <code>float</code> operands.</p>
</div>
<div class="paragraph">
<p>The macro names given in the following list must use the values specified.
These constant expressions are suitable for use in <code>#if</code> preprocessing
directives.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#define FLT_DIG 6
#define FLT_MANT_DIG 24
#define FLT_MAX_10_EXP +38
#define FLT_MAX_EXP +128
#define FLT_MIN_10_EXP -37
#define FLT_MIN_EXP -125
#define FLT_RADIX 2
#define FLT_MAX 0x1.fffffep127f
#define FLT_MIN 0x1.0p-126f
#define FLT_EPSILON 0x1.0p-23f</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The following table describes the built-in macro names given above in the
OpenCL C programming language and the corresponding macro names available to
the application.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Macro in OpenCL Language</th>
<th class="tableblock halign-left valign-top">Macro for application</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_DIG</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>DIG</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_MANT_DIG</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>MANT_<wbr>DIG</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_MAX_10_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>MAX_<wbr>10_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_MAX_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>MAX_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_MIN_10_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>MIN_<wbr>10_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_MIN_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>MIN_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_RADIX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>RADIX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_MIN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>MIN</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>FLT_EPSILON</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_FLT_<wbr>EPSILON</code></p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following macros shall expand to integer constant expressions whose
values are returned by <strong>ilogb</strong>(<em>x</em>) if <em>x</em> is zero or NaN, respectively.
The value of <code>FP_ILOGB0</code> shall be either <code>INT_MIN</code> or <code>-INT_MAX</code>.
The value of <code>FP_ILOGBNAN</code> shall be either <code>INT_MAX</code> or <code>INT_MIN</code>.</p>
</div>
<div class="paragraph">
<p>The following constants are also available.
They are of type <code>float</code> and are accurate within the precision of the
<code>float</code> type.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Constant</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_E_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of <em>e</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LOG2E_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>2</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LOG10E_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>10</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LN2_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>e</sub>2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LN10_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>e</sub>10</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI_2_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π / 2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI_4_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π / 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_1_PI_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 1 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_2_PI_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 2 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_2_SQRTPI_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 2 / √π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_SQRT2_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of √2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_SQRT1_2_F</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 1 / √2</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>If <a href="#double-precision-support">double-precision is supported by the
device</a>, then the following macros and constants are also available:</p>
</div>
<div class="paragraph">
<p>The <code>FP_FAST_FMA</code> macro indicates whether the <strong>fma</strong>() family of functions
are fast compared with direct code for double-precision floating-point.
If defined, the <code>FP_FAST_FMA</code> macro shall indicate that the <strong>fma</strong>() function
generally executes about as fast as, or faster than, a multiply and an add
of <code>double</code> operands</p>
</div>
<div class="paragraph">
<p>The macro names given in the following list must use the values specified.
These constant expressions are suitable for use in <code>#if</code> preprocessing
directives.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#define DBL_DIG 15
#define DBL_MANT_DIG 53
#define DBL_MAX_10_EXP +308
#define DBL_MAX_EXP +1024
#define DBL_MIN_10_EXP -307
#define DBL_MIN_EXP -1021
#define DBL_MAX 0x1.fffffffffffffp1023
#define DBL_MIN 0x1.0p-1022
#define DBL_EPSILON 0x1.0p-52</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The following table describes the built-in macro names given above in the
OpenCL C programming language and the corresponding macro names available to
the application.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Macro in OpenCL Language</th>
<th class="tableblock halign-left valign-top">Macro for application</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_DIG</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>DIG</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_MANT_DIG</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>MANT_<wbr>DIG</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_MAX_10_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>MAX_<wbr>10_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_MAX_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>MAX_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_MIN_10_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>MIN_<wbr>10_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_MIN_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>MIN_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_MIN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>MIN</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>DBL_EPSILON</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_DBL_<wbr>EPSILON</code></p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following constants are also available.
They are of type <code>double</code> and are accurate within the precision of the
double type.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Constant</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_E</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of <em>e</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LOG2E</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>2</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LOG10E</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>10</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LN2</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>e</sub>2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LN10</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>e</sub>10</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI_2</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π / 2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI_4</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π / 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_1_PI</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 1 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_2_PI</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 2 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_2_SQRTPI</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 2 / √π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_SQRT2</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of √2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_SQRT1_2</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 1 / √2</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>fp16</code> extension macro is supported, then the following
macros and constants are also available:</p>
</div>
<div class="paragraph">
<p>The <code>FP_FAST_FMA_HALF</code> macro indicates whether the <strong>fma</strong>() family of
functions are fast compared with direct code for half-precision
floating-point.
If defined, the <code>FP_FAST_FMA_HALF</code> macro shall indicate that the <strong>fma</strong>()
function generally executes about as fast as, or faster than, a multiply and
an add of <code>half</code> operands.</p>
</div>
<div class="paragraph">
<p>The macro names given in the following list must use the values specified.
These constant expressions are suitable for use in #if preprocessing
directives.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#define HALF_DIG 3
#define HALF_MANT_DIG 11
#define HALF_MAX_10_EXP +4
#define HALF_MAX_EXP +16
#define HALF_MIN_10_EXP -4
#define HALF_MIN_EXP -13
#define HALF_RADIX 2
#define HALF_MAX 0x1.ffcp15h
#define HALF_MIN 0x1.0p-14h
#define HALF_EPSILON 0x1.0p-10h</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The following table describes the built-in macro names given above in the
OpenCL C programming language and the corresponding macro names available to
the application.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Macro in OpenCL Language</th>
<th class="tableblock halign-left valign-top">Macro for application</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_DIG</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>DIG</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_MANT_DIG</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>MANT_<wbr>DIG</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_MAX_10_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>MAX_<wbr>10_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_MAX_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>MAX_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_MIN_10_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>MIN_<wbr>10_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_MIN_EXP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>MIN_<wbr>EXP</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_RADIX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>RADIX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_MIN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>MIN</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>HALF_EPSILON</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_HALF_<wbr>EPSILON</code></p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following constants are also available.
They are of type <code>half</code> and are accurate within the precision of the <code>half</code>
type.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Constant</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_E_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LOG2E_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>2</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LOG10E_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>10</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LN2_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>e</sub>2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_LN10_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of log<sub>e</sub>10</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI_2_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π / 2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_PI_4_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of π / 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_1_PI_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 1 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_2_PI_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 2 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_2_SQRTPI_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 2 / √π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_SQRT2_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of √2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>M_SQRT1_2_H</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Value of 1 / √2</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="integer-functions"><a class="anchor" href="#integer-functions"></a>6.15.3. Integer Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <a href="#table-builtin-functions">following table</a> describes the built-in integer
functions that take scalar or vector arguments.
The vector versions of the integer functions operate component-wise.
The description is per-component.</p>
</div>
<div class="paragraph">
<p>We use the generic type name <code>gentype</code> to indicate that the function can take
<code>char</code>, <code>char<em>n</em></code>, <code>uchar</code>, <code>uchar<em>n</em></code>, <code>short</code>,
<code>short<em>n</em></code>, <code>ushort</code>, <code>ushort<em>n</em></code>, <code>int</code>, <code>int<em>n</em></code>,
<code>uint</code>, <code>uint<em>n</em></code>, <code>long</code> <sup class="footnote">[<a id="_footnoteref_49" class="footnote" href="#_footnotedef_49" title="View footnote.">49</a>]</sup>,
<code>long<em>n</em></code>, <code>ulong</code>, or <code>ulong<em>n</em></code> as the type for the
arguments.
We use the generic type name <code>ugentype</code> to refer to unsigned versions of
<code>gentype</code>.
For example, if <code>gentype</code> is <code>char4</code>, <code>ugentype</code> is <code>uchar4</code>.
We also use the generic type name <code>sgentype</code> to indicate that the function
can take a scalar data type, i.e. <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>, <code>int</code>,
<code>uint</code>, <code>long</code>, or <code>ulong</code>, as the type for the arguments.
For built-in integer functions that take <code>gentype</code> and <code>sgentype</code> arguments,
the <code>gentype</code> argument must be a vector or scalar version of the <code>sgentype</code>
argument.
For example, if <code>sgentype</code> is <code>uchar</code>, <code>gentype</code> must be <code>uchar</code> or
<code>uchar<em>n</em></code>.
For vector versions, <code>sgentype</code> is implicitly widened to <code>gentype</code> as
described for <a href="#operators-arithmetic">arithmetic operators</a>.
<em>n</em> is 2, 3, 4, 8, or 16.</p>
</div>
<div class="paragraph">
<p>For any specific use of a function with <code>gentype*</code> arguments the actual type
has to be the same for all arguments and the return type, unless they are
explicitly specified as an actual type.</p>
</div>
<table id="table-builtin-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 13. Built-in Scalar and Vector Integer Argument Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ugentype <strong>abs</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns |x|.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ugentype <strong>abs_diff</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns |x - y| without modulo overflow.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>add_sat</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>x</em> + <em>y</em> and saturates the result.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>hadd</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns (<em>x</em> + <em>y</em>) &gt;&gt; 1.
The intermediate sum does not modulo overflow.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>rhadd</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns (<em>x</em> + <em>y</em> + 1) &gt;&gt; 1.
The intermediate sum does not modulo overflow.
<sup class="footnote">[<a id="_footnoteref_50" class="footnote" href="#_footnotedef_50" title="View footnote.">50</a>]</sup></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>clamp</strong>(gentype <em>x</em>, gentype <em>minval</em>, gentype <em>maxval</em>)<br>
gentype <strong>clamp</strong>(gentype <em>x</em>, sgentype <em>minval</em>, sgentype <em>maxval</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>min</strong>(<strong>max</strong>(<em>x</em>, <em>minval</em>), <em>maxval</em>).
Results are undefined if <em>minval</em> &gt; <em>maxval</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>clz</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of leading 0-bits in <em>x</em>, starting at the most
significant bit position.
If <em>x</em> is 0, returns the size in bits of the type of <em>x</em> or component
type of <em>x</em>, if <em>x</em> is a vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>ctz</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the count of trailing 0-bits in <em>x</em>.
If <em>x</em> is 0, returns the size in bits of the type of <em>x</em> or component
type of <em>x</em>, if <em>x</em> is a vector.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>dot</strong>(uchar4 a, uchar4 b)<br>
int <strong>dot</strong>(char4 a, char4 b)<br>
int <strong>dot</strong>(uchar4 a, char4 b)<br>
int <strong>dot</strong>(char4 a, uchar4 b)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>dot</code> returns the dot product of the two input vectors <code>a</code> and <code>b</code>.
The components of <code>a</code> and <code>b</code> are sign- or zero-extended to the width
of the destination type and the vectors with extended components are
multiplied component-wise.
All the components of the resulting vectors are added together to form
the final result.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>__opencl_c_<wbr>integer_<wbr>dot_<wbr>product_<wbr>input_<wbr>4x8bit</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>dot_acc_sat</strong>(uchar4 a, uchar4 b, uint acc)<br>
int <strong>dot_acc_sat</strong>(char4 a, char4 b, int acc)<br>
int <strong>dot_acc_sat</strong>(uchar4 a, char4 b, int acc)<br>
int <strong>dot_acc_sat</strong>(char4 a, uchar4 b, int acc)</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><code>dot_acc_sat</code> returns the saturating addition of the dot product of
the two input vectors <code>a</code> and <code>b</code> and the accumulator <code>acc</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">product</span> <span class="o">=</span> <span class="n">dot</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">);</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">add_sat</span><span class="p">(</span><span class="n">product</span><span class="p">,</span> <span class="n">acc</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><a href="#unified-spec">Requires</a> support for the
<code>__opencl_c_<wbr>integer_<wbr>dot_<wbr>product_<wbr>input_<wbr>4x8bit</code> feature.</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>dot_4x8packed_uu_uint</strong>(uint a, uint b)<br>
int <strong>dot_4x8packed_ss_int</strong>(uint a, uint b)<br>
int <strong>dot_4x8packed_us_int</strong>(uint a, uint b)<br>
int <strong>dot_4x8packed_su_int</strong>(uint a, uint b)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>dot</strong> for 4x8 bit input vectors packed into a 32-bit word.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>__opencl_c_<wbr>integer_<wbr>dot_<wbr>product_<wbr>input_<wbr>4x8bit_<wbr>packed</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>dot_acc_sat_4x8packed_uu_uint</strong>(uint a, uint b, uint acc)<br>
int <strong>dot_acc_sat_4x8packed_ss_int</strong>(uint a, uint b, int acc)<br>
int <strong>dot_acc_sat_4x8packed_us_int</strong>(uint a, uint b, int acc)<br>
int <strong>dot_acc_sat_4x8packed_su_int</strong>(uint a, uint b, int acc)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>dot_acc_set</strong> for 4x8 bit input vectors packed into a 32-bit
word.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>__opencl_c_<wbr>integer_<wbr>dot_<wbr>product_<wbr>input_<wbr>4x8bit_<wbr>packed</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>mad_hi</strong>(gentype <em>a</em>, gentype <em>b</em>, gentype <em>c</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>mul_hi</strong>(<em>a</em>, <em>b</em>) + <em>c</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>mad_sat</strong>(gentype <em>a</em>, gentype <em>b</em>, gentype <em>c</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>a</em> * <em>b</em> + <em>c</em> and saturates the result.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>max</strong>(gentype <em>x</em>, gentype <em>y</em>)</p>
<p class="tableblock"> For OpenCL C 1.1 or newer:</p>
<p class="tableblock"> gentype <strong>max</strong>(gentype <em>x</em>, sgentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>y</em> if <em>x</em> &lt; <em>y</em>, otherwise it returns <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>min</strong>(gentype <em>x</em>, gentype <em>y</em>)</p>
<p class="tableblock"> For OpenCL C 1.1 or newer:</p>
<p class="tableblock"> gentype <strong>min</strong>(gentype <em>x</em>, sgentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>y</em> if <em>y</em> &lt; <em>x</em>, otherwise it returns <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>mul_hi</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Computes <em>x</em> * <em>y</em> and returns the high half of the product of <em>x</em> and
<em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>rotate</strong>(gentype <em>v</em>, gentype <em>i</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For each element in <em>v</em>, the bits are shifted left by the number of
bits given by the corresponding element in <em>i</em> (subject to the usual
<a href="#operators-shift">shift modulo rules</a>).
Bits shifted off the left side of the element are shifted back in from
the right.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sub_sat</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>x</em> - <em>y</em> and saturates the result.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">short <strong>upsample</strong>(char <em>hi</em>, uchar <em>lo</em>)<br>
ushort <strong>upsample</strong>(uchar <em>hi</em>, uchar <em>lo</em>)<br>
short<em>n</em> <strong>upsample</strong>(char<em>n</em> <em>hi</em>, uchar<em>n</em> <em>lo</em>)<br>
ushort<em>n</em> <strong>upsample</strong>(uchar<em>n</em> <em>hi</em>, uchar<em>n</em> <em>lo</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>result</em>[i] = ((short)<em>hi</em>[i] &lt;&lt; 8) | <em>lo</em>[i]<br>
<em>result</em>[i] = ((ushort)<em>hi</em>[i] &lt;&lt; 8) | <em>lo</em>[i]<br></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>upsample</strong>(short <em>hi</em>, ushort <em>lo</em>)<br>
uint <strong>upsample</strong>(ushort <em>hi</em>, ushort <em>lo</em>)<br>
int<em>n</em> <strong>upsample</strong>(short<em>n</em> <em>hi</em>, ushort<em>n</em> <em>lo</em>)<br>
uint<em>n</em> <strong>upsample</strong>(ushort<em>n</em> <em>hi</em>, ushort<em>n</em> <em>lo</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>result</em>[i] = ((int)<em>hi</em>[i] &lt;&lt; 16) | <em>lo</em>[i]<br>
<em>result</em>[i] = ((uint)<em>hi</em>[i] &lt;&lt; 16) | <em>lo</em>[i]<br></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>upsample</strong>(int <em>hi</em>, uint <em>lo</em>)<br>
ulong <strong>upsample</strong>(uint <em>hi</em>, uint <em>lo</em>)<br>
long<em>n</em> <strong>upsample</strong>(int<em>n</em> <em>hi</em>, uint<em>n</em> <em>lo</em>)<br>
ulong<em>n</em> <strong>upsample</strong>(uint<em>n</em> <em>hi</em>, uint<em>n</em> <em>lo</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>result</em>[i] = ((long)<em>hi</em>[i] &lt;&lt; 32) | <em>lo</em>[i]<br>
<em>result</em>[i] = ((ulong)<em>hi</em>[i] &lt;&lt; 32) | <em>lo</em>[i]</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>popcount</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of non-zero bits in <em>x</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following table describes fast integer functions that can be used for
optimizing performance of kernels.
We use the generic type name <code>gentype</code> to indicate that the function can
take <code>int</code>, <code>int2</code>, <code>int3</code>, <code>int4</code>, <code>int8</code>, <code>int16</code>, <code>uint</code>, <code>uint2</code>,
<code>uint3</code>, <code>uint4</code>, <code>uint8</code> or <code>uint16</code> as the type for the arguments.</p>
</div>
<table id="table-builtin-fast-integer" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 14. Built-in 24-bit Integer Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>mad24</strong>(gentype <em>x</em>, gentype <em>y</em>, gentype z)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Multipy two 24-bit integer values <em>x</em> and <em>y</em> and add the 32-bit
integer result to the 32-bit integer <em>z</em>.
Refer to definition of <strong>mul24</strong> to see how the 24-bit integer
multiplication is performed.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>mul24</strong>(gentype <em>x</em>, gentype <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Multiply two 24-bit integer values <em>x</em> and <em>y</em>.
<em>x</em> and <em>y</em> are 32-bit integers but only the low 24-bits are used to
perform the multiplication.
<strong>mul24</strong> should only be used when values in <em>x</em> and <em>y</em> are in the
range [-2<sup>23</sup>, 2<sup>23</sup>-1] if <em>x</em> and <em>y</em> are signed integers and in the
range [0, 2<sup>24</sup>-1] if <em>x</em> and <em>y</em> are unsigned integers.
If <em>x</em> and <em>y</em> are not in this range, the multiplication result is
implementation-defined.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect4">
<h5 id="extended-bit-operations"><a class="anchor" href="#extended-bit-operations"></a>6.15.3.1. Extended Bit Operations</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>If
the <code>cl_khr_<wbr>extended_<wbr>bit_<wbr>ops</code> extension macro or
OpenCL C 3.1 or newer is supported, the functions described in the
<a href="#table-builtin-extended-bit-operations">Built-in Scalar and Vector Extended Bit
Operations</a> table can be used with built-in scalar or vector integer types to
perform extended bit operations.
The functions that operate on vector types operate component-wise.
The description is per-component.</p>
</div>
<div class="paragraph">
<p>In the table below, the generic type name <code>gentype</code> refers to the built-in
integer types <code>char</code>, <code>char<em>n</em></code>, <code>uchar</code>, <code>uchar<em>n</em></code>, <code>short</code>,
<code>short<em>n</em></code>, <code>ushort</code>, <code>ushort<em>n</em></code>, <code>int</code>, <code>int<em>n</em></code>, <code>uint</code>,
<code>uint<em>n</em></code>, <code>long</code>, <code>long<em>n</em></code>, <code>ulong</code>, and <code>ulong<em>n</em></code>.
The generic type name <code>igentype</code> refers to the built-in signed integer types
<code>char</code>, <code>char<em>n</em></code>, <code>short</code>, <code>short<em>n</em></code>, <code>int</code>, <code>int<em>n</em></code>, <code>long</code>, and
<code>long<em>n</em></code>.
The generic type name <code>ugentype</code> refers to the built-in unsigned integer
types <code>uchar</code>, <code>uchar<em>n</em></code>, <code>ushort</code>, <code>ushort<em>n</em></code>, <code>uint</code>, <code>uint<em>n</em></code>,
<code>ulong</code>, and <code>ulong<em>n</em></code>.
<em>n</em> is 2, 3, 4, 8, or 16.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in the following table <a href="#unified-spec">requires</a> support for
the <code>cl_khr_<wbr>extended_<wbr>bit_<wbr>ops</code> extension macro or
OpenCL C 3.1 or newer.
</td>
</tr>
</table>
</div>
<table id="table-builtin-extended-bit-operations" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 15. Built-in Scalar and Vector Extended Bit Operations</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">bitfield_insert</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">base</span><span class="p">,</span> <span class="kp">gentype</span> <span class="n">insert</span><span class="p">,</span>
<span class="kt">uint</span> <span class="n">offset</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">count</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a copy of <em>base</em>, with a modified bitfield that comes from
<em>insert</em>.</p>
<p class="tableblock"> Any bits of the result value numbered outside [<em>offset</em>, <em>offset</em> +
<em>count</em> - 1] (inclusive) will come from the corresponding bits in
<em>base</em>.</p>
<p class="tableblock"> Any bits of the result value numbered inside [<em>offset</em>, <em>offset</em> +
<em>count</em> - 1] (inclusive) will come from the bits numbered [0, <em>count</em>
- 1] (inclusive) of <em>insert</em>.</p>
<p class="tableblock"> <em>count</em> is the number of bits to be modified.
If <em>count</em> equals 0, the return value will be equal to <em>base</em>.</p>
<p class="tableblock"> If <em>count</em> or <em>offset</em> or <em>offset</em> + <em>count</em> is greater than number of
bits in <code>gentype</code> (for scalar types) or components of <code>gentype</code> (for
vector types), the result is undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">igentype</span> <span class="n">bitfield_extract_signed</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">base</span><span class="p">,</span>
<span class="kt">uint</span> <span class="n">offset</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">count</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns an extracted bitfield from <em>base</em> with sign extension.
The type of the return value is always a signed type.</p>
<p class="tableblock"> The bits of <em>base</em> numbered in [<em>offset</em>, <em>offset</em> + <em>count</em> - 1]
(inclusive) are returned as the bits numbered in [0, <em>count</em> - 1]
(inclusive) of the result.
The remaining bits in the result will be sign extended by replicating
the bit numbered <em>offset</em> + <em>count</em> - 1 of <em>base</em>.</p>
<p class="tableblock"> <em>count</em> is the number of bits to be extracted.
If <em>count</em> equals 0, the result is 0.</p>
<p class="tableblock"> If the <em>count</em> or <em>offset</em> or <em>offset</em> + <em>count</em> is greater than
number of bits in <code>gentype</code> (for scalar types) or components of
<code>gentype</code> (for vector types), the result is undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">ugentype</span> <span class="n">bitfield_extract_unsigned</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">base</span><span class="p">,</span>
<span class="kt">uint</span> <span class="n">offset</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">count</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns an extracted bitfield from <em>base</em> with zero extension.
The type of the return value is always an unsigned type.</p>
<p class="tableblock"> The bits of <em>base</em> numbered in [<em>offset</em>, <em>offset</em> + <em>count</em> - 1]
(inclusive) are returned as the bits numbered in [0, <em>count</em> - 1]
(inclusive) of the result.
The remaining bits in the result will be zero.</p>
<p class="tableblock"> <em>count</em> is the number of bits to be extracted.
If <em>count</em> equals 0, the result is 0.</p>
<p class="tableblock"> If the <em>count</em> or <em>offset</em> or <em>offset</em> + <em>count</em> is greater than
number of bits in <code>gentype</code> (for scalar types) or components of
<code>gentype</code> (for vector types), the result is undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">bit_reverse</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">base</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the value of <em>base</em> with reversed bits.
That is, the bit numbered <em>n</em> of the result value will be taken from
the bit numbered <em>width</em> - <em>n</em> - 1 of <em>base</em> (for scalar types) or a
component of <em>base</em> (for vector types), where <em>width</em> is number of
bits of <code>gentype</code> (for scalar types) or components of <code>gentype</code> (for
vector types).</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect4">
<h5 id="integer-macros"><a class="anchor" href="#integer-macros"></a>6.15.3.2. Integer Macros</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The macro names given in the following list must use the values specified.
The values shall all be constant expressions suitable for use in <code>#if</code>
preprocessing directives.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#define CHAR_BIT 8
#define CHAR_MAX SCHAR_MAX
#define CHAR_MIN SCHAR_MIN
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define LONG_MAX 0x7fffffffffffffffL
#define LONG_MIN (-0x7fffffffffffffffL - 1)
#define SCHAR_MAX 127
#define SCHAR_MIN (-127 - 1)
#define SHRT_MAX 32767
#define SHRT_MIN (-32767 - 1)
#define UCHAR_MAX 255
#define USHRT_MAX 65535
#define UINT_MAX 0xffffffff
#define ULONG_MAX 0xffffffffffffffffUL</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The following table describes the built-in macro names given above in the
OpenCL C programming language and the corresponding macro names available to
the application.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Macro in OpenCL Language</th>
<th class="tableblock halign-left valign-top">Macro for application</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CHAR_BIT</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_CHAR_<wbr>BIT</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CHAR_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_CHAR_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CHAR_MIN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_CHAR_<wbr>MIN</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>INT_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_INT_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>INT_MIN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_INT_<wbr>MIN</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>LONG_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_LONG_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>LONG_MIN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_LONG_<wbr>MIN</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>SCHAR_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_SCHAR_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>SCHAR_MIN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_SCHAR_<wbr>MIN</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>SHRT_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_SHRT_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>SHRT_MIN</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_SHRT_<wbr>MIN</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>UCHAR_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_UCHAR_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>USHRT_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_USHRT_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>UINT_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_UINT_<wbr>MAX</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ULONG_MAX</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_ULONG_<wbr>MAX</code></p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="common-functions"><a class="anchor" href="#common-functions"></a>6.15.4. Common Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <a href="#table-builtin-common">following table</a> describes the list of built-in
common functions.
These all operate component-wise.
The description is per-component.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentype</code> indicates that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>float</code>, <code>float2</code>, <code>float3</code>, <code>float4</code>, <code>float8</code>, or <code>float16</code></p>
</li>
<li>
<p><code>double</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_42" title="View footnote.">42</a>]</sup>, <code>double2</code>,
<code>double3</code>, <code>double4</code>, <code>double8</code> or <code>double16</code></p>
</li>
<li>
<p><code>half</code> <sup class="footnote">[<a id="_footnoteref_51" class="footnote" href="#_footnotedef_51" title="View footnote.">51</a>]</sup>, <code>half2</code>, <code>half3</code>, <code>half4</code>,
<code>half8</code> or <code>half16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentypef</code> indicates that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>float</code>, <code>float2</code>, <code>float3</code>, <code>float4</code>, <code>float8</code>, or <code>float16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentyped</code> <sup class="footnote">[<a id="_footnoteref_52" class="footnote" href="#_footnotedef_52" title="View footnote.">52</a>]</sup> indicates
that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>double</code>, <code>double2</code>, <code>double3</code>, <code>double4</code>, <code>double8</code> or <code>double16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentypeh</code> <sup class="footnote">[<a id="_footnoteref_53" class="footnote" href="#_footnotedef_53" title="View footnote.">53</a>]</sup> indicates
that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>half</code>, <code>half2</code>, <code>half3</code>, <code>half4</code>, <code>half8</code> or <code>half16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
All functions taking or returning <code>half</code> types are supported only when
the <code>cl_khr_<wbr>fp16</code> extension macro is supported.
</td>
</tr>
</table>
</div>
<table id="table-builtin-common" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 16. Built-in Scalar and Vector Argument Common Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>clamp</strong>(gentype <em>x</em>, gentype <em>minval</em>, gentype <em>maxval</em>)<br>
gentypef <strong>clamp</strong>(gentypef <em>x</em>, float <em>minval</em>, float <em>maxval</em>)<br>
gentyped <strong>clamp</strong>(gentyped <em>x</em>, double <em>minval</em>, double <em>maxval</em>)</p>
<p class="tableblock">gentypeh <strong>clamp</strong>(gentypeh <em>x</em>, half <em>minval</em>, half <em>maxval</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>fmin</strong>(<strong>fmax</strong>(<em>x</em>, <em>minval</em>), <em>maxval</em>).
Results are undefined if <em>minval</em> &gt; <em>maxval</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>degrees</strong>(gentype <em>radians</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Converts <em>radians</em> to degrees, i.e. (180 / π) * <em>radians</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>max</strong>(gentype <em>x</em>, gentype <em>y</em>)<br>
gentypef <strong>max</strong>(gentypef <em>x</em>, float <em>y</em>)<br>
gentyped <strong>max</strong>(gentyped <em>x</em>, double <em>y</em>)</p>
<p class="tableblock">gentypeh <strong>max</strong>(gentypeh <em>x</em>, half <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>y</em> if <em>x</em> &lt; <em>y</em>, otherwise it returns <em>x</em>.
If <em>x</em> or <em>y</em> are infinite or NaN, the return values are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>min</strong>(gentype <em>x</em>, gentype <em>y</em>)<br>
gentypef <strong>min</strong>(gentypef <em>x</em>, float <em>y</em>)<br>
gentyped <strong>min</strong>(gentyped <em>x</em>, double <em>y</em>)</p>
<p class="tableblock">gentypeh <strong>min</strong>(gentypeh <em>x</em>, half <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>y</em> if <em>y</em> &lt; <em>x</em>, otherwise it returns <em>x</em>.
If <em>x</em> or <em>y</em> are infinite or NaN, the return values are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>mix</strong>(gentype <em>x</em>, gentype <em>y</em>, gentype <em>a</em>)<br>
gentypef <strong>mix</strong>(gentypef <em>x</em>, gentypef <em>y</em>, float <em>a</em>)<br>
gentyped <strong>mix</strong>(gentyped <em>x</em>, gentyped <em>y</em>, double <em>a</em>)</p>
<p class="tableblock">gentypeh <strong>mix</strong>(gentypeh <em>x</em>, gentypeh <em>y</em>, half <em>a</em>)</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>Returns the linear blend of <em>x</em> and <em>y</em> implemented as:</p>
</div>
<div class="paragraph">
<p><em>x</em> + (<em>y</em> - <em>x</em>) * <em>a</em></p>
</div>
<div class="paragraph">
<p><em>a</em> must be a value in the range [0.0, 1.0]. If <em>a</em> is not in the range [0.0,
1.0], the return values are undefined.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The half-precision <strong>mix</strong> function can be implemented using
contractions such as <strong>mad</strong> or <strong>fma</strong>.
</td>
</tr>
</table>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>radians</strong>(gentype <em>degrees</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Converts <em>degrees</em> to radians, i.e. (Ï€ / 180) * <em>degrees</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>step</strong>(gentype <em>edge</em>, gentype <em>x</em>)<br>
gentypef <strong>step</strong>(float <em>edge</em>, gentypef <em>x</em>)<br>
gentyped <strong>step</strong>(double <em>edge</em>, gentyped <em>x</em>)</p>
<p class="tableblock">gentypeh <strong>step</strong>(half <em>edge</em>, gentypeh <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns 0.0 if <em>x</em> &lt; <em>edge</em>, otherwise it returns 1.0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>smoothstep</strong>(gentype <em>edge0</em>, gentype <em>edge1</em>, gentype <em>x</em>)<br>
gentypef <strong>smoothstep</strong>(float <em>edge0</em>, float <em>edge1</em>, gentypef <em>x</em>)<br>
gentyped <strong>smoothstep</strong>(double <em>edge0</em>, double <em>edge1</em>, gentyped <em>x</em>)</p>
<p class="tableblock">gentypeh <strong>smoothstep</strong>(half <em>edge0</em>, half <em>edge1</em>, gentypeh <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>Returns 0.0 if <em>x</em> &lt;= <em>edge0</em> and 1.0 if <em>x</em> &gt;= <em>edge1</em> and performs
smooth Hermite interpolation between 0 and 1 when <em>edge0</em> &lt; <em>x</em> &lt;
<em>edge1</em>.
This is useful in cases where you would want a threshold function with
a smooth transition.</p>
</div>
<div class="paragraph">
<p>This is equivalent to:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">t</span><span class="p">;</span>
<span class="n">t</span> <span class="o">=</span> <span class="n">clamp</span> <span class="p">((</span><span class="n">x</span> <span class="o">-</span> <span class="n">edge0</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">edge1</span> <span class="o">-</span> <span class="n">edge0</span><span class="p">),</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
<span class="k">return</span> <span class="n">t</span> <span class="o">*</span> <span class="n">t</span> <span class="o">*</span> <span class="p">(</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">t</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Results are undefined if <em>edge0</em> &gt;= <em>edge1</em> or if <em>x</em>, <em>edge0</em> or <em>edge1</em> is
a NaN.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The half-precision <strong>mix</strong> function can be implemented using
contractions such as <strong>mad</strong> or <strong>fma</strong>.
</td>
</tr>
</table>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sign</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns 1.0 if <em>x</em> &gt; 0, -0.0 if <em>x</em> = -0.0, +0.0 if <em>x</em> = +0.0, or
-1.0 if <em>x</em> &lt; 0.
Returns 0.0 if <em>x</em> is a NaN.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="geometric-functions"><a class="anchor" href="#geometric-functions"></a>6.15.5. Geometric Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <a href="#table-builtin-geometric">following table</a> describes the list of built-in
geometric functions.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentypef</code> indicates that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>float</code>, <code>float2</code>, <code>float3</code>, or <code>float4</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentyped</code> <sup class="footnote">[<a id="_footnoteref_54" class="footnote" href="#_footnotedef_54" title="View footnote.">54</a>]</sup> indicates
that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>double</code>, <code>double2</code>, <code>double3</code>, or <code>double4</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentypeh</code> <sup class="footnote">[<a id="_footnoteref_55" class="footnote" href="#_footnotedef_55" title="View footnote.">55</a>]</sup> indicates
that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>half</code>, <code>half2</code>, <code>half3</code>, or <code>half4</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
All functions taking or returning <code>half</code> types are supported only when
the <code>cl_khr_<wbr>fp16</code> extension macro is supported.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>For any specific use of a function with <code>gentype*</code> arguments the actual type
has to be the same for all arguments and the return type, unless they are
explicitly specified as an actual type.</p>
</div>
<table id="table-builtin-geometric" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 17. Built-in Scalar and Vector Argument Geometric Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>cross</strong>(float4 <em>p0</em>, float4 <em>p1</em>)<br>
float3 <strong>cross</strong>(float3 <em>p0</em>, float3 <em>p1</em>)<br>
double4 <strong>cross</strong>(double4 <em>p0</em>, double4 <em>p1</em>)<br>
double3 <strong>cross</strong>(double3 <em>p0</em>, double3 <em>p1</em>)</p>
<p class="tableblock"> half4 <strong>cross</strong>(half4 <em>p0</em>, half4 <em>p1</em>)<br>
half3 <strong>cross</strong>(half3 <em>p0</em>, half3 <em>p1</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the cross product of <em>p0.xyz</em> and <em>p1.xyz</em>.
The <em>w</em> component of <code>float4</code> result returned will be 0.0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>dot</strong>(gentypef <em>p0</em>, gentypef <em>p1</em>)<br>
double <strong>dot</strong>(gentyped <em>p0</em>, gentyped <em>p1</em>)</p>
<p class="tableblock">half <strong>dot</strong>(gentypeh <em>p0</em>, gentypeh <em>p1</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compute the dot product of <em>p0</em> and <em>p1</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>distance</strong>(gentypef <em>p0</em>, gentypef <em>p1</em>)<br>
double <strong>distance</strong>(gentyped <em>p0</em>, gentyped <em>p1</em>)</p>
<p class="tableblock">half <strong>distance</strong>(gentypeh <em>p0</em>, gentypeh <em>p1</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the distance between <em>p0</em> and <em>p1</em>.
This is calculated as <strong>length</strong>(<em>p0</em> - <em>p1</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>length</strong>(gentypef <em>p</em>)<br>
double <strong>length</strong>(gentyped <em>p</em>)</p>
<p class="tableblock">half <strong>length</strong>(gentypeh <em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the length of vector <em>p</em>, i.e., √ <em>p.x</em><sup>2</sup> + <em>p.y</em> <sup>2</sup>
+ &#8230;&#8203;</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentypef <strong>normalize</strong>(gentypef <em>p</em>)<br>
gentyped <strong>normalize</strong>(gentyped <em>p</em>)</p>
<p class="tableblock">gentypeh <strong>normalize</strong>(gentypeh <em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a vector in the same direction as <em>p</em> but with a length of 1.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>fast_distance</strong>(float<em>n</em> <em>p0</em>, float<em>n</em> <em>p1</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <strong>fast_length</strong>(<em>p0</em> - <em>p1</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>fast_length</strong>(float<em>n</em> <em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the length of vector <em>p</em> computed as:</p>
<p class="tableblock"> <strong>half_sqrt</strong>(<em>p.x</em><sup>2</sup> + <em>p.y</em><sup>2</sup> + &#8230;&#8203;)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>fast_normalize</strong>(float<em>n</em> <em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>Returns a vector in the same direction as <em>p</em> but with a length of 1.
<strong>fast_normalize</strong> is computed as:</p>
</div>
<div class="paragraph">
<p><em>p</em> * <strong>half_rsqrt</strong>(<em>p.x</em><sup>2</sup> + <em>p.y</em><sup>2</sup> + &#8230;&#8203;)</p>
</div>
<div class="paragraph">
<p>The result shall be within 8192 ulps error from the infinitely precise
result of</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">if</span> <span class="p">(</span><span class="n">all</span><span class="p">(</span><span class="n">p</span> <span class="o">==</span> <span class="mf">0.0f</span><span class="p">))</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">p</span><span class="p">;</span>
<span class="k">else</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">p</span> <span class="o">/</span>
<span class="n">sqrt</span><span class="p">(</span><span class="n">p</span><span class="p">.</span><span class="n">x</span><span class="o">*</span><span class="n">p</span><span class="p">.</span><span class="n">x</span> <span class="o">+</span> <span class="n">p</span><span class="p">.</span><span class="n">y</span><span class="o">*</span><span class="n">p</span><span class="p">.</span><span class="n">y</span> <span class="o">+</span> <span class="p">...);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>with the following exceptions:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>If the sum of squares is greater than <code>FLT_MAX</code> then the value of the
floating-point values in the result vector are undefined.</p>
</li>
<li>
<p>If the sum of squares is less than <code>FLT_MIN</code> then the implementation
may return back <em>p</em>.</p>
</li>
<li>
<p>If the device is in &#8220;denorms are flushed to zero&#8221; mode, individual
operand elements with magnitude less than <strong>sqrt</strong>(<code>FLT_MIN</code>) may be flushed
to zero before proceeding with the calculation.</p>
</li>
</ol>
</div></div></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="relational-functions"><a class="anchor" href="#relational-functions"></a>6.15.6. Relational Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <a href="#operators-relational">relational</a> and <a href="#operators-equality">equality</a>
operators (<strong>&lt;</strong>, <strong>&lt;=</strong>, <strong>&gt;</strong>, <strong>&gt;=</strong>, <strong>!=</strong>, <strong>==</strong>) can be used with scalar and
vector built-in types and produce a scalar or vector signed integer result
respectively.</p>
</div>
<div class="paragraph">
<p>The functions described in the <a href="#table-builtin-relational">Built-in Scalar and
Vector Relational Functions</a> table can be used with built-in scalar or vector
types as arguments and return a scalar or vector integer result
<sup class="footnote">[<a id="_footnoteref_56" class="footnote" href="#_footnotedef_56" title="View footnote.">56</a>]</sup>.
The argument type <code>gentype</code> refers to the following built-in types: <code>char</code>,
<code>char<em>n</em></code>, <code>uchar</code>, <code>uchar<em>n</em></code>, <code>short</code>, <code>short<em>n</em></code>, <code>ushort</code>,
<code>ushort<em>n</em></code>, <code>int</code>, <code>int<em>n</em></code>, <code>uint</code>, <code>uint<em>n</em></code>, <code>long</code>
<sup class="footnote">[<a id="_footnoteref_57" class="footnote" href="#_footnotedef_57" title="View footnote.">57</a>]</sup>, <code>long<em>n</em></code>, <code>ulong</code>, <code>ulong<em>n</em></code>, <code>float</code>,
<code>float<em>n</em></code>, <code>double</code> <sup class="footnote">[<a id="_footnoteref_58" class="footnote" href="#_footnotedef_58" title="View footnote.">58</a>]</sup>, and
<code>double<em>n</em></code>.
The argument type <code>igentype</code> refers to the built-in signed integer types
i.e. <code>char</code>, <code>char<em>n</em></code>, <code>short</code>, <code>short<em>n</em></code>, <code>int</code>, <code>int<em>n</em></code>, <code>long</code>
and <code>long<em>n</em></code>.
The argument type <code>ugentype</code> refers to the built-in unsigned integer types
i.e. <code>uchar</code>, <code>uchar<em>n</em></code>, <code>ushort</code>, <code>ushort<em>n</em></code>, <code>uint</code>, <code>uint<em>n</em></code>,
<code>ulong</code> and <code>ulong<em>n</em></code>.
<em>n</em> is 2, 3, 4, 8, or 16.</p>
</div>
<div class="paragraph">
<p>The functions <strong>isequal</strong>, <strong>isnotequal</strong>, <strong>isgreater</strong>, <strong>isgreaterequal</strong>,
<strong>isless</strong>, <strong>islessequal</strong>, <strong>islessgreater</strong>, <strong>isfinite</strong>, <strong>isinf</strong>, <strong>isnan</strong>,
<strong>isnormal</strong>, <strong>isordered</strong>, <strong>isunordered</strong> and <strong>signbit</strong> described in the
following table shall return a 0 if the specified relation is <em>false</em> and a
1 if the specified relation is <em>true</em> for scalar argument types.
These functions shall return a 0 if the specified relation is <em>false</em> and a
-1 (i.e. all bits set) if the specified relation is <em>true</em> for vector
argument types.</p>
</div>
<div class="paragraph">
<p>The relational functions <strong>isequal</strong>, <strong>isgreater</strong>, <strong>isgreaterequal</strong>, <strong>isless</strong>,
<strong>islessequal</strong>, and <strong>islessgreater</strong> always return 0 if either argument is not
a number (NaN).
<strong>isnotequal</strong> returns 1 if one or both arguments are not a number (NaN) and
the argument type is a scalar and returns -1 if one or both arguments are
not a number (NaN) and the argument type is a vector.</p>
</div>
<table id="table-builtin-relational" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 18. Built-in Scalar and Vector Relational Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isequal</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>isequal</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>isequal</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>isequal</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>isequal</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isequal</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <em>x</em> == <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isnotequal</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>isnotequal</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>isnotequal</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>isnotequal</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>isnotequal</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isnotequal</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <em>x</em> != <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isgreater</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>isgreater</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>isgreater</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>isgreater</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>isgreater</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isgreater</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <em>x</em> &gt; <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isgreaterequal</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>isgreaterequal</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>isgreaterequal</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>isgreaterequal</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>isgreaterequal</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isgreaterequal</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <em>x</em> &gt;= <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isless</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>isless</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>isless</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>isless</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>isless</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isless</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <em>x</em> &lt; <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>islessequal</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>islessequal</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>islessequal</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>islessequal</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>islessequal</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>islessequal</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of <em>x</em> &lt;= <em>y</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>islessgreater</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>islessgreater</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>islessgreater</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>islessgreater</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>islessgreater</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>islessgreater</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the component-wise compare of (<em>x</em> &lt; <em>y</em>) || (<em>x</em> &gt; <em>y</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isfinite</strong>(float)<br>
int<em>n</em> <strong>isfinite</strong>(float<em>n</em>)<br>
int <strong>isfinite</strong>(double)<br>
long<em>n</em> <strong>isfinite</strong>(double<em>n</em>)</p>
<p class="tableblock"> int <strong>isfinite</strong>(half)<br>
short<em>n</em> <strong>isfinite</strong>(half<em>n</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Test for finite value.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isinf</strong>(float)<br>
int<em>n</em> <strong>isinf</strong>(float<em>n</em>)<br>
int <strong>isinf</strong>(double)<br>
long<em>n</em> <strong>isinf</strong>(double<em>n</em>)</p>
<p class="tableblock"> int <strong>isinf</strong>(half)<br>
short<em>n</em> <strong>isinf</strong>(half<em>n</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Test for infinity value (positive or negative).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isnan</strong>(float)<br>
int<em>n</em> <strong>isnan</strong>(float<em>n</em>)<br>
int <strong>isnan</strong>(double)<br>
long<em>n</em> <strong>isnan</strong>(double<em>n</em>)</p>
<p class="tableblock"> int <strong>isnan</strong>(half)<br>
short<em>n</em> <strong>isnan</strong>(half<em>n</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Test for a NaN.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isnormal</strong>(float)<br>
int<em>n</em> <strong>isnormal</strong>(float<em>n</em>)<br>
int <strong>isnormal</strong>(double)<br>
long<em>n</em> <strong>isnormal</strong>(double<em>n</em>)</p>
<p class="tableblock"> int <strong>isnormal</strong>(half)<br>
short<em>n</em> <strong>isnormal</strong>(half<em>n</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Test for a normal value.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isordered</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>isordered</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>isordered</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>isordered</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>isordered</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isordered</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Test if arguments are ordered.
<strong>isordered</strong>() takes arguments <em>x</em> and <em>y</em>, and returns the result
<strong>isequal</strong>(<em>x</em>, <em>x</em>) &amp;&amp; <strong>isequal</strong>(<em>y</em>, <em>y</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>isunordered</strong>(float <em>x</em>, float <em>y</em>)<br>
int<em>n</em> <strong>isunordered</strong>(float<em>n</em> <em>x</em>, float<em>n</em> <em>y</em>)<br>
int <strong>isunordered</strong>(double <em>x</em>, double <em>y</em>)<br>
long<em>n</em> <strong>isunordered</strong>(double<em>n</em> <em>x</em>, double<em>n</em> <em>y</em>)</p>
<p class="tableblock"> int <strong>isunordered</strong>(half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isunordered</strong>(half<em>n</em> <em>x</em>, half<em>n</em> <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Test if arguments are unordered.
<strong>isunordered</strong>() takes arguments <em>x</em> and <em>y</em>, returning non-zero if <em>x</em>
or <em>y</em> is NaN, and zero otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>signbit</strong>(float <em>x</em>)<br>
int<em>n</em> <strong>signbit</strong>(float<em>n</em> <em>x</em>)<br>
int <strong>signbit</strong>(double <em>x</em>)<br>
long<em>n</em> <strong>signbit</strong>(double<em>n</em> <em>x</em>)</p>
<p class="tableblock"> int <strong>signbit</strong>(half <em>x</em>)<br>
short<em>n</em> <strong>signbit</strong>(half<em>n</em> <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Test for sign bit.
The scalar version of the function returns a 1 if the sign bit in <em>x</em>
is set else returns 0.
The vector version of the function returns the following for each
component in <em>x</em>: -1 (i.e all bits set) if the sign bit in the float is
set else returns 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>any</strong>(igentype <em>x</em>)</p>
<p class="tableblock">Scalar inputs to <strong>any</strong> are <a href="#unified-spec">deprecated by</a> OpenCL C version
3.0.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns 1 if the most significant bit of <em>x</em> is set for scalar inputs, or
if the most significant bit is set for any component of <em>x</em> for vector
inputs; otherwise returns 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>all</strong>(igentype <em>x</em>)</p>
<p class="tableblock">Scalar inputs to <strong>all</strong> are <a href="#unified-spec">deprecated by</a> OpenCL C version
3.0.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns 1 if the most significant bit of <em>x</em> is set for scalar inputs, or
if the most significant bit is set for all components of <em>x</em> for vector
inputs; otherwise returns 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>bitselect</strong>(gentype <em>a</em>, gentype <em>b</em>, gentype <em>c</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Each bit of the result is the corresponding bit of <em>a</em> if the
corresponding bit of <em>c</em> is 0.
Otherwise it is the corresponding bit of <em>b</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>select</strong>(gentype <em>a</em>, gentype <em>b</em>, igentype <em>c</em>)<br>
gentype <strong>select</strong>(gentype <em>a</em>, gentype <em>b</em>, ugentype <em>c</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For each component of a vector type,</p>
<p class="tableblock"> <em>result[i]</em> = if MSB of <em>c[i]</em> is set ? <em>b[i]</em> : <em>a[i]</em>.</p>
<p class="tableblock"> For a scalar type, <em>result</em> = <em>c</em> ? <em>b</em> : <em>a</em>.</p>
<p class="tableblock"> <code>igentype</code> and <code>ugentype</code> must have the same number of elements and
bits as <code>gentype</code> <sup class="footnote">[<a id="_footnoteref_59" class="footnote" href="#_footnotedef_59" title="View footnote.">59</a>]</sup>.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="vector-data-load-and-store-functions"><a class="anchor" href="#vector-data-load-and-store-functions"></a>6.15.7. Vector Data Load and Store Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <a href="#table-vector-loadstore">Built-in Vector Data Load and Store
Functions</a> table describes the list of supported functions that allow you
to read and write vector types from a pointer to memory.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentype</code> indicates that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>, <code>int</code>, <code>uint</code>, <code>long</code>
<sup class="footnote">[<a id="_footnoteref_60" class="footnote" href="#_footnotedef_60" title="View footnote.">60</a>]</sup> or <code>ulong</code></p>
</li>
<li>
<p><code>float</code> or <code>double</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_42" title="View footnote.">42</a>]</sup></p>
</li>
<li>
<p><code>half</code> <sup class="footnote">[<a id="_footnoteref_61" class="footnote" href="#_footnotedef_61" title="View footnote.">61</a>]</sup></p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
All functions taking or returning <code>half</code> types are supported only when
the <code>cl_khr_<wbr>fp16</code> extension macro is supported.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>as the type for the arguments.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentype<em>n</em></code> indicates an <em>n</em>-element vector of
<code>gentype</code> elements.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>half<em>n</em></code> indicates an <em>n</em>-element vector of <code>half</code>
elements.</p>
</div>
<div class="paragraph">
<p>The suffix <em>n</em> is also used in the function names (i.e. <strong>vload<em>n</em></strong>,
<strong>vstore<em>n</em></strong> etc.), where <em>n</em> = 2, 3 <sup class="footnote">[<a id="_footnoteref_62" class="footnote" href="#_footnotedef_62" title="View footnote.">62</a>]</sup>, 4,
8 or 16.</p>
</div>
<table id="table-vector-loadstore" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 19. Built-in Vector Data Load and Store Functions</caption>
<colgroup>
<col style="width: 70%;">
<col style="width: 30%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype<em>n</em> <strong>vload<em>n</em></strong>(size_t <em>offset</em>, const __global gentype *<em>p</em>)<br>
gentype<em>n</em> <strong>vload<em>n</em></strong>(size_t <em>offset</em>, const __local gentype *<em>p</em>)<br>
gentype<em>n</em> <strong>vload<em>n</em></strong>(size_t <em>offset</em>, const __constant gentype *<em>p</em>)<br>
gentype<em>n</em> <strong>vload<em>n</em></strong>(size_t <em>offset</em>, const __private gentype *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> gentype<em>n</em> <strong>vload<em>n</em></strong>(size_t <em>offset</em>, const gentype *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return <code>sizeof(gentype<em>n</em>)</code> bytes of data, where the first <code>(<em>n</em> *
sizeof(gentype))</code> bytes are read from the address
computed as <code>(<em>p</em> + (<em>offset</em> * <em>n</em>))</code>.
The computed address must be 8-bit aligned if <code>gentype</code> is <code>char</code> or
<code>uchar</code>; 16-bit aligned if <code>gentype</code> is
<code>half</code>,
<code>short</code> or <code>ushort</code>; 32-bit aligned if <code>gentype</code> is <code>int</code>, <code>uint</code>, or
<code>float</code>; and 64-bit aligned if <code>gentype</code> is <code>long</code> or <code>ulong</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>vstore<em>n</em></strong>(gentype<em>n</em> <em>data</em>, size_t <em>offset</em>, __global gentype *<em>p</em>)<br>
void <strong>vstore<em>n</em></strong>(gentype<em>n</em> <em>data</em>, size_t <em>offset</em>, __local gentype *<em>p</em>)<br>
void <strong>vstore<em>n</em></strong>(gentype<em>n</em> <em>data</em>, size_t <em>offset</em>, __private gentype *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> void <strong>vstore<em>n</em></strong>(gentype<em>n</em> <em>data</em>, size_t <em>offset</em>, gentype *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <code><em>n</em> * sizeof(gentype)</code> bytes given by <em>data</em> to the address
computed as <code>(<em>p</em> + (<em>offset</em> * <em>n</em>))</code>.
The computed address must be 8-bit aligned if <code>gentype</code> is <code>char</code> or
<code>uchar</code>; 16-bit aligned if <code>gentype</code> is
<code>half</code>,
<code>short</code> or <code>ushort</code>; 32-bit aligned if <code>gentype</code> is <code>int</code>, <code>uint</code>, or
<code>float</code>; and 64-bit aligned if <code>gentype</code> is <code>long</code> or <code>ulong</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>vload_half</strong>(size_t <em>offset</em>, const __global half *<em>p</em>)<br>
float <strong>vload_half</strong>(size_t <em>offset</em>, const __local half *<em>p</em>)<br>
float <strong>vload_half</strong>(size_t <em>offset</em>, const __constant half *<em>p</em>)<br>
float <strong>vload_half</strong>(size_t <em>offset</em>, const __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> float <strong>vload_half</strong>(size_t <em>offset</em>, const half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read <code>sizeof(half)</code> bytes of data from the address computed as <code>(<em>p</em>
+ <em>offset</em>)</code>.
The data read is interpreted as a <code>half</code> value.
The <code>half</code> value is converted to a <code>float</code> value and the <code>float</code> value
is returned.
The computed read address must be 16-bit aligned.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>vload_half<em>n</em></strong>(size_t <em>offset</em>, const __global half *<em>p</em>)<br>
float<em>n</em> <strong>vload_half<em>n</em></strong>(size_t <em>offset</em>, const __local half *<em>p</em>)<br>
float<em>n</em> <strong>vload_half<em>n</em></strong>(size_t <em>offset</em>, const __constant half *<em>p</em>)<br>
float<em>n</em> <strong>vload_half<em>n</em></strong>(size_t <em>offset</em>, const __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> float<em>n</em> <strong>vload_half<em>n</em></strong>(size_t <em>offset</em>, const half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read <code>(<em>n</em> * sizeof(half))</code> bytes of data from the address computed as
<code>(<em>p</em> + (<em>offset * n</em>))</code>.
The data read is interpreted as a <code>half<em>n</em></code> value.
The <code>half<em>n</em></code> value read is converted to a <code>float<em>n</em></code> value and
the <code>float<em>n</em></code> value is returned.
The computed read address must be 16-bit aligned.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>vstore_half</strong>(float <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half_rte</strong>(float <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half_rtz</strong>(float <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half_rtp</strong>(float <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half_rtn</strong>(float <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstore_half</strong>(float <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half_rte</strong>(float <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half_rtz</strong>(float <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half_rtp</strong>(float <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half_rtn</strong>(float <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstore_half</strong>(float <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half_rte</strong>(float <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half_rtz</strong>(float <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half_rtp</strong>(float <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half_rtn</strong>(float <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> void <strong>vstore_half</strong>(float <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half_rte</strong>(float <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half_rtz</strong>(float <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half_rtp</strong>(float <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half_rtn</strong>(float <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>float</code> value given by <em>data</em> is first converted to a <code>half</code> value
using the appropriate rounding mode.
The <code>half</code> value is then written to the address computed as <code>(<em>p</em>
+ <em>offset</em>)</code>.
The computed address must be 16-bit aligned.</p>
<p class="tableblock"> <strong>vstore_half</strong> uses the default rounding mode.
The default rounding mode is round to nearest even.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>vstore_half<em>n</em></strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rte</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtz</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtp</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtn</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstore_half<em>n</em></strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rte</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtz</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtp</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtn</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstore_half<em>n</em></strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rte</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtz</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtp</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtn</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> void <strong>vstore_half<em>n</em></strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rte</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtz</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtp</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtn</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>float<em>n</em></code> value given by <em>data</em> is converted to a <code>half<em>n</em></code>
value using the appropriate rounding mode.
<code><em>n</em> * sizeof(half)</code> bytes from the <code>half<em>n</em></code> value are then written to
the address computed as <code>(<em>p</em>
+ (<em>offset</em> * <em>n</em>))</code>.
The computed address must be 16-bit aligned.</p>
<p class="tableblock"> <strong>vstore_half<em>n</em></strong> uses the default rounding mode.
The default rounding mode is round to nearest even.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>vstore_half</strong>(double <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half_rte</strong>(double <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half_rtz</strong>(double <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half_rtp</strong>(double <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half_rtn</strong>(double <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstore_half</strong>(double <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half_rte</strong>(double <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half_rtz</strong>(double <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half_rtp</strong>(double <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half_rtn</strong>(double <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstore_half</strong>(double <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half_rte</strong>(double <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half_rtz</strong>(double <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half_rtp</strong>(double <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half_rtn</strong>(double <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> void <strong>vstore_half</strong>(double <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half_rte</strong>(double <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half_rtz</strong>(double <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half_rtp</strong>(double <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half_rtn</strong>(double <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>double</code> value given by <em>data</em> is first converted to a <code>half</code>
value using the appropriate rounding mode.
The <code>half</code> value is then written to the address computed as <code>(<em>p</em>
+ <em>offset</em>)</code>.
The computed address must be 16-bit aligned.</p>
<p class="tableblock"> <strong>vstore_half</strong> uses the default rounding mode.
The default rounding mode is round to nearest even.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>vstore_half<em>n</em></strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rte</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtz</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtp</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtn</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstore_half<em>n</em></strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rte</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtz</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtp</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtn</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstore_half<em>n</em></strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rte</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtz</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtp</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtn</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> void <strong>vstore_half<em>n</em></strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rte</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtz</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtp</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstore_half<em>n</em>_rtn</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>double<em>n</em></code> value given by <em>data</em> is converted to a <code>half<em>n</em></code>
value using the appropriate rounding mode.
<code><em>n</em> * sizeof(half)</code> bytes from the <code>half<em>n</em></code> value are then written to
the address computed as <code>(<em>p</em> + (<em>offset</em> * <em>n</em>))</code>.
The computed address must be 16-bit aligned.</p>
<p class="tableblock"> <strong>vstore_half<em>n</em></strong> uses the default rounding mode.
The default rounding mode is round to nearest even.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float<em>n</em> <strong>vloada_half<em>n</em></strong>(size_t <em>offset</em>, const __global half *<em>p</em>)<br>
float<em>n</em> <strong>vloada_half<em>n</em></strong>(size_t <em>offset</em>, const __local half *<em>p</em>)<br>
float<em>n</em> <strong>vloada_half<em>n</em></strong>(size_t <em>offset</em>, const __constant half *<em>p</em>)<br>
float<em>n</em> <strong>vloada_half<em>n</em></strong>(size_t <em>offset</em>, const __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> float<em>n</em> <strong>vloada_half<em>n</em></strong>(size_t <em>offset</em>, const half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For n = 2, 4, 8 and 16, read <code>sizeof(half<em>n</em>)</code> bytes of data from
the address computed as (<em>p</em> + (<em>offset</em> * <em>n</em>)).
The data read is interpreted as a <code>half<em>n</em></code> value.
The <code>half<em>n</em></code> value read is converted to a <code>float<em>n</em></code> value and
the <code>float<em>n</em></code> value is returned.
The computed address must be aligned to <code>sizeof(half<em>n</em>)</code> bytes.</p>
<p class="tableblock"> For n = 3, <strong>vloada_half3</strong> reads a <code>half3</code> from the address computed as
<code>(<em>p</em> + (<em>offset * 4</em>))</code> and returns a <code>float3</code>.
The computed address must be aligned to <code>sizeof(half)</code> * 4 bytes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>vstorea_half<em>n</em></strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rte</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtz</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtp</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtn</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstorea_half<em>n</em></strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rte</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtz</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtp</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtn</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstorea_half<em>n</em></strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rte</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtz</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtp</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtn</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> void <strong>vstorea_half<em>n</em></strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rte</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtz</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtp</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtn</strong>(float<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>float<em>n</em></code> value given by <em>data</em> is converted to a <code>half<em>n</em></code>
value using the appropriate rounding mode.</p>
<p class="tableblock"> For n = 2, 4, 8 and 16, the <code>half<em>n</em></code> value is written to the
address computed as <code>(<em>p</em> + (<em>offset</em> * <em>n</em>))</code>.
The computed address must be aligned to <code>sizeof(half<em>n</em>)</code> bytes.</p>
<p class="tableblock"> For n = 3, the <code>half3</code> value is written
to the address computed as <code>(<em>p</em> + (<em>offset</em> * 4))</code>.
The computed address must be aligned to <code>sizeof(half) * 4</code> bytes.</p>
<p class="tableblock"> <strong>vstorea_half<em>n</em></strong> uses the default rounding mode.
The default rounding mode is round to nearest even.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>vstorea_half<em>n</em></strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rte</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtz</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtp</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtn</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __global half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstorea_half<em>n</em></strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rte</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtz</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtp</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtn</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __local half *<em>p</em>)</p>
<p class="tableblock"> void <strong>vstorea_half<em>n</em></strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rte</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtz</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtp</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtn</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, __private half *<em>p</em>)</p>
<p class="tableblock"> For OpenCL C 2.0, or OpenCL C 3.0 or newer with the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature:</p>
<p class="tableblock"> void <strong>vstorea_half<em>n</em></strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rte</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtz</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtp</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)<br>
void <strong>vstorea_half<em>n</em>_rtn</strong>(double<em>n</em> <em>data</em>, size_t <em>offset</em>, half *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>double<em>n</em></code> value is converted to a <code>half<em>n</em></code> value using the
appropriate rounding mode.</p>
<p class="tableblock"> For n = 2, 4, 8 or 16, the <code>half<em>n</em></code> value is written to the address
computed as <code>(<em>p</em> + (<em>offset</em> * <em>n</em>))</code>.
The computed address must be aligned to <code>sizeof(half<em>n</em>)</code> bytes.</p>
<p class="tableblock"> For n = 3, the <code>half3</code> value is written
to the address computed as <code>(<em>p</em> + (<em>offset</em> * 4))</code>.
The computed address must be aligned to <code>sizeof(half) * 4</code> bytes.</p>
<p class="tableblock"> <strong>vstorea_half<em>n</em></strong> uses the default rounding mode.
The default rounding mode is round to nearest even.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The results of vector data load and store functions are undefined if the
address being read from or written to is not correctly aligned as described
in <a href="#table-vector-loadstore">Built-in Vector Data Load and Store Functions</a>.
The pointer argument p can be a pointer to <code>global</code>, <code>local</code>, or <code>private</code>
memory for store functions described in <a href="#table-vector-loadstore">Built-in Vector
Data Load and Store Functions</a>.
The pointer argument p can be a pointer to <code>global</code>, <code>local</code>, <code>constant</code>, or
<code>private</code> memory for load functions described in
<a href="#table-vector-loadstore">Built-in Vector Data Load and Store Functions</a>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The vector data load and store functions variants that take pointer
arguments which point to the generic address space are also supported.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="synchronization-functions"><a class="anchor" href="#synchronization-functions"></a>6.15.8. Synchronization Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following table describes built-in functions to synchronize the work-items
in a work-group.</p>
</div>
<table id="table-builtin-synchronization" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 20. Built-in Work-group Synchronization Functions</caption>
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>barrier</strong>(<br>
cl_mem_fence_flags <em>flags</em>)</p>
<p class="tableblock"> For OpenCL C 2.0 or newer, as an alias for <strong>barrier</strong>:</p>
<p class="tableblock"> void <strong>work_group_barrier</strong>(<br>
cl_mem_fence_flags <em>flags</em>)</p>
<p class="tableblock"> void <strong>work_group_barrier</strong>(<br>
cl_mem_fence_flags <em>flags</em>,
memory_scope <em>scope</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For these functions, if any work-item in a work-group encounters a
barrier, the barrier must be encountered by all work-items in the
work-group before any are allowed to continue execution beyond the
barrier.</p>
<p class="tableblock"> If the barrier is inside a conditional statement, then all
work-items in the work-group must enter the conditional if any work-item in the work-group enters the
conditional statement and executes the barrier.</p>
<p class="tableblock"> If the barrier is inside a loop, then all work-items in the work-group must execute
the barrier on each iteration of the loop if any work-item executes the barrier on that iteration.</p>
<p class="tableblock"> The <strong>barrier</strong> and <strong>work_group_barrier</strong> functions can specify which
memory operations become visible to the appropriate memory scope
identified by <em>scope</em> <sup class="footnote">[<a id="_footnoteref_63" class="footnote" href="#_footnotedef_63" title="View footnote.">63</a>]</sup>.
The <em>flags</em> argument specifies the memory address spaces.
This is a bitfield and can be set to 0 or a combination of the
following values OR&#8217;ed together.
When these flags are OR&#8217;ed together the barrier acts as a
combined barrier for all address spaces specified by the flags
ordering memory accesses both within and across the specified address
spaces.
For <strong>barrier</strong> and the <strong>work_group_barrier</strong> variant that does not take a
memory scope, the <em>scope</em> is <code>memory_scope_work_group</code>.</p>
<p class="tableblock"> <code>CLK_LOCAL_MEM_FENCE</code> - ensure
that all <code>local</code> memory accesses become visible to all work-items in the
work-group.
Note that the value of <em>scope</em> is ignored as the memory scope is
always <code>memory_scope_work_group</code>.</p>
<p class="tableblock"> <code>CLK_GLOBAL_MEM_FENCE</code> - ensure that
all <code>global</code> memory accesses become visible to the appropriate memory scope
as given by <em>scope</em>.</p>
<p class="tableblock"> <code>CLK_IMAGE_MEM_FENCE</code> - ensure that all image memory accesses
become visible to the appropriate scope given by <em>scope</em>.
The value of <em>scope</em> must be <code>memory_scope_work_group</code>.</p>
<p class="tableblock"> The values of <em>flags</em> and <em>scope</em> must be the same for all work-items
in the work-group.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in the following table <a href="#unified-spec">requires</a> support for
the <code>cl_khr_<wbr>subgroups</code> extension, or
OpenCL 3.0 or newer and the <code>__opencl_c_<wbr>subgroups</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The following table describes built-in functions to synchronize the work-items
in a sub-group.</p>
</div>
<table id="table-synchronization-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 21. Built-in Sub-Group Synchronization Functions</caption>
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>sub_group_barrier</strong>(<br>
cl_mem_fence_flags <em>flags</em>)</p>
<p class="tableblock"> void <strong>sub_group_barrier</strong>(<br>
cl_mem_fence_flags <em>flags</em>,<br>
memory_scope <em>scope</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For these functions, if any work-item in a sub-group encounters a
<strong>sub_group_barrier</strong>, the barrier must be encountered by all work-items in the
sub-group before any are allowed to continue execution beyond the barrier.</p>
<p class="tableblock"> If <strong>sub_group_barrier</strong> is inside a conditional statement, then all
work-items within the sub-group must enter the conditional if any work-item in
the sub-group enters the conditional statement and executes the
<strong>sub_group_barrier</strong>.</p>
<p class="tableblock"> If the <strong>sub_group_barrier</strong> is inside a loop, then all work-items in the sub-group
must execute the barrier on each iteration of the loop if any work-item executes the barrier on that iteration.</p>
<p class="tableblock"> The <strong>sub_group_barrier</strong> function can specify which
memory operations become visible to the appropriate memory scope
identified by <em>scope</em>.
The <em>flags</em> argument specifies the memory address spaces.
This is a bitfield and can be set to 0 or a combination of the
following values OR&#8217;ed together.
When these flags are OR&#8217;ed together the barrier acts as a
combined barrier for all address spaces specified by the flags
ordering memory accesses both within and across the specified address
spaces.
For the <strong>sub_group_barrier</strong> variant that does not take a
memory scope, the <em>scope</em> is <code>memory_scope_sub_group</code>.</p>
<p class="tableblock"> <code>CLK_LOCAL_MEM_FENCE</code> - The <strong>sub_group_barrier</strong> function will either flush
any variables stored in local memory or queue a memory fence to ensure
correct ordering of memory operations to local memory.</p>
<p class="tableblock"> <code>CLK_GLOBAL_MEM_FENCE</code> - The <strong>sub_group_barrier</strong> function will queue a
memory fence to ensure correct ordering of memory operations to global
memory.
This can be useful when work-items, for example, write to buffer objects
and then want to read the updated data from these buffer objects.</p>
<p class="tableblock"> <code>CLK_IMAGE_MEM_FENCE</code> - The <strong>sub_group_barrier</strong> function will queue a memory
fence to ensure correct ordering of memory operations to image objects.
This can be useful when work-items, for example, write to image objects
and then want to read the updated data from these image objects.</p>
<p class="tableblock"> The value of <em>scope</em> must match requirements of the
<a href="#atomic-restrictions">atomic restrictions section</a>.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="legacy-mem-fence-functions"><a class="anchor" href="#legacy-mem-fence-functions"></a>6.15.9. Legacy Explicit Memory Fence Functions</h4>
<div class="openblock">
<div class="content">
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
The memory fence functions described in this sub-section are
<a href="#unified-spec">deprecated by</a> OpenCL C 2.0.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The OpenCL C programming language implements the following explicit memory fence functions to provide ordering between memory operations of a work-item.</p>
</div>
<table id="table-builtin-explicit-memory-fences" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 22. Built-in Explicit Memory Fence Functions</caption>
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>mem_fence</strong>(<br>
cl_mem_fence_flags <em>flags</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Orders loads and stores of a work-item executing a kernel. This means that
loads and stores preceding the <strong>mem_fence</strong> will be committed to memory
before any loads and stores following the <strong>mem_fence</strong>.</p>
<p class="tableblock"> The <em>flags</em> argument specifies the memory address space and can be set to a
combination of the following literal values:</p>
<p class="tableblock"> <code>CLK_LOCAL_MEM_FENCE</code><br>
<code>CLK_GLOBAL_MEM_FENCE</code></p>
<p class="tableblock"> The value of <em>flags</em> must be the same for all work-items in the work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>read_mem_fence</strong>(<br>
cl_mem_fence_flags <em>flags</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read memory barrier that orders only loads.</p>
<p class="tableblock"> The <em>flags</em> argument specifies the memory address space and can be set to a
combination of the following literal values:</p>
<p class="tableblock"> <code>CLK_LOCAL_MEM_FENCE</code><br>
<code>CLK_GLOBAL_MEM_FENCE</code></p>
<p class="tableblock"> The value of <em>flags</em> must be the same for all work-items in the work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>write_mem_fence</strong>(<br>
cl_mem_fence_flags <em>flags</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write memory barrier that orders only stores.</p>
<p class="tableblock"> The <em>flags</em> argument specifies the memory address space and can be set to a
combination of the following literal values:</p>
<p class="tableblock"> <code>CLK_LOCAL_MEM_FENCE</code><br>
<code>CLK_GLOBAL_MEM_FENCE</code></p>
<p class="tableblock"> The value of <em>flags</em> must be the same for all work-items in the work-group.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="address-space-qualifier-functions"><a class="anchor" href="#address-space-qualifier-functions"></a>6.15.10. Address Space Qualifier Functions</h4>
<div class="openblock">
<div class="content">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and the
<code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>This section describes built-in functions to safely convert from pointers
to the generic address space to pointers to named address spaces, and to
query the appropriate fence flags for a pointer to the generic address space.
We use the generic type name <code>gentype</code> to indicate any of the built-in data
types supported by OpenCL C or a user defined type.</p>
</div>
<table id="table-builtin-address-qualifier" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 23. Built-in Address Space Qualifier Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">global gentype * <strong>to_global</strong>(gentype *<em>ptr</em>)<br>
const global gentype * <strong>to_global</strong>(const gentype *<em>ptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a pointer that points to a region in the <code>global</code> address
space if <strong>to_global</strong> can cast <em>ptr</em> to the <code>global</code> address space.
Otherwise it returns <code>NULL</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">local gentype * <strong>to_local</strong>(gentype *<em>ptr</em>)<br>
const local gentype * <strong>to_local</strong>(const gentype *<em>ptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a pointer that points to a region in the <code>local</code> address space
if <strong>to_local</strong> can cast <em>ptr</em> to the local address space.
Otherwise it returns <code>NULL</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">private gentype * <strong>to_private</strong>(gentype *<em>ptr</em>)<br>
const private gentype * <strong>to_private</strong>(const gentype *<em>ptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a pointer that points to a region in the <code>private</code> address
space if <strong>to_private</strong> can cast <em>ptr</em> to the <code>private</code> address space.
Otherwise it returns <code>NULL</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">cl_mem_fence_flags <strong>get_fence</strong>(gentype *<em>ptr</em>)<br>
cl_mem_fence_flags <strong>get_fence</strong>(const gentype *<em>ptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a valid memory fence value for <em>ptr</em>.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="async-copies"><a class="anchor" href="#async-copies"></a>6.15.11. Async Copies From Global to Local Memory, Local to Global Memory, and Prefetch</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The OpenCL C programming language implements the <a href="#table-builtin-async-copy">following functions</a> that provide asynchronous copies between <code>global</code> and
local memory and a prefetch from <code>global</code> memory.</p>
</div>
<div class="paragraph">
<p>The async copy and wait group events functions are performed by all work-items
in a work-group and therefore must be encountered by all work-items in a
work-group executing the kernel with the same argument values, otherwise the
results are undefined.
This rule applies to ND-ranges implemented with uniform and non-uniform
work-groups.</p>
</div>
<div class="paragraph">
<p>If an async copy or wait group events function is inside a conditional statement
then all work-items in the work-group must enter the conditional if any
work-item in the work-group enters the conditional statement and executes the
async copy or wait group events function.</p>
</div>
<div class="paragraph">
<p>If an async copy or wait group events function is inside a loop then all
work-items in the work-group must execute the async copy or wait group events
function on each iteration of the loop if any work-item executes the async copy
or wait group events function on that iteration.</p>
</div>
<div class="paragraph">
<p>The generic type name <code>gentype</code> indicates that the function can take any of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>char</code>, <code>char<em>n</em></code>, <code>uchar</code>, or <code>uchar<em>n</em></code></p>
</li>
<li>
<p><code>short</code>, <code>short<em>n</em></code>, <code>ushort</code>, or <code>ushort<em>n</em></code></p>
</li>
<li>
<p><code>int</code>, <code>int<em>n</em></code>, <code>uint</code>, or <code>uint<em>n</em></code></p>
</li>
<li>
<p><code>long</code> <sup class="footnote">[<a id="_footnoteref_64" class="footnote" href="#_footnotedef_64" title="View footnote.">64</a>]</sup>, <code>long<em>n</em></code>, <code>ulong</code>, or
<code>ulong<em>n</em></code></p>
</li>
<li>
<p><code>float</code>, <code>float<em>n</em></code></p>
</li>
<li>
<p><code>double</code> <sup class="footnote">[<a id="_footnoteref_65" class="footnote" href="#_footnotedef_65" title="View footnote.">65</a>]</sup> or <code>double<em>n</em></code></p>
</li>
<li>
<p><code>half</code> <sup class="footnote">[<a id="_footnoteref_66" class="footnote" href="#_footnotedef_66" title="View footnote.">66</a>]</sup> or <code>half<em>n</em></code></p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
All functions taking or returning <code>half</code> types are supported only when
the <code>cl_khr_<wbr>fp16</code> extension macro is supported.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>as the type for the arguments unless otherwise stated.
<em>n</em> is 2, 3 <sup class="footnote">[<a id="_footnoteref_67" class="footnote" href="#_footnotedef_67" title="View footnote.">67</a>]</sup>, 4, 8, or 16.</p>
</div>
<table id="table-builtin-async-copy" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 24. Built-in Async Copy and Prefetch Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>event_t <strong>async_work_group_copy</strong>(__local gentype <em>*dst</em>,
const __global gentype *<em>src</em>, size_t <em>num_gentypes</em>, event_t <em>event</em>)<br>
event_t <strong>async_work_group_copy</strong>(__global gentype <em>*dst</em>,
const __local gentype *<em>src</em>, size_t <em>num_gentypes</em>, event_t <em>event</em>)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Perform an async copy of <em>num_gentypes</em> gentype elements from <em>src</em> to
<em>dst</em>.</p>
<p class="tableblock"> Returns an event object that can be used by <strong>wait_group_events</strong> to
wait for the async copy to finish.
The <em>event</em> argument can also be used to associate the
<strong>async_work_group_copy</strong> with a previous async copy allowing an event
to be shared by multiple async copies; otherwise <em>event</em> should be
zero.</p>
<p class="tableblock"> 0 can be implicitly and explicitly cast to <code>event_t</code> type.</p>
<p class="tableblock"> If <em>event</em> argument is non-zero, the event object supplied in <em>event</em>
argument will be returned.</p>
<p class="tableblock"> This function does not perform any implicit synchronization of source
data such as using a <strong>barrier</strong> before performing the copy.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"></div></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>event_t <strong>async_work_group_strided_copy</strong>(__local gentype <em>*dst</em>,
const __global gentype *<em>src</em>, size_t <em>num_gentypes</em>, size_t <em>src_stride</em>,
event_t <em>event</em>)<br>
event_t <strong>async_work_group_strided_copy</strong>(__global gentype <em>*dst</em>,
const __local gentype *<em>src</em>, size_t <em>num_gentypes</em>, size_t <em>dst_stride</em>,
event_t <em>event</em>)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Perform an async gather of <em>num_gentypes</em> <code>gentype</code> elements from
<em>src</em> to <em>dst</em>.
The <em>src_stride</em> is the stride in elements for each <code>gentype</code>
element read from <em>src</em>.
The <em>dst_stride</em> is the stride in elements for each <code>gentype</code> element
written to <em>dst</em>.</p>
<p class="tableblock"> Returns an event object that can be used by <strong>wait_group_events</strong> to
wait for the async copy to finish.
The <em>event</em> argument can also be used to associate the
<strong>async_work_group_strided_copy</strong> with a previous async copy allowing an
event to be shared by multiple async copies; otherwise <em>event</em> should
be zero.</p>
<p class="tableblock"> 0 can be implicitly and explicitly cast to event_t type.</p>
<p class="tableblock"> If <em>event</em> argument is non-zero, the event object supplied in <em>event</em>
argument will be returned.</p>
<p class="tableblock"> This function does not perform any implicit synchronization of source
data such as using a <strong>barrier</strong> before performing the copy.</p>
<p class="tableblock"> The behavior of <strong>async_work_group_strided_copy</strong> is undefined if
<em>src_stride</em> or <em>dst_stride</em> is 0, or if the <em>src_stride</em> or
<em>dst_stride</em> values cause the <em>src</em> or <em>dst</em> pointers to exceed the
upper bounds of the address space during the copy.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"></div></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>void <strong>wait_group_events</strong>(int <em>num_events</em>, event_t *<em>event_list</em>)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Wait for events that identify the <strong>async_work_group_copy</strong> operations
to complete.
The event objects specified in <em>event_list</em> will be released after the
wait is performed.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"></div></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>void <strong>prefetch</strong>(const __global gentype *<em>p</em>, size_t <em>num_gentypes</em>)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Prefetch <code><em>num_gentypes</em> * sizeof(gentype)</code> bytes into the global
cache.
The prefetch instruction is applied to a work-item in a work-group and
does not affect the functional behavior of the kernel.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="fm">async_work_group_copy_fence</span><span class="p">(</span>
<span class="kt">cl_mem_fence_flags</span> <span class="n">flags</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Orders async copies produced by the work-items of a work-group
executing a kernel.
Async copies preceding the <strong>async_work_group_copy_fence</strong> must complete
their access to the designated memory or memories, including both
reads-from and writes-to it, before async copies following the fence
are allowed to start accessing these memories.
In other words, every async copy preceding the
<strong>async_work_group_copy_fence</strong> must happen-before every async copy
following the fence, with respect to the designated memory or
memories.</p>
<p class="tableblock"> The <em>flags</em> argument specifies the memory address space and can be set
to a combination of the following literal values:</p>
<p class="tableblock"> <code>CLK_LOCAL_MEM_FENCE</code><br>
<code>CLK_GLOBAL_MEM_FENCE</code></p>
<p class="tableblock"> The async fence is performed by all work-items in a work-group and
this built-in function must therefore be encountered by all work-items
in a work-group executing the kernel with the same argument values;
otherwise the results are undefined.
This rule applies to ND-ranges implemented with uniform and
non-uniform work-groups.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>async_<wbr>work_<wbr>group_<wbr>copy_<wbr>fence</code> extension macro.</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The kernel must wait for the completion of all async copies using the
<strong>wait_group_events</strong> built-in function before exiting; otherwise the behavior
is undefined.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect4">
<h5 id="extended-async-copies"><a class="anchor" href="#extended-async-copies"></a>6.15.11.1. Extended Async Copy Functions</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>extended_<wbr>async_<wbr>copies</code> extension macro is supported,
additional <a href="#table-builtin-extended-async-copy">Built-in Extended Async Copy
Functions</a> are provided which interpret the source and destination as 2D or
3D data.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p><a href="#table-builtin-async-copy"><strong>async_work_group_strided_copy</strong></a> is a special
case of <strong>async_work_group_copy_2D2D</strong>, namely one which copies a single
column to a single line or vice versa.
For example:<br>
<code>async_work_group_strided_copy(dst, src, num_gentypes, src_stride, event)</code>
is equal to <code>async_work_group_copy_2D2D(dst, 0, src, 0, sizeof(gentype), 1,
num_gentypes, src_stride, 1, event)</code></p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The functions described in this section support arbitrary <code>gentype</code>-based
buffers by casting pointers to <code>void*</code>.</p>
</div>
<div class="paragraph">
<p>These functions do not perform any implicit synchronization of source data
such as using a <strong>barrier</strong> before performing the copy.</p>
</div>
<div class="paragraph">
<p>These functions are performed by all work-items in a work-group and must
therefore be encountered by all work-items in a work-group executing the
kernel with the same argument values; otherwise the results are undefined.</p>
</div>
<div class="paragraph">
<p>The <em>src_offset</em>, <em>dst_offset</em>, <em>src_total_line_length</em>,
<em>dst_total_line_length</em>, <em>src_total_plane_area</em> and <em>dst_total_plane_area</em>
function arguments are expressed in elements.</p>
</div>
<div class="paragraph">
<p>Both <em>src_total_line_length</em> and <em>dst_total_line_length</em> describe the
number of elements between the beginning of the current line and the
beginning of the next line.</p>
</div>
<div class="paragraph">
<p>Both <em>src_total_plane_area</em> and <em>dst_total_plane_area</em> describe the
number of elements between the beginning of the current plane and the
beginning of the next plane.</p>
</div>
<div class="paragraph">
<p>These functions return an event object that can be used by
<strong>wait_group_events</strong> to wait for the async copy to finish.
The <em>event</em> argument can also be used to associate the async copy with a
previous async copy allowing an event to be shared by multiple async copies;
otherwise <em>event</em> should be zero.
If the <em>event</em> argument is non-zero, the event object supplied as the
<em>event</em> argument will be returned.</p>
</div>
<table id="table-builtin-extended-async-copy" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 25. Built-in Extended Async Copy Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">event_t</span> <span class="fm">async_work_group_copy_2D2D</span><span class="p">(</span>
<span class="nx">__local</span> <span class="kt">void</span> <span class="o">*</span><span class="n">dst</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_offset</span><span class="p">,</span>
<span class="k">const</span> <span class="nx">__global</span> <span class="kt">void</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_offset</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_bytes_per_element</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_elements_per_line</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_lines</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_total_line_length</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_total_line_length</span><span class="p">,</span>
<span class="kt">event_t</span> <span class="n">event</span><span class="p">)</span>
<span class="kt">event_t</span> <span class="fm">async_work_group_copy_2D2D</span><span class="p">(</span>
<span class="nx">__global</span> <span class="kt">void</span> <span class="o">*</span><span class="n">dst</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_offset</span><span class="p">,</span>
<span class="k">const</span> <span class="nx">__local</span> <span class="kt">void</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_offset</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_bytes_per_element</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_elements_per_line</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_lines</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_total_line_length</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_total_line_length</span><span class="p">,</span>
<span class="kt">event_t</span> <span class="n">event</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Perform an async copy of (<em>num_elements_per_line</em> * <em>num_lines</em>)
elements of size <em>num_bytes_per_element</em> from (<em>src</em> + (<em>src_offset</em> *
<em>num_bytes_per_element</em>)) to (<em>dst</em> + (<em>dst_offset</em> *
<em>num_bytes_per_element</em>)).
All pointer arithmetic is performed with implicit casting to <code>char*</code>
by the implementation.
Each line contains <em>num_elements_per_line</em> elements of size
<em>num_bytes_per_element</em>.
After each line of transfer, the <em>src</em> address is incremented by
<em>src_total_line_length</em> elements (i.e. <em>src_total_line_length</em> *
<em>num_bytes_per_element</em> bytes), and the <em>dst</em> address is incremented
by <em>dst_total_line_length</em> elements (i.e. <em>dst_total_line_length</em> *
<em>num_bytes_per_element</em> bytes), for the next line of transfer.</p>
<p class="tableblock"> The behavior of <strong>async_work_group_copy_2D2D</strong> is undefined if the
source or destination addresses exceed the upper bounds of the address
space during the copy.</p>
<p class="tableblock"> The behavior of <strong>async_work_group_copy_2D2D</strong> is also undefined if the
<em>src_total_line_length</em> or <em>dst_total_line_length</em> values are smaller
than <em>num_elements_per_line</em>, i.e. overlapping of lines is undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">event_t</span> <span class="fm">async_work_group_copy_3D3D</span><span class="p">(</span>
<span class="nx">__local</span> <span class="kt">void</span> <span class="o">*</span><span class="n">dst</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_offset</span><span class="p">,</span>
<span class="k">const</span> <span class="nx">__global</span> <span class="kt">void</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_offset</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_bytes_per_element</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_elements_per_line</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_lines</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_planes</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_total_line_length</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_total_plane_area</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_total_line_length</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_total_plane_area</span><span class="p">,</span>
<span class="kt">event_t</span> <span class="n">event</span><span class="p">)</span>
<span class="kt">event_t</span> <span class="fm">async_work_group_copy_3D3D</span><span class="p">(</span>
<span class="nx">__global</span> <span class="kt">void</span> <span class="o">*</span><span class="n">dst</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_offset</span><span class="p">,</span>
<span class="k">const</span> <span class="nx">__local</span> <span class="kt">void</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_offset</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_bytes_per_element</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_elements_per_line</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_lines</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">num_planes</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_total_line_length</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">src_total_plane_area</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_total_line_length</span><span class="p">,</span>
<span class="kt">size_t</span> <span class="n">dst_total_plane_area</span><span class="p">,</span>
<span class="kt">event_t</span> <span class="n">event</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Perform an async copy of <em>num_elements_per_line</em> * <em>num_lines</em>) * <em>num_planes</em>) elements of size <em>num_bytes_per_element</em> from (<em>src</em> + (<em>src_offset</em> * <em>num_bytes_per_element</em> to (<em>dst</em> + (<em>dst_offset</em> *
<em>num_bytes_per_element</em>)), arranged in <em>num_planes</em> planes.
All pointer arithmetic is performed with implicit casting to <code>char*</code>
by the implementation.
Each plane contains <em>num_lines</em> lines.
Each line contains <em>num_elements_per_line</em> elements.
After each line of transfer, the <em>src</em> address is incremented by
<em>src_total_line_length</em> elements (i.e. <em>src_total_line_length</em> *
<em>num_bytes_per_element</em> bytes), and the <em>dst</em> address is incremented
by <em>dst_total_line_length</em> elements (i.e. <em>dst_total_line_length</em> *
<em>num_bytes_per_element</em> bytes), for the next line of transfer.</p>
<p class="tableblock"> The behavior of <strong>async_work_group_copy_3D3D</strong> is undefined if the
source or destination addresses exceed the upper bounds of the address
space during the copy.</p>
<p class="tableblock"> The behavior of <strong>async_work_group_copy_3D3D</strong> is also undefined if the
<em>src_total_line_length</em> or <em>dst_total_line_length</em> values are smaller
than <em>num_elements_per_line</em>, i.e. overlapping of lines is undefined.</p>
<p class="tableblock"> The behavior of <strong>async_work_group_copy_3D3D</strong> is also undefined if
<em>src_total_plane_area</em> is smaller than (<em>num_lines</em> *
<em>src_total_line_length</em>), or <em>dst_total_plane_area</em> is smaller than
(<em>num_lines</em> * <em>dst_total_line_length</em>), i.e. overlapping of planes is
undefined.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="atomic-functions"><a class="anchor" href="#atomic-functions"></a>6.15.12. Atomic Functions</h4>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
The C11 style atomic functions in this sub-section <a href="#unified-spec">require</a> support for OpenCL C 2.0 or newer. However, this statement does not
apply to the <a href="#atomic-legacy">"OpenCL C 1.x Legacy Atomics"</a> descriptions at
the end of this sub-section.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The OpenCL C programming language implements a subset of the C11 atomics
(refer to <a href="#C11-spec">section 7.17 of the C11 Specification</a>) and
synchronization operations.
These operations play a special role in making assignments in one work-item
visible to another.
A synchronization operation on one or more memory locations is either an
acquire operation, a release operation, or both an acquire and release
operation <sup class="footnote">[<a id="_footnoteref_68" class="footnote" href="#_footnotedef_68" title="View footnote.">68</a>]</sup>.
A synchronization operation without an associated memory location is a fence
and can be either an acquire fence, a release fence or both an acquire and
release fence.
In addition, there are relaxed atomic operations, which are not
synchronization operations, and atomic read-modify-write operations which
have special characteristics.</p>
</div>
<div class="paragraph">
<p>The types include</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><code>memory_order</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>which is an enumerated type whose enumerators identify memory ordering
constraints;</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><code>memory_scope</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>which is an enumerated type whose enumerators identify scope of memory
ordering constraints;</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><code>atomic_flag</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>which is a 32-bit integer type representing a primitive atomic flag; and
several atomic analogs of integer types.</p>
</div>
<div class="paragraph">
<p>In the following operation definitions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>An A refers to one of the atomic types.</p>
</li>
<li>
<p>A C refers to its corresponding non-atomic type.</p>
</li>
<li>
<p>An M refers to the type of the other argument for arithmetic operations.
For atomic integer types, M is C.</p>
</li>
<li>
<p>The functions not ending in explicit have the same semantics as the
corresponding explicit function with <code>memory_order_seq_cst</code> for the
<code>memory_order</code> argument.</p>
</li>
<li>
<p>The functions that do not have <code>memory_scope</code> argument have the same
semantics as the corresponding functions with the <code>memory_scope</code>
argument set to <code>memory_scope_device</code>.</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>With fine-grained system SVM, sharing happens at the granularity of
individual loads and stores anywhere in host memory.
Memory consistency is always guaranteed at synchronization points, but to
obtain finer control over consistency, the OpenCL atomics functions may be
used to ensure that the updates to individual data values made by one unit
of execution are visible to other execution units.
In particular, when a host thread needs fine control over the consistency of
memory that is shared with one or more OpenCL devices, it must use atomic
and fence operations that are compatible with the C11 atomic operations.</p>
</div>
<div class="paragraph">
<p>We can&#8217;t require <a href="#C11-spec">C11 atomics</a> since host programs can be
implemented in other programming languages and versions of C or C++, but we
do require that the host programs use atomics and that those atomics be
compatible with those in C11.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="sect4">
<h5 id="the-atomic_var_init-macro"><a class="anchor" href="#the-atomic_var_init-macro"></a>6.15.12.1. The <code>ATOMIC_VAR_INIT</code> Macro</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>ATOMIC_VAR_INIT</code> macro expands to a token sequence suitable for
initializing an atomic object of a type that is initialization-compatible
with value.
An atomic object with automatic storage duration that is not explicitly
initialized using <code>ATOMIC_VAR_INIT</code> is initially in an indeterminate state;
however, the default (zero) initialization for objects with <code>static</code> storage
duration is guaranteed to produce a valid state.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#define ATOMIC_VAR_INIT(C value)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>This macro can only be used to initialize atomic objects that are declared
in program scope in the <code>global</code> address space.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">global</span> <span class="n">atomic_int</span> <span class="n">guide</span> <span class="o">=</span> <span class="n">ATOMIC_VAR_INIT</span><span class="p">(</span><span class="mi">42</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Concurrent access to the variable being initialized, even via an atomic
operation, constitutes a data-race.</p>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="the-atomic_init-function"><a class="anchor" href="#the-atomic_init-function"></a>6.15.12.2. The atomic_init Function</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>atomic_init</code> function non-atomically initializes the atomic object
pointed to by <em>obj</em> to the value <em>value</em>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="kt">void</span> <span class="fm">atomic_init</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">obj</span><span class="p">,</span> <span class="n">C</span> <span class="n">value</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">atomic_init</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">obj</span><span class="p">,</span> <span class="n">C</span> <span class="n">value</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="kt">void</span> <span class="fm">atomic_init</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">obj</span><span class="p">,</span> <span class="n">C</span> <span class="n">value</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">local</span> <span class="n">atomic_int</span> <span class="n">guide</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="fm">get_local_id</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span>
<span class="fm">atomic_init</span><span class="p">(</span><span class="o">&amp;</span><span class="n">guide</span><span class="p">,</span> <span class="mi">42</span><span class="p">);</span>
<span class="fm">work_group_barrier</span><span class="p">(</span><span class="n">CLK_LOCAL_MEM_FENCE</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The function variant that uses the generic address space, i.e. no
explicit address space is listed, <a href="#unified-spec">requires</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>
feature.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="order-and-consistency"><a class="anchor" href="#order-and-consistency"></a>6.15.12.3. Order and Consistency</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The enumerated type <code>memory_order</code> specifies the detailed regular
(non-atomic) memory synchronization operations as defined in
<a href="#C11-spec">section 5.1.2.4 of the C11 Specification</a>, and may provide for
operation ordering.
The following table lists the enumeration constants:</p>
</div>
<table id="table-memory-orders" class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Memory Order</th>
<th class="tableblock halign-left valign-top">Additional Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_order_relaxed</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_order_acquire</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for OpenCL C 2.0, but in OpenCL C 3.0
or newer some uses require the <code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>acq_<wbr>rel</code>
feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_order_release</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for OpenCL C 2.0, but in OpenCL C 3.0
or newer some uses require the <code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>acq_<wbr>rel</code>
feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_order_acq_rel</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for OpenCL C 2.0, but in OpenCL C 3.0
or newer some uses require the <code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>acq_<wbr>rel</code>
feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_order_seq_cst</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> feature.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <code>memory_order</code> can be used when performing atomic operations to <code>global</code>
or <code>local</code> memory.</p>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="memory-scope"><a class="anchor" href="#memory-scope"></a>6.15.12.4. Memory Scope</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The enumerated type <code>memory_scope</code> specifies whether the memory ordering
constraints given by <code>memory_order</code> apply to work-items in a sub-group,
work-items in a work-group, or work-items from one or more kernels executing
on the device or across devices (in the case of shared virtual memory).
The following table lists the enumeration constants:</p>
</div>
<table id="table-memory-scopes" class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Memory Scope</th>
<th class="tableblock halign-left valign-top">Additional Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_scope_work_item</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_scope_work_item</code> can only be used with <code>atomic_work_item_fence</code>
with flags set to <code>CLK_IMAGE_MEM_FENCE</code>.
<a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_scope_sub_group</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for
the <code>cl_khr_<wbr>subgroups</code> extension, or
OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>subgroups</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_scope_work_group</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_scope_device</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_scope_all_svm_devices</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#unified-spec">Requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>all_<wbr>devices</code> feature.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memory_scope_all_devices</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">An alias for <code>memory_scope_all_svm_devices</code>.
<a href="#unified-spec">Requires</a> support for OpenCL C 3.0 or newer and the
<code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>all_<wbr>devices</code> feature.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect4">
<h5 id="fences"><a class="anchor" href="#fences"></a>6.15.12.5. Fences</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following fence operations are supported.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="fm">atomic_work_item_fence</span><span class="p">(</span><span class="kt">cl_mem_fence_flags</span> <span class="n">flags</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Older syntax memory fences are equivalent to atomic_work_item_fence with the</span>
<span class="c1">// same flags parameter, memory_scope_work_group scope, and ordering as follows:</span>
<span class="kt">void</span> <span class="fm">mem_fence</span><span class="p">(</span><span class="kt">cl_mem_fence_flags</span> <span class="n">flags</span><span class="p">)</span> <span class="c1">// memory_order_acq_rel</span>
<span class="kt">void</span> <span class="fm">read_mem_fence</span><span class="p">(</span><span class="kt">cl_mem_fence_flags</span> <span class="n">flags</span><span class="p">)</span> <span class="c1">// memory_order_acquire</span>
<span class="kt">void</span> <span class="fm">write_mem_fence</span><span class="p">(</span><span class="kt">cl_mem_fence_flags</span> <span class="n">flags</span><span class="p">)</span> <span class="c1">// memory_order_release</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>flags</code> must be set to <code>CLK_GLOBAL_MEM_FENCE</code>, <code>CLK_LOCAL_MEM_FENCE</code>,
<code>CLK_IMAGE_MEM_FENCE</code> or a combination of these values ORed together;
otherwise the behavior is undefined.
The behavior of calling <code>atomic_work_item_fence</code> with <code>CLK_IMAGE_MEM_FENCE</code>
ORed together with either <code>CLK_GLOBAL_MEM_FENCE</code> or <code>CLK_LOCAL_MEM_FENCE</code> is
equivalent to calling <code>atomic_work_item_fence</code> individually for
<code>CLK_IMAGE_MEM_FENCE</code> and the other flags.
Passing both <code>CLK_GLOBAL_MEM_FENCE</code> and <code>CLK_LOCAL_MEM_FENCE</code> to
<code>atomic_work_item_fence</code> will synchronize memory operations to both <code>local</code>
and <code>global</code> memory through some shared atomic action, as described in
<a href="#opencl-spec">section 3.3.6.2 of the OpenCL Specification</a>.</p>
</div>
<div class="paragraph">
<p>Depending on the value of order, this operation:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>has no effects, if <em>order</em> == <code>memory_order_relaxed</code>.</p>
</li>
<li>
<p>is an acquire fence, if <em>order</em> == <code>memory_order_acquire</code>.</p>
</li>
<li>
<p>is a release fence, if <em>order</em> == <code>memory_order_release</code>.</p>
</li>
<li>
<p>is both an acquire fence and a release fence, if <em>order</em> ==
<code>memory_order_acq_rel</code>.</p>
</li>
<li>
<p>is a sequentially consistent acquire and release fence, if <em>order</em> ==
<code>memory_order_seq_cst</code>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For images declared with the <code>read_write</code> qualifier, the
<code>atomic_work_item_fence</code> must be called to make sure that writes to the
image by a work-item become visible to that work-item on subsequent reads to
that image by that work-item.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The use of memory order and scope enumerations must respect the
<a href="#atomic-restrictions">restrictions section below</a>.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="atomic-integer-and-floating-point-types"><a class="anchor" href="#atomic-integer-and-floating-point-types"></a>6.15.12.6. Atomic Integer and Floating-point Types</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The list of supported atomic type names are:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><code>atomic_int</code></p>
</li>
<li>
<p><code>atomic_uint</code></p>
</li>
<li>
<p><code>atomic_long</code> <sup class="footnote" id="_footnote_atomic-int64-supported">[<a id="_footnoteref_69" class="footnote" href="#_footnotedef_69" title="View footnote.">69</a>]</sup></p>
</li>
<li>
<p><code>atomic_ulong</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_69" title="View footnote.">69</a>]</sup></p>
</li>
<li>
<p><code>atomic_float</code></p>
</li>
<li>
<p><code>atomic_double</code> <sup class="footnote">[<a id="_footnoteref_70" class="footnote" href="#_footnotedef_70" title="View footnote.">70</a>]</sup></p>
</li>
<li>
<p><code>atomic_intptr_t</code> <sup class="footnote" id="_footnote_atomic-size_t-supported">[<a id="_footnoteref_71" class="footnote" href="#_footnotedef_71" title="View footnote.">71</a>]</sup></p>
</li>
<li>
<p><code>atomic_uintptr_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_71" title="View footnote.">71</a>]</sup></p>
</li>
<li>
<p><code>atomic_size_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_71" title="View footnote.">71</a>]</sup></p>
</li>
<li>
<p><code>atomic_ptrdiff_t</code> <sup class="footnoteref">[<a class="footnote" href="#_footnotedef_71" title="View footnote.">71</a>]</sup></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Arguments to a kernel can be declared to be a pointer to the above atomic
types or the atomic_flag type.</p>
</div>
<div class="paragraph">
<p>The representation of atomic integer, floating-point and pointer types have
the same size as their corresponding regular types.
The atomic_flag type must be implemented as a 32-bit integer.</p>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="operations-on-atomic-types"><a class="anchor" href="#operations-on-atomic-types"></a>6.15.12.7. Operations on Atomic Types</h5>
<div class="paragraph">
<p>There are only a few kinds of operations on atomic types, though there are
many instances of those kinds.
This section specifies each general kind.</p>
</div>
<div class="sect5">
<h6 id="atomic_store"><a class="anchor" href="#atomic_store"></a>6.15.12.7.1. The atomic_store Functions</h6>
<div class="openblock">
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst</span>
<span class="c1">// and __opencl_c_atomic_scope_device features.</span>
<span class="kt">void</span> <span class="fm">atomic_store</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">atomic_store</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and all of the</span>
<span class="c1">// __opencl_c_generic_address_space, __opencl_c_atomic_order_seq_cst and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="kt">void</span> <span class="fm">atomic_store</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and the __opencl_c_atomic_scope_device</span>
<span class="c1">// feature.</span>
<span class="kt">void</span> <span class="fm">atomic_store_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">atomic_store_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and both the</span>
<span class="c1">// __opencl_c_generic_address_space and __opencl_c_atomic_scope_device</span>
<span class="c1">// features.</span>
<span class="kt">void</span> <span class="fm">atomic_store_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="kt">void</span> <span class="fm">atomic_store_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">atomic_store_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="kt">void</span> <span class="fm">atomic_store_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <em>order</em> argument shall not be <code>memory_order_acquire</code>, nor
<code>memory_order_acq_rel</code>.
Atomically replace the value pointed to by <em>object</em> with the value of
<em>desired</em>.
Memory is affected according to the value of <em>order</em>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The non-explicit <code>atomic_store</code> function <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and both the
<code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> and <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code>
features.
For the explicit variants, memory order and scope enumerations must respect the
<a href="#atomic-restrictions">restrictions section below</a>.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The function variants that use the generic address space, i.e. no
explicit address space is listed, <a href="#unified-spec">require</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>
feature.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect5">
<h6 id="atomic_load"><a class="anchor" href="#atomic_load"></a>6.15.12.7.2. The atomic_load Functions</h6>
<div class="openblock">
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst</span>
<span class="c1">// and __opencl_c_atomic_scope_device features.</span>
<span class="n">C</span> <span class="fm">atomic_load</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="n">C</span> <span class="fm">atomic_load</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and all of the</span>
<span class="c1">// __opencl_c_generic_address_space, __opencl_c_atomic_order_seq_cst and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="n">C</span> <span class="fm">atomic_load</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and the __opencl_c_atomic_scope_device</span>
<span class="c1">// feature.</span>
<span class="n">C</span> <span class="fm">atomic_load_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="n">C</span> <span class="fm">atomic_load_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and both the</span>
<span class="c1">// __opencl_c_generic_address_space and __opencl_c_atomic_scope_device</span>
<span class="c1">// features.</span>
<span class="n">C</span> <span class="fm">atomic_load_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="n">C</span> <span class="fm">atomic_load_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="n">C</span> <span class="fm">atomic_load_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="n">C</span> <span class="fm">atomic_load_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <em>order</em> argument shall not be <code>memory_order_release</code> nor
<code>memory_order_acq_rel</code>.
Memory is affected according to the value of <em>order</em>.
Atomically returns the value pointed to by <em>object</em>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The non-explicit <code>atomic_load</code> function <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and both the
<code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> and <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code>
features.
For the explicit variants, memory order and scope enumerations must respect the
<a href="#atomic-restrictions">restrictions section below</a>.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The function variants that use the generic address space, i.e. no
explicit address space is listed, <a href="#unified-spec">require</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>
feature.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect5">
<h6 id="atomic_exchange"><a class="anchor" href="#atomic_exchange"></a>6.15.12.7.3. The atomic_exchange Functions</h6>
<div class="openblock">
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst</span>
<span class="c1">// and __opencl_c_atomic_scope_device features.</span>
<span class="n">C</span> <span class="fm">atomic_exchange</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="n">C</span> <span class="fm">atomic_exchange</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and all of the</span>
<span class="c1">// __opencl_c_generic_address_space, __opencl_c_atomic_order_seq_cst and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="n">C</span> <span class="fm">atomic_exchange</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and the __opencl_c_atomic_scope_device</span>
<span class="c1">// feature.</span>
<span class="n">C</span> <span class="fm">atomic_exchange_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="n">C</span> <span class="fm">atomic_exchange_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and both the</span>
<span class="c1">// __opencl_c_generic_address_space and __opencl_c_atomic_scope_device</span>
<span class="c1">// feature.</span>
<span class="n">C</span> <span class="fm">atomic_exchange_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="n">C</span> <span class="fm">atomic_exchange_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="n">C</span> <span class="fm">atomic_exchange_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="n">C</span> <span class="fm">atomic_exchange_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Atomically replace the value pointed to by <code>object</code> with <code>desired</code>.
Memory is affected according to the value of <code>order</code>.
These operations are read-modify-write operations (as defined by
<a href="#C11-spec">section 5.1.2.4 of the C11 Specification</a>).
Atomically returns the value pointed to by <code>object</code> immediately before the
effects.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The non-explicit <code>atomic_exchange</code> function <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and both the
<code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> and <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code>
features.
For the explicit variants, memory order and scope enumerations must respect the
<a href="#atomic-restrictions">restrictions section below</a>.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The function variants that use the generic address space, i.e. no
explicit address space is listed, <a href="#unified-spec">require</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>
feature.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect5">
<h6 id="atomic_compare_exchange"><a class="anchor" href="#atomic_compare_exchange"></a>6.15.12.7.4. The atomic_compare_exchange Functions</h6>
<div class="openblock">
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst</span>
<span class="c1">// and __opencl_c_atomic_scope_device features.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and all of the</span>
<span class="c1">// __opencl_c_generic_address_space, __opencl_c_atomic_order_seq_cst and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and the __opencl_c_atomic_scope_device</span>
<span class="c1">// feature.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and both the</span>
<span class="c1">// __opencl_c_generic_address_space and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_strong_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst</span>
<span class="c1">// and __opencl_c_atomic_scope_device features.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and all of the</span>
<span class="c1">// __opencl_c_generic_address_space, __opencl_c_atomic_order_seq_cst and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span> <span class="n">C</span> <span class="n">desired</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and the __opencl_c_atomic_scope_device</span>
<span class="c1">// feature.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and both the</span>
<span class="c1">// __opencl_c_generic_address_space and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__global</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__local</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="nx">__private</span> <span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="kt">bool</span> <span class="fm">atomic_compare_exchange_weak_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">C</span> <span class="o">*</span><span class="n">expected</span><span class="p">,</span>
<span class="n">C</span> <span class="n">desired</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">success</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">failure</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>failure</code> argument shall not be <code>memory_order_release</code> nor
<code>memory_order_acq_rel</code>.
The <code>failure</code> argument shall be no stronger than the <code>success</code> argument.
Atomically, compares the value pointed to by <code>object</code> for equality with that
in <code>expected</code>, and if <em>true</em>, replaces the value pointed to by <code>object</code> with
<code>desired</code>, and if <em>false</em>, updates the value in <code>expected</code> with the value
pointed to by <code>object</code>.
Further, if the comparison is <em>true</em>, memory is affected according to the
value of <code>success</code>, and if the comparison is <em>false</em>, memory is affected
according to the value of <code>failure</code>.
If the comparison is <em>true</em>, these operations are atomic read-modify-write operations (as defined by
<a href="#C11-spec">section 5.1.2.4 of the C11 Specification</a>).
Otherwise, these operations are atomic load operations.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The effect of the compare-and-exchange operations is</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">if</span> <span class="p">(</span><span class="n">memcmp</span><span class="p">(</span><span class="n">object</span><span class="p">,</span> <span class="n">expected</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="o">*</span><span class="n">object</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="n">memcpy</span><span class="p">(</span><span class="n">object</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">desired</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="o">*</span><span class="n">object</span><span class="p">));</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="n">memcpy</span><span class="p">(</span><span class="n">expected</span><span class="p">,</span> <span class="n">object</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="o">*</span><span class="n">object</span><span class="p">));</span>
<span class="p">}</span></code></pre>
</div>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The weak compare-and-exchange operations may fail spuriously
<sup class="footnote">[<a id="_footnoteref_72" class="footnote" href="#_footnotedef_72" title="View footnote.">72</a>]</sup>.
That is, even when the contents of memory referred to by <code>expected</code> and
<code>object</code> are equal, it may return zero and store back to <code>expected</code> the same
memory contents that were originally there.</p>
</div>
<div class="paragraph">
<p>These generic functions return the result of the comparison.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The non-explicit <code>atomic_compare_exchange_strong</code> and
<code>atomic_compare_exchange_weak</code> functions <a href="#unified-spec">requires</a> support
for OpenCL C 2.0, or OpenCL C 3.0 or newer and both the
<code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> and <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code>
features.
For the explicit variants, memory order and scope enumerations must respect the
<a href="#atomic-restrictions">restrictions section below</a>.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The function variants that use the generic address space, i.e. no
explicit address space is listed, <a href="#unified-spec">require</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>
feature.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect5">
<h6 id="atomic_fetch_key"><a class="anchor" href="#atomic_fetch_key"></a>6.15.12.7.5. The atomic_fetch and modify Functions</h6>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following operations perform arithmetic and bitwise computations.
All of these operations are applicable to an object of any atomic integer
type.
The key, operator, and computation correspondence is given in table below:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"><strong>key</strong></th>
<th class="tableblock halign-left valign-top"><strong>op</strong></th>
<th class="tableblock halign-left valign-top"><strong>computation</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>add</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>+</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">addition</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>-</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">subtraction</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>|</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">bitwise inclusive or</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>^</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">bitwise exclusive or</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>&amp;</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">bitwise and</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>min</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>min</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">compute min</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>max</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>max</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">compute max</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>For <strong>atomic_fetch</strong> and modify functions with <strong>key</strong> = <code>add</code> or <code>sub</code> on
atomic types <code>atomic_intptr_t</code> and <code>atomic_uintptr_t</code>, <code>M</code> is <code>ptrdiff_t</code>.
For <strong>atomic_fetch</strong> and modify functions with <strong>key</strong> = <code>or</code>, <code>xor</code>, <code>and</code>,
<code>min</code> and <code>max</code> on atomic type <code>atomic_intptr_t</code>, <code>M</code> is <code>intptr_t</code>,
and on atomic type <code>atomic_uintptr_t</code>, <code>M</code> is <code>uintptr_t</code>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst</span>
<span class="c1">// and __opencl_c_atomic_scope_device features.</span>
<span class="n">C</span> <span class="n">atomic_fetch_key</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">M</span> <span class="n">operand</span><span class="p">)</span>
<span class="n">C</span> <span class="n">atomic_fetch_key</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">M</span> <span class="n">operand</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or all of the __opencl_c_generic_address_space,</span>
<span class="c1">// __opencl_c_atomic_order_seq_cst and __opencl_c_atomic_scope_device features.</span>
<span class="n">C</span> <span class="n">atomic_fetch_key</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span> <span class="n">M</span> <span class="n">operand</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and the __opencl_c_atomic_scope_device feature.</span>
<span class="n">C</span> <span class="n">atomic_fetch_key_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">M</span> <span class="n">operand</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="n">C</span> <span class="n">atomic_fetch_key_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">M</span> <span class="n">operand</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and both the</span>
<span class="c1">// __opencl_c_generic_address_space and __opencl_c_atomic_scope_device</span>
<span class="c1">// features.</span>
<span class="n">C</span> <span class="n">atomic_fetch_key_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">M</span> <span class="n">operand</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="n">C</span> <span class="n">atomic_fetch_key_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">M</span> <span class="n">operand</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="n">C</span> <span class="n">atomic_fetch_key_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">M</span> <span class="n">operand</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="n">C</span> <span class="n">atomic_fetch_key_explicit</span><span class="p">(</span><span class="k">volatile</span> <span class="n">A</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">M</span> <span class="n">operand</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Atomically replaces the value pointed to by <code>object</code> with the result of the
computation applied to the value pointed to by <code>object</code> and the given
operand.
Memory is affected according to the value of <code>order</code>.
These operations are atomic read-modify-write operations (as defined by
<a href="#C11-spec">section 5.1.2.4 of the C11 Specification</a>).
For signed integer types, arithmetic is defined to use two&#8217;s complement
representation with silent wrap-around on overflow; there are no undefined
results.
For address types, the result may be an undefined address, but the
operations otherwise have no undefined behavior.
Returns atomically the value pointed to by <code>object</code> immediately before the
effects.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The non-explicit <code>atomic_fetch_key</code> functions <a href="#unified-spec">require</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and both the
<code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> and <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code>
features.
For the explicit variants, memory order and scope enumerations must respect the
<a href="#atomic-restrictions">restrictions section below</a>.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The function variants that use the generic address space, i.e. no
explicit address space is listed, <a href="#unified-spec">require</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>
feature.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect5">
<h6 id="atomic_flag"><a class="anchor" href="#atomic_flag"></a>6.15.12.7.6. Atomic Flag Type and Operations</h6>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The <code>atomic_flag</code> type provides the classic test-and-set functionality.
It has two states, <em>set</em> (value is non-zero) and <em>clear</em> (value is 0).</p>
</div>
<div class="paragraph">
<p>In OpenCL C 2.0 Operations on an object of type <code>atomic_flag</code> shall be
lock-free, in OpenCL C 3.0 or newer they may be lock-free.</p>
</div>
<div class="paragraph">
<p>The macro <code>ATOMIC_FLAG_INIT</code> may be used to initialize an <code>atomic_flag</code> to the
<em>clear</em> state.
An <code>atomic_flag</code> that is not explicitly initialized with <code>ATOMIC_FLAG_INIT</code> is
initially in an indeterminate state.</p>
</div>
<div class="paragraph">
<p>This macro can only be used for atomic objects that are declared in program
scope in the <code>global</code> address space with the <code>atomic_flag</code> type.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">global</span> <span class="n">atomic_flag</span> <span class="n">guard</span> <span class="o">=</span> <span class="n">ATOMIC_FLAG_INIT</span><span class="p">;</span></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect5">
<h6 id="atomic_flag_test_and_set"><a class="anchor" href="#atomic_flag_test_and_set"></a>6.15.12.7.7. The atomic_flag_test_and_set Functions</h6>
<div class="openblock">
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst</span>
<span class="c1">// and __opencl_c_atomic_scope_device features.</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and all of the</span>
<span class="c1">// __opencl_c_generic_address_space, __opencl_c_atomic_order_seq_cst and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and the __opencl_c_atomic_scope_device</span>
<span class="c1">// feature.</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and both the</span>
<span class="c1">// __opencl_c_generic_address_space and __opencl_c_atomic_scope_device</span>
<span class="c1">// features.</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="kt">bool</span> <span class="fm">atomic_flag_test_and_set_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Atomically sets the value pointed to by <code>object</code> to <em>true</em>.
Memory is affected according to the value of <code>order</code>.
These operations are atomic read-modify-write operations (as defined by
<a href="#C11-spec">section 5.1.2.4 of the C11 Specification</a>).
Returns atomically the value of the <code>object</code> immediately before the effects.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The non-explicit <code>atomic_flag_test_and_set</code> function <a href="#unified-spec">requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or newer and both the
<code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> and <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code>
features.
For the explicit variants, memory order and scope enumerations must respect the
<a href="#atomic-restrictions">restrictions section below</a>.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The function variants that use the generic address space, i.e. no
explicit address space is listed, <a href="#unified-spec">require</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>
feature.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect5">
<h6 id="atomic_flag_clear"><a class="anchor" href="#atomic_flag_clear"></a>6.15.12.7.8. The atomic_flag_clear Functions</h6>
<div class="openblock">
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Requires OpenCL C 3.0 or newer and both the __opencl_c_atomic_order_seq_cst</span>
<span class="c1">// and __opencl_c_atomic_scope_device features.</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__global</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear</span><span class="p">(</span><span class="k">volatile</span> <span class="nx">__local</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and all of the</span>
<span class="c1">// __opencl_c_generic_address_space, __opencl_c_atomic_order_seq_cst and</span>
<span class="c1">// __opencl_c_atomic_scope_device features.</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear</span><span class="p">(</span><span class="k">volatile</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer and the __opencl_c_atomic_scope_device</span>
<span class="c1">// feature.</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and both the</span>
<span class="c1">// __opencl_c_generic_address_space and __opencl_c_atomic_scope_device</span>
<span class="c1">// features.</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 3.0 or newer.</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__global</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="nx">__local</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span>
<span class="c1">// Requires OpenCL C 2.0, or OpenCL C 3.0 or newer and the</span>
<span class="c1">// __opencl_c_generic_address_space feature.</span>
<span class="kt">void</span> <span class="fm">atomic_flag_clear_explicit</span><span class="p">(</span>
<span class="k">volatile</span> <span class="n">atomic_flag</span> <span class="o">*</span><span class="n">object</span><span class="p">,</span>
<span class="n">memory_order</span> <span class="n">order</span><span class="p">,</span>
<span class="n">memory_scope</span> <span class="n">scope</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>order</code> argument shall not be <code>memory_order_acquire</code> nor
<code>memory_order_acq_rel</code>.
Atomically sets the value pointed to by <code>object</code> to <em>false</em>.
Memory is affected according to the value of <code>order</code>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The non-explicit <code>atomic_flag_clear</code> function <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and both the
<code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> and <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code>
features.
For the explicit variants, memory order and scope enumerations must respect the
<a href="#atomic-restrictions">restrictions section below</a>.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The function variants that use the generic address space, i.e. no
explicit address space is listed, <a href="#unified-spec">require</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>generic_<wbr>address_<wbr>space</code>
feature.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="atomic-legacy"><a class="anchor" href="#atomic-legacy"></a>6.15.12.8. OpenCL C 1.x Legacy Atomics</h5>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
The atomic functions described in this sub-section <a href="#unified-spec">require</a> support for OpenCL C 1.1 or newer, and are <a href="#unified-spec">deprecated by</a> OpenCL C 2.0.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>OpenCL C 1.x had support for relaxed atomic operations via built-in functions
that could operate on any memory address in <code>__global</code> or <code>__local</code> spaces.
Unlike C11 style atomics these did not require using dedicated atomic types,
and instead operated on 32-bit signed integers, 32-bit unsigned integers, and
only in the case of <strong>atomic_xchg</strong> additionally single precision floating-point.
These were equivalent to atomic operations with <code>memory_order_relaxed</code>
consistency, and <code>memory_scope_work_group</code> scope.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Some implementations may implement legacy atomics with a stricter memory
consistency order than <code>memory_order_relaxed</code> or a broader scope than
<code>memory_scope_work_group</code>.
This is because all the stricter orders and broader scopes fully satisfy the
semantics of the minimum requirements.
</td>
</tr>
</table>
</div>
<table id="table-legacy-atomic-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 26. Legacy Atomic Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_add</strong>(volatile __global int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_add</strong>(volatile __global int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_add</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_add</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> int <strong>atomic_add</strong>(volatile __local int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_add</strong>(volatile __local int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_add</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_add</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute (<em>old</em> + <em>val</em>) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_sub</strong>(volatile __global int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_sub</strong>(volatile __global int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_sub</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_sub</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> int <strong>atomic_sub</strong>(volatile __local int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_sub</strong>(volatile __local int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_sub</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_sub</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute (<em>old</em> - <em>val</em>) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_xchg</strong>(volatile __global int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_xchg</strong>(volatile __global int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_xchg</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_xchg</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> float <strong>atomic_xchg</strong>(volatile __global float *<em>p</em>, float <em>val</em>)<br></p>
<p class="tableblock"> int <strong>atomic_xchg</strong>(volatile __local int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_xchg</strong>(volatile __local int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_xchg</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_xchg</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> float <strong>atomic_xchg</strong>(volatile __local float *<em>p</em>, float <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Swaps the <em>old</em> value stored at location <em>p</em> with new value given by
<em>val</em>. Returns <em>old</em> value.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_inc</strong>(volatile __global int *<em>p</em>)<br>
int <strong>atom_inc</strong>(volatile __global int *<em>p</em>)</p>
<p class="tableblock"> uint <strong>atomic_inc</strong>(volatile __global uint *<em>p</em>)<br>
uint <strong>atom_inc</strong>(volatile __global uint *<em>p</em>)</p>
<p class="tableblock"> int <strong>atomic_inc</strong>(volatile __local int *<em>p</em>)<br>
int <strong>atom_inc</strong>(volatile __local int *<em>p</em>)</p>
<p class="tableblock"> uint <strong>atomic_inc</strong>(volatile __local uint *<em>p</em>)<br>
uint <strong>atom_inc</strong>(volatile __local uint *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute (<em>old</em> + 1) and store result at location pointed by <em>p</em>. The
function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_dec</strong>(volatile __global int *<em>p</em>)<br>
int <strong>atom_dec</strong>(volatile __global int *<em>p</em>)</p>
<p class="tableblock"> uint <strong>atomic_dec</strong>(volatile __global uint *<em>p</em>)<br>
uint <strong>atom_dec</strong>(__global uint *<em>p</em>)</p>
<p class="tableblock"> int <strong>atomic_dec</strong>(volatile __local int *<em>p</em>)<br>
int <strong>atom_dec</strong>(volatile __local int *<em>p</em>)</p>
<p class="tableblock"> uint <strong>atomic_dec</strong>(volatile __local uint *<em>p</em>)<br>
uint <strong>atom_dec</strong>(volatile __local uint *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute (<em>old</em> - 1) and store result at location pointed by <em>p</em>. The
function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_cmpxchg</strong>(volatile __global int *<em>p</em>, int <em>cmp</em>, int <em>val</em>)<br>
int <strong>atom_cmpxchg</strong>(volatile __global int *<em>p</em>, int <em>cmp</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_cmpxchg</strong>(volatile __global uint *<em>p</em>, uint <em>cmp</em>, uint <em>val</em>)<br>
uint <strong>atom_cmpxchg</strong>(volatile __global uint *<em>p</em>, uint <em>cmp</em>, uint <em>val</em>)</p>
<p class="tableblock"> int <strong>atomic_cmpxchg</strong>(volatile __local int *<em>p</em>, int <em>cmp</em>, int <em>val</em>)<br>
int <strong>atom_cmpxchg</strong>(volatile __local int *<em>p</em>, int <em>cmp</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_cmpxchg</strong>(volatile __local uint *<em>p</em>, uint <em>cmp</em>, uint <em>val</em>)<br>
uint <strong>atom_cmpxchg</strong>(volatile __local uint *<em>p</em>, uint <em>cmp</em>, uint <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute (<em>old</em> == <em>cmp</em>) ? <em>val</em> : <em>old</em> and store result at location
pointed by <em>p</em>. The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_min</strong>(volatile __global int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_min</strong>(volatile __global int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_min</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_min</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> int <strong>atomic_min</strong>(volatile __local int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_min</strong>(volatile __local int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_min</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_min</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute <strong>min</strong>(<em>old</em>, <em>val</em>) and store minimum value at location
pointed by <em>p</em>. The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_max</strong>(volatile __global int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_max</strong>(volatile __global int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_max</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_max</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> int <strong>atomic_max</strong>(volatile __local int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_max</strong>(volatile __local int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_max</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_max</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute <strong>max</strong>(<em>old</em>, <em>val</em>) and store maximum value at location
pointed by <em>p</em>. The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_and</strong>(volatile __global int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_and</strong>(volatile __global int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_and</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_and</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> int <strong>atomic_and</strong>(volatile __local int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_and</strong>(volatile __local int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_and</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_and</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute (<em>old</em> &amp; <em>val</em>) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_or</strong>(volatile __global int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_or</strong>(volatile __global int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_or</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_or</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> int <strong>atomic_or</strong>(volatile __local int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_or</strong>(volatile __local int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_or</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_or</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute (<em>old</em> | <em>val</em>) and store result at location pointed by
<em>p</em>. The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>atomic_xor</strong>(volatile __global int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_xor</strong>(volatile __global int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_xor</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_xor</strong>(volatile __global uint *<em>p</em>, uint <em>val</em>)</p>
<p class="tableblock"> int <strong>atomic_xor</strong>(volatile __local int *<em>p</em>, int <em>val</em>)<br>
int <strong>atom_xor</strong>(volatile __local int *<em>p</em>, int <em>val</em>)</p>
<p class="tableblock"> uint <strong>atomic_xor</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)<br>
uint <strong>atom_xor</strong>(volatile __local uint *<em>p</em>, uint <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 32-bit value (referred to as <em>old</em>) stored at location pointed by
<em>p</em>. Compute (<em>old</em> ^ <em>val</em>) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>A subset of the atomic functions described above are also supported in
OpenCL 1.0 when appropriate OpenCL extension macros are supported, as
described in the <a href="#table-atomic-function-extensions">Atomic Function
Extensions</a> table below.</p>
</div>
<table id="table-atomic-function-extensions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 27. Atomic Function Extensions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Extension Macro</th>
<th class="tableblock halign-left valign-top">Supported Functions</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_khr_<wbr>global_<wbr>int32_<wbr>base_<wbr>atomics</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atom_add</strong><br>
<strong>atom_sub</strong><br>
<strong>atom_xchg</strong><br>
<strong>atom_inc</strong><br>
<strong>atom_dec</strong><br>
<strong>atom_cmpxchg</strong><br>
(with __global parameters)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_khr_<wbr>global_<wbr>int32_<wbr>extended_<wbr>atomics</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atom_min</strong><br>
<strong>atom_max</strong><br>
<strong>atom_and</strong><br>
<strong>atom_or</strong><br>
<strong>atom_xor</strong><br>
(with __global parameters)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_khr_<wbr>local_<wbr>int32_<wbr>base_<wbr>atomics</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atom_add</strong><br>
<strong>atom_sub</strong><br>
<strong>atom_xchg</strong><br>
<strong>atom_inc</strong><br>
<strong>atom_dec</strong><br>
<strong>atom_cmpxchg</strong><br>
(with __local parameters)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cl_khr_<wbr>local_<wbr>int32_<wbr>extended_<wbr>atomics</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atom_min</strong><br>
<strong>atom_max</strong><br>
<strong>atom_and</strong><br>
<strong>atom_or</strong><br>
<strong>atom_xor</strong><br>
(with __local parameters)</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="atomic-legacy-int64"><a class="anchor" href="#atomic-legacy-int64"></a>6.15.12.9. Legacy 64-Bit Atomic Extensions</h5>
<div class="paragraph">
<p>Similar to the <a href="#atomic-legacy">OpenCL C 1.x Legacy Atomics</a>, atomic
functions operating on 64-bit integers are provided by extensions.</p>
</div>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>int64_<wbr>base_<wbr>atomics</code> extension macro is supported, it
provides the functions described in the <a href="#table-atomic-int64-base">Built-in
64-Bit Base Atomic Functions</a> table below.</p>
</div>
<table id="table-atomic-int64-base" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 28. Built-in 64-Bit Base Atomic Functions</caption>
<colgroup>
<col style="width: 64.2857%;">
<col style="width: 35.7143%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"><strong>Function</strong></th>
<th class="tableblock halign-left valign-top"><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_add</strong> (volatile __global long *<em>p</em>, long <em>val</em>)<br>
long <strong>atom_add</strong> (volatile __local long *<em>p</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_add</strong> (volatile __global ulong *<em>p</em>, ulong <em>val</em>)<br>
ulong <strong>atom_add</strong> (volatile __local ulong *<em>p</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute (<em>old</em> + <em>val</em>) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_sub</strong> (volatile __global long *<em>p</em>, long <em>val</em>)<br>
long <strong>atom_sub</strong> (volatile __local long *<em>p</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_sub</strong> (volatile __global ulong *<em>p</em>, ulong <em>val</em>)<br>
ulong <strong>atom_sub</strong> (volatile __local ulong *<em>p</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute (<em>old</em> - <em>val</em>) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_xchg</strong> (volatile __global long *<em>p</em>, long <em>val</em>)<br>
long <strong>atom_xchg</strong> (volatile __local long *<em>p</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_xchg</strong> (volatile __global ulong *<em>p</em>, ulong <em>val</em>)<br>
ulong <strong>atom_xchg</strong> (volatile __local ulong *<em>p</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Swaps the <em>old</em> value stored at location <em>p</em> with new value given by
<em>val</em>.
Returns <em>old</em> value.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_inc</strong> (volatile __global long *<em>p</em>)<br>
long <strong>atom_inc</strong> (volatile __local long *<em>p</em>)</p>
<p class="tableblock"> ulong <strong>atom_inc</strong> (volatile __global ulong *<em>p</em>)<br>
ulong <strong>atom_inc</strong> (volatile __local ulong *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute (<em>old</em> + <em>1</em>) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_dec</strong> (volatile __global long *<em>p</em>)<br>
long <strong>atom_dec</strong> (volatile __local long *<em>p</em>)</p>
<p class="tableblock"> ulong <strong>atom_dec</strong> (volatile __global ulong *<em>p</em>)<br>
ulong <strong>atom_dec</strong> (volatile __local ulong *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute (<em>old</em> - <em>1</em>) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_cmpxchg</strong> (volatile __global long *<em>p</em>, long <em>cmp</em>, long <em>val</em>)<br>
long <strong>atom_cmpxchg</strong> (volatile __local long *<em>p</em>, long <em>cmp</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_cmpxchg</strong> (volatile __global ulong *<em>p</em>, ulong <em>cmp</em>, ulong <em>val</em>)<br>
ulong <strong>atom_cmpxchg</strong> (volatile __local ulong *<em>p</em>, ulong <em>cmp</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute (<em>old</em> == <em>cmp</em>) ? <em>val</em> : <em>old</em> and store result at location
pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>int64_<wbr>extended_<wbr>atomics</code> extension macro is supported, it
provides the functions described in the <a href="#table-atomic-int64-extended">Built-in 64-Bit Extended Atomic Functions</a> table below.</p>
</div>
<table id="table-atomic-int64-extended" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 29. Built-in 64-Bit Extended Atomic Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"><strong>Function</strong></th>
<th class="tableblock halign-left valign-top"><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_min</strong> (volatile __global long *<em>p</em>, long <em>val</em>)<br>
long <strong>atom_min</strong> (volatile __local long *<em>p</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_min</strong> (volatile __global ulong *<em>p</em>, ulong <em>val</em>)<br>
ulong <strong>atom_min</strong> (volatile __local ulong *<em>p</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute <strong>min</strong>(<em>old</em>, <em>val</em>) and store minimum value at location
pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_max</strong> (volatile __global long *<em>p</em>, long <em>val</em>)<br>
long <strong>atom_max</strong> (volatile __local long *<em>p</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_max</strong> (volatile __global ulong *<em>p</em>, ulong <em>val</em>)<br>
ulong <strong>atom_max</strong> (volatile __local ulong *<em>p</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute <strong>max</strong>(<em>old</em>, <em>val</em>) and store maximum value at location
pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_and</strong> (volatile __global long *<em>p</em>, long <em>val</em>)<br>
long <strong>atom_and</strong> (volatile __local long *<em>p</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_and</strong> (volatile __global ulong *<em>p</em>, ulong <em>val</em>)<br>
ulong <strong>atom_and</strong> (volatile __local ulong *<em>p</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute (<em>old</em> &amp; val) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_or</strong> (volatile __global long *<em>p</em>, long <em>val</em>)<br>
long <strong>atom_or</strong> (volatile __local long *<em>p</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_or</strong> (volatile __global ulong *<em>p</em>, ulong <em>val</em>)<br>
ulong <strong>atom_or</strong> (volatile __local ulong *<em>p</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute (<em>old</em> | val) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">long <strong>atom_xor</strong> (volatile __global long *<em>p</em>, long <em>val</em>)<br>
long <strong>atom_xor</strong> (volatile __local long *<em>p</em>, long <em>val</em>)</p>
<p class="tableblock"> ulong <strong>atom_xor</strong> (volatile __global ulong *<em>p</em>, ulong <em>val</em>)<br>
ulong <strong>atom_xor</strong> (volatile __local ulong *<em>p</em>, ulong <em>val</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read the 64-bit value (referred to as <em>old</em>) stored at location
pointed by <em>p</em>.
Compute (<em>old</em> ^ val) and store result at location pointed by <em>p</em>.
The function returns <em>old</em>.</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Atomic operations on 64-bit integers and 32-bit integers (and floats)
are also atomic with respect to each other.
</td>
</tr>
</table>
</div>
</div>
<div class="sect4">
<h5 id="atomic-restrictions"><a class="anchor" href="#atomic-restrictions"></a>6.15.12.10. Restrictions</h5>
<div class="openblock">
<div class="content">
<div class="ulist">
<ul>
<li>
<p>All operations on atomic types must be performed using the built-in
atomic functions.
C11 and C++11 support operators on atomic types.
OpenCL C does not support operators with atomic types.
Using atomic types with operators should result in a compilation error.</p>
</li>
<li>
<p>The <code>atomic_bool</code>, <code>atomic_char</code>, <code>atomic_uchar</code>, <code>atomic_short</code>,
<code>atomic_ushort</code>, <code>atomic_intmax_t</code> and <code>atomic_uintmax_t</code> types are not
supported by OpenCL C.</p>
</li>
<li>
<p>OpenCL C 2.0 requires that the built-in atomic functions on atomic types
are lock-free.
In OpenCL C 3.0 or newer, built-in atomic functions on atomic types may be
lock-free.</p>
</li>
<li>
<p>The <code>_Atomic</code> type specifier and <code>_Atomic</code> type qualifier are not supported
by OpenCL C.</p>
</li>
<li>
<p>The behavior of atomic operations where pointer arguments to the atomic
functions refers to an atomic type in the <code>private</code> address space is
undefined.</p>
</li>
<li>
<p>Using <code>memory_order_acquire</code> with any built-in atomic function except
<code>atomic_work_item_fence</code> <a href="#unified-spec">requires</a> support for OpenCL C
2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>acq_<wbr>rel</code>
feature.</p>
</li>
<li>
<p>Using <code>memory_order_release</code> with any built-in atomic function except
<code>atomic_work_item_fence</code> <a href="#unified-spec">requires</a> support for OpenCL C
2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>acq_<wbr>rel</code>
feature.</p>
</li>
<li>
<p>Using <code>memory_order_acq_rel</code> with any built-in atomic function except
<code>atomic_work_item_fence</code> <a href="#unified-spec">requires</a> support for OpenCL C
2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>acq_<wbr>rel</code>
feature.</p>
</li>
<li>
<p>Using <code>memory_order_seq_cst</code> with any built-in atomic function
<a href="#unified-spec">requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>atomic_<wbr>order_<wbr>seq_<wbr>cst</code> feature.</p>
</li>
<li>
<p>Using <code>memory_scope_sub_group</code> with any built-in atomic function
<a href="#unified-spec">requires</a> support for
the <code>cl_khr_<wbr>subgroups</code> extension, or
OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>subgroups</code> feature.</p>
</li>
<li>
<p>Using <code>memory_scope_device</code> <a href="#unified-spec">requires</a> support for OpenCL
C 2.0, or OpenCL C 3.0 or newer and the
<code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>device</code> feature.</p>
</li>
<li>
<p>Using <code>memory_scope_all_svm_devices</code> <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>all_<wbr>devices</code> feature.</p>
</li>
<li>
<p>Using <code>memory_scope_all_devices</code> <a href="#unified-spec">requires</a> support for OpenCL
C 3.0 or newer and the <code>__opencl_c_<wbr>atomic_<wbr>scope_<wbr>all_<wbr>devices</code> feature.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="miscellaneous-vector-functions"><a class="anchor" href="#miscellaneous-vector-functions"></a>6.15.13. Miscellaneous Vector Functions</h4>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The OpenCL C programming language implements the following additional
built-in vector functions.
We use the generic type name <code>gentype<em>n</em></code> (or <code>gentype<em>m</em></code>) to indicate the
built-in data types <code>char<em>n</em></code>, <code>uchar<em>n</em></code>, <code>short<em>n</em></code>,
<code>ushort<em>n</em></code>,
<code>int<em>n</em></code>, <code>uint<em>n</em></code>, <code>long<em>n</em></code>
<sup class="footnote">[<a id="_footnoteref_73" class="footnote" href="#_footnotedef_73" title="View footnote.">73</a>]</sup>, <code>ulong<em>n</em></code>, <code>half<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_74" class="footnote" href="#_footnotedef_74" title="View footnote.">74</a>]</sup>, <code>float<em>n</em></code>, or
<code>double<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_75" class="footnote" href="#_footnotedef_75" title="View footnote.">75</a>]</sup> as the type for
the arguments unless otherwise stated.
We use the generic name <code>ugentype<em>n</em></code> to indicate the built-in unsigned
integer data types.
<em>n</em> is 2, 4, 8, or 16.</p>
</div>
<table id="table-misc-vector" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 30. Built-in Miscellaneous Vector Functions</caption>
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 66.6667%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>vec_step</strong>(gentype<em>n</em> <em>a</em>)<br>
int <strong>vec_step</strong>(char3 <em>a</em>)<br>
int <strong>vec_step</strong>(uchar3 <em>a</em>)<br>
int <strong>vec_step</strong>(short3 <em>a</em>)<br>
int <strong>vec_step</strong>(ushort3 <em>a</em>)<br>
int <strong>vec_step</strong>(half3 <em>a</em>)<br>
int <strong>vec_step</strong>(int3 <em>a</em>)<br>
int <strong>vec_step</strong>(uint3 <em>a</em>)<br>
int <strong>vec_step</strong>(long3 <em>a</em>)<br>
int <strong>vec_step</strong>(ulong3 <em>a</em>)<br>
int <strong>vec_step</strong>(float3 <em>a</em>)<br>
int <strong>vec_step</strong>(double3 <em>a</em>)<br>
int <strong>vec_step</strong>(<em>type</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <strong>vec_step</strong> built-in function takes a built-in scalar or vector
data type argument and returns an integer value representing the
number of elements in the scalar or vector. The argument is not
evaluated.</p>
<p class="tableblock"> For all scalar types, <strong>vec_step</strong> returns 1.</p>
<p class="tableblock"> The <strong>vec_step</strong> built-in functions that take a 3-component vector
return 4.</p>
<p class="tableblock"> <strong>vec_step</strong> may also take a type name as an argument, e.g.
<strong>vec_step</strong>(float2)</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype<em>n</em> <strong>shuffle</strong>(gentype<em>m</em> <em>x</em>,
ugentype<em>n</em> <em>mask</em>)<br>
gentype<em>n</em> <strong>shuffle2</strong>(gentype<em>m</em> <em>x</em>,
gentype<em>m</em> <em>y</em>,
ugentype<em>n</em> <em>mask</em>)</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>The <strong>shuffle</strong> and <strong>shuffle2</strong> built-in functions construct a
permutation of elements from one or two input vectors respectively
that are of the same type, returning a vector with the same element
type as the input and length that is the same as the shuffle mask.
The size of each element in the <em>mask</em> must match the size of each
element in the result.
For <strong>shuffle</strong>, only the <strong>ilogb</strong>(2<em>m</em>-1) least significant bits of each
<em>mask</em> element are considered.
For <strong>shuffle2</strong>, only the <strong>ilogb</strong>(2<em>m</em>-1)+1 least significant bits of
each <em>mask</em> element are considered.
Other bits in the mask shall be ignored.</p>
</div>
<div class="paragraph">
<p>The elements of the input vectors are numbered from left to right across one
or both of the vectors.
For this purpose, the number of elements in a vector is given by
<strong>vec_step</strong>(gentype<em>m</em>).
The shuffle <em>mask</em> operand specifies, for each element of the result vector,
which element of the one or two input vectors the result element gets.</p>
</div>
<div class="paragraph">
<p><a href="#unified-spec">Requires</a> support for OpenCL C 1.1 or newer.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint4</span> <span class="n">mask</span> <span class="o">=</span> <span class="p">(</span><span class="kt">uint4</span><span class="p">)(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">a</span><span class="p">;</span>
<span class="kt">float4</span> <span class="n">r</span> <span class="o">=</span> <span class="fm">shuffle</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">mask</span><span class="p">);</span>
<span class="kt">uint8</span> <span class="n">mask</span> <span class="o">=</span> <span class="p">(</span><span class="kt">uint8</span><span class="p">)(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">;</span>
<span class="kt">float8</span> <span class="n">r</span> <span class="o">=</span> <span class="fm">shuffle2</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">mask</span><span class="p">);</span>
<span class="kt">uint4</span> <span class="n">mask</span><span class="p">;</span>
<span class="kt">float8</span> <span class="n">a</span><span class="p">;</span>
<span class="kt">float4</span> <span class="n">b</span><span class="p">;</span>
<span class="n">b</span> <span class="o">=</span> <span class="fm">shuffle</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">mask</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Examples that are not valid are:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint8</span> <span class="n">mask</span><span class="p">;</span>
<span class="kt">short16</span> <span class="n">a</span><span class="p">;</span>
<span class="kt">short8</span> <span class="n">b</span><span class="p">;</span>
<span class="n">b</span> <span class="o">=</span> <span class="fm">shuffle</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">mask</span><span class="p">);</span> <span class="c1">// not valid</span></code></pre>
</div>
</div></div></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="printf"><a class="anchor" href="#printf"></a>6.15.14. printf</h4>
<div class="openblock">
<div class="content">
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
<strong>printf</strong> <a href="#unified-spec">requires</a> support for OpenCL C 1.2.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The OpenCL C programming language implements the <strong>printf</strong> function.</p>
</div>
<table id="table-printf" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 31. Built-in printf Function</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>printf</strong>(constant char *restrict <em>format</em>, &#8230;&#8203;)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <strong>printf</strong> built-in function writes output to an
implementation-defined stream such as stdout under control of the
string pointed to by <em>format</em> that specifies how subsequent arguments
are converted for output.
If there are insufficient arguments for the format, the behavior is
undefined.
If the format is exhausted while arguments remain, the excess
arguments are evaluated (as always) but are otherwise ignored.
The <strong>printf</strong> function returns when the end of the format string is
encountered.</p>
<p class="tableblock"> <strong>printf</strong> returns 0 if it was executed successfully and -1 otherwise.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect4">
<h5 id="printf-output-synchronization"><a class="anchor" href="#printf-output-synchronization"></a>6.15.14.1. printf Output Synchronization</h5>
<div class="paragraph">
<p>When the event that is associated with a particular kernel invocation is
completed, the output of all printf() calls executed by this kernel
invocation is flushed to the implementation-defined output stream.
Calling <strong>clFinish</strong> on a command-queue flushes all pending output by printf
in previously enqueued and completed commands to the implementation-defined
output stream.
In the case that printf is executed from multiple work-items concurrently,
there is no guarantee of ordering with respect to written data.
For example, it is valid for the output of a work-item with a global id
(0,0,1) to appear intermixed with the output of a work-item with a global id
(0,0,4) and so on.</p>
</div>
</div>
<div class="sect4">
<h5 id="printf-format-string"><a class="anchor" href="#printf-format-string"></a>6.15.14.2. printf Format String</h5>
<div class="paragraph">
<p>The format shall be a character sequence, beginning and ending in its
initial shift state.
The format is composed of zero or more directives: ordinary characters (not
<strong>%</strong>), which are copied unchanged to the output stream; and conversion
specifications, each of which results in fetching zero or more subsequent
arguments, converting them, if applicable, according to the corresponding
conversion specifier, and then writing the result to the output stream.
The format is in the constant address space and must be resolvable at
compile time, i.e. cannot be dynamically created by the executing program
itself.</p>
</div>
<div class="paragraph">
<p>Each conversion specification is introduced by the character <strong>%</strong>.
After the <strong>%</strong>, the following appear in sequence:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Zero or more <em>flags</em> (in any order) that modify the meaning of the
conversion specification.</p>
</li>
<li>
<p>An optional minimum <em>field width</em>.
If the converted value has fewer characters than the field width, it is
padded with spaces (by default) on the left (or right, if the left
adjustment flag, described later, has been given) to the field width.
The field width takes the form of a nonnegative decimal integer
<sup class="footnote">[<a id="_footnoteref_76" class="footnote" href="#_footnotedef_76" title="View footnote.">76</a>]</sup>.</p>
</li>
<li>
<p>An optional <em>precision</em> that gives the minimum number of digits to
appear for the <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, and <strong>X</strong> conversions, the number
of digits to appear after the decimal-point character for <strong>a</strong>, <strong>A</strong>, <strong>e</strong>,
<strong>E</strong>, <strong>f</strong>, and <strong>F</strong> conversions, the maximum number of significant digits
for the <strong>g</strong> and <strong>G</strong> conversions, or the maximum number of bytes to be
written for <strong>s</strong> conversions.
The precision takes the form of a period (<strong>.</strong>) followed by an optional
decimal integer; if only the period is specified, the precision is taken
as zero.
If a precision appears with any other conversion specifier, the behavior
is undefined.</p>
</li>
<li>
<p>An optional <em>vector specifier</em>.</p>
</li>
<li>
<p>A <em>length modifier</em> that specifies the size of the argument.
The <em>length modifier</em> is required with a vector specifier and together
specifies the vector type.
<a href="#implicit-conversions">Implicit conversions</a> between vector types are
disallowed.
If the <em>vector specifier</em> is not specified, the <em>length modifier</em> is
optional.</p>
</li>
<li>
<p>A <em>conversion specifier</em> character that specifies the type of
conversion to be applied.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The flag characters and their meanings are:</p>
</div>
<div class="paragraph">
<p><strong>-</strong> The result of the conversion is left-justified within the field.
(It is right-justified if this flag is not specified.)</p>
</div>
<div class="paragraph">
<p><strong>+</strong> The result of a signed conversion always begins with a plus or minus
sign.
(It begins with a sign only when a negative value is converted if this flag
is not specified.) <sup class="footnote">[<a id="_footnoteref_77" class="footnote" href="#_footnotedef_77" title="View footnote.">77</a>]</sup></p>
</div>
<div class="paragraph">
<p><em>space</em> If the first character of a signed conversion is not a sign, or if a
signed conversion results in no characters, a space is prefixed to the
result.
If the <em>space</em> and <strong>+</strong> flags both appear, the <em>space</em> flag is ignored.</p>
</div>
<div class="paragraph">
<p><strong>#</strong> The result is converted to an &#8220;alternative form&#8221;.
For <strong>o</strong> conversion, it increases the precision, if and only if necessary,
to force the first digit of the result to be a zero (if the value and
precision are both 0, a single 0 is printed).
For <strong>x</strong> (or <strong>X</strong>) conversion, a nonzero result has <strong>0x</strong> (or <strong>0X</strong>)
prefixed to it.
For <strong>a</strong>, <strong>A</strong>, <strong>e</strong>, <strong>E</strong>, <strong>f</strong>, <strong>F</strong>, <strong>g</strong>, and <strong>G</strong> conversions,
the result of converting a floating-point number always contains a
decimal-point character, even if no digits follow it.
(Normally, a decimal-point character appears in the result of these
conversions only if a digit follows it.) For <strong>g</strong> and <strong>G</strong> conversions,
trailing zeros are <strong>not</strong> removed from the result.
For other conversions, the behavior is undefined.</p>
</div>
<div class="paragraph">
<p><strong>0</strong> For <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, <strong>X</strong>, <strong>a</strong>, <strong>A</strong>, <strong>e</strong>,
<strong>E</strong>, <strong>f</strong>, <strong>F</strong>, <strong>g</strong>, and <strong>G</strong> conversions, leading zeros (following
any indication of sign or base) are used to pad to the field width rather
than performing space padding, except when converting an infinity or NaN.
If the <strong>0</strong> and <strong>-</strong> flags both appear, the <strong>0</strong> flag is ignored.
For <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, and <strong>X</strong> conversions, if a precision
is specified, the <strong>0</strong> flag is ignored.
For other conversions, the behavior is undefined.</p>
</div>
<div class="paragraph">
<p>The vector specifier and its meaning is:</p>
</div>
<div class="paragraph">
<p><strong>v</strong><em>n</em> Specifies that a following <strong>a</strong>, <strong>A</strong>, <strong>e</strong>, <strong>E</strong>, <strong>f</strong>, <strong>F</strong>, <strong>g</strong>, <strong>G</strong>,
<strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong> conversion specifier applies to a vector
argument, where <em>n</em> is the size of the vector and must be 2, 3, 4, 8 or 16.</p>
</div>
<div class="paragraph">
<p>The vector value is displayed in the following general form:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>value1 C value2 C &#8230;&#8203; C value<em>n</em></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>where C is a separator character.
The value for this separator character is a comma.</p>
</div>
<div class="paragraph">
<p>If the vector specifier is not used, the length modifiers and their meanings
are:</p>
</div>
<div class="paragraph">
<p><strong>hh</strong> Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong> conversion
specifier applies to a <code>char</code> or <code>uchar</code> argument (the argument will have
been promoted according to the integer promotions, but its value shall be
converted to <code>char</code> or <code>uchar</code> before printing).</p>
</div>
<div class="paragraph">
<p><strong>h</strong> Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong> conversion
specifier applies to a <code>short</code> or <code>ushort</code> argument (the argument will have
been promoted according to the integer promotions, but its value shall be
converted to <code>short</code> or <code>unsigned short</code> before printing).</p>
</div>
<div class="paragraph">
<p><strong>l</strong> (ell) Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong>
conversion specifier applies to a <code>long</code> or <code>ulong</code> argument.
The <strong>l</strong> modifier is supported by the full profile.
For the embedded profile, the <strong>l</strong> modifier is supported only if 64-bit
integers are supported by the device.</p>
</div>
<div class="paragraph">
<p><strong>z</strong> Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong> conversion
specifier applies to a <code>size_t</code> argument.
The <strong>z</strong> length modifier <a href="#unified-spec">requires</a> support for OpenCL C 3.1 or
newer.</p>
</div>
<div class="paragraph">
<p><strong>t</strong> Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong> conversion
specifier applies to a <code>ptrdiff_t</code> argument.
The <strong>t</strong> length modifier <a href="#unified-spec">requires</a> support for OpenCL C 3.1 or
newer.</p>
</div>
<div class="paragraph">
<p>If the vector specifier is used, the length modifiers and their meanings
are:</p>
</div>
<div class="paragraph">
<p><strong>hh</strong> Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong> conversion
specifier applies to a <code>char<em>n</em></code> or <code>uchar<em>n</em></code> argument (the argument
will not be promoted).</p>
</div>
<div class="paragraph">
<p><strong>h</strong> Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong> conversion
specifier applies to a <code>short<em>n</em></code> or <code>ushort<em>n</em></code> argument (the argument
will not be promoted); that a following <strong>a</strong>, <strong>A</strong>, <strong>e</strong>, <strong>E</strong>, <strong>f</strong>, <strong>F</strong>, <strong>g</strong>,
or <strong>G</strong> conversion specifier applies to a <code>half<em>n</em></code>
<sup class="footnote">[<a id="_footnoteref_78" class="footnote" href="#_footnotedef_78" title="View footnote.">78</a>]</sup> argument.</p>
</div>
<div class="paragraph">
<p><strong>hl</strong> This modifier can only be used with the vector specifier.
Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong> conversion
specifier applies to a <code>int<em>n</em></code> or <code>uint<em>n</em></code> argument; that a following
<strong>a</strong>, <strong>A</strong>, <strong>e</strong>, <strong>E</strong>, <strong>f</strong>, <strong>F</strong>, <strong>g</strong>, or <strong>G</strong> conversion specifier applies to a
<code>float<em>n</em></code> argument.</p>
</div>
<div class="paragraph">
<p><strong>l</strong>(ell) Specifies that a following <strong>d</strong>, <strong>i</strong>, <strong>o</strong>, <strong>u</strong>, <strong>x</strong>, or <strong>X</strong>
conversion specifier applies to a <code>long<em>n</em></code> or <code>ulong<em>n</em></code> argument; that
a following <strong>a</strong>, <strong>A</strong>, <strong>e</strong>, <strong>E</strong>, <strong>f</strong>, <strong>F</strong>, <strong>g</strong>, or <strong>G</strong> conversion specifier
applies to a <code>double<em>n</em></code> argument.
The <strong>l</strong> modifier is supported by the full profile.
For the embedded profile, the <strong>l</strong> modifier is supported only if 64-bit
integers or double-precision floating-point are supported by the device.</p>
</div>
<div class="paragraph">
<p>If a vector specifier appears without a length modifier, the behavior is
undefined.
The vector data type described by the vector specifier and length modifier
must match the data type of the argument; otherwise the behavior is
undefined.</p>
</div>
<div class="paragraph">
<p>If a length modifier appears with any conversion specifier other than as
specified above, the behavior is undefined.</p>
</div>
<div class="paragraph">
<p>The conversion specifiers and their meanings are:</p>
</div>
<div class="paragraph">
<p><strong>d,i</strong> The <code>int</code>, <code>char<em>n</em></code>, <code>short<em>n</em></code>, <code>int<em>n</em></code> or <code>long<em>n</em></code>
argument is converted to signed decimal in the style <em>[</em><strong>-</strong><em>]dddd</em>.
The precision specifies the minimum number of digits to appear; if the value
being converted can be represented in fewer digits, it is expanded with
leading zeros.
The default precision is 1.
The result of converting a zero value with a precision of zero is no
characters.</p>
</div>
<div class="paragraph">
<p><strong>o,u,</strong></p>
</div>
<div class="paragraph">
<p><strong>x,X</strong> The <code>uint</code>, <code>uchar<em>n</em></code>, <code>ushort<em>n</em></code>, <code>uint<em>n</em></code> or
<code>ulong<em>n</em></code> argument is converted to unsigned octal (<strong>o</strong>), unsigned decimal
(<strong>u</strong>), or unsigned hexadecimal notation (<strong>x</strong> or <strong>X</strong>) in the style <em>dddd</em>;
the letters <strong>abcdef</strong> are used for <strong>x</strong> conversion and the letters <strong>ABCDEF</strong>
for <strong>X</strong> conversion.
The precision specifies the minimum number of digits to appear; if the value
being converted can be represented in fewer digits, it is expanded with
leading zeros.
The default precision is 1.
The result of converting a zero value with a precision of zero is no
characters.</p>
</div>
<div class="paragraph">
<p><strong>f,F</strong> A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> argument
representing a floating-point number is converted to decimal notation in the
style <em>[</em><strong>-</strong><em>]ddd</em><strong>.</strong><em>ddd</em>, where the number of digits after the
decimal-point character is equal to the precision specification.
If the precision is missing, it is taken as 6; if the precision is zero and
the <strong># </strong>flag is not specified, no decimal-point character appears.
If a decimal-point character appears, at least one digit appears before it.
The value is rounded to the appropriate number of digits.
A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> argument representing
an infinity is converted in one of the styles <em>[</em><strong>-</strong><em>]</em><strong>inf </strong>or
<em>[</em><strong>-</strong><em>]</em><strong>infinity </strong>&#8201;&#8212;&#8201;which style is implementation-defined.
A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> argument representing
a NaN is converted in one of the styles <em>[</em><strong>-</strong><em>]</em><strong>nan </strong>or
<em>[</em><strong>-</strong><em>]</em><strong>nan(</strong><em>n-char-sequence</em><strong>) </strong>&#8201;&#8212;&#8201;which style, and the meaning of any <em>n-char-sequence</em>, is
implementation-defined.
The <strong>F</strong> conversion specifier produces <code>INF</code>, <code>INFINITY</code>, or <code>NAN</code> instead of
<strong>inf</strong>, <strong>infinity</strong>, or <strong>nan</strong>, respectively <sup class="footnote">[<a id="_footnoteref_79" class="footnote" href="#_footnotedef_79" title="View footnote.">79</a>]</sup>.</p>
</div>
<div class="paragraph">
<p><strong>e,E</strong> A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> argument
representing a floating-point number is converted in the style
<em>[</em><strong>-</strong><em>]d</em><strong>.</strong><em>ddd </em><strong>e±</strong><em>dd</em>, where there is one digit
(which is nonzero if the argument is nonzero) before the decimal-point
character and the number of digits after it is equal to the precision; if
the precision is missing, it is taken as 6; if the precision is zero and the
<strong>#</strong> flag is not specified, no decimal-point character appears.
The value is rounded to the appropriate number of digits.
The <strong>E</strong> conversion specifier produces a number with <strong>E</strong> instead of <strong>e</strong>
introducing the exponent.
The exponent always contains at least two digits, and only as many more
digits as necessary to represent the exponent.
If the value is zero, the exponent is zero.
A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> argument representing
an infinity or NaN is converted in the style of an <strong>f</strong> or <strong>F</strong> conversion
specifier.</p>
</div>
<div class="paragraph">
<p><strong>g,G</strong> A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> argument
representing a floating-point number is converted in style <strong>f</strong> or <strong>e</strong> (or in
style <strong>F</strong> or <strong>E</strong> in the case of a <strong>G</strong> conversion specifier), depending on
the value converted and the precision.
Let <em>P </em>equal the precision if nonzero, 6 if the precision is omitted, or
1 if the precision is zero.
Then, if a conversion with style <strong>E</strong> would have an exponent of <em>X</em>:&#8201;&#8212;&#8201;if
<em>P</em> &gt; <em>X</em> ≥ -4, the conversion is with style <strong>f</strong> (or <strong>F</strong>) and precision
<em>P</em> <strong>-</strong> (<em>X</em> <strong>+</strong> 1).&#8201;&#8212;&#8201;otherwise, the conversion is with style <strong>e *(or *E</strong>) and precision <em>P</em>
<strong>-</strong> 1.
Finally, unless the <strong>#</strong> flag is used, any trailing zeros are removed from
the fractional portion of the result and the decimal-point character is
removed if there is no fractional portion remaining.
A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> <strong>e</strong> argument
representing an infinity or NaN is converted in the style of an <strong>f</strong> or <strong>F</strong>
conversion specifier.</p>
</div>
<div class="paragraph">
<p><strong>a,A</strong> A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> argument
representing a floating-point number is converted in the style
<em>[</em><strong>-</strong><em>]</em><strong>0x</strong><em>h</em><strong>.</strong><em>hhhh </em><strong>p±</strong><em>d</em>, where there is one
hexadecimal digit (which is nonzero if the argument is a normalized
floating-point number and is otherwise unspecified) before the decimal-point
character <sup class="footnote">[<a id="_footnoteref_80" class="footnote" href="#_footnotedef_80" title="View footnote.">80</a>]</sup> and the number of hexadecimal digits
after it is equal to the precision; if the precision is missing, then the
precision is sufficient for an exact representation of the value; if the
precision is zero and the <strong>#</strong> flag is not specified, no decimal point character
appears.
The letters <strong>abcdef</strong> are used for <strong>a</strong> conversion and the letters <strong>ABCDEF</strong>
for <strong>A</strong> conversion.
The <strong>A</strong> conversion specifier produces a number with <strong>X</strong> and <strong>P</strong> instead of
<strong>x</strong> and <strong>p</strong>.
The exponent always contains at least one digit, and only as many more
digits as necessary to represent the decimal exponent of 2.
If the value is zero, the exponent is zero.
A <code>double</code>, <code>half<em>n</em></code>, <code>float<em>n</em></code> or <code>double<em>n</em></code> argument representing
an infinity or NaN is converted in the style of an <strong>f</strong> or <strong>F</strong> conversion
specifier.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The conversion specifiers <strong>e,E,g,G,a,A</strong> convert a <code>float</code> or <code>half</code> argument
that is a scalar type to a <code>double</code> only if <a href="#double-precision">double
precision is supported</a>.
Otherwise, the argument will be a <code>float</code> instead of a <code>double</code> and the
<code>half</code> type will be converted to a <code>float</code>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p><strong>c</strong> The <code>int</code> argument is converted to an <code>unsigned char</code>, and the resulting
character is written.</p>
</div>
<div class="paragraph">
<p><strong>s</strong> The argument shall be a literal string
<sup class="footnote">[<a id="_footnoteref_81" class="footnote" href="#_footnotedef_81" title="View footnote.">81</a>]</sup>.
Characters from the literal string array are written up to (but not
including) the terminating null character.
If the precision is specified, no more than that many bytes are written.
If the precision is not specified or is greater than the size of the array,
the array shall contain a null character.</p>
</div>
<div class="paragraph">
<p><strong>p</strong> The argument shall be a pointer to <strong>void</strong>.
The pointer can refer to a memory region in the <code>global</code>, <code>constant</code>,
<code>local</code>, <code>private</code>, or generic address space.
The value of the pointer is converted to a sequence of printing characters
in an implementation-defined manner.</p>
</div>
<div class="paragraph">
<p><strong>%</strong> A <strong>%</strong> character is written.
No argument is converted.
The complete conversion specification shall be <strong>%%</strong>.</p>
</div>
<div class="paragraph">
<p>If a conversion specification is invalid, the behavior is undefined.
If any argument is not the correct type for the corresponding conversion
specification, the behavior is undefined.</p>
</div>
<div class="paragraph">
<p>In no case does a nonexistent or small field width cause truncation of a
field; if the result of a conversion is wider than the field width, the
field is expanded to contain the conversion result.</p>
</div>
<div class="paragraph">
<p>For <strong>a</strong> and <strong>A</strong> conversions, the value is correctly rounded to a hexadecimal
floating number with the given precision.</p>
</div>
<div class="paragraph">
<p>A few examples of printf are given below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="kt">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
<span class="kt">uchar4</span> <span class="n">uc</span> <span class="o">=</span> <span class="p">(</span><span class="kt">uchar4</span><span class="p">)(</span><span class="mh">0xFA</span><span class="p">,</span> <span class="mh">0xFB</span><span class="p">,</span> <span class="mh">0xFC</span><span class="p">,</span> <span class="mh">0xFD</span><span class="p">);</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"f4 = %2.2v4hlf</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">f</span><span class="p">);</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"uc = %#v4hhx</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">uc</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The above two printf calls print the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">f4</span> <span class="o">=</span> <span class="mf">1.00</span><span class="p">,</span><span class="mf">2.00</span><span class="p">,</span><span class="mf">3.00</span><span class="p">,</span><span class="mf">4.00</span>
<span class="n">uc</span> <span class="o">=</span> <span class="mh">0xfa</span><span class="p">,</span><span class="mh">0xfb</span><span class="p">,</span><span class="mh">0xfc</span><span class="p">,</span><span class="mh">0xfd</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>A few examples of valid use cases of printf for the conversion specifier <strong>s</strong>
are given below.
The argument value must be a pointer to a literal string.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_kernel</span><span class="p">(</span> <span class="p">...</span> <span class="p">)</span>
<span class="p">{</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"%s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="s">"this is a test string</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>A few examples of invalid use cases of printf for the conversion specifier
<strong>s</strong> are given below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_kernel</span><span class="p">(</span><span class="nx">global</span> <span class="kt">char</span> <span class="o">*</span><span class="n">s</span><span class="p">,</span> <span class="p">...</span> <span class="p">)</span>
<span class="p">{</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"%s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">s</span><span class="p">);</span>
<span class="nx">constant</span> <span class="kt">char</span> <span class="o">*</span><span class="n">p</span> <span class="o">=</span> <span class="s">"`this is a test string</span><span class="se">\n</span><span class="s">`"</span><span class="p">;</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"%s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">p</span><span class="p">);</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"%s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">p</span><span class="p">[</span><span class="mi">3</span><span class="p">]);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>A few examples of invalid use cases of printf where data types given by the
vector specifier and length modifier do not match the argument type are
given below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span> <span class="nf">my_kernel</span><span class="p">(</span><span class="nx">global</span> <span class="kt">char</span> <span class="o">*</span><span class="n">s</span><span class="p">,</span> <span class="p">...</span> <span class="p">)</span>
<span class="p">{</span>
<span class="kt">uint2</span> <span class="n">ui</span> <span class="o">=</span> <span class="p">(</span><span class="kt">uint2</span><span class="p">)(</span><span class="mh">0x12345678</span><span class="p">,</span> <span class="mh">0x87654321</span><span class="p">);</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"unsigned short value = (%#v2hx)</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">ui</span><span class="p">)</span>
<span class="fm">printf</span><span class="p">(</span><span class="s">"unsigned char value = (%#v2hhx)</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">ui</span><span class="p">)</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="differences-between-opencl-c-and-c99-printf"><a class="anchor" href="#differences-between-opencl-c-and-c99-printf"></a>6.15.14.3. Differences Between OpenCL C and C99 printf</h5>
<div class="ulist">
<ul>
<li>
<p>The asterisk <strong>*</strong> field width specifier is not supported by OpenCL C.</p>
</li>
<li>
<p>The <strong>l</strong> modifier followed by a <strong>c</strong> conversion specifier or <strong>s</strong>
conversion specifier is not supported by OpenCL C.</p>
</li>
<li>
<p>The <strong>ll</strong>, <strong>j</strong>, and <strong>L</strong> length modifiers are not supported by OpenCL C but
are reserved.
Prior to OpenCL C 3.1, the <strong>z</strong> and <strong>t</strong> length modifiers additionally are not
supported by OpenCL C but are reserved.</p>
</li>
<li>
<p>The <strong>n</strong> conversion specifier is not supported by OpenCL C but is
reserved.</p>
</li>
<li>
<p>OpenCL C adds the optional <strong>v</strong><em>n</em> vector specifier to support printing
of vector types.</p>
</li>
<li>
<p>The conversion specifiers <strong>f</strong>, <strong>F</strong>, <strong>e</strong>, <strong>E</strong>, <strong>g</strong>, <strong>G</strong>, <strong>a</strong>, <strong>A</strong> convert
a <code>float</code> argument to a <code>double</code> only if the <code>double</code> data type is
supported.
Refer to the value of the <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>DOUBLE_<wbr>FP_<wbr>CONFIG</code> device query</a>.
If the <code>double</code> data type is not supported, the argument will be a
<code>float</code> instead of a <code>double</code>.</p>
</li>
<li>
<p>For the embedded profile, the <strong>l</strong> length modifier is supported only if
64-bit integers are supported.</p>
</li>
<li>
<p>In OpenCL C, <strong>printf</strong> returns 0 if it was executed successfully and -1
otherwise vs.
C99 where <strong>printf</strong> returns the number of characters printed or a
negative value if an output or encoding error occurred.</p>
</li>
<li>
<p>In OpenCL C, the conversion specifier <strong>s</strong> can only be used for arguments
that are literal strings.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect3">
<h4 id="image-read-and-write-functions"><a class="anchor" href="#image-read-and-write-functions"></a>6.15.15. Image Read and Write Functions</h4>
<div class="paragraph">
<p>The built-in functions defined in this section can only be used with image
memory objects.
An image memory object can be accessed by specific function calls that read
from and/or write to specific locations in the image.</p>
</div>
<div class="paragraph">
<p>Support for the image built-in functions is optional.
If a device supports images then the value of the <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>IMAGE_<wbr>SUPPORT</code> device query</a>) is <code>CL_TRUE</code> and the OpenCL C
compiler for that device must define the <code>__IMAGE_SUPPORT__</code> macro.
A compiler for OpenCL C 3.0 or newer for that device must also support the
<code>__opencl_c_<wbr>images</code> feature.</p>
</div>
<div class="paragraph">
<p>Image memory objects that are being read by a kernel should be declared with
the <code>read_only</code> qualifier.
<strong>write_image</strong> calls to image memory objects declared with the read_only
qualifier will generate a compilation error.
Image memory objects that are being written to by a kernel should be
declared with the write_only qualifier.
<strong>read_image</strong> calls to image memory objects declared with the <code>write_only</code>
qualifier will generate a compilation error.
<strong>read_image</strong> and <strong>write_image</strong> calls to the same image memory object in a
kernel are supported.
Image memory objects that are being read and written by a kernel should be
declared with the <code>read_write</code> qualifier.</p>
</div>
<div class="paragraph">
<p>The <strong>read_image</strong> calls returns a four component floating-point, integer or
unsigned integer color value.
The color values returned by <strong>read_image</strong> are identified as <em>x</em>, <em>y</em>, <em>z</em>,
<em>w</em> where <em>x</em> refers to the red component, <em>y</em> refers to the green
component, <em>z</em> refers to the blue component and <em>w</em> refers to the alpha
component.</p>
</div>
<div class="sect4">
<h5 id="samplers"><a class="anchor" href="#samplers"></a>6.15.15.1. Samplers</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The image read functions take a sampler argument.
The sampler can be passed as an argument to the kernel using
<strong>clSetKernelArg</strong>, or can be declared in the outermost scope of kernel
functions, or it can be a constant variable of type <code>sampler_t</code> declared in
the program source.</p>
</div>
<div class="paragraph">
<p>Sampler variables in a program are declared to be of type <code>sampler_t</code>.
A variable of <code>sampler_t</code> type declared in the program source must be
initialized with a 32-bit unsigned integer constant, which is interpreted as
a bit-field specifying the following properties:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Addressing Mode</p>
</li>
<li>
<p>Filter Mode</p>
</li>
<li>
<p>Normalized Coordinates</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>These properties control how elements of an image object are read by
<strong>read_image{f|i|ui}</strong>.</p>
</div>
<div class="paragraph">
<p>Samplers can also be declared as global constants in the program source
using the following syntax.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">const</span> <span class="kt">sampler_t</span> <span class="o">&lt;</span><span class="n">sampler</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">=</span> <span class="o">&lt;</span><span class="n">value</span><span class="o">&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>or</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">constant</span> <span class="kt">sampler_t</span> <span class="o">&lt;</span><span class="n">sampler</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">=</span> <span class="o">&lt;</span><span class="n">value</span><span class="o">&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>or</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">__constant</span> <span class="kt">sampler_t</span> <span class="o">&lt;</span><span class="n">sampler_name</span><span class="o">&gt;</span> <span class="o">=</span> <span class="o">&lt;</span><span class="n">value</span><span class="o">&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that samplers declared using the <code>constant</code> qualifier are not counted
towards the maximum number of arguments pointing to the constant address
space or the maximum size of the <code>constant</code> address space allowed per device
(i.e. the value of the <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>MAX_<wbr>CONSTANT_<wbr>ARGS</code></a> and <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>MAX_<wbr>CONSTANT_<wbr>BUFFER_<wbr>SIZE</code></a> device queries).</p>
</div>
<div class="paragraph">
<p>The sampler fields are described in the following table.</p>
</div>
<table id="table-sampler-descriptor" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 32. Sampler Descriptor</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Sampler State</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>&lt;normalized coords&gt;</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Specifies whether the <em>x</em>, <em>y</em> and <em>z</em> coordinates are passed in as
normalized or unnormalized values.
This must be a literal value and can be one of the following
predefined enums:</p>
<p class="tableblock"> <code>CLK_NORMALIZED_COORDS_TRUE</code> or <code>CLK_NORMALIZED_COORDS_FALSE</code>.</p>
<p class="tableblock"> The samplers used with an image in multiple calls to
<strong>read_image{f|i|ui}</strong> declared in a kernel must use the same value
for &lt;normalized coords&gt;.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>&lt;addressing mode&gt;</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Specifies the image addressing mode, i.e. how out-of-range image
coordinates are handled.
This must be a literal value and can be one of the following
predefined enums:</p>
<p class="tableblock"> <code>CLK_ADDRESS_MIRRORED_REPEAT</code> - Flip the image coordinate at every
integer junction.
This addressing mode can only be used with normalized coordinates.
If normalized coordinates are not used, this addressing mode may
generate image coordinates that are undefined.</p>
<p class="tableblock"> <code>CLK_ADDRESS_REPEAT</code> - out-of-range image coordinates are wrapped to
the valid range.
This addressing mode can only be used with normalized coordinates.
If normalized coordinates are not used, this addressing mode may
generate image coordinates that are undefined.</p>
<p class="tableblock"> <code>CLK_ADDRESS_CLAMP_TO_EDGE</code> - out-of-range image coordinates are
clamped to the extent.</p>
<p class="tableblock"> <code>CLK_ADDRESS_CLAMP</code> - out-of-range image coordinates will return a
border color <sup class="footnote">[<a id="_footnoteref_82" class="footnote" href="#_footnotedef_82" title="View footnote.">82</a>]</sup>.</p>
<p class="tableblock"> <code>CLK_ADDRESS_NONE</code> - for this addressing mode the programmer
guarantees that the image coordinates used to sample elements of the
image refer to a location inside the image; otherwise the results are
undefined.</p>
<p class="tableblock"> For 1D and 2D image arrays, the addressing mode applies only to the
<em>x</em> and (<em>x, y</em>) coordinates.
The addressing mode for the coordinate which specifies the array index
is always <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>&lt;filter mode&gt;</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Specifies the filter mode to use.
This must be a literal value and can be one of the following
predefined enums: <code>CLK_FILTER_NEAREST</code> or <code>CLK_FILTER_LINEAR</code>.</p>
<p class="tableblock"> Refer to the <a href="#addressing-and-filter-modes">detailed description of
these filter modes</a>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>Examples</strong>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">const</span> <span class="kt">sampler_t</span> <span class="n">samplerA</span> <span class="o">=</span> <span class="n">CLK_NORMALIZED_COORDS_TRUE</span> <span class="o">|</span>
<span class="n">CLK_ADDRESS_REPEAT</span> <span class="o">|</span>
<span class="n">CLK_FILTER_NEAREST</span><span class="p">;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>samplerA</code> specifies a sampler that uses normalized coordinates, the repeat
addressing mode and a nearest filter.</p>
</div>
<div class="paragraph">
<p>The maximum number of samplers that can be declared in a kernel can be
queried using the <code>CL_DEVICE_<wbr>MAX_<wbr>SAMPLERS</code> token in <strong>clGetDeviceInfo</strong>.</p>
</div>
</div>
</div>
<div class="sect5">
<h6 id="determining-the-border-color-or-value"><a class="anchor" href="#determining-the-border-color-or-value"></a>6.15.15.1.1. Determining the Border Color or Value</h6>
<div class="paragraph">
<p>If <code>&lt;addressing mode&gt;</code> in sampler is <code>CLK_ADDRESS_CLAMP</code>, then out-of-range
image coordinates return the border color.
The border color selected depends on the image channel order and can be one
of the following values:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>If the image channel order is <code>CL_A</code>, <code>CL_INTENSITY</code>, <code>CL_Rx</code>,
<code>CL_RA</code>, <code>CL_RGx</code>, <code>CL_RGBx</code>, <code>CL_sRGBx</code>, <code>CL_ARGB</code>, <code>CL_BGRA</code>,
<code>CL_ABGR</code>, <code>CL_RGBA</code>, <code>CL_sRGBA</code> or <code>CL_sBGRA</code>, the border color is
<code>(0.0f, 0.0f, 0.0f, 0.0f)</code>.</p>
</li>
<li>
<p>If the image channel order is <code>CL_R</code>, <code>CL_RG</code>, <code>CL_RGB</code>, or
<code>CL_LUMINANCE</code>, the border color is <code>(0.0f, 0.0f, 0.0f, 1.0f)</code>.</p>
</li>
<li>
<p>If the image channel order is <code>CL_DEPTH</code>, the border value is <code>0.0f</code>.</p>
</li>
</ul>
</div>
</div>
<div class="sect5">
<h6 id="srgb-images"><a class="anchor" href="#srgb-images"></a>6.15.15.1.2. sRGB Images</h6>
<div class="paragraph">
<p>The built-in image read functions will perform sRGB to linear RGB
conversions if the image is an sRGB image.
Likewise, the built-in image write functions perform the linear to
sRGB conversion if the image is an sRGB image.</p>
</div>
<div class="paragraph">
<p>Only the R, G and B components are converted from linear to sRGB and
vice-versa.
The alpha component is returned as is.</p>
</div>
</div>
</div>
<div class="sect4">
<h5 id="built-in-image-read-functions"><a class="anchor" href="#built-in-image-read-functions"></a>6.15.15.2. Built-in Image Read Functions</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following built-in function calls to read images with a sampler are
supported <sup class="footnote">[<a id="_footnoteref_83" class="footnote" href="#_footnotedef_83" title="View footnote.">83</a>]</sup>.</p>
</div>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>mipmap_<wbr>image</code> extension macro is supported, read
functions which do not either</p>
</div>
<div class="ulist">
<ul>
<li>
<p>explicitly specify a level of detail <em>lod</em>, or</p>
</li>
<li>
<p>compute a level of detail from <em>gradient</em> parameters</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>read from mip level 0 if <em>image</em> is a mipmapped image.</p>
</div>
<table id="table-image-read" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 33. Built-in Image Read Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(read_only image2d_t <em>image</em>, sampler_t <em>sampler</em>,
int2 <em>coord</em>)<br>
float4 <strong>read_imagef</strong>(read_only image2d_t <em>image</em>, sampler_t <em>sampler</em>,
float2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>) to do an element lookup in
the 2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imagef</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(read_only image2d_t <em>image</em>, sampler_t <em>sampler</em>,
int2 <em>coord</em>)<br>
half4 <strong>read_imageh</strong>(read_only image2d_t <em>image</em>, sampler_t <em>sampler</em>,
float2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>(coord.x, coord.y)</em> to do an element lookup in the
2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed
formats or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imageh</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(read_only image2d_t <em>image</em>, sampler_t <em>sampler</em>,
int2 <em>coord</em>)<br>
int4 <strong>read_imagei</strong>(read_only image2d_t <em>image</em>, sampler_t <em>sampler</em>,
float2 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image2d_t <em>image</em>, sampler_t <em>sampler</em>,
int2 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image2d_t <em>image</em>, sampler_t <em>sampler</em>,
float2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>) to do an element lookup in
the 2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively.
Each channel will be stored in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p>
<p class="tableblock"> The <strong>read_image{i|ui}</strong> calls support a nearest filter only.
The filter_mode specified in <em>sampler</em> must be set to
<code>CLK_FILTER_NEAREST</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Furthermore, the <strong>read_image{i|ui}</strong> calls that take integer
coordinates must use a sampler with normalized coordinates set to
<code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode set to
<code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(read_only image3d_t <em>image</em>, sampler_t <em>sampler</em>,
int4 <em>coord</em> )<br>
float4 <strong>read_imagef</strong>(read_only image3d_t <em>image</em>, sampler_t <em>sampler</em>,
float4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>, <em>coord.z</em>) to do an element
lookup in the 3D image object specified by <em>image</em>.
<em>coord.w</em> is ignored.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imagef</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description are
undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(read_only image3d_t <em>image</em>, sampler_t <em>sampler</em>,
int4 <em>coord</em> )<br>
half4 <strong>read_imageh</strong>(read_only image3d_t <em>image</em>, sampler_t <em>sampler</em>,
float4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>(coord.x</em>, <em>coord.y</em>, <em>coord.z)</em> to do an
elementlookup in the 3D image object specified by <em>image</em>.
<em>coord.w</em> is ignored.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imageh</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description are
undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(read_only image3d_t <em>image</em>, sampler_t <em>sampler</em>,
int4 <em>coord</em>)<br>
int4 <strong>read_imagei</strong>(read_only image3d_t <em>image</em>, sampler_t <em>sampler</em>,
float4 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image3d_t <em>image</em>, sampler_t <em>sampler</em>,
int4 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image3d_t <em>image</em>, sampler_t <em>sampler</em>,
float4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>, <em>coord.z</em>) to do an element
lookup in the 3D image object specified by <em>image</em>.
<em>coord.w</em> is ignored.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively.
Each channel will be stored in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p>
<p class="tableblock"> The <strong>read_image{i|ui}</strong> calls support a nearest filter only.
The filter_mode specified in <em>sampler</em> must be set to
<code>CLK_FILTER_NEAREST</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Furthermore, the <strong>read_image{i|ui}</strong> calls that take integer
coordinates must use a sampler with normalized coordinates set to
<code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode set to
<code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(read_only image2d_array_t <em>image</em>,
sampler_t <em>sampler</em>, int4 <em>coord</em>)<br>
float4 <strong>read_imagef</strong>(read_only image2d_array_t <em>image</em>,
sampler_t <em>sampler</em>, float4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> to do an element lookup in the 2D image identified by
<em>coord.z</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imagef</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description above
are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(read_only image2d_array_t <em>image</em>, sampler_t
<em>sampler</em>, int4 <em>coord</em>)<br>
half4 <strong>read_imageh</strong>(read_only image2d_array_t <em>image</em>, sampler_t
<em>sampler</em>, float4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> to do an element lookup in the 2D image identified by
<em>coord.z</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imageh</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description above
are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(read_only image2d_array_t <em>image</em>, sampler_t <em>sampler</em>,
int4 <em>coord</em>)<br>
int4 <strong>read_imagei</strong>(read_only image2d_array_t <em>image</em>, sampler_t <em>sampler</em>,
float4 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image2d_array_t <em>image</em>,
sampler_t <em>sampler</em>, int4 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image2d_array_t <em>image</em>,
sampler_t <em>sampler</em>, float4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> to do an element lookup in the 2D image identified by
<em>coord.z</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively.
Each channel will be stored in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p>
<p class="tableblock"> The <strong>read_image{i|ui}</strong> calls support a nearest filter only.
The filter_mode specified in <em>sampler</em> must be set to
<code>CLK_FILTER_NEAREST</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Furthermore, the <strong>read_image{i|ui}</strong> calls that take integer
coordinates must use a sampler with normalized coordinates set to
<code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode set to
<code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(read_only image1d_t <em>image</em>, sampler_t <em>sampler</em>,
int <em>coord</em>)<br>
float4 <strong>read_imagef</strong>(read_only image1d_t <em>image</em>, sampler_t <em>sampler</em>,
float <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord</em> to do an element lookup in the 1D image object specified
by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imagef</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(read_only image1d_t <em>image</em>, sampler_t <em>sampler</em>,
int <em>coord</em>)<br>
half4 <strong>read_imageh</strong>(read_only image1d_t <em>image</em>, sampler_t <em>sampler</em>,
float <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord</em> to do an element lookup in the 1D image object specified
by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imageh</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(read_only image1d_t <em>image</em>, sampler_t <em>sampler</em>,
int <em>coord</em>)<br>
int4 <strong>read_imagei</strong>(read_only image1d_t <em>image</em>, sampler_t <em>sampler</em>,
float <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image1d_t <em>image</em>, sampler_t <em>sampler</em>,
int <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image1d_t <em>image</em>, sampler_t <em>sampler</em>,
float <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord</em> to do an element lookup in the 1D image object specified
by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively.
Each channel will be stored in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p>
<p class="tableblock"> The <strong>read_image{i|ui}</strong> calls support a nearest filter only.
The filter_mode specified in <em>sampler</em> must be set to
<code>CLK_FILTER_NEAREST</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Furthermore, the <strong>read_image{i|ui}</strong> calls that take integer
coordinates must use a sampler with normalized coordinates set to
<code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode set to
<code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(read_only image1d_array_t <em>image</em>,
sampler_t <em>sampler</em>, int2 <em>coord</em>)<br>
float4 <strong>read_imagef</strong>(read_only image1d_array_t <em>image</em>,
sampler_t <em>sampler</em>, float2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.x</em> to do an element lookup in the 1D image identified by
<em>coord.y</em> in the 1D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imagef</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description above
are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(read_only image1d_array_t <em>image</em>,
sampler_t <em>sampler</em>, int2 <em>coord</em>)<br>
half4 <strong>read_imageh</strong>(read_only image1d_array_t <em>image</em>,
sampler_t <em>sampler</em>, float2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.x</em> to do an element lookup in the 1D image identified by
<em>coord.y</em> in the 1D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imageh</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description above
are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(read_only image1d_array_t <em>image</em>, sampler_t <em>sampler</em>,
int2 <em>coord</em>)<br>
int4 <strong>read_imagei</strong>(read_only image1d_array_t <em>image</em>, sampler_t <em>sampler</em>,
float2 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image1d_array_t <em>image</em>,
sampler_t <em>sampler</em>, int2 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(read_only image1d_array_t <em>image</em>,
sampler_t <em>sampler</em>, float2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.x</em> to do an element lookup in the 1D image identified by
<em>coord.y</em> in the 1D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively. Each channel will be stored
in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p>
<p class="tableblock"> The <strong>read_image{i|ui}</strong> calls support a nearest filter only.
The filter_mode specified in <em>sampler</em> must be set to
<code>CLK_FILTER_NEAREST</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Furthermore, the <strong>read_image{i|ui}</strong> calls that take integer
coordinates must use a sampler with normalized coordinates set to
<code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode set to
<code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>read_imagef</strong>(read_only image2d_depth_t <em>image</em>,
sampler_t <em>sampler</em>, int2 <em>coord</em>)<br>
float <strong>read_imagef</strong>(read_only image2d_depth_t <em>image</em>,
sampler_t <em>sampler</em>, float2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>) to do an element lookup in
the 2D depth image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value in the range [0.0, 1.0]
for depth image objects created with <em>image_channel_data_type</em> set to
<code>CL_UNORM_<wbr>INT16</code> or <code>CL_UNORM_<wbr>INT24</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value for depth image objects
created with <em>image_channel_data_type</em> set to <code>CL_FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imagef</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for depth image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>read_imagef</strong>(read_only image2d_array_depth_t <em>image</em>,
sampler_t <em>sampler</em>, int4 <em>coord</em>)<br>
float <strong>read_imagef</strong>(read_only image2d_array_depth_t <em>image</em>,
sampler_t <em>sampler</em>, float4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> to do an element lookup in the 2D image identified by
<em>coord.z</em> in the 2D depth image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value in the range [0.0, 1.0]
for depth image objects created with <em>image_channel_data_type</em> set to
<code>CL_UNORM_<wbr>INT16</code> or <code>CL_UNORM_<wbr>INT24</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value for depth image objects
created with <em>image_channel_data_type</em> set to <code>CL_FLOAT</code>.</p>
<p class="tableblock"> The <strong>read_imagef</strong> calls that take integer coordinates must use a
sampler with filter mode set to <code>CLK_FILTER_NEAREST</code>, normalized
coordinates set to <code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode
set to <code>CLK_ADDRESS_CLAMP_TO_EDGE</code>, <code>CLK_ADDRESS_CLAMP</code> or
<code>CLK_ADDRESS_NONE</code>; otherwise the values returned are undefined.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">float</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_depth_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>coord.xy</em> to do an element lookup in the mip level
specified by <em>lod</em> in the 2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">float</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_depth_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_y</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the gradients to compute the lod and coordinate <em>coord.xy</em> to do
an element lookup in the mip level specified by the computed lod in
the 2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>coord</em> to do an element lookup in the mip level
specified by <em>lod</em> in the 1D image object specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_y</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the gradients to compute the lod and coordinate <em>coord</em> to do an
element lookup in the mip level specified by the computed lod in the
1D image object specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>coord.xyz</em> to do an element lookup in the mip
level specified by <em>lod</em> in the 3D image object specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">gradient_y</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the gradients to compute the lod and coordinate <em>coord.xyz</em> to do
an element lookup in the mip level specified by the computed lod in
the 3D image object specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>coord.x</em> to do an element lookup in the 1D image
identified by <em>coord.x</em> and mip level specified by <em>lod</em> in the 1D
image array specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">gradient_y</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the gradients to compute the lod and coordinate <em>coord.x</em> to do an
element lookup in the mip level specified by the computed lod in the
1D image array specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span>
<span class="kt">float</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_array_depth_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">lod</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>coord.xy</em> to do an element lookup in the 2D image
identified by <em>coord.z</em> and mip level specified by <em>lod</em> in the 2D
image array specified by <em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_y</span><span class="p">)</span>
<span class="kt">float</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="nx">read_only</span> <span class="kt">image2d_array_depth_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">sampler_t</span> <span class="n">sampler</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_x</span><span class="p">,</span>
<span class="kt">float2</span> <span class="n">gradient_y</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the gradients to compute the lod coordinate and <em>coord.xy</em> to do
an element lookup in the 2D image identified by <em>coord.z</em> and mip
level specified by the computed lod in the 2D image array specified by
<em>image</em>.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>mipmap_<wbr>image</code>
extension macro.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If the <code>cl_khr_<wbr>mipmap_<wbr>image</code> extension macro is supported,
<code>CL_SAMPLER_<wbr>NORMALIZED_<wbr>COORDS</code> must be <code>CL_TRUE</code> for built-in functions
described in the table above that read from a mipmapped image; otherwise
behavior is undefined.
The value specified in the <em>lod</em> argument is clamped to the minimum of
(actual number of mip levels - 1) in the image or the value specified for
<code>CL_SAMPLER_<wbr>LOD_<wbr>MAX</code>.
</td>
</tr>
</table>
</div>
</div>
<div class="sect4">
<h5 id="built-in-image-sampler-less-read-functions"><a class="anchor" href="#built-in-image-sampler-less-read-functions"></a>6.15.15.3. Built-in Image Sampler-less Read Functions</h5>
<div class="openblock">
<div class="content">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Sampler-less image read functions <a href="#unified-spec">require</a> support for
OpenCL C 1.2 or newer, with some functions requiring support for newer
versions of OpenCL C as noted in the <a href="#table-image-samplerless-read">table
below</a>.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The sampler-less image read functions behave exactly as the corresponding
<a href="#built-in-image-read-functions">built-in image read functions</a> that take
integer coordinates and a sampler with filter mode set to
<code>CLK_FILTER_NEAREST</code>, normalized coordinates set to
<code>CLK_NORMALIZED_COORDS_FALSE</code> and addressing mode to <code>CLK_ADDRESS_NONE</code>.
There is one exception when the <em>image_channel_data_type</em> is a floating-point
type (such as <code>CL_FLOAT</code>).
In this exceptional case, when channel data values are denormalized, the
sampler-less image read function may return the denormalized data, while
the image read function with a sampler argument may flush the denormalized
channel data values to zero.</p>
</div>
<div class="paragraph">
<p><em>aQual</em> in the following table refers to one of the access qualifiers.
For sampler-less read functions this may be <code>read_only</code> or <code>read_write</code>.</p>
</div>
<table id="table-image-samplerless-read" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 34. Built-in Image Sampler-less Read Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(<em>aQual</em> image2d_t <em>image</em>, int2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>) to do an element lookup in
the 2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(<em>aQual</em> image2d_t <em>image</em>, int2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>(coord.x, coord.y)</em> to do an element lookup in the
2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(<em>aQual</em> image2d_t <em>image</em>, int2 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(<em>aQual</em> image2d_t <em>image</em>, int2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>) to do an element lookup in
the 2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively. Each channel will be stored
in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(<em>aQual</em> image3d_t <em>image</em>, int4 <em>coord</em> )</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>, <em>coord.z</em>) to do an element
lookup in the 3D image object specified by <em>image</em>.
<em>coord.w</em> is ignored.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description are
undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(<em>aQual</em> image3d_t <em>image</em>, int4 <em>coord</em> )</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>(coord.x</em>, <em>coord.y</em>, <em>coord.z)</em> to do an element
lookup in the 3D image object specified by <em>image</em>. <em>coord.w</em> is
ignored.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description are
undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(<em>aQual</em> image3d_t <em>image</em>, int4 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(<em>aQual</em> image3d_t <em>image</em>, int4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>, <em>coord.z</em>) to do an element
lookup in the 3D image object specified by <em>image</em>.
<em>coord.w</em> is ignored.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively.
Each channel will be stored in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(<em>aQual</em> image2d_array_t <em>image</em>, int4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> to do an element lookup in the 2D image identified by
<em>coord.z</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(<em>aQual</em> image2d_array_t <em>image</em>, int4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> to do an element lookup in the 2D image identified by
<em>coord.z</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(<em>aQual</em> image2d_array_t <em>image</em>, int4 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(<em>aQual</em> image2d_array_t <em>image</em>, int4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> to do an element lookup in the 2D image identified by
<em>coord.z</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively. Each channel will be stored
in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(<em>aQual</em> image1d_t <em>image</em>, int <em>coord</em>)<br>
float4 <strong>read_imagef</strong>(<em>aQual</em> image1d_buffer_t <em>image</em>, int <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord</em> to do an element lookup in the 1D image or 1D image buffer
object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(<em>aQual</em> image1d_t <em>image</em>, int <em>coord</em>)<br>
half4 <strong>read_imageh</strong>(<em>aQual</em> image1d_buffer_t <em>image</em>, int <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord</em> to do an element lookup in the 1D image or 1D image buffer
object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(<em>aQual</em> image1d_t <em>image</em>, int <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(<em>aQual</em> image1d_t <em>image</em>, int <em>coord</em>)<br>
int4 <strong>read_imagei</strong>(<em>aQual</em> image1d_buffer_t <em>image</em>, int <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(<em>aQual</em> image1d_buffer_t <em>image</em>, int <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord</em> to do an element lookup in the 1D image or 1D image buffer
object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively. Each channel will be stored
in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float4 <strong>read_imagef</strong>(<em>aQual</em> image1d_array_t <em>image</em>, int2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.x</em> to do an element lookup in the 1D image identified by
<em>coord.y</em> in the 1D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">half4 <strong>read_imageh</strong>(<em>aQual</em> image1d_array_t <em>image</em>, int2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.x</em> to do an element lookup in the 2D image identified by
<em>coord.y</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [0.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or <code>CL_UNORM_<wbr>INT8</code>, or <code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values in the
range [-1.0, 1.0] for image objects created with
<em>image_channel_data_type</em> set to <code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imageh</strong> returns half-precision floating-point values for image
objects created with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imageh</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the <code>cl_khr_<wbr>fp16</code> extension
macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>read_imagei</strong>(<em>aQual</em> image1d_array_t <em>image</em>, int2 <em>coord</em>)<br>
uint4 <strong>read_imageui</strong>(<em>aQual</em> image1d_array_t <em>image</em>, int2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.x</em> to do an element lookup in the 1D image identified by
<em>coord.y</em> in the 1D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively. Each channel will be stored
in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>read_imagef</strong>(<em>aQual</em> image2d_depth_t <em>image</em>, int2 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate (<em>coord.x</em>, <em>coord.y</em>) to do an element lookup in
the 2D depth image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value in the range [0.0, 1.0]
for depth image objects created with <em>image_channel_data_type</em> set to
<code>CL_UNORM_<wbr>INT16</code> or <code>CL_UNORM_<wbr>INT24</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value for depth image objects
created with <em>image_channel_data_type</em> set to <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">float <strong>read_imagef</strong>(<em>aQual</em> image2d_array_depth_t <em>image</em>, int4 <em>coord</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> to do an element lookup in the 2D image identified by
<em>coord.z</em> in the 2D depth image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value in the range [0.0, 1.0]
for depth image objects created with <em>image_channel_data_type</em> set to
<code>CL_UNORM_<wbr>INT16</code> or <code>CL_UNORM_<wbr>INT24</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value for depth image objects
created with <em>image_channel_data_type</em> set to <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="kt">image2d_msaa_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">sample</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>(coord.x, coord.y)</em> and <em>sample</em> to do an element
lookup in the 2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="kt">image2d_msaa_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">sample</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="kt">image2d_msaa_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">sample</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>(coord.x, coord.y)</em> and <em>sample</em> to do an element
lookup in the 2D image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively.
Each channel will be stored in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float4</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="kt">image2d_array_msaa_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">sample</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> and <em>sample</em> to do an element lookup in the 2D image
identified by <em>coord.z</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [0.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to one of
the pre-defined packed formats or <code>CL_UNORM_<wbr>INT8</code>, or
<code>CL_UNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values in the range [-1.0, 1.0]
for image objects created with <em>image_channel_data_type</em> set to
<code>CL_SNORM_<wbr>INT8</code>, or <code>CL_SNORM_<wbr>INT16</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns floating-point values for image objects created
with <em>image_channel_data_type</em> set to <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int4</span> <span class="fm">read_imagei</span><span class="p">(</span>
<span class="kt">image2d_array_msaa_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">sample</span><span class="p">)</span>
<span class="kt">uint4</span> <span class="fm">read_imageui</span><span class="p">(</span>
<span class="kt">image2d_array_msaa_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">sample</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> and <em>sample</em> to do an element lookup in the 2D image
identified by <em>coord.z</em> in the 2D image array specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagei</strong> and <strong>read_imageui</strong> return unnormalized signed integer
and unsigned integer values respectively.
Each channel will be stored in a 32-bit integer.</p>
<p class="tableblock"> <strong>read_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imagei</strong> are undefined.</p>
<p class="tableblock"> <strong>read_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> If the <em>image_channel_data_type</em> is not one of the above values, the
values returned by <strong>read_imageui</strong> are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="kt">image2d_msaa_depth_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">sample</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use the coordinate <em>(coord.x, coord.y)</em> and <em>sample</em> to do an element
lookup in the 2D depth image object specified by <em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value in the range [0.0, 1.0]
for depth image objects created with <em>image_channel_data_type</em> set to
<code>CL_UNORM_<wbr>INT16</code> or <code>CL_UNORM_<wbr>INT24</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value for depth image objects
created with <em>image_channel_data_type</em> set to <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">float</span> <span class="fm">read_imagef</span><span class="p">(</span>
<span class="kt">image2d_array_msaa_depth_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">sample</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use <em>coord.xy</em> and <em>sample</em> to do an element lookup in the 2D image
identified by <em>coord.z</em> in the 2D depth image array specified by
<em>image</em>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value in the range [0.0, 1.0]
for depth image objects created with <em>image_channel_data_type</em> set to
<code>CL_UNORM_<wbr>INT16</code> or <code>CL_UNORM_<wbr>INT24</code>.</p>
<p class="tableblock"> <strong>read_imagef</strong> returns a floating-point value for depth image objects
created with <em>image_channel_data_type</em> set to <code>CL_FLOAT</code>.</p>
<p class="tableblock"> Values returned by <strong>read_imagef</strong> for image objects with
<em>image_channel_data_type</em> values not specified in the description
above are undefined.</p>
<p class="tableblock"> Note: When a multisample image is accessed in a kernel, the access
takes one vector of integers describing which pixel to fetch and an
integer corresponding to the sample numbers describing which sample
within the pixel to fetch.
<em>sample</em> identifies the sample position in the multi-sample image.</p>
<p class="tableblock"> <strong>For best performance, we recommend that <em>sample</em> be a literal value
so it is known at compile time and the OpenCL compiler can perform
appropriate optimizations for multi-sample reads on the device</strong>.</p>
<p class="tableblock"> No standard sampling instructions are allowed on the multisample
image. Accessing a coordinate outside the image and/or a sample that
is outside the number of samples associated with each pixel in the
image is undefined</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect4">
<h5 id="built-in-image-write-functions"><a class="anchor" href="#built-in-image-write-functions"></a>6.15.15.4. Built-in Image Write Functions</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following built-in function calls to write images are supported.</p>
</div>
<div class="paragraph">
<p><em>aQual</em> in the following table refers to one of the access qualifiers.
For write functions this may be <code>write_only</code> or <code>read_write</code>.</p>
</div>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>mipmap_<wbr>image_<wbr>writes</code> extension macro is supported, write
functions which do not explicitly specify a level of detail <em>lod</em> write to
mip level 0 if <em>image</em> is a mipmapped image.
<em>mipwidth</em>, <em>mipheight</em>, and <em>mipdepth</em> in the table refer to the width,
height, and depth of the <em>image</em> mip level specified by <em>lod</em> respectively;
<em>miplayers</em> refers to the number of layers in <em>image</em>; and <em>miplevels</em>
refers to the number of mip levels in <em>image</em>.</p>
</div>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>srgb_<wbr>image_<wbr>writes</code> extension macro is supported, the
<strong>write_imagef</strong> functions described below may write to sRGB images.
Linear to sRGB conversion is performed by the function.
Only the R, G, and B components are converted from linear to sRGB; the A
component is written as-is.</p>
</div>
<table id="table-image-write" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 35. Built-in Image Write Functions</caption>
<colgroup>
<col style="width: 42.8571%;">
<col style="width: 57.1429%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>write_imagef</strong>(<br>
<em>aQual</em> image2d_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
float4 <em>color</em>)<br>
void <strong>write_imageh</strong>(<br>
<em>aQual</em> image2d_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
half4 <em>color</em>)<br>
void <strong>write_imagei</strong>(<br>
<em>aQual</em> image2d_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
int4 <em>color</em>)<br>
void <strong>write_imageui</strong>(<br>
<em>aQual</em> image2d_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
uint4 <em>color</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord.xy</em> in the 2D
image object specified by <em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the color value.
<em>coord.x</em> and <em>coord.y</em> are considered to be unnormalized coordinates,
and must be in the range [0, image width-1] and [0, image height-1]
respectively.</p>
<p class="tableblock"> <strong>write_imagef</strong>
and <strong>write_imageh</strong>
can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or set to <code>CL_SNORM_<wbr>INT8</code>, <code>CL_UNORM_<wbr>INT8</code>, <code>CL_SNORM_<wbr>INT16</code>,
<code>CL_UNORM_<wbr>INT16</code>, <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.
Appropriate data format conversion will be done to convert channel
data from a floating-point value to actual data format in which the
channels are stored.</p>
<p class="tableblock"> <strong>write_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> <strong>write_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> The behavior of <strong>write_imagef</strong>,
<strong>write_imageh</strong>,
<strong>write_imagei</strong> and <strong>write_imageui</strong> for
image objects created with <em>image_channel_data_type</em> values not
specified in the description above or with <em>x</em> and <em>y</em> coordinate
values that are not in the range [0, image width-1] and [0, image
height-1], respectively, is undefined.</p>
<p class="tableblock"> <strong>write_imageh</strong> <a href="#unified-spec">requires</a> support for the
<code>cl_khr_<wbr>fp16</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>write_imagef</strong>(<br>
<em>aQual</em> image2d_array_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
float4 <em>color</em>)<br>
void <strong>write_imageh</strong>(<br>
<em>aQual</em> image2d_array_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
half4 <em>color</em>)<br>
void <strong>write_imagei</strong>(<br>
<em>aQual</em> image2d_array_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
int4 <em>color</em>)<br>
void <strong>write_imageui</strong>(<br>
<em>aQual</em> image2d_array_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
uint4 <em>color</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord.xy</em> in the 2D
image identified by <em>coord.z</em> in the 2D image array specified by
<em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the color value.
<em>coord.x</em>, <em>coord.y</em> and <em>coord.z</em> are considered to be unnormalized
coordinates, and must be in the range [0, image width-1] and [0, image
height-1], and [0, image number of layers-1], respectively.</p>
<p class="tableblock"> <strong>write_imagef</strong>
and <strong>write_imageh</strong>
can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or set to <code>CL_SNORM_<wbr>INT8</code>, <code>CL_UNORM_<wbr>INT8</code>, <code>CL_SNORM_<wbr>INT16</code>,
<code>CL_UNORM_<wbr>INT16</code>, <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.
Appropriate data format conversion will be done to convert channel
data from a floating-point value to actual data format in which the
channels are stored.</p>
<p class="tableblock"> <strong>write_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> <strong>write_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> The behavior of <strong>write_imagef</strong>,
<strong>write_imageh</strong>,
<strong>write_imagei</strong> and <strong>write_imageui</strong> for
image objects created with <em>image_channel_data_type</em> values not
specified in the description above or with (<em>x</em>, <em>y</em>, <em>z</em>) coordinate
values that are not in the range [0, image width-1], [0, image
height-1], and [0, image number of layers-1], respectively, is
undefined.</p>
<p class="tableblock"> <strong>write_imageh</strong> <a href="#unified-spec">requires</a> support for the
<code>cl_khr_<wbr>fp16</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>write_imagef</strong>(<br>
<em>aQual</em> image1d_t <em>image</em>,<br>
int <em>coord</em>,<br>
float4 <em>color</em>)<br>
void <strong>write_imageh</strong>(<br>
<em>aQual</em> image1d_t <em>image</em>,<br>
int <em>coord</em>,<br>
half4 <em>color</em>)<br>
void <strong>write_imagei</strong>(<br>
<em>aQual</em> image1d_t <em>image</em>,<br>
int <em>coord</em>,<br>
int4 <em>color</em>)<br>
void <strong>write_imageui</strong>(<br>
<em>aQual</em> image1d_t <em>image</em>,<br>
int <em>coord</em>,<br>
uint4 <em>color</em>)<br>
void <strong>write_imagef</strong>(<br>
<em>aQual</em> image1d_buffer_t <em>image</em>,<br>
int <em>coord</em>,<br>
float4 <em>color</em>)<br>
void <strong>write_imageh</strong>(<br>
<em>aQual</em> image1d_buffer_t <em>image</em>,<br>
int <em>coord</em>,<br>
half4 <em>color</em>)<br>
void <strong>write_imagei</strong>(<br>
<em>aQual</em> image1d_buffer_t <em>image</em>,<br>
int <em>coord</em>,<br>
int4 <em>color</em>)<br>
void <strong>write_imageui</strong>(<br>
<em>aQual</em> image1d_buffer_t <em>image</em>,<br>
int <em>coord</em>,<br>
uint4 <em>color</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord</em> in the 1D image
or 1D image buffer object specified by <em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the color value.
<em>coord</em> is considered to be an unnormalized coordinate, and must be in
the range [0, image width-1].</p>
<p class="tableblock"> <strong>write_imagef</strong>
and <strong>write_imageh</strong>
can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or set to <code>CL_SNORM_<wbr>INT8</code>, <code>CL_UNORM_<wbr>INT8</code>, <code>CL_SNORM_<wbr>INT16</code>,
<code>CL_UNORM_<wbr>INT16</code>, <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.
Appropriate data format conversion will be done to convert channel
data from a floating-point value to actual data format in which the
channels are stored.</p>
<p class="tableblock"> <strong>write_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> <strong>write_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> The behavior of <strong>write_imagef</strong>,
<strong>write_imageh</strong>,
<strong>write_imagei</strong> and <strong>write_imageui</strong> for
image objects created with <em>image_channel_data_type</em> values not
specified in the description above, or with a coordinate value that is
not in the range [0, image width-1], is undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p>
<p class="tableblock"> <strong>write_imageh</strong> <a href="#unified-spec">requires</a> support for the
<code>cl_khr_<wbr>fp16</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>write_imagef</strong>(<br>
<em>aQual</em> image1d_array_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
float4 <em>color</em>)<br>
void <strong>write_imageh</strong>(<br>
<em>aQual</em> image1d_array_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
half4 <em>color</em>)<br>
void <strong>write_imagei</strong>(<br>
<em>aQual</em> image1d_array_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
int4 <em>color</em>)<br>
void <strong>write_imageui</strong>(<br>
<em>aQual</em> image1d_array_t <em>image</em>,<br>
int2 <em>coord</em>,
uint4 <em>color</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord.x</em> in the 1D image
identified by <em>coord.y</em> in the 1D image array specified by <em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the color value.
<em>coord.x</em> and <em>coord.y</em> are considered to be unnormalized coordinates
and must be in the range [0, image width-1] and [0, image number of
layers-1], respectively.</p>
<p class="tableblock"> <strong>write_imagef</strong>
and <strong>write_imageh</strong>
can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or set to <code>CL_SNORM_<wbr>INT8</code>, <code>CL_UNORM_<wbr>INT8</code>, <code>CL_SNORM_<wbr>INT16</code>,
<code>CL_UNORM_<wbr>INT16</code>, <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.
Appropriate data format conversion will be done to convert channel
data from a floating-point value to actual data format in which the
channels are stored.</p>
<p class="tableblock"> <strong>write_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> <strong>write_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> The behavior of <strong>write_imagef</strong>,
<strong>write_imageh</strong>,
<strong>write_imagei</strong> and <strong>write_imageui</strong> for
image objects created with <em>image_channel_data_type</em> values not
specified in the description above or with (<em>x</em>, <em>y</em>) coordinate
values that are not in the range [0, image width-1] and [0, image
number of layers-1], respectively, is undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or newer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>write_imagef</strong>(<br>
<em>aQual</em> image2d_depth_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
float <em>depth</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>depth</em> value to location specified by <em>coord.xy</em> in the 2D
depth image object specified by <em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the depth value.
<em>coord.x</em> and <em>coord.y</em> are considered to be unnormalized coordinates,
and must be in the range [0, image width-1], and [0, image height-1],
respectively.</p>
<p class="tableblock"> <strong>write_imagef</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to <code>CL_UNORM_<wbr>INT16</code>, <code>CL_UNORM_<wbr>INT24</code> or
<code>CL_FLOAT</code>.
Appropriate data format conversion will be done to convert depth valye
from a floating-point value to actual data format associated with the
image.</p>
<p class="tableblock"> The behavior of <strong>write_imagef</strong>, <strong>write_imagei</strong> and <strong>write_imageui</strong> for
image objects created with <em>image_channel_data_type</em> values not
specified in the description above or with (<em>x</em>, <em>y</em>) coordinate
values that are not in the range [0, image width-1] and [0, image
height-1], respectively, is undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>write_imagef</strong>(<br>
<em>aQual</em> image2d_array_depth_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
float <em>depth</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>depth</em> value to location specified by <em>coord.xy</em> in the 2D
image identified by <em>coord.z</em> in the 2D depth image array specified by
<em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the depth value.
<em>coord.x</em>, <em>coord.y</em> and <em>coord.z</em> are considered to be unnormalized
coordinates, and must be in the range [0, image width-1], [0, image
height-1], and [0, image number of layers-1], respectively.</p>
<p class="tableblock"> <strong>write_imagef</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to <code>CL_UNORM_<wbr>INT16</code>, <code>CL_UNORM_<wbr>INT24</code> or
<code>CL_FLOAT</code>.
Appropriate data format conversion will be done to convert depth valye
from a floating-point value to actual data format associated with the
image.</p>
<p class="tableblock"> The behavior of <strong>write_imagef</strong>, <strong>write_imagei</strong> and <strong>write_imageui</strong> for
image objects created with <em>image_channel_data_type</em> values not
specified in the description above or with (<em>x</em>, <em>y</em>, <em>z</em>) coordinate
values that are not in the range [0, image width-1], [0, image
height-1], [0, image number of layers-1], respectively, is undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>write_imagef</strong>(<br>
<em>aQual</em> image3d_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
float4 <em>color</em>)<br>
void <strong>write_imageh</strong>(<br>
<em>aQual</em> image3d_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
half4 <em>color</em>)<br>
void <strong>write_imagei</strong>(<br>
<em>aQual</em> image3d_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
int4 <em>color</em>)<br>
void <strong>write_imageui</strong>(<br>
<em>aQual</em> image3d_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
uint4 <em>color</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to the location specified by <em>coord.xyz</em> in the 3D
image object specified by <em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the color value.
<em>coord.x</em>, <em>coord.y</em> and <em>coord.z</em> are considered to be unnormalized
coordinates, and must be in the range [0, image width-1], [0, image
height-1], and [0, image depth-1], respectively.</p>
<p class="tableblock"> <strong>write_imagef</strong>
and <strong>write_imageh</strong>
can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the pre-defined packed formats
or set to <code>CL_SNORM_<wbr>INT8</code>, <code>CL_UNORM_<wbr>INT8</code>, <code>CL_SNORM_<wbr>INT16</code>,
<code>CL_UNORM_<wbr>INT16</code>, <code>CL_HALF_<wbr>FLOAT</code> or <code>CL_FLOAT</code>.
Appropriate data format conversion will be done to convert channel
data from a floating-point value to actual data format in which the
channels are stored.</p>
<p class="tableblock"> <strong>write_imagei</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_SIGNED_<wbr>INT8</code>,<br>
<code>CL_SIGNED_<wbr>INT16</code> and<br>
<code>CL_SIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> <strong>write_imageui</strong> can only be used with image objects created with
<em>image_channel_data_type</em> set to one of the following values:</p>
<p class="tableblock"> <code>CL_UNSIGNED_<wbr>INT8</code>,<br>
<code>CL_UNSIGNED_<wbr>INT16</code> and<br>
<code>CL_UNSIGNED_<wbr>INT32</code>.</p>
<p class="tableblock"> The behavior of <strong>write_imagef</strong>,
<strong>write_imageh</strong>,
<strong>write_imagei</strong> and <strong>write_imageui</strong> for
image objects with <em>image_channel_data_type</em> values not specified in
the description above or with (<em>x</em>, <em>y</em>, <em>z</em>) coordinate values that
are not in the range [0, image width-1], [0, image height-1], and [0,
image depth-1], respectively, is undefined.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for OpenCL C 2.0, or OpenCL C 3.0 or
newer and the <code>__opencl_c_<wbr>3d_<wbr>image_<wbr>writes</code> feature, or the
<code>cl_khr_<wbr>3d_<wbr>image_<wbr>writes</code> extension.</p>
<p class="tableblock"> <strong>write_imageh</strong> <a href="#unified-spec">requires</a> support for the
<code>cl_khr_<wbr>fp16</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="fm">write_imagef</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imagei</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imageui</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image2d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">uint4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imagef</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image2d_depth_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">depth</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord.xy</em> in the mip
level specified by <em>lod</em> in the 2D image object specified by <em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the color value.</p>
<p class="tableblock"> <em>lod</em> must be in the range [0, <em>miplevels</em>-1].
<em>coord.x</em> and <em>coord.y</em> are considered to be unnormalized coordinates
and must be in the range [0, <em>mipwidth</em>-1] and [0, <em>mipheight</em>-1]
respectively.
Behavior is undefined if <em>lod</em>, <em>coord.x</em>, or <em>coord.y</em> is not in
range.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>mipmap_<wbr>image_<wbr>writes</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="fm">write_imagef</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imagei</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imageui</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image1d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">uint4</span> <span class="n">color</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord</em> in the mip level
specified by <em>lod</em> in the 1D image object specified by <em>image</em>.
Appropriate data format conversion to the specified image format is
done before writing the color value.</p>
<p class="tableblock"> <em>lod</em> must be in the range [0, <em>miplevels</em>-1].
<em>coord</em> is considered to be an unnormalized coordinate and must be in
the range [0, <em>mipwidth</em>-1].
Behavior is undefined if <em>lod</em> or <em>coord</em> is not in range.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>mipmap_<wbr>image_<wbr>writes</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="fm">write_imagef</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imagei</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imageui</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image1d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">uint4</span> <span class="n">color</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord.x</em> in the 1D image
identified by <em>coord.y</em> and mip level <em>lod</em> in the 1D image array
specified by <em>image</em>.
Appropriate data format conversion to the specified image format is done
before writing the color value.</p>
<p class="tableblock"> <em>lod</em> must be in the range [0, <em>miplevels</em>-1].
<em>coord.x</em> and <em>coord.y</em> are considered to be unnormalized coordinates
and must be in the range [0, <em>mipwidth</em>-1] and [0, <em>miplayers</em> -1]
respectively.
Behavior is undefined if <em>lod</em>, <em>coord.x</em>, or <em>coord.y</em> is not in range.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>mipmap_<wbr>image_<wbr>writes</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="fm">write_imagef</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imagei</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imageui</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image2d_array_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">uint4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imagef</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image2d_array_depth_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">float</span> <span class="n">depth</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord.xy</em> in the 2D image
identified by <em>coord.z</em> and mip level <em>lod</em> in the 2D image array
specified by <em>image</em>.
Appropriate data format conversion to the specified image format is done
before writing the color value.</p>
<p class="tableblock"> <em>lod</em> must be in the range [0, <em>miplevels</em>-1].
<em>coord.x</em>, <em>coord.y</em> and <em>coord.z</em> are considered to be unnormalized
coordinates and must be in the range [0, <em>mipwidth</em>-1], [0,
<em>mipheight</em>-1], and [0, <em>miplayers</em>-1] respectively.
Behavior is undefined if
<em>lod</em>, <em>coord.x</em>, <em>coord.y</em>, or <em>coord.z</em> is not in range.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>mipmap_<wbr>image_<wbr>writes</code> extension macro.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="fm">write_imagef</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">float4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imagei</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">color</span><span class="p">)</span>
<span class="kt">void</span> <span class="fm">write_imageui</span><span class="p">(</span>
<span class="nx">write_only</span> <span class="kt">image3d_t</span> <span class="n">image</span><span class="p">,</span>
<span class="kt">int4</span> <span class="n">coord</span><span class="p">,</span>
<span class="kt">int</span> <span class="n">lod</span><span class="p">,</span>
<span class="kt">uint4</span> <span class="n">color</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write <em>color</em> value to location specified by <em>coord.xyz</em> and mip level
<em>lod</em> in the 3D image object specified by <em>image</em>.
Appropriate data format conversion to the specified image format is done
before writing the color value.</p>
<p class="tableblock"> <em>lod</em> must be in the range [0, <em>miplevels</em>-1].
<em>coord.x</em>, <em>coord.y</em> and <em>coord.z</em> are considered to be unnormalized
coordinates and must be in the range [0, <em>mipwidth</em>-1], [0,
<em>mipheight</em>-1] and [0, <em>mipdepth</em>-1] respectively.
Behavior is undefined if <em>lod</em>, <em>coord.x</em>, <em>coord.y</em>, or <em>coord.z</em> is
not in range.</p>
<p class="tableblock"> <a href="#unified-spec">Requires</a> support for the
<code>cl_khr_<wbr>mipmap_<wbr>image_<wbr>writes</code> extension macro.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect4">
<h5 id="built-in-image-query-functions"><a class="anchor" href="#built-in-image-query-functions"></a>6.15.15.5. Built-in Image Query Functions</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following built-in function calls to query image information are
supported.</p>
</div>
<div class="paragraph">
<p><em>aQual</em> in the following table refers to one of the access qualifiers.
For query functions this may be <code>read_only</code>, <code>write_only</code> or <code>read_write</code>.</p>
</div>
<table id="table-image-query" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 36. Built-in Image Query Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>get_image_width</strong>(<em>aQual</em> image2d_t <em>image</em>)<br>
int <strong>get_image_width</strong>(<em>aQual</em> image3d_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 1.2 or newer:</p>
<p class="tableblock"> int <strong>get_image_width</strong>(<em>aQual</em> image1d_t <em>image</em>)<br>
int <strong>get_image_width</strong>(<em>aQual</em> image1d_buffer_t <em>image</em>)<br>
int <strong>get_image_width</strong>(<em>aQual</em> image1d_array_t <em>image</em>)<br>
int <strong>get_image_width</strong>(<em>aQual</em> image2d_array_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 2.0 or newer, or if the <code>cl_khr_<wbr>depth_<wbr>images</code> extension
macro is supported:</p>
<p class="tableblock"> int <strong>get_image_width</strong>(<em>aQual</em> image2d_depth_t <em>image</em>)<br>
int <strong>get_image_width</strong>(<em>aQual</em> image2d_array_depth_t <em>image</em>)</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro is supported:</p>
<p class="tableblock"> int <strong>get_image_width</strong>(<em>aQual</em> image2d_msaa_t image)<br>
int <strong>get_image_width</strong>(<em>aQual</em> image2d_array_msaa_t image)<br>
int <strong>get_image_width</strong>(<em>aQual</em> image2d_msaa_depth_t image)<br>
int <strong>get_image_width</strong>(<em>aQual</em> image2d_array_msaa_depth_t image)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the image width in pixels.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>get_image_height</strong>(<em>aQual</em> image2d_t <em>image</em>)<br>
int <strong>get_image_height</strong>(<em>aQual</em> image3d_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 1.2 or newer:</p>
<p class="tableblock"> int <strong>get_image_height</strong>(<em>aQual</em> image2d_array_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 2.0 or newer, or if the <code>cl_khr_<wbr>depth_<wbr>images</code> extension
macro is supported:</p>
<p class="tableblock"> int <strong>get_image_height</strong>(<em>aQual</em> image2d_depth_t <em>image</em>)<br>
int <strong>get_image_height</strong>(<em>aQual</em> image2d_array_depth_t <em>image</em>)</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro is supported:</p>
<p class="tableblock"> int <strong>get_image_height</strong>(<em>aQual</em> image2d_msaa_t image)<br>
int <strong>get_image_height</strong>(<em>aQual</em> image2d_array_msaa_t image)<br>
int <strong>get_image_height</strong>(<em>aQual</em> image2d_msaa_depth_t image)<br>
int <strong>get_image_height</strong>(<em>aQual</em> image2d_array_msaa_depth_t image)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the image height in pixels.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>get_image_depth</strong>(image3d_t <em>image</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the image depth in pixels.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_t <em>image</em>)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image3d_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 1.2 or newer:</p>
<p class="tableblock"> int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image1d_t <em>image</em>)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image1d_buffer_t <em>image</em>)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_t <em>image</em>)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image3d_t <em>image</em>)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image1d_array_t <em>image</em>)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_array_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 2.0 or newer, or if the <code>cl_khr_<wbr>depth_<wbr>images</code> extension
macro is supported:</p>
<p class="tableblock"> int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_depth_t <em>image</em>)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_array_depth_t <em>image</em>)</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro is supported:</p>
<p class="tableblock"> int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_msaa_t image)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_array_msaa_t image)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_msaa_depth_t image)<br>
int <strong>get_image_channel_data_type</strong>(<em>aQual</em> image2d_array_msaa_depth_t image)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the channel data type. Valid values are:</p>
<p class="tableblock"> <code>CLK_SNORM_INT8</code><br>
<code>CLK_SNORM_INT16</code><br>
<code>CLK_UNORM_INT8</code><br>
<code>CLK_UNORM_INT16</code><br>
<code>CLK_UNORM_SHORT_565</code><br>
<code>CLK_UNORM_SHORT_555</code><br>
<code>CLK_UNORM_INT_101010</code><br>
<code>CLK_SIGNED_INT8</code><br>
<code>CLK_SIGNED_INT16</code><br>
<code>CLK_SIGNED_INT32</code><br>
<code>CLK_UNSIGNED_INT8</code><br>
<code>CLK_UNSIGNED_INT16</code><br>
<code>CLK_UNSIGNED_INT32</code><br>
<code>CLK_HALF_FLOAT</code><br>
<code>CLK_FLOAT</code><br></p>
<p class="tableblock"> Additionally, for OpenCL C 3.0 or newer:</p>
<p class="tableblock"> <code>CLK_UNORM_INT_101010_2</code> <sup class="footnote">[<a id="_footnoteref_84" class="footnote" href="#_footnotedef_84" title="View footnote.">84</a>]</sup></p>
<p class="tableblock"> Additionally, if the <code>__opencl_c_<wbr>ext_<wbr>image_<wbr>unorm_<wbr>int_<wbr>2_<wbr>101010</code> feature is
supported:</p>
<p class="tableblock"> <code>CLK_UNORM_INT_2_101010_EXT</code></p>
<p class="tableblock"> Additionally, if the <code>__opencl_c_<wbr>ext_<wbr>image_<wbr>unsigned_<wbr>10x6_<wbr>12x4_<wbr>14x2</code> feature
macro is supported:</p>
<p class="tableblock"> <code>CLK_UNSIGNED_INT10X6_EXT</code><br>
<code>CLK_UNSIGNED_INT12X4_EXT</code><br>
<code>CLK_UNSIGNED_INT14X2_EXT</code><br>
<code>CLK_UNORM_INT10X6_EXT</code><br>
<code>CLK_UNORM_INT12X4_EXT</code><br>
<code>CLK_UNORM_INT14X2_EXT</code><br></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>get_image_channel_order</strong>(<em>aQual</em> image2d_t <em>image</em>)<br>
int <strong>get_image_channel_order</strong>(<em>aQual</em> image3d_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 1.2 or newer:</p>
<p class="tableblock"> int <strong>get_image_channel_order</strong>(<em>aQual</em> image1d_t <em>image</em>)<br>
int <strong>get_image_channel_order</strong>(<em>aQual</em> image1d_buffer_t <em>image</em>)<br>
int <strong>get_image_channel_order</strong>(<em>aQual</em> image1d_array_t <em>image</em>)<br>
int <strong>get_image_channel_order</strong>(<em>aQual</em> image2d_array_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 2.0 or newer, or if the <code>cl_khr_<wbr>depth_<wbr>images</code> extension
macro is supported:</p>
<p class="tableblock"> int <strong>get_image_channel_order</strong>(<em>aQual</em> image2d_depth_t <em>image</em>)<br>
int <strong>get_image_channel_order</strong>(<em>aQual</em> image2d_array_depth_t <em>image</em>)</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro is supported:</p>
<p class="tableblock"> int <strong>get_image_channel_order</strong>(<em>aQual</em> image2d_msaa_t image)<br>
int <strong>get_image_channel_order</strong>(<em>aQual</em> image2d_array_msaa_t image)<br>
int <strong>get_image_channel_order</strong>(<em>aQual</em> image2d_msaa_depth_t image)<br>
int <strong>get_image_channel_order</strong>(<em>aQual</em> image2d_array_msaa_depth_t image)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the image channel order. Valid values are:</p>
<p class="tableblock"> <code>CLK_A</code><br>
<code>CLK_R</code><br>
<code>CLK_RG</code><br>
<code>CLK_RA</code><br>
<code>CLK_RGB</code><br>
<code>CLK_RGBA</code><br>
<code>CLK_ARGB</code><br>
<code>CLK_BGRA</code><br>
<code>CLK_INTENSITY</code><br>
<code>CLK_LUMINANCE</code></p>
<p class="tableblock"> Additionally, for OpenCL C 1.1 or newer:</p>
<p class="tableblock"> <code>CLK_Rx</code><br>
<code>CLK_RGx</code><br>
<code>CLK_RGBx</code></p>
<p class="tableblock"> Additionally, for OpenCL C 2.0 or newer:</p>
<p class="tableblock"> <code>CLK_ABGR</code><br>
<code>CLK_DEPTH</code><br>
<code>CLK_sRGB</code><br>
<code>CLK_sRGBx</code><br>
<code>CLK_sRGBA</code><br>
<code>CLK_sBGRA</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int2 <strong>get_image_dim</strong>(<em>aQual</em> image2d_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 1.2 or newer:</p>
<p class="tableblock"> int2 <strong>get_image_dim</strong>(<em>aQual</em> image2d_array_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 2.0 or newer, or if the <code>cl_khr_<wbr>depth_<wbr>images</code> extension
macro is supported:</p>
<p class="tableblock"> int2 <strong>get_image_dim</strong>(<em>aQual</em> image2d_depth_t <em>image</em>)<br>
int2 <strong>get_image_dim</strong>(<em>aQual</em> image2d_array_depth_t <em>image</em>)</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro is supported:</p>
<p class="tableblock"> int2 <strong>get_image_dim</strong>(<em>aQual</em> image2d_msaa_t image)<br>
int2 <strong>get_image_dim</strong>(<em>aQual</em> image2d_array_msaa_t image)<br>
int2 <strong>get_image_dim</strong>(<em>aQual</em> image2d_msaa_depth_t image)<br>
int2 <strong>get_image_dim</strong>(<em>aQual</em> image2d_array_msaa_depth_t image)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the 2D image width and height as an <code>int2</code> type.
The width is returned in the <em>x</em> component, and the height in the <em>y</em>
component.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int4 <strong>get_image_dim</strong>(<em>aQual</em> image3d_t <em>image</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the 3D image width, height, and depth as an <code>int4</code> type.
The width is returned in the <em>x</em> component, height in the <em>y</em>
component, depth in the <em>z</em> component and the <em>w</em> component is 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">For OpenCL C 1.2 or newer:</p>
<p class="tableblock"> size_t <strong>get_image_array_size</strong>(<em>aQual</em> image2d_array_t <em>image</em>)</p>
<p class="tableblock"> For OpenCL C 2.0 or newer, or if the <code>cl_khr_<wbr>depth_<wbr>images</code> extension
macro is supported:</p>
<p class="tableblock"> size_t <strong>get_image_array_size</strong>(<em>aQual</em> image2d_array_depth_t <em>image</em>)</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro is supported:</p>
<p class="tableblock"> size_t <strong>get_image_array_size</strong>(<em>aQual</em> image2d_array_msaa_depth_t <em>image</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the number of images in the 2D image array.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">For OpenCL C 1.2 or newer:</p>
<p class="tableblock"> size_t <strong>get_image_array_size</strong>(<em>aQual</em> image1d_array_t <em>image</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the number of images in the 1D image array.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">If the <code>cl_khr_<wbr>gl_<wbr>msaa_<wbr>sharing</code> extension macro is supported:</p>
<p class="tableblock"> int <strong>get_image_num_samples</strong>(<em>aQual</em> image2d_msaa_t <em>image</em>)<br>
int <strong>get_image_num_samples</strong>(<em>aQual</em> image2d_array_msaa_t <em>image</em>)<br>
int <strong>get_image_num_samples</strong>(<em>aQual</em> image2d_msaa_depth_t <em>image</em>)<br>
int <strong>get_image_num_samples</strong>(<em>aQual</em> image2d_array_msaa_depth_t <em>image</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the number of samples in the 2D MSAA image</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">If the <code>cl_khr_<wbr>mipmap_<wbr>image</code> extension macro is supported:</p>
<p class="tableblock"> int <strong>get_image_num_mip_levels</strong>(<em>aQual</em> image1d_t <em>image</em>)<br>
int <strong>get_image_num_mip_levels</strong>(<em>aQual</em> image2d_t <em>image</em>)<br>
int <strong>get_image_num_mip_levels</strong>(<em>aQual</em> image3d_t <em>image</em>)<br>
int <strong>get_image_num_mip_levels</strong>(<em>aQual</em> image1d_array_t <em>image</em>)<br>
int <strong>get_image_num_mip_levels</strong>(<em>aQual</em> image2d_array_t <em>image</em>)<br>
int <strong>get_image_num_mip_levels</strong>(<em>aQual</em> image2d_depth_t <em>image</em>)<br>
int <strong>get_image_num_mip_levels</strong>(<em>aQual</em> image2d_array_depth_t <em>image</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return the number of mip levels in <em>image</em>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The values returned by <strong>get_image_channel_data_type</strong> and
<strong>get_image_channel_order</strong> as specified in <a href="#table-image-query">Built-in Image
Query Functions</a> with the <code>CLK_</code> prefixes correspond to the <code>CL_</code> prefixes used
to describe the <a href="#opencl-channel-order">image channel order</a> and
<a href="#opencl-channel-data-type">data type</a> in the <a href="#opencl-spec">OpenCL
Specification</a>.
For example, both <code>CL_UNORM_<wbr>INT8</code> and <code>CLK_UNORM_INT8</code> refer to an image
channel data type that is an unnormalized unsigned 8-bit integer.</p>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="reading-and-writing-to-the-same-image-in-a-kernel"><a class="anchor" href="#reading-and-writing-to-the-same-image-in-a-kernel"></a>6.15.15.6. Reading and Writing to the Same Image in a Kernel</h5>
<div class="paragraph">
<p>The <strong>atomic_work_item_fence</strong>(<code>CLK_IMAGE_MEM_FENCE</code>) built-in function can be
used to make sure that sampler-less writes are visible to later reads by the
same work-item.
Only a scope of <code>memory_scope_work_item</code> and an order of
<code>memory_order_acq_rel</code> is valid for <code>atomic_work_item_fence</code> when passed the
<code>CLK_IMAGE_MEM_FENCE</code> flag.
If multiple work-items are writing to and reading from multiple locations in
an image, the <strong>work_group_barrier</strong>(<code>CLK_IMAGE_MEM_FENCE</code>) should be used.</p>
</div>
<div class="paragraph">
<p>Consider the following example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">foo</span><span class="p">(</span><span class="nx">read_write</span> <span class="kt">image2d_t</span> <span class="n">img</span><span class="p">,</span> <span class="p">...</span> <span class="p">)</span>
<span class="p">{</span>
<span class="kt">int2</span> <span class="n">coord</span><span class="p">;</span>
<span class="n">coord</span><span class="p">.</span><span class="n">x</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="fm">get_global_id</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="n">coord</span><span class="p">.</span><span class="n">y</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="fm">get_global_id</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">clr</span> <span class="o">=</span> <span class="fm">read_imagef</span><span class="p">(</span><span class="n">img</span><span class="p">,</span> <span class="n">coord</span><span class="p">);</span>
<span class="p">...</span>
<span class="fm">write_imagef</span><span class="p">(</span><span class="n">img</span><span class="p">,</span> <span class="n">coord</span><span class="p">,</span> <span class="n">clr</span><span class="p">);</span>
<span class="c1">// required to ensure that following read from image at</span>
<span class="c1">// location coord returns the latest color value.</span>
<span class="fm">atomic_work_item_fence</span><span class="p">(</span>
<span class="n">CLK_IMAGE_MEM_FENCE</span><span class="p">,</span>
<span class="vm">memory_order_acq_rel</span><span class="p">,</span>
<span class="vm">memory_scope_work_item</span><span class="p">);</span>
<span class="kt">float4</span> <span class="n">clr_new</span> <span class="o">=</span> <span class="fm">read_imagef</span><span class="p">(</span><span class="n">img</span><span class="p">,</span> <span class="n">coord</span><span class="p">);</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="mapping-image-channels-to-color-values-returned-by-read_image-and-color-values-passed-to-write_image-to-image-channels"><a class="anchor" href="#mapping-image-channels-to-color-values-returned-by-read_image-and-color-values-passed-to-write_image-to-image-channels"></a>6.15.15.7. Mapping Image Channels to Color Values Returned by read_image and Color Values Passed to write_image to Image Channels</h5>
<div class="paragraph">
<p>The following table describes the mapping of the number of channels of an
image element to the appropriate components in the <code>float4</code>, <code>int4</code> or
<code>uint4</code> vector data type for the color values returned by
<strong>read_image{f|i|ui}</strong> or supplied to <strong>write_image{f|i|ui}</strong>.
The unmapped components will be set to 0.0 for red, green and blue channels
and will be set to 1.0 for the alpha channel.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Channel Order</th>
<th class="tableblock halign-left valign-top"><code>float4</code>, <code>int4</code> or <code>uint4</code> components of channel data</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_R</code>, <code>CL_Rx</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(r, 0.0, 0.0, 1.0)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_A</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(0.0, 0.0, 0.0, a)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_RG</code>, <code>CL_RGx</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(r, g, 0.0, 1.0)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_RA</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(r, 0.0, 0.0, a)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_RGB</code>, <code>CL_RGBx</code>, <code>CL_sRGB</code>, <code>CL_sRGBx</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(r, g, b, 1.0)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_RGBA</code>, <code>CL_BGRA</code>, <code>CL_ARGB</code>, <code>CL_ABGR</code>, <code>CL_sRGBA</code>, <code>CL_sBGRA</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(r, g, b, a)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_INTENSITY</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(I, I, I, I)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CL_LUMINANCE</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">(L, L, L, 1.0)</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>For <code>CL_DEPTH</code> images, a scalar value is returned by <strong>read_imagef</strong> or
supplied to <strong>write_imagef</strong>.
<a href="#unified-spec">Requires</a> support for OpenCL C 2.0 or newer, or for
the <code>cl_khr_<wbr>depth_<wbr>images</code> extension macro.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>A kernel that uses a sampler with the <code>CL_ADDRESS_<wbr>CLAMP</code> addressing mode
with multiple images may result in additional samplers being used internally
by an implementation.
If the same sampler is used with multiple images called via
<strong>read_image{f|i|ui}</strong>, then it is possible that an implementation may need to
allocate an additional sampler to handle the different border color values
that may be needed depending on the image formats being used.
These implementation allocated samplers will count against the maximum
sampler values supported by the device and given by
<code>CL_DEVICE_<wbr>MAX_<wbr>SAMPLERS</code>.
Enqueuing a kernel that requires more samplers than the implementation can
support will result in a <code>CL_OUT_<wbr>OF_<wbr>RESOURCES</code> error being returned.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="work-group-functions"><a class="anchor" href="#work-group-functions"></a>6.15.16. Work-group Collective Functions</h4>
<div class="openblock">
<div class="content">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and the
<code>__opencl_c_<wbr>work_<wbr>group_<wbr>collective_<wbr>functions</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>This section describes built-in functions that perform collective options
across a work-group.
These built-in functions must be encountered by all work-items in a
work-group executing the kernel.
We use the generic type name <code>gentype</code> to indicate the built-in data types
<code>half</code> <sup class="footnote">[<a id="_footnoteref_85" class="footnote" href="#_footnotedef_85" title="View footnote.">85</a>]</sup>, <code>int</code>, <code>uint</code>, <code>long</code>
<sup class="footnote">[<a id="_footnoteref_86" class="footnote" href="#_footnotedef_86" title="View footnote.">86</a>]</sup>, <code>ulong</code>, <code>float</code> or <code>double</code>
<sup class="footnote">[<a id="_footnoteref_87" class="footnote" href="#_footnotedef_87" title="View footnote.">87</a>]</sup> as the type for the arguments.</p>
</div>
<table id="table-builtin-work-group" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 37. Built-in Work-group Collective Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>work_group_all</strong>(int <em>predicate</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Evaluates <em>predicate</em> for all work-items in the work-group and returns
a non-zero value if <em>predicate</em> evaluates to non-zero for all
work-items in the work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>work_group_any</strong>(int <em>predicate</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Evaluates <em>predicate</em> for all work-items in the work-group and returns
a non-zero value if <em>predicate</em> evaluates to non-zero for any
work-items in the work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>work_group_broadcast</strong>(gentype <em>a</em>, size_t <em>local_id</em>)<br>
gentype <strong>work_group_broadcast</strong>(gentype <em>a</em>, size_t <em>local_id_x</em>,
size_t <em>local_id_y</em>)<br>
gentype <strong>work_group_broadcast</strong>(gentype <em>a</em>, size_t <em>local_id_x</em>,
size_t <em>local_id_y</em>, size_t <em>local_id_z</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Broadcast the value of <em>a</em> for work-item identified by <em>local_id</em> to
all work-items in the work-group.</p>
<p class="tableblock"> Behavior is undefined when the value of <em>local_id</em> is not equivalent for
all work-items in the work-group.</p>
<p class="tableblock"> Behavior is undefined when <em>local_id</em> is greater or equal to the
work-group size in the corresponding dimension.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>work_group_reduce_&lt;op&gt;</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return result of reduction operation specified by <strong>&lt;op&gt;</strong> for all
values of <em>x</em> specified by work-items in a work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>work_group_scan_exclusive_&lt;op&gt;</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Do an exclusive scan operation specified by <strong>&lt;op&gt;</strong> of all values
specified by work-items in the work-group. The scan results are
returned for each work-item.</p>
<p class="tableblock"> The scan order is defined by increasing 1D linear global ID within the
work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>work_group_scan_inclusive_&lt;op&gt;</strong>(gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Do an inclusive scan operation specified by <strong>&lt;op&gt;</strong> of all values
specified by work-items in the work-group. The scan results are
returned for each work-item.</p>
<p class="tableblock"> The scan order is defined by increasing 1D linear global ID within the
work-group.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <strong>&lt;op&gt;</strong> in <strong>work_group_reduce_&lt;op&gt;</strong>, <strong>work_group_scan_exclusive_&lt;op&gt;</strong> and
<strong>work_group_scan_inclusive_&lt;op&gt;</strong> defines the operator and can be <strong>add</strong>,
<strong>min</strong> or <strong>max</strong>.</p>
</div>
<div class="paragraph">
<p>The inclusive scan operation takes a binary operator <strong>op</strong> with <em>n</em> (where <em>n</em>
is the size of the work-group) elements [a<sub>0</sub>, a<sub>1</sub>, &#8230;&#8203; a<sub>n-1</sub>] and returns
[a<sub>0</sub>, (a<sub>0</sub> <strong>op</strong> a<sub>1</sub>), &#8230;&#8203; (a<sub>0</sub> <strong>op</strong> a<sub>1</sub> <strong>op</strong> &#8230;&#8203; <strong>op</strong> a<sub>n-1</sub>)].</p>
</div>
<div class="paragraph">
<p>Consider the following example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span><span class="n">p</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="kt">int</span> <span class="n">prefix_sum_val</span> <span class="o">=</span> <span class="fm">work_group_scan_inclusive_add</span><span class="p">(</span>
<span class="n">p</span><span class="p">[</span><span class="fm">get_local_id</span><span class="p">(</span><span class="mi">0</span><span class="p">)]);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>For the example above, let&#8217;s assume that the work-group size is 8 and <em>p</em>
points to the following elements [3 1 7 0 4 1 6 3].
Work-item 0 calls <strong>work_group_scan_inclusive_add</strong> with 3 and returns 3.
Work-item 1 calls <strong>work_group_scan_inclusive_add</strong> with 1 and returns 4.
The full set of values returned by <strong>work_group_scan_inclusive_add</strong> for
work-items 0 &#8230;&#8203; 7 are [3 4 11 11 15 16 22 25].</p>
</div>
<div class="paragraph">
<p>The exclusive scan operation takes a binary associative operator <strong>op</strong> with
an identity I and n (where n is the size of the work-group) elements [a<sub>0</sub>,
a<sub>1</sub>, &#8230;&#8203; a<sub>n-1</sub>] and returns [I, a<sub>0</sub>, (a<sub>0</sub> <strong>op</strong> a<sub>1</sub>), &#8230;&#8203; (a<sub>0</sub> <strong>op</strong>
a<sub>1</sub> <strong>op</strong> &#8230;&#8203; <strong>op</strong> a<sub>n-2</sub>)].
If <strong>op</strong> = add, the identity I is 0.
If <strong>op</strong> = min, the identity I is <code>INT_MAX</code>, <code>UINT_MAX</code>, <code>LONG_MAX</code>,
<code>ULONG_MAX</code>, for <code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code> types and is <code>+INF</code> for
floating-point types.
Similarly if <strong>op</strong> = max, the identity I is <code>INT_MIN</code>, 0, <code>LONG_MIN</code>, 0 and
<code>-INF</code>.
For the example above, the exclusive scan add operation on the ordered set
[3 1 7 0 4 1 6 3] would return [0 3 4 11 11 15 16 22].</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The order of floating-point operations is not guaranteed for the
<strong>work_group_reduce_&lt;op&gt;</strong>, <strong>work_group_scan_inclusive_&lt;op&gt;</strong> and
<strong>work_group_scan_exclusive_&lt;op&gt;</strong> built-in functions that operate on <code>half</code>,
<code>float</code> and <code>double</code> data types.
The order of these floating-point operations is also non-deterministic for a
given work-group.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="work-group-collective-uniform-arithmetic-functions"><a class="anchor" href="#work-group-collective-uniform-arithmetic-functions"></a>6.15.17. Work-group Collective Uniform Arithmetic Functions</h4>
<div class="openblock">
<div class="content">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for OpenCL C 2.0 and the <code>cl_khr_<wbr>work_<wbr>group_<wbr>uniform_<wbr>arithmetic</code>
extension macro.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <a href="#table-builtin-work-group-logical">Built-in Work-group Logical Arithmetic Functions</a> table describes the OpenCL C
programming language built-in functions that perform logical arithmetic
operations across work items in a work-group.
These functions must be encountered by all work items in a work-group
executing the kernel, otherwise the behavior is undefined.
For these functions, a non-zero <em>predicate</em> argument or return value is
logically <code>true</code> and a zero <em>predicate</em> argument or return value is
logically <code>false</code>.</p>
</div>
<table id="table-builtin-work-group-logical" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 38. Built-in Work-group Logical Arithmetic Functions</caption>
<colgroup>
<col style="width: 57.1428%;">
<col style="width: 42.8572%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="nf">work_group_reduce_logical_and</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">work_group_reduce_logical_or</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">work_group_reduce_logical_xor</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the logical <strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>predicate</em> for all work
items in the work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="nf">work_group_scan_inclusive_logical_and</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">work_group_scan_inclusive_logical_or</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">work_group_scan_inclusive_logical_xor</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an inclusive scan operation, which is the logical
<strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>predicate</em> for all work items in the
work-group with a work-group linear local ID less than or equal to this
work item&#8217;s work-group linear local ID.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="nf">work_group_scan_exclusive_logical_and</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">work_group_scan_exclusive_logical_or</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">work_group_scan_exclusive_logical_xor</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an exclusive scan operation, which is the logical
<strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>predicate</em> for all work items in the
work-group with a work-group linear local ID less than this work item&#8217;s
work-group linear local ID.</p>
<p class="tableblock"> If there is no work item in the work-group with a work-group linear
local ID less than this work item&#8217;s work-group linear local ID then an
identity value <code>I</code> is returned.
For <strong>and</strong>, the identity value is <code>true</code> (non-zero).
For <strong>or</strong> and <strong>xor</strong>, the identity value is <code>false</code> (zero).</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <a href="#table-builtin-work-group-bitwise-integer">Built-in Work-group Bitwise Integer Functions</a> table describes the OpenCL
C programming language built-in functions that perform bitwise integer
operations across work items in a work-group.
These functions must be encountered by all work items in a work-group
executing the kernel, otherwise the behavior is undefined.
For the functions below, the generic type name <code>gentype</code> may be one of the
supported built-in scalar data types <code>int</code>, <code>uint</code>, <code>long</code>, and <code>ulong</code>.</p>
</div>
<table id="table-builtin-work-group-bitwise-integer" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 39. Built-in Work-group Bitwise Integer Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="nf">work_group_reduce_and</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span>
<span class="kp">gentype</span> <span class="nf">work_group_reduce_or</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span>
<span class="kp">gentype</span> <span class="nf">work_group_reduce_xor</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the bitwise <strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>value</em> for all work items
in the work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="nf">work_group_scan_inclusive_and</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span>
<span class="kp">gentype</span> <span class="nf">work_group_scan_inclusive_or</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span>
<span class="kp">gentype</span> <span class="nf">work_group_scan_inclusive_xor</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an inclusive scan operation, which is the bitwise
<strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>value</em> for all work items in the work-group
with a work-group linear local ID less than or equal to this work item&#8217;s
work-group linear local ID.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="nf">work_group_scan_exclusive_and</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span>
<span class="kp">gentype</span> <span class="nf">work_group_scan_exclusive_or</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span>
<span class="kp">gentype</span> <span class="nf">work_group_scan_exclusive_xor</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an exclusive scan operation, which is the bitwise
<strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>value</em> for all work items in the work-group
with a work-group linear local ID less than this work item&#8217;s work-group
linear local ID.</p>
<p class="tableblock"> If there is no work item in the work-group with a work-group linear
local ID less than this work item&#8217;s work-group linear local ID then an
identity value <code>I</code> is returned.
For <strong>and</strong>, the identity value is <code>~0</code> (all bits set).
For <strong>or</strong> and <strong>xor</strong>, the identity value is <code>0</code>.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <a href="#table-builtin-work-group-multiplicative">Built-in Work-group Multiplicative Functions</a> table describes the OpenCL C
programming language built-in functions that perform multiplicative
operations across work items in a work-group.
These functions must be encountered by all work items in a work-group
executing the kernel, otherwise the behavior is undefined.
For the functions below, the generic type name <code>gentype</code> may be one of the
supported built-in scalar data types <code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>,
<code>float</code>, <code>double</code> (if double precision is supported), or <code>half</code> (if half
precision is supported).</p>
</div>
<table id="table-builtin-work-group-multiplicative" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 40. Built-in Work-group Multiplicative Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="nf">work_group_reduce_mul</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the multiplication of <em>value</em> for all work items in the
work-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="nf">work_group_scan_inclusive_mul</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an inclusive scan operation which is the
multiplication of <em>value</em> for all work items in the work-group with a
work-group linear local ID less than or equal to this work item&#8217;s
work-group linear local ID.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="nf">work_group_scan_exclusive_mul</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">);</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an exclusive scan operation which is the
multiplication of <em>value</em> for all work items in the work-group with a
work-group linear local ID less than this work item&#8217;s work-group linear
local ID.</p>
<p class="tableblock"> If there is no work item in the work-group with a work-group linear
local ID less than this work item&#8217;s work-group linear local ID then the
identity value <code>1</code> is returned.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="pipe-functions"><a class="anchor" href="#pipe-functions"></a>6.15.18. Pipe Functions</h4>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>pipes</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>A pipe is identified by specifying the <code>pipe</code> keyword with a type.
The data type specifies the type of each element in the pipe.
The <code>pipe</code> keyword is a type specifier.
When it is applied to another type <strong>T</strong>, the result is a pipe type whose
elements (or packets) are of type <strong>T</strong>.
The packet type <strong>T</strong> may be any supported OpenCL C scalar and vector integer
or floating-point data types, or a user-defined type built from these scalar
and vector data types.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">pipe</span> <span class="kt">int4</span> <span class="n">pipeA</span><span class="p">;</span> <span class="c1">// a pipe with int4 packets</span>
<span class="nx">pipe</span> <span class="n">user_type_t</span> <span class="n">pipeB</span><span class="p">;</span> <span class="c1">// a pipe with user_type_t packets</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>read_only</code> (or <code>__read_only</code>) and <code>write_only</code> (or <code>__write_only</code>)
qualifiers must be used with the <code>pipe</code> specifier when a pipe is a parameter
of a kernel or of a user-defined function to identify if a pipe can be read
from or written to by a kernel and its callees and enqueued child kernels.
If no qualifier is specified, <code>read_only</code> is assumed.</p>
</div>
<div class="paragraph">
<p>A kernel cannot read from and write to the same pipe object.
Using the <code>read_write</code> (or <code>__read_write</code>) qualifier with the <code>pipe</code>
specifier is a compilation error.</p>
</div>
<div class="paragraph">
<p>In the following example</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">foo</span> <span class="p">(</span><span class="nx">read_only</span> <span class="nx">pipe</span> <span class="n">fooA_t</span> <span class="n">pipeA</span><span class="p">,</span>
<span class="nx">write_only</span> <span class="nx">pipe</span> <span class="n">fooB_t</span> <span class="n">pipeB</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><code>pipeA</code> is a read-only pipe object, and <code>pipeB</code> is a write-only pipe object.</p>
</div>
<div class="paragraph">
<p>The macro <code>CLK_NULL_RESERVE_ID</code> refers to an invalid reservation ID.</p>
</div>
<div class="sect4">
<h5 id="restrictions-3"><a class="anchor" href="#restrictions-3"></a>6.15.18.1. Restrictions</h5>
<div class="ulist">
<ul>
<li>
<p>Pipes can only be passed as arguments to a function (including kernel
functions).
The <a href="#operators">C operators</a> cannot be used with variables declared
with the pipe specifier.</p>
</li>
<li>
<p>The <code>pipe</code> specifier cannot be used with variables declared inside a
kernel, a structure or union field, a pointer type, an array, global
variables declared in program scope or the return type of a function.</p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="built-in-pipe-read-and-write-functions"><a class="anchor" href="#built-in-pipe-read-and-write-functions"></a>6.15.18.2. Built-in Pipe Read and Write Functions</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The OpenCL C programming language implements the following built-in
functions that read from or write to a pipe.
We use the generic type name <code>gentype</code> to indicate the built-in OpenCL C scalar
or vector integer or floating-point data types
<sup class="footnote">[<a id="_footnoteref_88" class="footnote" href="#_footnotedef_88" title="View footnote.">88</a>]</sup> or any user defined type built from these
scalar and vector data types can be used as the type for the arguments to the
pipe functions listed in the following table.</p>
</div>
<table id="table-builtin-pipe" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 41. Built-in Pipe Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>read_pipe</strong>(read_only pipe gentype <em>p</em>, gentype *<em>ptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read packet from pipe <em>p</em> into <em>ptr</em>.
Returns 0 if <strong>read_pipe</strong> is successful and a negative value if the
pipe is empty.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>write_pipe</strong>(write_only pipe gentype <em>p</em>, const gentype *<em>ptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write packet specified by <em>ptr</em> to pipe <em>p</em>.
Returns 0 if <strong>write_pipe</strong> is successful and a negative value if the
pipe is full.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>read_pipe</strong>(read_only pipe gentype <em>p</em>, reserve_id_t <em>reserve_id</em>,
uint <em>index</em>, gentype *<em>ptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Read packet from the reserved area of the pipe referred to by
<em>reserve_id</em> and <em>index</em> into <em>ptr</em>.</p>
<p class="tableblock"> The reserved pipe entries are referred to by indices that go from 0
&#8230;&#8203; <em>num_packets</em> - 1.</p>
<p class="tableblock"> Returns 0 if <strong>read_pipe</strong> is successful and a negative value otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>write_pipe</strong>(write_only pipe gentype <em>p</em>, reserve_id_t
<em>reserve_id</em>, uint <em>index</em>, const gentype *<em>ptr</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Write packet specified by <em>ptr</em> to the reserved area of the pipe
referred to by <em>reserve_id</em> and <em>index</em>.</p>
<p class="tableblock"> The reserved pipe entries are referred to by indices that go from 0
&#8230;&#8203; <em>num_packets</em> - 1.</p>
<p class="tableblock"> Returns 0 if <strong>write_pipe</strong> is successful and a negative value
otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">reserve_id_t <strong>reserve_read_pipe</strong>(read_only pipe gentype <em>p</em>,
uint <em>num_packets</em>)<br>
reserve_id_t <strong>reserve_write_pipe</strong>(write_only pipe gentype <em>p</em>,
uint <em>num_packets</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Reserve <em>num_packets</em> entries for reading from or writing to pipe <em>p</em>.
Returns a valid reservation ID if the reservation is successful.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>commit_read_pipe</strong>(read_only pipe gentype <em>p</em>,
reserve_id_t <em>reserve_id</em>)<br>
void <strong>commit_write_pipe</strong>(write_only pipe gentype <em>p</em>,
reserve_id_t <em>reserve_id</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates that all reads and writes to <em>num_packets</em> associated with
reservation <em>reserve_id</em> are completed.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">bool <strong>is_valid_reserve_id</strong>(reserve_id_t <em>reserve_id</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return <em>true</em> if <em>reserve_id</em> is a valid reservation ID and <em>false</em>
otherwise.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect4">
<h5 id="built-in-work-group-pipe-read-and-write-functions"><a class="anchor" href="#built-in-work-group-pipe-read-and-write-functions"></a>6.15.18.3. Built-in Work-group Pipe Read and Write Functions</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The OpenCL C programming language implements the following built-in pipe
functions that operate at a work-group level.
These built-in functions must be encountered by all work-items in a
work-group executing the kernel with the same argument values; otherwise the
behavior is undefined.
We use the generic type name <code>gentype</code> to indicate the built-in OpenCL C scalar
or vector integer or floating-point data types
<sup class="footnote">[<a id="_footnoteref_89" class="footnote" href="#_footnotedef_89" title="View footnote.">89</a>]</sup> or any user defined type built from these
scalar and vector data types can be used as the type for the arguments to the
pipe functions listed in the following table.</p>
</div>
<table id="table-builtin-pipe-work-group" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 42. Built-in Pipe Work-group Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">reserve_id_t <strong>work_group_reserve_read_pipe</strong>(read_only pipe gentype <em>p</em>,
uint <em>num_packets</em>)<br>
reserve_id_t <strong>work_group_reserve_write_pipe</strong>(write_only pipe gentype <em>p</em>,
uint <em>num_packets</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Reserve <em>num_packets</em> entries for reading from or writing to pipe <em>p</em>.
Returns a valid reservation ID if the reservation is successful.</p>
<p class="tableblock"> The reserved pipe entries are referred to by indices that go from 0
&#8230;&#8203; <em>num_packets</em> - 1.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>work_group_commit_read_pipe</strong>(read_only pipe gentype <em>p</em>,
reserve_id_t <em>reserve_id</em>)
void <strong>work_group_commit_write_pipe</strong>(write_only pipe gentype <em>p</em>,
reserve_id_t <em>reserve_id</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates that all reads and writes to <em>num_packets</em> associated with
reservation <em>reserve_id</em> are completed.</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The <strong>read_pipe</strong> and <strong>write_pipe</strong> functions that take a reservation ID as an
argument can be used to read from or write to a packet index.
These built-ins can be used to read from or write to a packet index one or
multiple times.
If a packet index that is reserved for writing is not written to using the
<strong>write_pipe</strong> function, the contents of that packet in the pipe are
undefined.
<strong>commit_read_pipe</strong> and <strong>work_group_commit_read_pipe</strong> remove the entries
reserved for reading from the pipe.
<strong>commit_write_pipe</strong> and <strong>work_group_commit_write_pipe</strong> ensures that the
entries reserved for writing are all added in-order as one contiguous set of
packets to the pipe.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>There can only be the value of the <a href="#opencl-device-queries"><code>CL_DEVICE_<wbr>PIPE_<wbr>MAX_<wbr>ACTIVE_<wbr>RESERVATIONS</code> device query</a> reservations active
(i.e. reservation IDs that have been reserved but not committed) per
work-item or work-group for a pipe in a kernel executing on a device.</p>
</div>
<div class="paragraph">
<p>Work-item based reservations made by a work-item are ordered in the pipe as
they are ordered in the program.
Reservations made by different work-items that belong to the same work-group
can be ordered using the work-group barrier function.
The order of work-item based reservations that belong to different
work-groups is implementation-defined.</p>
</div>
<div class="paragraph">
<p>Work-group based reservations made by a work-group are ordered in the pipe
as they are ordered in the program.
The order of work-group based reservations by different work-groups is
implementation-defined.</p>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="built-in-pipe-query-functions"><a class="anchor" href="#built-in-pipe-query-functions"></a>6.15.18.4. Built-in Pipe Query Functions</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The OpenCL C programming language implements the following built-in query
functions for a pipe.
We use the generic type name <code>gentype</code> to indicate the built-in OpenCL C scalar
or vector integer or floating-point data types
<sup class="footnote">[<a id="_footnoteref_90" class="footnote" href="#_footnotedef_90" title="View footnote.">90</a>]</sup> or any user defined type built from these
scalar and vector data types can be used as the type for the arguments to the
pipe functions listed in the following table.</p>
</div>
<div class="paragraph">
<p><em>aQual</em> in the following table refers to one of the access qualifiers.
For pipe query functions this may be <code>read_only</code> or <code>write_only</code>.</p>
</div>
<table id="table-builtin-pipe-query" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 43. Built-in Pipe Query Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>get_pipe_num_packets</strong>(<em>aQual</em> pipe gentype <em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of available entries in the pipe.
The number of available entries in a pipe is a dynamic value.
The value returned should be considered immediately stale.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>get_pipe_max_packets</strong>(<em>aQual</em> pipe gentype <em>p</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the maximum number of packets specified when <em>pipe</em> was
created.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect4">
<h5 id="restrictions-4"><a class="anchor" href="#restrictions-4"></a>6.15.18.5. Restrictions</h5>
<div class="paragraph">
<p>The following behavior is undefined</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A kernel fails to call <strong>reserve_pipe</strong> before calling <strong>read_pipe</strong> or
<strong>write_pipe</strong> that take a reservation ID.</p>
</li>
<li>
<p>A kernel calls <strong>read_pipe</strong>, <strong>write_pipe</strong>, <strong>commit_read_pipe</strong> or
<strong>commit_write_pipe</strong> with an invalid reservation ID.</p>
</li>
<li>
<p>A kernel calls <strong>read_pipe</strong> or <strong>write_pipe</strong> with an valid reservation ID
but with an <em>index</em> that is not a value in the range [0,
<em>num_packets</em>-1] specified to the corresponding call to <em>reserve_pipe</em>.</p>
</li>
<li>
<p>A kernel calls <strong>read_pipe</strong> or <strong>write_pipe</strong> with a reservation ID that
has already been committed (i.e. a <strong>commit_read_pipe</strong> or
<strong>commit_write_pipe</strong> with this reservation ID has already been called).</p>
</li>
<li>
<p>A kernel fails to call <strong>commit_read_pipe</strong> for any reservation ID
obtained by a prior call to <strong>reserve_read_pipe</strong>.</p>
</li>
<li>
<p>A kernel fails to call <strong>commit_write_pipe</strong> for any reservation ID
obtained by a prior call to <strong>reserve_write_pipe</strong>.</p>
</li>
<li>
<p>The contents of the reserved data packets in the pipe are undefined if
the kernel does not call <strong>write_pipe</strong> for all entries that were reserved
by the corresponding call to <strong>reserve_pipe</strong>.</p>
</li>
<li>
<p>Calls to <strong>read_pipe</strong> that takes a reservation ID and <strong>commit_read_pipe</strong>
or <strong>write_pipe</strong> that takes a reservation ID and <strong>commit_write_pipe</strong> for
a given reservation ID must be called by the same kernel that made the
reservation using <strong>reserve_read_pipe</strong> or <strong>reserve_write_pipe</strong>.
The reservation ID cannot be passed to another kernel including child
kernels.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect3">
<h4 id="enqueuing-kernels"><a class="anchor" href="#enqueuing-kernels"></a>6.15.19. Enqueuing Kernels</h4>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for OpenCL C 2.0, or OpenCL C 3.0 or newer and the
<code>__opencl_c_<wbr>device_<wbr>enqueue</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>This section describes built-in functions that allow a kernel to
enqueue additional work to the same device, without host interaction.
A kernel may enqueue code represented by Block syntax, and control execution
order with event dependencies including user events and markers.
There are several advantages to using the Block syntax: it is more compact;
it does not require a <code>cl_kernel</code> object; and enqueuing can be done as a
single semantic step.</p>
</div>
<div class="paragraph">
<p>The macro <code>CLK_NULL_EVENT</code> refers to an invalid device event.
The macro <code>CLK_NULL_QUEUE</code> refers to an invalid device queue.</p>
</div>
<div class="sect4">
<h5 id="built-in-functions-enqueuing-a-kernel"><a class="anchor" href="#built-in-functions-enqueuing-a-kernel"></a>6.15.19.1. Built-in Functions - Enqueuing a Kernel</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following table describes the list of built-in functions that can be
used to enqueue a kernel.</p>
</div>
<div class="paragraph">
<p>When the <code>cl_khr_<wbr>device_<wbr>enqueue_<wbr>local_<wbr>arg_<wbr>types</code> extension macro is
supported, the <a href="#table-builtin-kernel-enqueue">Built-in Kernel Enqueue
Functions</a> and <a href="#table-builtin-kernel-query">Built-in Kernel Query
Functions</a> described in this section can use any of the built-in OpenCL C
scalar or vector integer or floating-point data types, or any user defined
type built from these scalar and vector data types, as the pointee type of
their arguments.
This is indicated by the generic type name <code>gentype</code> in those function
signatures.</p>
</div>
<div class="paragraph">
<p>When the <code>cl_khr_<wbr>device_<wbr>enqueue_<wbr>local_<wbr>arg_<wbr>types</code> extension macro is
not supported, the pointee type of these functions must be <code>void</code>.</p>
</div>
<table id="table-builtin-kernel-enqueue" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 44. Built-in Kernel Enqueue Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Built-in Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>enqueue_kernel</strong>(queue_t <em>queue</em>, kernel_enqueue_flags_t <em>flags</em>,
const ndrange_t <em>ndrange</em>, void (^<em>block</em>)(void))<br>
int <strong>enqueue_kernel</strong>(queue_t <em>queue</em>, kernel_enqueue_flags_t <em>flags</em>,
const ndrange_t <em>ndrange</em>, uint <em>num_events_in_wait_list</em>,
const clk_event_t *<em>event_wait_list</em>, clk_event_t *<em>event_ret</em>,
void (^<em>block</em>)(void))<br>
int <strong>enqueue_kernel</strong>(queue_t <em>queue</em>, kernel_enqueue_flags_t <em>flags</em>,
const ndrange_t <em>ndrange</em>, void (^<em>block</em>)(local void *, &#8230;&#8203;),
uint size0, &#8230;&#8203;)<br>
int <strong>enqueue_kernel</strong>(queue_t <em>queue</em>, kernel_enqueue_flags_t <em>flags</em>,
const ndrange_t <em>ndrange</em>, uint <em>num_events_in_wait_list</em>,
const clk_event_t *<em>event_wait_list</em>, clk_event_t *<em>event_ret</em>,
void (^<em>block</em>)(local void *, &#8230;&#8203;), uint size0, &#8230;&#8203;)</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>device_<wbr>enqueue_<wbr>local_<wbr>arg_<wbr>types</code> extension macro is supported:</p>
<p class="tableblock"> int <strong>enqueue_kernel</strong>(queue_t <em>queue</em>, kernel_enqueue_flags_t <em>flags</em>,
const ndrange_t <em>ndrange</em>, void (^<em>block</em>)(local gentype *, &#8230;&#8203;),
uint size0, &#8230;&#8203;)<br>
int <strong>enqueue_kernel</strong>(queue_t <em>queue</em>, kernel_enqueue_flags_t <em>flags</em>,
const ndrange_t <em>ndrange</em>, uint <em>num_events_in_wait_list</em>,
const clk_event_t *<em>event_wait_list</em>, clk_event_t *<em>event_ret</em>,
void (^<em>block</em>)(local gentype *, &#8230;&#8203;), uint size0, &#8230;&#8203;)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enqueue the block for execution to <em>queue</em>.</p>
<p class="tableblock"> If an event is returned, <strong>enqueue_kernel</strong> performs an implicit retain
on the returned event.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <strong>enqueue_kernel</strong> built-in function allows a work-item to enqueue a
block.
Work-items can enqueue multiple blocks to device queues.</p>
</div>
<div class="paragraph">
<p>The <strong>enqueue_kernel</strong> built-in function returns <code>CLK_SUCCESS</code> if the block is
enqueued successfully and returns <code>CLK_ENQUEUE_FAILURE</code> otherwise.
If the -g compile option is specified in compiler options passed to
<strong>clCompileProgram</strong> or <strong>clBuildProgram</strong> when compiling or building the parent
program, the following errors may be returned instead of
<code>CLK_ENQUEUE_FAILURE</code> to indicate why <strong>enqueue_kernel</strong> failed to enqueue the
block:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CLK_INVALID_QUEUE</code> if <em>queue</em> is not a valid device queue.</p>
</li>
<li>
<p><code>CLK_INVALID_NDRANGE</code> if <em>ndrange</em> is not a valid ND-range descriptor or
if the program was compiled with <code>-cl-uniform-work-group-size</code> and the
<em>local_work_size</em> is specified in <em>ndrange</em> but the <em>global_work_size</em>
specified in <em>ndrange</em> is not a multiple of the <em>local_work_size</em>.</p>
</li>
<li>
<p><code>CLK_INVALID_EVENT_WAIT_LIST</code> if <em>event_wait_list</em> is <code>NULL</code> and
<em>num_events_in_wait_list</em> &gt; 0, or if <em>event_wait_list</em> is not <code>NULL</code> and
<em>num_events_in_wait_list</em> is 0, or if event objects in <em>event_wait_list</em>
are not valid events.</p>
</li>
<li>
<p><code>CLK_DEVICE_QUEUE_FULL</code> if <em>queue</em> is full.</p>
</li>
<li>
<p><code>CLK_INVALID_ARG_SIZE</code> if size of local memory arguments is 0.</p>
</li>
<li>
<p><code>CLK_EVENT_ALLOCATION_FAILURE</code> if <em>event_ret</em> is not <code>NULL</code> and an event
could not be allocated.</p>
</li>
<li>
<p><code>CLK_OUT_OF_RESOURCES</code> if there is a failure to queue the block in
<em>queue</em> because of insufficient resources needed to execute the kernel.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="paragraph">
<p>Below are some examples of how to enqueue a block.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_func_A</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">c</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_func_B</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">c</span><span class="p">)</span>
<span class="p">{</span>
<span class="kt">ndrange_t</span> <span class="n">ndrange</span><span class="p">;</span>
<span class="c1">// build ndrange information</span>
<span class="p">...</span>
<span class="c1">// example - enqueue a kernel as a block</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="fm">get_default_queue</span><span class="p">(),</span> <span class="n">ndrange</span><span class="p">,</span>
<span class="o">^</span><span class="p">{</span><span class="n">my_func_A</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">);});</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_func_C</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">b</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">c</span><span class="p">)</span>
<span class="p">{</span>
<span class="kt">ndrange_t</span> <span class="n">ndrange</span><span class="p">;</span>
<span class="c1">// build ndrange information</span>
<span class="p">...</span>
<span class="c1">// note that a, b and c are variables in scope of</span>
<span class="c1">// the block</span>
<span class="kt">void</span> <span class="p">(</span><span class="o">^</span><span class="n">my_block_A</span><span class="p">)(</span><span class="kt">void</span><span class="p">)</span> <span class="o">=</span> <span class="o">^</span><span class="p">{</span><span class="n">my_func_A</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">);};</span>
<span class="c1">// enqueue the block variable</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="fm">get_default_queue</span><span class="p">(),</span>
<span class="n">CLK_ENQUEUE_FLAGS_WAIT_KERNEL</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="n">my_block_A</span><span class="p">);</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The example below shows how to declare a block literal and enqueue it.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_func</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">b</span><span class="p">)</span>
<span class="p">{</span>
<span class="kt">ndrange_t</span> <span class="n">ndrange</span><span class="p">;</span>
<span class="c1">// build ndrange information</span>
<span class="p">...</span>
<span class="c1">// note that a, b and c are variables in scope of</span>
<span class="c1">// the block</span>
<span class="kt">void</span> <span class="p">(</span><span class="o">^</span><span class="n">my_block_A</span><span class="p">)(</span><span class="kt">void</span><span class="p">)</span> <span class="o">=</span>
<span class="o">^</span><span class="p">{</span>
<span class="kt">size_t</span> <span class="n">id</span> <span class="o">=</span> <span class="fm">get_global_id</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="n">b</span><span class="p">[</span><span class="n">id</span><span class="p">]</span> <span class="o">+=</span> <span class="n">a</span><span class="p">[</span><span class="n">id</span><span class="p">];</span>
<span class="p">};</span>
<span class="c1">// enqueue the block variable</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="fm">get_default_queue</span><span class="p">(),</span>
<span class="n">CLK_ENQUEUE_FLAGS_WAIT_KERNEL</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="n">my_block_A</span><span class="p">);</span>
<span class="c1">// or we could have done the following</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="fm">get_default_queue</span><span class="p">(),</span>
<span class="n">CLK_ENQUEUE_FLAGS_WAIT_KERNEL</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="o">^</span><span class="p">{</span>
<span class="kt">size_t</span> <span class="n">id</span> <span class="o">=</span> <span class="fm">get_global_id</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="n">b</span><span class="p">[</span><span class="n">id</span><span class="p">]</span> <span class="o">+=</span> <span class="n">a</span><span class="p">[</span><span class="n">id</span><span class="p">];</span>
<span class="p">};</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Blocks passed to enqueue_kernel cannot use global variables or stack
variables local to the enclosing lexical scope that are a pointer type in
the <code>local</code> or <code>private</code> address space.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">foo</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lptr</span><span class="p">,</span> <span class="p">...)</span>
<span class="p">{</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="fm">get_default_queue</span><span class="p">(),</span>
<span class="n">CLK_ENQUEUE_FLAGS_WAIT_KERNEL</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="o">^</span><span class="p">{</span>
<span class="kt">size_t</span> <span class="n">id</span> <span class="o">=</span> <span class="fm">get_global_id</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">p</span> <span class="o">=</span> <span class="n">lptr</span><span class="p">;</span> <span class="c1">// undefined behavior</span>
<span class="p">}</span> <span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="arguments-that-are-a-pointer-type-to-local-address-space"><a class="anchor" href="#arguments-that-are-a-pointer-type-to-local-address-space"></a>6.15.19.2. Arguments That are a Pointer Type to Local Address Space</h5>
<div class="paragraph">
<p>A block passed to enqueue_kernel can have arguments declared to be a pointer
to <code>local</code> memory.
The enqueue_kernel built-in function variants allow blocks to be enqueued
with a variable number of arguments.
Each argument must be declared to be a <code>void</code> pointer to local memory.
These enqueue_kernel built-in function variants also have a corresponding
number of arguments each of type <code>uint</code> that follow the block argument.
These arguments specify the size of each local memory pointer argument of
the enqueued block.</p>
</div>
<div class="paragraph">
<p>Some examples follow:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_func_A_local_arg1</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lptr</span><span class="p">,</span> <span class="p">...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_func_A_local_arg2</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span>
<span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="n">lptr1</span><span class="p">,</span> <span class="nx">local</span> <span class="kt">float4</span> <span class="o">*</span><span class="n">lptr2</span><span class="p">,</span> <span class="p">...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_func_B</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="p">...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="kt">ndrange_t</span> <span class="n">ndrange</span> <span class="o">=</span> <span class="fm">ndrange_1D</span><span class="p">(...);</span>
<span class="kt">uint</span> <span class="n">local_mem_size</span> <span class="o">=</span> <span class="n">compute_local_mem_size</span><span class="p">();</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="fm">get_default_queue</span><span class="p">(),</span>
<span class="n">CLK_ENQUEUE_FLAGS_WAIT_KERNEL</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="o">^</span><span class="p">(</span><span class="nx">local</span> <span class="kt">void</span> <span class="o">*</span><span class="n">p</span><span class="p">){</span>
<span class="n">my_func_A_local_arg1</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="p">)</span><span class="n">p</span><span class="p">,</span> <span class="p">...);},</span>
<span class="n">local_mem_size</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">my_func_C</span><span class="p">(</span><span class="nx">global</span> <span class="kt">int</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="p">...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="kt">ndrange_t</span> <span class="n">ndrange</span> <span class="o">=</span> <span class="fm">ndrange_1D</span><span class="p">(...);</span>
<span class="kt">void</span> <span class="p">(</span><span class="o">^</span><span class="n">my_blk_A</span><span class="p">)(</span><span class="nx">local</span> <span class="kt">void</span> <span class="o">*</span><span class="p">,</span> <span class="nx">local</span> <span class="kt">void</span> <span class="o">*</span><span class="p">)</span> <span class="o">=</span>
<span class="o">^</span><span class="p">(</span><span class="nx">local</span> <span class="kt">void</span> <span class="o">*</span><span class="n">lptr1</span><span class="p">,</span> <span class="nx">local</span> <span class="kt">void</span> <span class="o">*</span><span class="n">lptr2</span><span class="p">){</span>
<span class="n">my_func_A_local_arg2</span><span class="p">(</span>
<span class="n">a</span><span class="p">,</span>
<span class="p">(</span><span class="nx">local</span> <span class="kt">int</span> <span class="o">*</span><span class="p">)</span><span class="n">lptr1</span><span class="p">,</span>
<span class="p">(</span><span class="nx">local</span> <span class="kt">float4</span> <span class="o">*</span><span class="p">)</span><span class="n">lptr2</span><span class="p">,</span> <span class="p">...);};</span>
<span class="c1">// calculate local memory size for lptr</span>
<span class="c1">// argument in local address space for my_blk_A</span>
<span class="kt">uint</span> <span class="n">local_mem_size</span> <span class="o">=</span> <span class="n">compute_local_mem_size</span><span class="p">();</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="fm">get_default_queue</span><span class="p">(),</span>
<span class="n">CLK_ENQUEUE_FLAGS_WAIT_KERNEL</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="n">my_blk_A</span><span class="p">,</span>
<span class="n">local_mem_size</span><span class="p">,</span> <span class="n">local_mem_size</span><span class="o">*</span><span class="mi">4</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="a-complete-example"><a class="anchor" href="#a-complete-example"></a>6.15.19.3. A Complete Example</h5>
<div class="paragraph">
<p>The example below shows how to implement an iterative algorithm where the
host enqueues the first instance of the nd-range kernel (dp_func_A).
The kernel dp_func_A will launch a kernel (evaluate_dp_work_A) that will
determine if new nd-range work needs to be performed.
If new nd-range work does need to be performed, then evaluate_dp_work_A will
enqueue a new instance of dp_func_A.
This process is repeated until all the work is completed.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">dp_func_A</span><span class="p">(</span><span class="kt">queue_t</span> <span class="n">q</span><span class="p">,</span> <span class="p">...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="c1">// queue a single instance of evaluate_dp_work_A to</span>
<span class="c1">// device queue q. queued kernel begins execution after</span>
<span class="c1">// kernel dp_func_A finishes</span>
<span class="k">if</span> <span class="p">(</span><span class="fm">get_global_id</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span>
<span class="p">{</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="n">q</span><span class="p">,</span>
<span class="n">CLK_ENQUEUE_FLAGS_WAIT_KERNEL</span><span class="p">,</span>
<span class="fm">ndrange_1D</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span>
<span class="o">^</span><span class="p">{</span><span class="n">evaluate_dp_work_A</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="p">...);});</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">evaluate_dp_work_A</span><span class="p">(</span><span class="kt">queue_t</span> <span class="n">q</span><span class="p">,...)</span>
<span class="p">{</span>
<span class="c1">// check if more work needs to be performed</span>
<span class="kt">bool</span> <span class="n">more_work</span> <span class="o">=</span> <span class="n">check_new_work</span><span class="p">(...);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">more_work</span><span class="p">)</span>
<span class="p">{</span>
<span class="kt">size_t</span> <span class="n">global_work_size</span> <span class="o">=</span> <span class="n">compute_global_size</span><span class="p">(...);</span>
<span class="kt">void</span> <span class="p">(</span><span class="o">^</span><span class="n">dp_func_A_blk</span><span class="p">)(</span><span class="kt">void</span><span class="p">)</span> <span class="o">=</span>
<span class="o">^</span><span class="p">{</span><span class="n">dp_func_A</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="p">...});</span>
<span class="c1">// get local WG-size for kernel dp_func_A</span>
<span class="kt">size_t</span> <span class="n">local_work_size</span> <span class="o">=</span>
<span class="n">get_kernel_work_group_size</span><span class="p">(</span><span class="n">dp_func_A_blk</span><span class="p">);</span>
<span class="c1">// build nd-range descriptor</span>
<span class="kt">ndrange_t</span> <span class="n">ndrange</span> <span class="o">=</span> <span class="fm">ndrange_1D</span><span class="p">(</span><span class="n">global_work_size</span><span class="p">,</span>
<span class="n">local_work_size</span><span class="p">);</span>
<span class="c1">// enqueue dp_func_A</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="n">q</span><span class="p">,</span>
<span class="n">CLK_ENQUEUE_FLAGS_WAIT_KERNEL</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="n">dp_func_A_blk</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">...</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="determining-when-a-child-kernel-begins-execution"><a class="anchor" href="#determining-when-a-child-kernel-begins-execution"></a>6.15.19.4. Determining when a Child Kernel Begins Execution</h5>
<div class="paragraph">
<p>The <code>kernel_enqueue_flags_t</code> <sup class="footnote">[<a id="_footnoteref_91" class="footnote" href="#_footnotedef_91" title="View footnote.">91</a>]</sup> argument
to the <code>enqueue_kernel</code> built-in functions can be used to specify when the child
kernel begins execution.
Supported values are described in the <a href="#table-kernel-enqueue-flags">following table</a>:</p>
</div>
<table id="table-kernel-enqueue-flags" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 45. Kernel Enqueue Flags</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top"><code>kernel_enqueue_flags_t</code> enum</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CLK_ENQUEUE_FLAGS_NO_WAIT</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates that the enqueued kernels do not need to wait for the parent
kernel to finish execution before they begin execution.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CLK_ENQUEUE_FLAGS_WAIT_KERNEL</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates that all work-items of the parent kernel must finish
executing and all immediate <sup class="footnote">[<a id="_footnoteref_92" class="footnote" href="#_footnotedef_92" title="View footnote.">92</a>]</sup> side
effects committed before the enqueued child kernel may begin execution.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CLK_ENQUEUE_FLAGS_WAIT_WORK_GROUP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates that the enqueued kernels wait only for the work-group that
enqueued the kernels to finish before they begin execution.
<sup class="footnote">[<a id="_footnoteref_93" class="footnote" href="#_footnotedef_93" title="View footnote.">93</a>]</sup></p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The <code>kernel_enqueue_flags_t</code> flags are useful when a kernel enqueued from
the host and executing on a device enqueues kernels on the device.
The kernel enqueued from the host may not have an event associated with it.
The <code>kernel_enqueue_flags_t</code> flags allow the developer to indicate when the
child kernels can begin execution.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="sect4">
<h5 id="determining-when-a-parent-kernel-has-finished-execution"><a class="anchor" href="#determining-when-a-parent-kernel-has-finished-execution"></a>6.15.19.5. Determining When a Parent Kernel has Finished Execution</h5>
<div class="paragraph">
<p>A parent kernel&#8217;s execution status is considered to be complete when it and
all its child kernels have finished execution.
The execution status of a parent kernel will be <code>CL_COMPLETE</code> if this kernel
and all its child kernels finish execution successfully.
The execution status of the kernel will be an error code (given by a
negative integer value) if it or any of its child kernels encounter an
error, or are abnormally terminated.</p>
</div>
<div class="paragraph">
<p>For example, assume that the host enqueues a kernel <code>k</code> for execution on a
device.
Kernel <code>k</code> when executing on the device enqueues kernels <code>A</code> and <code>B</code> to a
device queue(s).
The enqueue_kernel call to enqueue kernel <code>B</code> specifies the event associated
with kernel <code>A</code> in the <code>event_wait_list</code> argument, i.e. wait for kernel <code>A</code>
to finish execution before kernel <code>B</code> can begin execution.
Let&#8217;s assume kernel <code>A</code> enqueues kernels <code>X</code>, <code>Y</code> and <code>Z</code>.
Kernel <code>A</code> is considered to have finished execution, i.e. its execution
status is <code>CL_COMPLETE</code>, only after <code>A</code> and the kernels <code>A</code> enqueued (and
any kernels these enqueued kernels enqueue and so on) have finished
execution.</p>
</div>
</div>
<div class="sect4">
<h5 id="built-in-functions-kernel-query-functions"><a class="anchor" href="#built-in-functions-kernel-query-functions"></a>6.15.19.6. Built-in Functions - Kernel Query Functions</h5>
<div class="openblock">
<div class="content">
<table id="table-builtin-kernel-query" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 46. Built-in Kernel Query Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Built-in Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>get_kernel_work_group_size</strong>(void (^block)(void))<br>
uint <strong>get_kernel_work_group_size</strong>(void (^block)(local void <strong>, &#8230;&#8203;))</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>device_<wbr>enqueue_<wbr>local_<wbr>arg_<wbr>types</code> extension macro is supported:</p>
<p class="tableblock"> uint *get_kernel_work_group_size</strong>(void (^block)(local gentype *, &#8230;&#8203;))</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">This provides a mechanism to query the maximum work-group size that
can be used to execute a block on a specific device given by <em>device</em>.</p>
<p class="tableblock"> <em>block</em> specifies the block to be enqueued.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>get_kernel_<wbr>preferred_<wbr>work_<wbr>group_<wbr>size_<wbr>multiple</strong>(
void (^block)(void))<br>
uint <strong>get_kernel_<wbr>preferred_<wbr>work_<wbr>group_<wbr>size_<wbr>multiple</strong>(
void (^block)(local void <strong>, &#8230;&#8203;))</p>
<p class="tableblock"> If the <code>cl_khr_<wbr>device_<wbr>enqueue_<wbr>local_<wbr>arg_<wbr>types</code> extension macro is supported:</p>
<p class="tableblock"> uint *get_kernel_<wbr>preferred_<wbr>work_<wbr>group_<wbr>size_<wbr>multiple</strong>(
void (^block)(local gentype *, &#8230;&#8203;))</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the preferred multiple of work-group size for launch.
This is a performance hint.
Specifying a work-group size that is not a multiple of the value
returned by this query as the value of the local work size argument to
enqueue_kernel will not fail to enqueue the block for execution unless
the work-group size specified is larger than the device maximum.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect4">
<h5 id="built-in-functions-queuing-other-commands"><a class="anchor" href="#built-in-functions-queuing-other-commands"></a>6.15.19.7. Built-in Functions - Queuing Other Commands</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following table describes the list of built-in functions that can be
used to enqueue commands such as a marker.</p>
</div>
<table id="table-builtin-other-enqueue" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 47. Built-in Other Enqueue Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Built-in Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>enqueue_marker</strong>(queue_t <em>queue</em>, uint <em>num_events_in_wait_list</em>,
const clk_event_t *<em>event_wait_list</em>, clk_event_t *<em>event_ret</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enqueue a marker command to <em>queue</em>.</p>
<p class="tableblock"> The marker command waits for a list of events specified by
<em>event_wait_list</em> to complete before the marker completes.</p>
<p class="tableblock"> <em>event_ret</em> must not be <code>NULL</code> as otherwise this is a no-op.</p>
<p class="tableblock"> If an event is returned, <strong>enqueue_marker</strong> performs an implicit retain
on the returned event.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <strong>enqueue_marker</strong> built-in function returns <code>CLK_SUCCESS</code> if the marked
command is enqueued successfully and returns <code>CLK_ENQUEUE_FAILURE</code>
otherwise.
If the -g compile option is specified in compiler options passed to
<strong>clCompileProgram</strong> or <strong>clBuildProgram</strong>, the following errors may be returned
instead of <code>CLK_ENQUEUE_FAILURE</code> to indicate why <strong>enqueue_marker</strong> failed to
enqueue the marker command:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CLK_INVALID_QUEUE</code> if <em>queue</em> is not a valid device queue.</p>
</li>
<li>
<p><code>CLK_INVALID_EVENT_WAIT_LIST</code> if <em>event_wait_list</em> is <code>NULL</code>, or if
<em>event_wait_list</em> is not <code>NULL</code> and <em>num_events_in_wait_list</em> is 0, or
if event objects in <em>event_wait_list</em> are not valid events.</p>
</li>
<li>
<p><code>CLK_DEVICE_QUEUE_FULL</code> if <em>queue</em> is full.</p>
</li>
<li>
<p><code>CLK_EVENT_ALLOCATION_FAILURE</code> if <em>event_ret</em> is not <code>NULL</code> and an event
could not be allocated.</p>
</li>
<li>
<p><code>CLK_OUT_OF_RESOURCES</code> if there is a failure to queue the block in
<em>queue</em> because of insufficient resources needed to execute the kernel.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="built-in-functions-event-functions"><a class="anchor" href="#built-in-functions-event-functions"></a>6.15.19.8. Built-in Functions - Event Functions</h5>
<div class="openblock">
<div class="content">
<div class="paragraph">
<p>The following table describes the list of built-in functions that work on
events.</p>
</div>
<table id="table-builtin-event" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 48. Built-in Event Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Built-in Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>retain_event</strong>(clk_event_t <em>event</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Increments the event reference count.
Behavior is undefined if <em>event</em> is not a valid event.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>release_event</strong>(clk_event_t <em>event</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Decrements the event reference count.
The event object is deleted once the event reference count is zero,
the specific command identified by this event has completed (or
terminated), and there are no commands in any device command-queue that
require a wait for this event to complete.
Behavior is undefined if <em>event</em> is not a valid event.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">clk_event_t <strong>create_user_event</strong>()</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Create a user event.
Returns the user event.
The execution status of the user event created is set to
<code>CL_SUBMITTED</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">bool <strong>is_valid_event</strong>(clk_event_t <em>event</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>true</em> if <em>event</em> is a valid event.
Otherwise returns <em>false</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>set_user_event_status</strong>(clk_event_t <em>event</em>, int <em>status</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Sets the execution status of a user event.
Behavior is undefined if <em>event</em> is not a valid event returned by
<strong>create_user_event</strong>.
<em>status</em> can be either <code>CL_COMPLETE</code> or a negative integer value
indicating an error.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>capture_event_profiling_info</strong>(clk_event_t <em>event</em>,
clk_profiling_info <em>name</em>, global void *<em>value</em>)</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>Captures the profiling information for functions that are enqueued as
commands.
These enqueued commands are identified by unique event objects.
The profiling information will be available in <em>value</em> once the
command identified by <em>event</em> has completed.</p>
</div>
<div class="paragraph">
<p>Behavior is undefined if <em>event</em> is not a valid event returned by
<strong>enqueue_kernel</strong>.</p>
</div>
<div class="paragraph">
<p><em>name</em> identifies which profiling information is to be queried and can be:</p>
</div>
<div class="paragraph">
<p><code>CLK_PROFILING_COMMAND_EXEC_TIME</code></p>
</div>
<div class="paragraph">
<p><em>value</em> is a pointer to two 64-bit values.</p>
</div>
<div class="paragraph">
<p>The first 64-bit value describes the elapsed time <code>CL_PROFILING_<wbr>COMMAND_<wbr>END</code>
- <code>CL_PROFILING_<wbr>COMMAND_<wbr>START</code> for the command identified by <em>event</em> in
nanoseconds.</p>
</div>
<div class="paragraph">
<p>The second 64-bit value describes the elapsed time
<code>CL_PROFILING_<wbr>COMMAND_<wbr>COMPLETE</code> - <code>CL_PROFILING_<wbr>COMMAND_<wbr>START</code> for the
command identified by <em>event</em> in nanoseconds.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The behavior of capture_event_profiling_info when called multiple times for
the same <em>event</em> is undefined.</p>
</div>
</td>
</tr>
</table>
</div></div></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Events can be used to identify commands enqueued to a command-queue from the
host.
These events created by the OpenCL runtime can only be used on the host,
i.e. as events passed in the <em>event_wait_list</em> argument to various
enqueue APIs or runtime APIs that take events as arguments, such as
<strong>clRetainEvent</strong>, <strong>clReleaseEvent</strong>, and <strong>clGetEventProfilingInfo</strong>.</p>
</div>
<div class="paragraph">
<p>Similarly, events can be used to identify commands enqueued to a device
queue (from a kernel).
These event objects cannot be passed to the host or used by OpenCL runtime
APIs such as the enqueue APIs or runtime APIs that take event arguments.</p>
</div>
<div class="paragraph">
<p><strong>clRetainEvent</strong> and <strong>clReleaseEvent</strong> will return <code>CL_INVALID_<wbr>OPERATION</code> if
<em>event</em> specified is an event that refers to any kernel enqueued to a device
queue using <strong>enqueue_kernel</strong> or <strong>enqueue_marker</strong>, or is a user event created
by <strong>create_user_event</strong>.</p>
</div>
<div class="paragraph">
<p>Similarly, <strong>clSetUserEventStatus</strong> can only be used to set the execution
status of events created using <strong>clCreateUserEvent</strong>.
User events created on the device can be set using set_user_event_status
built-in function.</p>
</div>
<div class="paragraph">
<p>The example below shows how events can be used with kernels enqueued to
multiple device queues.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">extern</span> <span class="kt">void</span> <span class="nf">barA_kernel</span><span class="p">(...);</span>
<span class="k">extern</span> <span class="kt">void</span> <span class="nf">barB_kernel</span><span class="p">(...);</span>
<span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">foo</span><span class="p">(</span><span class="kt">queue_t</span> <span class="n">q0</span><span class="p">,</span> <span class="n">queue</span> <span class="n">q1</span><span class="p">,</span> <span class="p">...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="kt">clk_event_t</span> <span class="n">evt0</span><span class="p">;</span>
<span class="c1">// enqueue kernel to queue q0</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="n">q0</span><span class="p">,</span>
<span class="n">CLK_ENQUEUE_FLAGS_NO_WAIT</span><span class="p">,</span>
<span class="n">ndrange_A</span><span class="p">,</span>
<span class="mi">0</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">evt0</span><span class="p">,</span>
<span class="o">^</span><span class="p">{</span><span class="n">barA_kernel</span><span class="p">(...);}</span> <span class="p">);</span>
<span class="c1">// enqueue kernel to queue q1</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="n">q1</span><span class="p">,</span>
<span class="n">CLK_ENQUEUE_FLAGS_NO_WAIT</span><span class="p">,</span>
<span class="n">ndrange_B</span><span class="p">,</span>
<span class="mi">1</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">evt0</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span>
<span class="o">^</span><span class="p">{</span><span class="n">barB_kernel</span><span class="p">(...);}</span> <span class="p">);</span>
<span class="c1">// release event evt0. This will get released</span>
<span class="c1">// after barA_kernel enqueued in queue q0 has finished</span>
<span class="c1">// execution and barB_kernel enqueued in queue q1 and</span>
<span class="c1">// waits for evt0 is submitted for execution, i.e. wait</span>
<span class="c1">// for evt0 is satisfied.</span>
<span class="fm">release_event</span><span class="p">(</span><span class="n">evt0</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The example below shows how the marker command can be used with kernels
enqueued to a device queue.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="nx">kernel</span> <span class="kt">void</span>
<span class="nf">foo</span><span class="p">(</span><span class="kt">queue_t</span> <span class="n">q</span><span class="p">,</span> <span class="p">...)</span>
<span class="p">{</span>
<span class="p">...</span>
<span class="kt">clk_event_t</span> <span class="n">marker_event</span><span class="p">;</span>
<span class="kt">clk_event_t</span> <span class="n">events</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="n">q</span><span class="p">,</span>
<span class="n">CLK_ENQUEUE_FLAGS_NO_WAIT</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="mi">0</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">events</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
<span class="o">^</span><span class="p">{</span><span class="n">barA_kernel</span><span class="p">(...);}</span> <span class="p">);</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="n">q</span><span class="p">,</span>
<span class="n">CLK_ENQUEUE_FLAGS_NO_WAIT</span><span class="p">,</span>
<span class="n">ndrange</span><span class="p">,</span>
<span class="mi">0</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">events</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
<span class="o">^</span><span class="p">{</span><span class="n">barB_kernel</span><span class="p">(...);}</span> <span class="p">);</span>
<span class="c1">// barA_kernel and barB_kernel can be executed</span>
<span class="c1">// out-of-order. We need to wait for both these</span>
<span class="c1">// kernels to finish execution before barC_kernel</span>
<span class="c1">// starts execution so we enqueue a marker command and</span>
<span class="c1">// then enqueue barC_kernel that waits on the event</span>
<span class="c1">// associated with the marker.</span>
<span class="n">enqueue_marker</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">events</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">marker_event</span><span class="p">);</span>
<span class="fm">enqueue_kernel</span><span class="p">(</span><span class="n">q</span><span class="p">,</span>
<span class="n">CLK_ENQUEUE_FLAGS_NO_WAIT</span><span class="p">,</span>
<span class="mi">1</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">marker_event</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span>
<span class="o">^</span><span class="p">{</span><span class="n">barC_kernel</span><span class="p">(...);}</span> <span class="p">);</span>
<span class="fm">release_event</span><span class="p">(</span><span class="n">events</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
<span class="fm">release_event</span><span class="p">(</span><span class="n">events</span><span class="p">[</span><span class="mi">1</span><span class="p">]);</span>
<span class="fm">release_event</span><span class="p">(</span><span class="n">marker_event</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect4">
<h5 id="built-in-functions-helper-functions"><a class="anchor" href="#built-in-functions-helper-functions"></a>6.15.19.9. Built-in Functions - Helper Functions</h5>
<div class="openblock">
<div class="content">
<table id="table-builtin-helper" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 49. Built-in Helper Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Built-in Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">queue_t <strong>get_default_queue</strong>(void)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the default device queue.
If a default device queue has not been created, <code>CLK_NULL_QUEUE</code> is
returned.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">ndrange_t <strong>ndrange_1D</strong>(size_t <em>global_work_size</em>)<br>
ndrange_t <strong>ndrange_1D</strong>(size_t <em>global_work_size</em>,
size_t <em>local_work_size</em>)<br>
ndrange_t <strong>ndrange_1D</strong>(size_t <em>global_work_offset</em>,
size_t <em>global_work_size</em>, size_t <em>local_work_size</em>)<br>
ndrange_t <strong>ndrange_2D</strong>(const size_t <em>global_work_size</em>[2])<br>
ndrange_t <strong>ndrange_2D</strong>(const size_t <em>global_work_size</em>[2],
const size_t <em>local_work_size</em>[2])<br>
ndrange_t <strong>ndrange_2D</strong>(const size_t <em>global_work_offset</em>[2],
const size_t <em>global_work_size</em>[2],
const size_t <em>local_work_size</em>[2])<br>
ndrange_t <strong>ndrange_3D</strong>(const size_t <em>global_work_size</em>[3])<br>
ndrange_t <strong>ndrange_3D</strong>(const size_t <em>global_work_size</em>[3],
const size_t <em>local_work_size</em>[3])<br>
ndrange_t <strong>ndrange_3D</strong>(const size_t <em>global_work_offset</em>[3],
const size_t <em>global_work_size</em>[3],
const size_t <em>local_work_size</em>[3])</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Builds a 1D, 2D or 3D ND-range descriptor.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="sub-group-functions"><a class="anchor" href="#sub-group-functions"></a>6.15.20. Sub-Group Functions</h4>
<div class="openblock">
<div class="content">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for
the <code>cl_khr_<wbr>subgroups</code> extension, or
OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>subgroups</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <a href="#table-collective-functions">following table</a> describes OpenCL C
programming language built-in functions that operate on a sub-group level.
These built-in functions must be encountered by all work-items in the
sub-group executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be the one of the
supported built-in scalar data types <code>int</code>, <code>uint</code>, <code>long</code>
<sup class="footnote">[<a id="_footnoteref_94" class="footnote" href="#_footnotedef_94" title="View footnote.">94</a>]</sup>, <code>ulong</code>, <code>half</code>
<sup class="footnote">[<a id="_footnoteref_95" class="footnote" href="#_footnotedef_95" title="View footnote.">95</a>]</sup>, <code>float</code>, and <code>double</code>
<sup class="footnote">[<a id="_footnoteref_96" class="footnote" href="#_footnotedef_96" title="View footnote.">96</a>]</sup>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If
the <code>cl_khr_<wbr>subgroup_<wbr>extended_<wbr>types</code> extension macro or
OpenCL C 3.1 or newer is supported, the generic type name <code>gentype</code> may
additionally be <code>char</code>, <code>uchar</code>, <code>short</code>, and <code>ushort</code>.
For the <code>sub_group_broadcast</code> function, <code>gentype</code> may additionally be one of
the supported built-in vector data types <code>char<em>n</em></code>, <code>uchar<em>n</em></code>,
<code>short<em>n</em></code>, <code>ushort<em>n</em></code>, <code>int<em>n</em></code>, <code>uint<em>n</em></code>, <code>long<em>n</em></code>,
<code>ulong<em>n</em></code>, <code>float<em>n</em></code>, <code>half<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_97" class="footnote" href="#_footnotedef_97" title="View footnote.">97</a>]</sup>, or
<code>double<em>n</em></code> <sup class="footnote">[<a id="_footnoteref_98" class="footnote" href="#_footnotedef_98" title="View footnote.">98</a>]</sup>.
</td>
</tr>
</table>
</div>
<table id="table-collective-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 50. Built-in Sub-Group Collective Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>sub_group_all</strong> (int <em>predicate</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Evaluates <em>predicate</em> for all work-items in the sub-group and returns a
non-zero value if <em>predicate</em> evaluates to non-zero for all work-items in
the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int <strong>sub_group_any</strong> (int <em>predicate</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Evaluates <em>predicate</em> for all work-items in the sub-group and returns a
non-zero value if <em>predicate</em> evaluates to non-zero for any work-items in
the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sub_group_broadcast</strong> (<br>
gentype <em>x</em>, uint <em>sub_group_local_id</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Broadcast the value of <em>x</em> for work-item identified by
<em>sub_group_local_id</em> (value returned by <strong>get_sub_group_local_id</strong>) to all
work-items in the sub-group.</p>
<p class="tableblock"> Behavior is undefined when the value of <em>sub_group_local_id</em> is not
equivalent for all work-items in the sub-group.</p>
<p class="tableblock"> Behavior is undefined when <em>sub_group_local_id</em> is greater or equal to the
sub-group size.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sub_group_reduce_&lt;op&gt;</strong> (<br>
gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Return result of reduction operation specified by <strong>&lt;op&gt;</strong> for all values of
<em>x</em> specified by work-items in a sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sub_group_scan_exclusive_&lt;op&gt;</strong> (<br>
gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Do an exclusive scan operation specified by <strong>&lt;op&gt;</strong> of all values specified
by work-items in a sub-group.
The scan results are returned for each work-item.</p>
<p class="tableblock"> The scan order is defined by increasing sub-group local ID within the
sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">gentype <strong>sub_group_scan_inclusive_&lt;op&gt;</strong> (<br>
gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Do an inclusive scan operation specified by <strong>&lt;op&gt;</strong> of all values specified
by work-items in a sub-group.
The scan results are returned for each work-item.</p>
<p class="tableblock"> The scan order is defined by increasing sub-group local ID within the
sub-group.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <strong>&lt;op&gt;</strong> in <strong>sub_group_reduce_&lt;op&gt;</strong>, <strong>sub_group_scan_inclusive_&lt;op&gt;</strong> and <strong>sub_group_scan_exclusive_&lt;op&gt;</strong> defines the operator and can be <strong>add</strong>, <strong>min</strong> or <strong>max</strong>.</p>
</div>
<div class="paragraph">
<p>The exclusive scan operation takes a binary operator <strong>op</strong> with an identity I and <em>n</em> (where <em>n</em> is the size of the sub-group) elements [a<sub>0</sub>, a<sub>1</sub>, &#8230;&#8203; a<sub>n-1</sub>] and returns [I, a<sub>0</sub>, (a<sub>0</sub> <strong>op</strong> a<sub>1</sub>), &#8230;&#8203; (a<sub>0</sub> <strong>op</strong> a<sub>1</sub> <strong>op</strong> &#8230;&#8203; <strong>op</strong> a<sub>n-2</sub>)].</p>
</div>
<div class="paragraph">
<p>The inclusive scan operation takes a binary operator <strong>op</strong> with an identity I and <em>n</em> (where <em>n</em> is the size of the sub-group) elements [a<sub>0</sub>, a<sub>1</sub>, &#8230;&#8203; a<sub>n-1</sub>] and returns [a<sub>0</sub>, (a<sub>0</sub> <strong>op</strong> a<sub>1</sub>), &#8230;&#8203; (a<sub>0</sub> <strong>op</strong> a<sub>1</sub> <strong>op</strong> &#8230;&#8203; <strong>op</strong> a<sub>n-1</sub>)].</p>
</div>
<div class="paragraph">
<p>If <strong>op</strong> = <strong>add</strong>, the identity I is 0.
If <strong>op</strong> = <strong>min</strong>, the identity I is <code>INT_MAX</code>, <code>UINT_MAX</code>, <code>LONG_MAX</code>, <code>ULONG_MAX</code>, for <code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code> types and is <code>+INF</code> for
floating-point types.
Similarly if <strong>op</strong> = max, the identity I is <code>INT_MIN</code>, 0, <code>LONG_MIN</code>, 0 and <code>-INF</code>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The order of floating-point operations is not guaranteed for the <strong>sub_group_reduce_&lt;op&gt;</strong>, <strong>sub_group_scan_inclusive_&lt;op&gt;</strong> and <strong>sub_group_scan_exclusive_&lt;op&gt;</strong> built-in functions that operate on <code>half</code>, <code>float</code> and <code>double</code> data types.
The order of these floating-point operations is also non-deterministic for a given sub-group.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in the following table <a href="#unified-spec">requires</a> support for
the <code>cl_khr_<wbr>subgroups</code> extension, or
OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>subgroups</code> and <code>__opencl_c_<wbr>pipes</code>
features.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <a href="#table-pipe-functions">following table</a> describes built-in pipe
functions that operate at a sub-group level.
These built-in functions must be encountered by all work-items in a sub-group
executing the kernel with the same argument values, otherwise the behavior
is undefined.
We use the generic type name <code>gentype</code> to indicate the built-in OpenCL C
scalar or vector integer or floating-point data types or any user defined
type built from these scalar and vector data types can be used as the type
for the arguments to the pipe functions listed in <em>table 6.29</em>.</p>
</div>
<table id="table-pipe-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 51. Built-in Sub-Group Pipe Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">reserve_id_t <strong>sub_group_reserve_read_pipe</strong> (<br>
read_only pipe gentype <em>pipe</em>,<br>
uint <em>num_packets</em>)</p>
<p class="tableblock"> reserve_id_t <strong>sub_group_reserve_write_pipe</strong> (<br>
write_only pipe gentype <em>pipe</em>,<br>
uint <em>num_packets</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Reserve <em>num_packets</em> entries for reading from or writing to <em>pipe</em>.
Returns a valid non-zero reservation ID if the reservation is successful
and 0 otherwise.</p>
<p class="tableblock"> The reserved pipe entries are referred to by indices that go from 0 &#8230;&#8203;
<em>num_packets</em> - 1.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">void <strong>sub_group_commit_read_pipe</strong> (<br>
read_only pipe gentype <em>pipe</em>,<br>
reserve_id_t <em>reserve_id</em>)</p>
<p class="tableblock"> void <strong>sub_group_commit_write_pipe</strong> (<br>
write_only pipe gentype <em>pipe</em>,<br>
reserve_id_t <em>reserve_id</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates that all reads and writes to <em>num_packets</em> associated with
reservation <em>reserve_id</em> are completed.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Note: Reservations made by a sub-group are ordered in the pipe as they are
ordered in the program.
Reservations made by different sub-groups that belong to the same work-group
can be ordered using sub-group synchronization.
The order of sub-group based reservations that belong to different work
groups is implementation-defined.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in the following table <a href="#unified-spec">requires</a> support
the <code>cl_khr_<wbr>subgroups</code> extension, or
OpenCL C 3.0 or newer and the <code>__opencl_c_<wbr>subgroups</code> and
<code>__opencl_c_<wbr>device_<wbr>enqueue</code> features.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <a href="#table-kernel-query-functions">following table</a> describes built-in
functions to query sub-group information for a block to be enqueued.</p>
</div>
<table id="table-kernel-query-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 52. Built-in Sub-Group Kernel Query Functions</caption>
<colgroup>
<col style="width: 55.5555%;">
<col style="width: 44.4445%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Built-in Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>get_kernel_sub_group_count_for_ndrange</strong> (<br>
const ndrange_t <em>ndrange</em>,<br>
void (^block)(void));</p>
<p class="tableblock"> uint <strong>get_kernel_sub_group_count_for_ndrange</strong> (<br>
const ndrange_t <em>ndrange</em>,<br>
void (^block)(local void *, &#8230;&#8203;));</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of sub-groups in each work-group of the dispatch (except
for the last in cases where the global size does not divide cleanly into
work-groups) given the combination of the passed ndrange and block.</p>
<p class="tableblock"> <em>block</em> specifies the block to be enqueued.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uint <strong>get_kernel_max_sub_group_size_for_ndrange</strong> (<br>
const ndrange_t <em>ndrange</em>,<br>
void (^block)(void));<br></p>
<p class="tableblock"> uint <strong>get_kernel_max_sub_group_size_for_ndrange</strong> (<br>
const ndrange_t <em>ndrange</em>,<br>
void (^block)(local void *, &#8230;&#8203;));</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the maximum sub-group size for a block.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect4">
<h5 id="sub-group-ballot-functions"><a class="anchor" href="#sub-group-ballot-functions"></a>6.15.20.1. Built-in Sub-Group Ballot Functions</h5>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for the <code>cl_khr_<wbr>subgroup_<wbr>ballot</code> extension.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <a href="#table-ballot-functions">following table</a> describes OpenCL C
programming language built-in functions to allow work items in a sub-group
to collect and operate on ballots from work items in the sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.</p>
</div>
<div class="paragraph">
<p>For the <code>sub_group_non_uniform_broadcast</code> and <code>sub_group_broadcast_first</code>
functions, the generic type name <code>gentype</code> may be one of the supported
built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>, <code>int</code>,
<code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, <code>half</code> <sup class="footnote">[<a id="_footnoteref_99" class="footnote" href="#_footnotedef_99" title="View footnote.">99</a>]</sup>, and
<code>double</code> <sup class="footnote">[<a id="_footnoteref_100" class="footnote" href="#_footnotedef_100" title="View footnote.">100</a>]</sup>.</p>
</div>
<div class="paragraph">
<p>For the <code>sub_group_non_uniform_broadcast</code> function, the generic type name
<code>gentype</code> may additionally be one of the supported built-in vector data
types <code>char<em>n</em></code>, <code>uchar<em>n</em></code>, <code>short<em>n</em></code>, <code>ushort<em>n</em></code>, <code>int<em>n</em></code>,
<code>uint<em>n</em></code>, <code>long<em>n</em></code>, <code>ulong<em>n</em></code>, <code>float<em>n</em></code>, <code>half<em>n</em></code>
<sup class="footnote">[<a id="_footnoteref_101" class="footnote" href="#_footnotedef_101" title="View footnote.">101</a>]</sup>, or <code>double<em>n</em></code>
<sup class="footnote">[<a id="_footnoteref_102" class="footnote" href="#_footnotedef_102" title="View footnote.">102</a>]</sup>.</p>
</div>
<table id="table-ballot-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 53. Built-in Sub-Group Ballot Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_non_uniform_broadcast</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span>
<span class="kt">uint</span> <span class="n">index</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>value</em> for the work item with sub-group local ID equal to
<em>index</em>.</p>
<p class="tableblock"> Behavior is undefined when the value of <em>index</em> is not equivalent for
all active work items in the sub-group.</p>
<p class="tableblock"> The return value is undefined if the work item with sub-group local ID
equal to <em>index</em> is inactive or if <em>index</em> is greater than or equal to
the size of the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_broadcast_first</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>value</em> for the work item with the smallest sub-group local ID
among active work items in the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint4</span> <span class="n">sub_group_ballot</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a bitfield combining the <em>predicate</em> values from all work items
in the sub-group.
Bit zero of the first vector component represents the sub-group local ID
zero, with higher-order bits and subsequent vector components
representing, in order, increasing sub-group local IDs.
The representative bit in the bitfield is set if the work item is active
and the <em>predicate</em> is non-zero, and is unset otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_inverse_ballot</span><span class="p">(</span>
<span class="kt">uint4</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the predicate value for this work item in the sub-group from the
bitfield <em>value</em> representing predicate values from all work items in
the sub-group.
The predicate return value will be non-zero if the bit in the bitfield
<em>value</em> for this work item is set, and zero otherwise.</p>
<p class="tableblock"> Behavior is undefined when <em>value</em> is not equivalent for all active work
items in the sub-group.</p>
<p class="tableblock"> This is a specialized function that may perform better than the
equivalent <code>sub_group_ballot_bit_extract</code> on some implementations.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_ballot_bit_extract</span><span class="p">(</span>
<span class="kt">uint4</span> <span class="n">value</span><span class="p">,</span>
<span class="kt">uint</span> <span class="n">index</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the predicate value for the work item with sub-group local ID
equal to <em>index</em> from the bitfield <em>value</em> representing predicate values
from all work items in the sub-group.
The predicate return value will be non-zero if the bit in the bitfield
<em>value</em> for the work item with sub-group local ID equal to <em>index</em> is
set, and zero otherwise.</p>
<p class="tableblock"> The predicate return value is undefined if the work item with sub-group
local ID equal to <em>index</em> is greater than or equal to the size of the
sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint</span> <span class="n">sub_group_ballot_bit_count</span><span class="p">(</span>
<span class="kt">uint4</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of bits that are set in the bitfield <em>value</em>, only
considering the bits in <em>value</em> that represent predicate values
corresponding to sub-group local IDs less than the maximum sub-group
size within the dispatch (as returned by <code>get_max_sub_group_size</code>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint</span> <span class="n">sub_group_ballot_inclusive_scan</span><span class="p">(</span>
<span class="kt">uint4</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of bits that are set in the bitfield <em>value</em>, only
considering the bits in <em>value</em> representing work items with a sub-group
local ID less than or equal to this work item&#8217;s sub-group local ID.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint</span> <span class="n">sub_group_ballot_exclusive_scan</span><span class="p">(</span>
<span class="kt">uint4</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the number of bits that are set in the bitfield <em>value</em>, only
considering the bits in <em>value</em> representing work items with a sub-group
local ID less than this work item&#8217;s sub-group local ID.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint</span> <span class="n">sub_group_ballot_find_lsb</span><span class="p">(</span>
<span class="kt">uint4</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the smallest sub-group local ID with a bit set in the bitfield
<em>value</em>, only considering the bits in <em>value</em> that represent predicate
values corresponding to sub-group local IDs less than the maximum
sub-group size within the dispatch (as returned by
<code>get_max_sub_group_size</code>).
If no bits representing predicate values from all work items in the
sub-group are set in the bitfield <em>value</em> then the return value is
undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint</span> <span class="n">sub_group_ballot_find_msb</span><span class="p">(</span>
<span class="kt">uint4</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the largest sub-group local ID with a bit set in the bitfield
<em>value</em>, only considering the bits in <em>value</em> that represent predicate
values corresponding to sub-group local IDs less than the maximum
sub-group size within the dispatch (as returned by
<code>get_max_sub_group_size</code>).
If no bits representing predicate values from all work items in the
sub-group are set in the bitfield <em>value</em> then the return value is
undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint4</span> <span class="n">get_sub_group_eq_mask</span><span class="p">()</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Generates a bitmask where the bit is set in the bitmask if the bit index
equals the sub-group local ID and unset otherwise.
Bit zero of the first vector component represents the sub-group local ID
zero, with higher-order bits and subsequent vector components
representing, in order, increasing sub-group local IDs.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint4</span> <span class="n">get_sub_group_ge_mask</span><span class="p">()</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Generates a bitmask where the bit is set in the bitmask if the bit index
is greater than or equal to the sub-group local ID and less than the
maximum sub-group size, and unset otherwise.
Bit zero of the first vector component represents the sub-group local ID
zero, with higher-order bits and subsequent vector components
representing, in order, increasing sub-group local IDs.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint4</span> <span class="n">get_sub_group_gt_mask</span><span class="p">()</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Generates a bitmask where the bit is set in the bitmask if the bit index
is greater than the sub-group local ID and less than the maximum
sub-group size, and unset otherwise.
Bit zero of the first vector component represents the sub-group local ID
zero, with higher-order bits and subsequent vector components
representing, in order, increasing sub-group local IDs.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint4</span> <span class="n">get_sub_group_le_mask</span><span class="p">()</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Generates a bitmask where the bit is set in the bitmask if the bit index
is less than or equal to the sub-group local ID and unset otherwise.
Bit zero of the first vector component represents the sub-group local ID
zero, with higher-order bits and subsequent vector components
representing, in order, increasing sub-group local IDs.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint4</span> <span class="n">get_sub_group_lt_mask</span><span class="p">()</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Generates a bitmask where the bit is set in the bitmask if the bit index
is less than the sub-group local ID and unset otherwise.
Bit zero of the first vector component represents the sub-group local ID
zero, with higher-order bits and subsequent vector components
representing, in order, increasing sub-group local IDs.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="sub-group-clustered-reduction-functions"><a class="anchor" href="#sub-group-clustered-reduction-functions"></a>6.15.20.2. Built-in Sub-Group Clustered Reduction Functions</h5>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for the <code>cl_khr_<wbr>subgroup_<wbr>clustered_<wbr>reduce</code> extension.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>This section describes arithmetic operations that are performed on a subset
of work items in a sub-group, referred to as a cluster.
A cluster is described by a specified cluster size.
Work items in a sub-group are assigned to clusters such that for cluster
size <em>n</em>, the <em>n</em> work items in the sub-group with the smallest sub-group
local IDs are assigned to the first cluster, then the <em>n</em> remaining work
items with the smallest sub-group local IDs are assigned to the next
cluster, and so on.</p>
</div>
<div class="sect5">
<h6 id="_arithmetic_operations"><a class="anchor" href="#_arithmetic_operations"></a>6.15.20.2.1. Arithmetic Operations</h6>
<div class="paragraph">
<p>The table below describes the OpenCL C programming language built-in
functions that perform simple arithmetic operations on a cluster of work
items in a sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be one of the
supported built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>,
<code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, <code>half</code>
<sup class="footnote">[<a id="_footnoteref_103" class="footnote" href="#_footnotedef_103" title="View footnote.">103</a>]</sup>, and <code>double</code>
<sup class="footnote">[<a id="_footnoteref_104" class="footnote" href="#_footnotedef_104" title="View footnote.">104</a>]</sup>.</p>
</div>
<table id="table-clustered-reduce-math-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 54. Built-in Sub-Group Clustered Reduction Arithmetic Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_clustered_reduce_add</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_clustered_reduce_mul</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_clustered_reduce_min</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_clustered_reduce_max</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the summation, multiplication, minimum, or maximum of <em>value</em>
for all active work items in the sub-group within a cluster of the
specified <em>clustersize</em>.</p>
<p class="tableblock"> Behavior is undefined if <em>clustersize</em> is not an integer constant
expression, is not a power-of-two, or is greater than the maximum size of a
sub-group within the dispatch.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Note: The order of floating-point operations is not guaranteed for the
sub-group clustered reduction built-in functions that operate on
floating-point types, and the order of operations may additionally be
non-deterministic for a given sub-group.</p>
</div>
</div>
<div class="sect5">
<h6 id="_bitwise_operations"><a class="anchor" href="#_bitwise_operations"></a>6.15.20.2.2. Bitwise Operations</h6>
<div class="paragraph">
<p>The table below describes the OpenCL C programming language built-in
functions to perform simple bitwise integer operations across a cluster of
work items in a sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be the one of
the supported built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>,
<code>int</code>, <code>uint</code>, <code>long</code>, or <code>ulong</code>.</p>
</div>
<table id="table-clustered-reduce-bitwise-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 55. Built-in Sub-Group Clustered Reduction Bitwise Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_clustered_reduce_and</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_clustered_reduce_or</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_clustered_reduce_xor</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the bitwise <strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>value</em> for all active work
items in the sub-group within a cluster of the specified <em>clustersize</em>.</p>
<p class="tableblock"> Behavior is undefined if <em>clustersize</em> is not an integer constant
expression, is not a power-of-two, or is greater than the maximum size of a
sub-group within the dispatch.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect5">
<h6 id="_logical_operations"><a class="anchor" href="#_logical_operations"></a>6.15.20.2.3. Logical Operations</h6>
<div class="paragraph">
<p>The table below describes the OpenCL C programming language built-in
functions to perform simple logical operations across a cluster of work
items in a sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For these functions, a non-zero <em>predicate</em> argument or return value is
logically <code>true</code> and a zero <em>predicate</em> argument or return value is
logically <code>false</code>.</p>
</div>
<table id="table-clustered-reduce-logical-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 56. Built-in Sub-Group Clustered Reduction Logical Functions</caption>
<colgroup>
<col style="width: 60%;">
<col style="width: 40%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_clustered_reduce_logical_and</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span>
<span class="kt">int</span> <span class="n">sub_group_clustered_reduce_logical_or</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span>
<span class="kt">int</span> <span class="n">sub_group_clustered_reduce_logical_xor</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">clustersize</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the logical <strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>predicate</em> for all active
work items in the sub-group within a cluster of the specified
<em>clustersize</em>.</p>
<p class="tableblock"> Behavior is undefined if <em>clustersize</em> is not an integer constant
expression, is not a power-of-two, or is greater than the maximum size of a
sub-group within the dispatch.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect4">
<h5 id="_built_in_sub_group_non_uniform_scan_and_reduction_functions"><a class="anchor" href="#_built_in_sub_group_non_uniform_scan_and_reduction_functions"></a>6.15.20.3. Built-in Sub-Group Non-Uniform Scan and Reduction Functions</h5>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for the <code>cl_khr_<wbr>subgroup_<wbr>non_<wbr>uniform_<wbr>arithmetic</code> extension.
</td>
</tr>
</table>
</div>
<div class="sect5">
<h6 id="_arithmetic_operations_2"><a class="anchor" href="#_arithmetic_operations_2"></a>6.15.20.3.1. Arithmetic Operations</h6>
<div class="paragraph">
<p>The <a href="#table-non-uniform-math-functions">following table</a> describes the
OpenCL C programming language built-in functions that perform simple
arithmetic operations across work items in a sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be one of the
supported built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>,
<code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, <code>half</code>
<sup class="footnote">[<a id="_footnoteref_105" class="footnote" href="#_footnotedef_105" title="View footnote.">105</a>]</sup>, and <code>double</code>
<sup class="footnote">[<a id="_footnoteref_106" class="footnote" href="#_footnotedef_106" title="View footnote.">106</a>]</sup>.</p>
</div>
<table id="table-non-uniform-math-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 57. Built-in Sub-Group Non-Uniform Arithmetic Functions</caption>
<colgroup>
<col style="width: 60%;">
<col style="width: 40%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_non_uniform_reduce_add</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_reduce_min</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_reduce_max</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_reduce_mul</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the summation, multiplication, minimum, or maximum of <em>value</em>
for all active work items in the sub-group.</p>
<p class="tableblock"> Note: This behavior is the same as the <strong>add</strong>, <strong>min</strong>, and <strong>max</strong> reduction
built-in functions from <code>cl_khr_<wbr>subgroups</code> and OpenCL 2.1, except
these functions support additional types and need not be encountered by
all work items in the sub-group executing the kernel.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_inclusive_add</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_inclusive_min</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_inclusive_max</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_inclusive_mul</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an inclusive scan operation, which is the
summation, multiplication, minimum, or maximum of <em>value</em> for all active
work items in the sub-group with a sub-group local ID less than or equal
to this work item&#8217;s sub-group local ID.</p>
<p class="tableblock"> Note: This behavior is the same as the <strong>add</strong>, <strong>min</strong>, and <strong>max</strong> inclusive
scan built-in functions from <code>cl_khr_<wbr>subgroups</code> and OpenCL 2.1,
except these functions support additional types and need not be
encountered by all work items in the sub-group executing the kernel.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_exclusive_add</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_exclusive_min</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_exclusive_max</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_exclusive_mul</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an exclusive scan operation, which is the
summation, multiplication, minimum, or maximum of <em>value</em> for all active
work items in the sub-group with a sub-group local ID less than this
work item&#8217;s sub-group local ID.</p>
<p class="tableblock"> If there is no active work item in the sub-group with a sub-group local
ID less than this work item&#8217;s sub-group local ID then an identity value
<code>I</code> is returned.
For <strong>add</strong>, the identity value is <code>0</code>.
For <strong>min</strong>, the identity value is the largest representable value for
integer types, or <code>+INF</code> for floating-point types.
For <strong>max</strong>, the identity value is the minimum representable value for
integer types, or <code>-INF</code> for floating-point types.
For <strong>mul</strong>, the identity value is <code>1</code>.</p>
<p class="tableblock"> Note: This behavior is the same as the <strong>add</strong>, <strong>min</strong>, and <strong>max</strong> exclusive
scan built-in functions from <code>cl_khr_<wbr>subgroups</code> and OpenCL 2.1,
except these functions support additional types and need not be
encountered by all work items in the sub-group executing the kernel.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Note: The order of floating-point operations is not guaranteed for the
sub-group scan and reduction built-in functions that operate on
floating-point types, and the order of operations may additionally be
non-deterministic for a given sub-group.</p>
</div>
</div>
<div class="sect5">
<h6 id="_bitwise_operations_2"><a class="anchor" href="#_bitwise_operations_2"></a>6.15.20.3.2. Bitwise Operations</h6>
<div class="paragraph">
<p>The table below describes the OpenCL C programming language built-in
functions that perform simple bitwise integer operations across work items
in a sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be one of the
supported built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>,
<code>int</code>, <code>uint</code>, <code>long</code>, and <code>ulong</code>.</p>
</div>
<table id="table-non-uniform-bitwise-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 58. Built-in Sub-Group Non-Uniform Bitwise Functions</caption>
<colgroup>
<col style="width: 60%;">
<col style="width: 40%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_non_uniform_reduce_and</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_reduce_or</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_reduce_xor</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the bitwise <strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>value</em> for all active work
items in the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_inclusive_and</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_inclusive_or</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_inclusive_xor</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an inclusive scan operation, which is the bitwise
<strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>value</em> for all active work items in the
sub-group with a sub-group local ID less than or equal to this work
item&#8217;s sub-group local ID.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_exclusive_and</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_exclusive_or</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span>
<span class="kp">gentype</span> <span class="n">sub_group_non_uniform_scan_exclusive_xor</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an exclusive scan operation, which is the bitwise
<strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>value</em> for all active work items in the
sub-group with a sub-group local ID less than this work item&#8217;s sub-group
local ID.</p>
<p class="tableblock"> If there is no active work item in the sub-group with a sub-group local
ID less than this work item&#8217;s sub-group local ID then an identity value
<code>I</code> is returned.
For <strong>and</strong>, the identity value is <code>~0</code> (all bits set).
For <strong>or</strong> and <strong>xor</strong>, the identity value is <code>0</code>.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect5">
<h6 id="_logical_operations_2"><a class="anchor" href="#_logical_operations_2"></a>6.15.20.3.3. Logical Operations</h6>
<div class="paragraph">
<p>The table below describes the OpenCL C programming language built-in
functions that perform simple logical operations across work items in a
sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For these functions, a non-zero <em>predicate</em> argument or return value is
logically <code>true</code> and a zero <em>predicate</em> argument or return value is
logically <code>false</code>.</p>
</div>
<table id="table-non-uniform-logical-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 59. Built-in Sub-Group Non-Uniform Logical Functions</caption>
<colgroup>
<col style="width: 66.6666%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_non_uniform_reduce_logical_and</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span>
<span class="kt">int</span> <span class="n">sub_group_non_uniform_reduce_logical_or</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span>
<span class="kt">int</span> <span class="n">sub_group_non_uniform_reduce_logical_xor</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the logical <strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>predicate</em> for all active
work items in the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_non_uniform_scan_inclusive_logical_and</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span>
<span class="kt">int</span> <span class="n">sub_group_non_uniform_scan_inclusive_logical_or</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span>
<span class="kt">int</span> <span class="n">sub_group_non_uniform_scan_inclusive_logical_xor</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an inclusive scan operation, which is the logical
<strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>predicate</em> for all active work items in the
sub-group with a sub-group local ID less than or equal to this work
item&#8217;s sub-group local ID.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_non_uniform_scan_exclusive_logical_and</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span>
<span class="kt">int</span> <span class="n">sub_group_non_uniform_scan_exclusive_logical_or</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span>
<span class="kt">int</span> <span class="n">sub_group_non_uniform_scan_exclusive_logical_xor</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns the result of an exclusive scan operation, which is the logical
<strong>and</strong>, <strong>or</strong>, or <strong>xor</strong> of <em>predicate</em> for all active work items in the
sub-group with a sub-group local ID less than this work item&#8217;s sub-group
local ID.</p>
<p class="tableblock"> If there is no active work item in the sub-group with a sub-group local
ID less than this work item&#8217;s sub-group local ID then an identity value
<code>I</code> is returned.
For <strong>and</strong>, the identity value is <code>true</code> (non-zero).
For <strong>or</strong> and <strong>xor</strong>, the identity value is <code>false</code> (zero).</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect4">
<h5 id="_built_in_sub_group_non_uniform_vote_functions"><a class="anchor" href="#_built_in_sub_group_non_uniform_vote_functions"></a>6.15.20.4. Built-in Sub-Group Non-Uniform Vote Functions</h5>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for the <code>cl_khr_<wbr>subgroup_<wbr>non_<wbr>uniform_<wbr>vote</code> extension.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <a href="#table-non-uniform-vote-functions">following table</a> describes the
OpenCL C programming language built-in functions to elect a single work item
in a sub-group to perform a task and to collectively vote to determine a
boolean condition for the sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be the one of
the supported built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>,
<code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, <code>half</code>
<sup class="footnote">[<a id="_footnoteref_107" class="footnote" href="#_footnotedef_107" title="View footnote.">107</a>]</sup>, and <code>double</code>
<sup class="footnote">[<a id="_footnoteref_108" class="footnote" href="#_footnotedef_108" title="View footnote.">108</a>]</sup>.</p>
</div>
<table id="table-non-uniform-vote-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 60. Built-in Sub-Group Non-Uniform Vote Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_elect</span><span class="p">()</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Elects a single work item in the sub-group to perform a task.</p>
<p class="tableblock"> This function will return true (nonzero) for the active work item in the
sub-group with the smallest sub-group local ID, and false (zero) for all
other active work items in the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_non_uniform_all</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Examines <em>predicate</em> for all active work items in the sub-group and
returns a non-zero value if <em>predicate</em> is non-zero for all active work
items in the sub-group and zero otherwise.</p>
<p class="tableblock"> Note: This behavior is the same as <code>sub_group_all</code> from
<code>cl_khr_<wbr>subgroups</code> and OpenCL 2.1, except this function need not be
encountered by all work items in the sub-group executing the kernel.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_non_uniform_any</span><span class="p">(</span>
<span class="kt">int</span> <span class="n">predicate</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Examines <em>predicate</em> for all active work items in the sub-group and
returns a non-zero value if <em>predicate</em> is non-zero for any active work
item in the sub-group and zero otherwise.</p>
<p class="tableblock"> Note: This behavior is the same as <code>sub_group_any</code> from
<code>cl_khr_<wbr>subgroups</code> and OpenCL 2.1, except this function need not be
encountered by all work items in the sub-group executing the kernel.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">int</span> <span class="n">sub_group_non_uniform_all_equal</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Examines <em>value</em> for all active work items in the sub-group and returns
a non-zero value if <em>value</em> is equivalent for all active invocations in
the sub-group and zero otherwise.</p>
<p class="tableblock"> Integer types use a bitwise test for equality. Floating-point types use
an ordered floating-point test for equality.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="sub-group-rotate-functions"><a class="anchor" href="#sub-group-rotate-functions"></a>6.15.20.5. Built-in Sub-Group Rotation Functions</h5>
<div class="paragraph">
<p>If
the <code>cl_khr_<wbr>subgroup_<wbr>rotate</code> extension macro or
OpenCL C 3.1 or newer is supported, the functions described in the
<a href="#table-rotate-functions">Built-in Sub-Group Rotation Functions</a> table can be
used to exchange data by rotating values through the work-items in a sub-group.
This function need not be encountered by all work items in a sub-group
executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be one of the
supported built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>,
<code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, <code>half</code>
<sup class="footnote">[<a id="_footnoteref_109" class="footnote" href="#_footnotedef_109" title="View footnote.">109</a>]</sup>, and <code>double</code>
<sup class="footnote">[<a id="_footnoteref_110" class="footnote" href="#_footnotedef_110" title="View footnote.">110</a>]</sup>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in the following table <a href="#unified-spec">requires</a>
support for
the <code>cl_khr_<wbr>subgroup_<wbr>rotate</code> extension macro or
OpenCL C 3.1 or newer.
</td>
</tr>
</table>
</div>
<table id="table-rotate-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 61. Built-in Sub-Group Rotation Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_rotate</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">int</span> <span class="n">delta</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>value</em> for the work item with sub-group local ID equal to the
remainder of the division of the sum of this work item&#8217;s sub-group local
ID and <em>delta</em> by the maximum sub-group size.<br>
The value of <em>delta</em> is required to be dynamically-uniform for all work
items in the sub-group, otherwise the behavior is undefined.</p>
<p class="tableblock"> The return value is undefined if the work item with sub-group local ID
equal to the calculated index is inactive.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_clustered_rotate</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">int</span> <span class="n">delta</span><span class="p">,</span>
<span class="kt">uint</span> <span class="n">clustersize</span><span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>value</em> for the work item with sub-group local ID equal to the
sum of, the remainder of the division of the sum of this work item&#8217;s ID
within the cluster and <em>delta</em> by <em>clustersize</em>, and the sub-group local
ID of the first work-item of the cluster to which the work-item
executing the function belongs.<br>
The value of <em>delta</em> is required to be dynamically-uniform for all work
items in the sub-group, otherwise the behavior is undefined.</p>
<p class="tableblock"> Behavior is undefined if <em>clustersize</em> is not an integer constant
expression, is not a power-of-two, or is greater than the maximum size of a
sub-group within the dispatch.</p>
<p class="tableblock"> The return value is undefined if the work item with sub-group local ID
equal to the calculated index is inactive.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="_built_in_sub_group_general_purpose_shuffle_functions"><a class="anchor" href="#_built_in_sub_group_general_purpose_shuffle_functions"></a>6.15.20.6. Built-in Sub-Group General Purpose Shuffle Functions</h5>
<div class="paragraph">
<p>If
the <code>cl_khr_<wbr>subgroup_<wbr>shuffle</code> extension macro or
OpenCL C 3.1 or newer is supported, the functions described in the
<a href="#table-shuffle-functions">Built-in Sub-Group General Purpose Shuffle
Functions</a> table can be used to flexibly exchange data among work-items in a
sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be one of the
supported built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>,
<code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, <code>half</code>
<sup class="footnote">[<a id="_footnoteref_111" class="footnote" href="#_footnotedef_111" title="View footnote.">111</a>]</sup>, and <code>double</code>
<sup class="footnote">[<a id="_footnoteref_112" class="footnote" href="#_footnotedef_112" title="View footnote.">112</a>]</sup>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for
the <code>cl_khr_<wbr>subgroup_<wbr>shuffle</code> extension macro or
OpenCL C 3.1 or newer.
</td>
</tr>
</table>
</div>
<table id="table-shuffle-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 62. Built-in Sub-Group General Purpose Shuffle Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_shuffle</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">index</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>value</em> for the work item with sub-group local ID equal to
<em>index</em>.
The shuffle <em>index</em> need not be the same for all work items in the
sub-group.</p>
<p class="tableblock"> The return value is undefined if the work item with sub-group local ID
equal to <em>index</em> is inactive or if <em>index</em> is greater than or equal to
the size of the sub-group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_shuffle_xor</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">mask</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>value</em> for the work item with sub-group local ID equal to
this work item&#8217;s sub-group local ID xor&#8217;d with <em>mask</em>.
The shuffle <em>mask</em> need not be the same for all work items in the
sub-group.</p>
<p class="tableblock"> The return value is undefined if the work item with sub-group local ID
equal to the calculated index is inactive or if the calculated index is
greater than or equal to the size of the sub-group.</p>
<p class="tableblock"> This is a specialized function that may perform better than the
equivalent <code>sub_group_shuffle</code> on some implementations.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="_built_in_sub_group_relative_shuffle_functions"><a class="anchor" href="#_built_in_sub_group_relative_shuffle_functions"></a>6.15.20.7. Built-in Sub-Group Relative Shuffle Functions</h5>
<div class="paragraph">
<p>If
the <code>cl_khr_<wbr>subgroup_<wbr>shuffle_<wbr>relative</code> extension macro or
OpenCL C 3.1 or newer is supported, the functions described in the
<a href="#table-shuffle-relative-functionss">Built-in Sub-Group Relative Shuffle
Functions</a> table can be used to exchange data among relative work-items in a
sub-group.
These functions need not be encountered by all work items in a sub-group
executing the kernel.
For the functions below, the generic type name <code>gentype</code> may be one of the
supported built-in scalar data types <code>char</code>, <code>uchar</code>, <code>short</code>, <code>ushort</code>,
<code>int</code>, <code>uint</code>, <code>long</code>, <code>ulong</code>, <code>float</code>, <code>half</code>
<sup class="footnote">[<a id="_footnoteref_113" class="footnote" href="#_footnotedef_113" title="View footnote.">113</a>]</sup>, and <code>double</code>
<sup class="footnote">[<a id="_footnoteref_114" class="footnote" href="#_footnotedef_114" title="View footnote.">114</a>]</sup>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for
the <code>cl_khr_<wbr>subgroup_<wbr>shuffle_<wbr>relative</code> extension macro or
OpenCL C 3.1 or newer.
</td>
</tr>
</table>
</div>
<table id="table-shuffle-relative-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 63. Built-in Sub-Group Relative Shuffle Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_shuffle_up</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">delta</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>value</em> for the work item with sub-group local ID equal to this
work item&#8217;s sub-group local ID minus <em>delta</em>.
The shuffle <em>delta</em> need not be the same for all work items in the
sub-group.</p>
<p class="tableblock"> The return value is undefined if the work item with sub-group local ID
equal to the calculated index is inactive, or <em>delta</em> is greater than
this work item&#8217;s sub-group local ID.</p>
<p class="tableblock"> This is a specialized function that may perform better than the
equivalent <code>sub_group_shuffle</code> on some implementations.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="n">sub_group_shuffle_down</span><span class="p">(</span>
<span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kt">uint</span> <span class="n">delta</span> <span class="p">)</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns <em>value</em> for the work item with sub-group local ID equal to this
work item&#8217;s sub-group local ID plus <em>delta</em>.
The shuffle <em>delta</em> need not be the same for all work items in the
sub-group.</p>
<p class="tableblock"> The return value is undefined if the work item with sub-group local ID
equal to the calculated index is inactive, or this work item&#8217;s sub-group
local ID plus <em>delta</em> is greater than or equal to the size of the
sub-group.</p>
<p class="tableblock"> This is a specialized function that may perform better than the
equivalent <code>sub_group_shuffle</code> on some implementations.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="extended-sub-groups-mapping"><a class="anchor" href="#extended-sub-groups-mapping"></a>6.15.20.8. Sub-Groups Function Mapping and Capabilities</h5>
<div class="paragraph">
<p>This section describes a possible mapping between OpenCL built-in sub-group functions
and SPIR-V instructions and required SPIR-V capabilities.</p>
</div>
<div class="paragraph">
<p>This section is informational and non-normative.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">OpenCL C Function</th>
<th class="tableblock halign-left valign-top">SPIR-V BuiltIn or Instruction</th>
<th class="tableblock halign-left valign-top">Enabling SPIR-V Capability</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">For OpenCL C 2.1, OpenCL C 3.0 and the <code>__opencl_c_<wbr>subgroups</code> feature,
OpenCL C 3.1 or newer, or <code>cl_khr_<wbr>subgroups</code>:</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_sub_<wbr>group_<wbr>size</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupSize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Kernel</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_max_<wbr>sub_<wbr>group_<wbr>size</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupMaxSize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Kernel</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_num_<wbr>sub_<wbr>groups</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>NumSubgroups</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Kernel</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_enqueued_<wbr>num_<wbr>sub_<wbr>groups</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>NumEnqueuedSubgroups</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Kernel</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_sub_<wbr>group_<wbr>id</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupId</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Kernel</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_sub_<wbr>group_<wbr>local_<wbr>id</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupLocalInvocationId</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Kernel</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>barrier</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpControlBarrier</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">None Needed</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>all</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupAll</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>any</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupAny</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>broadcast</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupBroadcast</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>reduce_<wbr>add</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupIAdd</strong>, <strong>OpGroupFAdd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>reduce_<wbr>min</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupSMin</strong>, <strong>OpGroupUMin</strong>, <strong>OpGroupFMin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>reduce_<wbr>max</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupSMax</strong>, <strong>OpGroupUMax</strong>, <strong>OpGroupFMax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>scan_<wbr>exclusive_<wbr>add</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupIAdd</strong>, <strong>OpGroupFAdd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>scan_<wbr>exclusive_<wbr>min</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupSMin</strong>, <strong>OpGroupUMin</strong>, <strong>OpGroupFMin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>scan_<wbr>exclusive_<wbr>max</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupSMax</strong>, <strong>OpGroupUMax</strong>, <strong>OpGroupFMax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>scan_<wbr>inclusive_<wbr>add</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupIAdd</strong>, <strong>OpGroupFAdd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>scan_<wbr>inclusive_<wbr>min</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupSMin</strong>, <strong>OpGroupUMin</strong>, <strong>OpGroupFMin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>scan_<wbr>inclusive_<wbr>max</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupSMax</strong>, <strong>OpGroupUMax</strong>, <strong>OpGroupFMax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Groups</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>reserve_<wbr>read_<wbr>pipe</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupReserveReadPipePackets</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Pipes</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>reserve_<wbr>write_<wbr>pipe</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupReserveReadWritePackets</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Pipes</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>commit_<wbr>read_<wbr>pipe</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupCommitReadPipe</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Pipes</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>commit_<wbr>write_<wbr>pipe</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupCommitWritePipe</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Pipes</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_kernel_<wbr>sub_<wbr>group_<wbr>count_<wbr>for_<wbr>ndrange</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGetKernelNDrangeSubGroupCount</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>DeviceEnqueue</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_kernel_<wbr>max_<wbr>sub_<wbr>group_<wbr>size_<wbr>for_<wbr>ndrange</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGetKernelNDrangeMaxSubGroupSize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>DeviceEnqueue</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">For <code>cl_khr_<wbr>subgroup_<wbr>ballot</code>:</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>broadcast</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBroadcast</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>broadcast_<wbr>first</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBroadcastFirst</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>ballot</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBallot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>inverse_<wbr>ballot</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformInverseBallot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>ballot_<wbr>bit_<wbr>extract</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBallotBitExtract</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>ballot_<wbr>bit_<wbr>count</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBallotBitCount</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>ballot_<wbr>inclusive_<wbr>scan</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBallotBitCount</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>ballot_<wbr>exclusive_<wbr>scan</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBallotBitCount</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>ballot_<wbr>find_<wbr>lsb</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBallotFindLSB</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>ballot_<wbr>find_<wbr>msb</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBallotFindMSB</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_sub_<wbr>group_<wbr>eq_<wbr>mask</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupEqMask</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_sub_<wbr>group_<wbr>ge_<wbr>mask</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupGeMask</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_sub_<wbr>group_<wbr>gt_<wbr>mask</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupGtMask</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_sub_<wbr>group_<wbr>le_<wbr>mask</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupLeMask</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>get_sub_<wbr>group_<wbr>lt_<wbr>mask</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SubgroupLtMask</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformBallot</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">For <code>cl_khr_<wbr>subgroup_<wbr>clustered_<wbr>reduce</code>:</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>add</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformIAdd</strong>, <strong>OpGroupNonUniformFAdd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>mul</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformIMul</strong>, <strong>OpGroupNonUniformFMul</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>min</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformSMin</strong>, <strong>OpGroupNonUniformUMin</strong>, <strong>OpGroupNonUniformFMin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>max</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformSMax</strong>, <strong>OpGroupNonUniformUMax</strong>, <strong>OpGroupNonUniformFMax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseAnd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseOr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>logical_<wbr>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalAnd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>logical_<wbr>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalOr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>reduce_<wbr>logical_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformClustered</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">For <code>cl_khr_<wbr>subgroup_<wbr>non_<wbr>uniform_<wbr>arithmetic</code>:</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>add</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformIAdd</strong>, <strong>OpGroupNonUniformFAdd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>mul</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformIMul</strong>, <strong>OpGroupNonUniformFMul</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>min</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformSMin</strong>, <strong>OpGroupNonUniformUMin</strong>, <strong>OpGroupNonUniformFMin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>max</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformSMax</strong>, <strong>OpGroupNonUniformUMax</strong>, <strong>OpGroupNonUniformFMax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseAnd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseOr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>logical_<wbr>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalAnd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>logical_<wbr>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalOr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>reduce_<wbr>logical_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>add</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformIAdd</strong>, <strong>OpGroupNonUniformFAdd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>mul</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformIMul</strong>, <strong>OpGroupNonUniformFMul</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>min</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformSMin</strong>, <strong>OpGroupNonUniformUMin</strong>, <strong>OpGroupNonUniformFMin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>max</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformSMax</strong>, <strong>OpGroupNonUniformUMax</strong>, <strong>OpGroupNonUniformFMax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseAnd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseOr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>logical_<wbr>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalAnd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>logical_<wbr>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalOr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>inclusive_<wbr>logical_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>add</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformIAdd</strong>, <strong>OpGroupNonUniformFAdd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>mul</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformIMul</strong>, <strong>OpGroupNonUniformFMul</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>min</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformSMin</strong>, <strong>OpGroupNonUniformUMin</strong>, <strong>OpGroupNonUniformFMin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>max</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformSMax</strong>, <strong>OpGroupNonUniformUMax</strong>, <strong>OpGroupNonUniformFMax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseAnd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseOr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformBitwiseXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>logical_<wbr>and</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalAnd</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>logical_<wbr>or</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalOr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>scan_<wbr>exclusive_<wbr>logical_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformLogicalXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformArithmetic</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">For <code>cl_khr_<wbr>subgroup_<wbr>non_<wbr>uniform_<wbr>vote</code>:</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>elect</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformElect</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniform</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>all</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformAll</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformVote</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>any</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformAny</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformVote</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>non_<wbr>uniform_<wbr>all_<wbr>equal</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformAllEqual</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformVote</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">For OpenCL C 3.1 or newer
or <code>cl_khr_<wbr>subgroup_<wbr>rotate</code>:</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>rotate</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformRotateKHR</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformRotateKHR</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>clustered_<wbr>rotate</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformRotateKHR</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformRotateKHR</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">For OpenCL C 3.1 or newer
or <code>cl_khr_<wbr>subgroup_<wbr>shuffle</code>:</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>shuffle</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformShuffle</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformShuffle</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>shuffle_<wbr>xor</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformShuffleXor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformShuffle</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">For OpenCL C 3.1 or newer
or <code>cl_khr_<wbr>subgroup_<wbr>shuffle_<wbr>relative</code>:</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>shuffle_<wbr>up</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformShuffleUp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformShuffleRelative</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sub_group_<wbr>shuffle_<wbr>down</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>OpGroupNonUniformShuffleDown</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>GroupNonUniformShuffleRelative</strong></p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect3">
<h4 id="kernel-clock-functions"><a class="anchor" href="#kernel-clock-functions"></a>6.15.21. Kernel Clock Functions</h4>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The functionality described in this section <a href="#unified-spec">requires</a>
support for the <code>cl_khr_<wbr>kernel_<wbr>clock</code> extension.<br>
The <code>clock_read_device</code> and <code>clock_read_hilo_device</code> functions require support
for the <code>__opencl_c_<wbr>kernel_<wbr>clock_<wbr>scope_<wbr>device</code> feature.
The <code>clock_read_work_group</code> and <code>clock_read_hilo_work_group</code> functions require
support for the <code>__opencl_c_<wbr>kernel_<wbr>clock_<wbr>scope_<wbr>work_<wbr>group</code> feature.
The <code>clock_read_sub_group</code> and <code>clock_read_hilo_sub_group</code> functions require
support for the <code>__opencl_c_<wbr>kernel_<wbr>clock_<wbr>scope_<wbr>sub_<wbr>group</code> feature.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>This section describes OpenCL C built-in functions that sample the value from
one of three clocks provided by compute units.</p>
</div>
<table id="table-kernel-clock-functions" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 64. Built-in Kernel Clock Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">ulong</span> <span class="nf">clock_read_device</span><span class="p">();</span>
<span class="kt">ulong</span> <span class="nf">clock_read_work_group</span><span class="p">();</span>
<span class="kt">ulong</span> <span class="nf">clock_read_sub_group</span><span class="p">();</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Returns a sampled value of a clock as seen by the compute unit.</p>
<p class="tableblock"> An idealized clock is an unbounded unsigned scalar integer tick count
increasing monotonically over time. A clock’s rate of progress may vary
within the lifetime of a work-item, may vary across different
executions of the program, and may be affected by conditions beyond the
control of the programmer. The sampled value read by this function consists of
the least significant bits of the idealized clock’s tick count at the time the
instruction was executed. In particular, an observer may see sampled values wrap
around zero.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kt">uint2</span> <span class="nf">clock_read_hilo_device</span><span class="p">();</span>
<span class="kt">uint2</span> <span class="nf">clock_read_hilo_work_group</span><span class="p">();</span>
<span class="kt">uint2</span> <span class="nf">clock_read_hilo_sub_group</span><span class="p">();</span></code></pre>
</div>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Performs the same operation as <code>clock_read</code>, but returns the value as a
<code>uint2</code> whose <code>.lo</code> component contains the 32 least significant bits of the
result and <code>.hi</code> component contains the 32 most significant bits of the
result.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="opencl-numerical-compliance"><a class="anchor" href="#opencl-numerical-compliance"></a>7. OpenCL Numerical Compliance</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This section describes features of the <a href="#C99-spec">C99</a> and IEEE 754
standards that must be supported by all OpenCL compliant devices.</p>
</div>
<div class="paragraph">
<p>This section describes the functionality that must be supported by all
OpenCL devices for single precision floating-point numbers.
Currently, only single precision floating-point is a requirement.
Double-precision floating-point is an optional feature.</p>
</div>
<div class="sect2">
<h3 id="rounding-modes-1"><a class="anchor" href="#rounding-modes-1"></a>7.1. Rounding Modes</h3>
<div class="paragraph">
<p>Floating-point calculations may be carried out internally with extra
precision and then rounded to fit into the destination type.
IEEE 754 defines four possible rounding modes:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Round to nearest even</p>
</li>
<li>
<p>Round toward +∞</p>
</li>
<li>
<p>Round toward -∞</p>
</li>
<li>
<p>Round toward zero</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><em>Round to nearest</em> <em>even</em> is currently the only rounding mode required by the
OpenCL specification for single precision and double-precision operations and is
therefore the default rounding mode
<sup class="footnote">[<a id="_footnoteref_115" class="footnote" href="#_footnotedef_115" title="View footnote.">115</a>]</sup>.
In addition, only static selection of rounding mode is supported.
Dynamically reconfiguring the rounding modes as specified by the IEEE 754
spec is unsupported.</p>
</div>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>fp16</code> extension macro is supported, then
if <code>CL_FP_<wbr>ROUND_<wbr>TO_<wbr>NEAREST</code> is supported, the default rounding mode for
half-precision floating-point operations will be round to nearest even;
otherwise the default rounding mode will be round to zero.</p>
</div>
<div class="paragraph">
<p>Conversions to half floating-point format must be correctly rounded using
the indicated <code>convert</code> operator rounding mode or the default rounding mode
for half-precision floating-point operations if no rounding mode is
specified by the operator, or a C-style cast is used.</p>
</div>
<div class="paragraph">
<p>Conversions from half to integer format shall correctly round using the
indicated <code>convert</code> operator rounding mode, or towards zero if no rounding
mode is specified by the operator or a C-style cast is used.
All conversions from half to floating-point formats are exact.</p>
</div>
<div class="openblock">
<div class="content">
<div id="select-rounding-mode" class="paragraph">
<p>If the <code>cl_khr_<wbr>select_<wbr>fprounding_<wbr>mode</code> extension macro is supported, the
floating-point rounding mode may be specified using the following <strong>#pragma</strong>
in the OpenCL program source:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#pragma OPENCL SELECT_ROUNDING_MODE &lt;rounding-mode&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The <em>&lt;rounding-mode&gt;</em> may be one of the following values:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>rte</strong> - round to nearest even</p>
</li>
<li>
<p><strong>rtz</strong> - round to zero</p>
</li>
<li>
<p><strong>rtp</strong> - round to positive infinity</p>
</li>
<li>
<p><strong>rtn</strong> - round to negative infinity</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>If this extensions is supported then the OpenCL implementation must support
all four rounding modes for single precision floating-point.</p>
</div>
<div class="paragraph">
<p>The <strong>#pragma</strong> sets the rounding mode for all instructions that operate on
floating-point types (scalar or vector types) or produce floating-point
values that follow this pragma in the program source until the next
<strong>#pragma</strong>.
Note that the rounding mode specified for a block of code is known at
compile time.
When inside a compound statement, the pragma takes effect from its
occurrence until another <strong>#pragma</strong> is encountered (including within a nested
compound statement), or until the end of the compound statement; at the end
of a compound statement the state for the pragma is restored to its
condition just before the compound statement.
Except where otherwise documented, the callee functions do not inherit the
rounding mode of the caller function.</p>
</div>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>select_<wbr>fprounding_<wbr>mode</code> extension is enabled, the
<code>__ROUNDING_MODE__</code> preprocessor symbol shall be defined to be one of the
following according to the current rounding mode:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#define __ROUNDING_MODE__ rte
#define __ROUNDING_MODE__ rtz
#define __ROUNDING_MODE__ rtp
#define __ROUNDING_MODE__ rtz</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>This is intended to enable remapping <code>foo()</code> to <code>foo_rte()</code> by the
preprocessor by using:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="cp">#define foo foo ## __ROUNDING_MODE__</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The default rounding mode is round to nearest even.
The <a href="#math-functions">Math Functions</a>, <a href="#common-functions">Common
Functions</a>, and <a href="#geometric-functions">Geometric Functions</a> are
implemented with the round to nearest even rounding mode.
Various built-in conversions and the <strong>vstore_half</strong> and <strong>vstorea_half</strong>
built-in functions that do not specify a rounding mode inherit the current
rounding mode.
Conversions from floating-point to integer type always use <code>rtz</code> mode,
except where the user specifically asks for another rounding mode.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The <code>cl_khr_<wbr>select_<wbr>fprounding_<wbr>mode</code> extension was deprecated in
OpenCL 1.1, and its use is not recommended.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="inf-nan-and-denormalized-numbers"><a class="anchor" href="#inf-nan-and-denormalized-numbers"></a>7.2. INF, NaN and Denormalized Numbers</h3>
<div class="paragraph">
<p><code>INF</code> and NaNs must be supported.
Support for signaling NaNs is not required.</p>
</div>
<div class="paragraph">
<p>Support for denormalized numbers with single precision floating-point is
optional.
Denormalized single precision floating-point numbers passed as input or
produced as the output of single precision floating-point operations such as
add, sub, mul, divide, and the functions defined in <a href="#math-functions">math
functions</a>, <a href="#common-functions">common functions</a>, and
<a href="#geometric-functions">geometric functions</a> may be flushed to zero.</p>
</div>
</div>
<div class="sect2">
<h3 id="floating-point-exceptions"><a class="anchor" href="#floating-point-exceptions"></a>7.3. Floating-Point Exceptions</h3>
<div class="paragraph">
<p>Floating-point exceptions are disabled in OpenCL.
The result of a floating-point exception must match the IEEE 754 spec for
the exceptions not enabled case.
Whether and when the implementation sets floating-point flags or raises
floating-point exceptions is implementation-defined.
This standard provides no method for querying, clearing or setting
floating-point flags or trapping raised exceptions.
Due to non-performance, non-portability of trap mechanisms and the
impracticality of servicing precise exceptions in a vector context
(especially on heterogeneous hardware), such features are discouraged.</p>
</div>
<div class="paragraph">
<p>Implementations that nevertheless support such operations through an
extension to the standard shall initialize with all exception flags cleared
and the exception masks set so that exceptions raised by arithmetic
operations do not trigger a trap to be taken.
If the underlying work is reused by the implementation, the implementation
is however not responsible for reclearing the flags or resetting exception
masks to default values before entering the kernel.
That is to say that kernels that do not inspect flags or enable traps are
licensed to expect that their arithmetic will not trigger a trap.
Those kernels that do examine flags or enable traps are responsible for
clearing flag state and disabling all traps before returning control to the
implementation.
Whether or when the underlying work-item (and accompanying global
floating-point state if any) is reused is implementation-defined.</p>
</div>
<div class="paragraph">
<p>The expressions <strong>math_errorhandling</strong> and <code>MATH_ERREXCEPT</code> are reserved for
use by this standard, but not defined.
Implementations that extend this specification with support for
floating-point exceptions shall define <strong>math_errorhandling</strong> and
<code>MATH_ERREXCEPT</code> per <a href="#C99-spec">TC2 to the C99 Specification</a>.</p>
</div>
</div>
<div class="sect2">
<h3 id="relative-error-as-ulps"><a class="anchor" href="#relative-error-as-ulps"></a>7.4. Relative Error as ULPs</h3>
<div class="paragraph">
<p>In this section we discuss the maximum relative error defined as ulp (units
in the last place).
Addition, subtraction, multiplication, fused multiply-add and conversion
between integer and a single precision floating-point format are IEEE 754
compliant and are therefore correctly rounded.
Conversion between floating-point formats and
<a href="#explicit-conversions">explicit conversions</a> must be correctly rounded.</p>
</div>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>fp16</code> extension macro is supported,
addition, subtraction, multiplication, fused multiply-add operations on half
types are required to be correctly rounded using the default rounding mode
for half-precision floating-point operations.</p>
</div>
<div class="paragraph">
<p>The ULP is defined as follows:</p>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>If <em>x</em> is a real number that lies between two finite consecutive
floating-point numbers <em>a</em> and <em>b</em>, without being equal to one of them, then
ulp(<em>x</em>) = |<em>b</em> - <em>a</em>|, otherwise ulp(<em>x</em>) is the distance between the two
non-equal finite floating-point numbers nearest <em>x</em>.
Moreover, ulp(NaN) is NaN.</p>
</div>
</div>
</div>
<div class="paragraph">
<p><em>Attribution: This definition was taken with consent from Jean-Michel Muller
with slight clarification for behavior at zero.</em></p>
</div>
<div class="exampleblock">
<div class="content">
<div class="paragraph">
<p>Jean-Michel Muller. On the definition of ulp(x). RR-5504, INRIA. 2005, pp.16. &lt;inria-00070503&gt;
Currently hosted at
<a href="https://hal.inria.fr/inria-00070503/document">https://hal.inria.fr/inria-00070503/document</a>.</p>
</div>
</div>
</div>
<div class="paragraph">
<p>The following table describes the minimum accuracy of single precision
floating-point arithmetic operations given as ULP values.
The reference value used to compute the ULP value of an arithmetic operation
is the infinitely precise result.
0 ulp is used for math functions that do not require rounding.</p>
</div>
<div class="paragraph">
<p>Result overflow within the specified ULP error is permitted. Math functions are
allowed to return infinity for a finite reference value when the next
floating-point number that would be representable after the finite maximum, if
there was sufficient range, meets ULP error tolerance.</p>
</div>
<table id="table-ulp-float-math" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 65. ULP Values for Single-Precision Built-in Math Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Min Accuracy - ULP values</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> + <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> - <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> * <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.0 / <em>x</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2.5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> / <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2.5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acospi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2pi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acosh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cbrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ceil</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>clamp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>copysign</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cosh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cospi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cross</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">absolute error tolerance of 'max * max * (3 * FLT_EPSILON)' per vector component, where <em>max</em> is the maximum input operand magnitude</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>degrees</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>distance</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2.5 + 2n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">absolute error tolerance of 'max * max * (2n - 1) * FLT_EPSILON', for vector width <em>n</em> and maximum input operand magnitude <em>max</em> across all vector components</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>erfc</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>erf</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>expm1</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fabs</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fdim</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>floor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmod</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fract</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>frexp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>hypot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ilogb</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>length</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2.75 + 0.5n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ldexp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>lgamma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Undefined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>lgamma_r</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Undefined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log1p</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>logb</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mad</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implemented either as a correctly rounded fma or
as a multiply followed by an add both of which are
correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>max</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>maxmag</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>min</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>minmag</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mix</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">absolute error tolerance of 1e-3</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>modf</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>nan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>nextafter</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>normalize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 + n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pow</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pown</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>powr</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>radians</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>remainder</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>remquo</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rint</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rootn</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>round</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rsqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sign</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sincos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp for sine and cosine values</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>smoothstep</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">absolute error tolerance of 1e-5</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>step</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tgamma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>trunc</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_cos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_divide</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_exp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_exp2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_exp10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_log</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_log2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_log10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_powr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_recip</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_rsqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_sin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_sqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_tan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fast_distance</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8191.5 + 2n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fast_length</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8191.5 + n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fast_normalize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 + n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_cos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_divide</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_exp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_exp2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_exp10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_log</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_log2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_log10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_powr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_recip</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_rsqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_sin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_sqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_tan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following table describes the minimum accuracy of single precision
floating-point arithmetic operations given as ULP values for the embedded
profile.
The reference value used to compute the ULP value of an arithmetic operation
is the infinitely precise result.
0 ulp is used for math functions that do not require rounding.</p>
</div>
<table id="table-ulp-embedded" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 66. ULP Values for the Embedded Profile</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Min Accuracy - ULP values</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> + <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> - <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> * <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.0 / <em>x</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> / <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acospi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2pi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acosh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cbrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ceil</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>clamp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>copysign</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cosh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cospi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cross</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>degrees</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>distance</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>erfc</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>erf</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>expm1</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fabs</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fdim</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>floor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmod</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fract</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>frexp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>hypot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ilogb</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ldexp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>length</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log1p</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>logb</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mad</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Any value allowed (infinite ulp)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>max</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>maxmag</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>min</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>minmag</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mix</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>modf</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>nan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>normalize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>nextafter</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pow</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pown</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>powr</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>radians</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>remainder</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>remquo</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rint</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rootn</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>round</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rsqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sign</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sincos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp for sine and cosine values</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>smoothstep</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>step</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tgamma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>trunc</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_cos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_divide</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_exp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_exp2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_exp10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_log</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_log2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_log10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_powr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_recip</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_rsqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_sin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_sqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>half_tan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fast_distance</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fast_length</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fast_normalize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_cos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_divide</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_exp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_exp2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_exp10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_log</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_log2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_log10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_powr</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_recip</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_rsqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_sin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_sqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>native_tan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <a href="#table-float-ulp-relaxed">following table</a> describes the minimum accuracy
of commonly used single precision floating-point arithmetic operations given
as ULP values if the <code>-cl-unsafe-math-optimizations</code> compiler option is
specified when compiling or building an OpenCL program.
For derived implementations, the operations used in the derivation may
themselves be relaxed according to the following table.
The minimum accuracy of math functions not defined in the following table when
the <code>-cl-unsafe-math-optimizations</code> compiler option is specified is as defined
in <a href="#table-ulp-float-math">ULP values for single precision built-in math
functions</a> when operating in the full profile, and as defined in
<a href="#table-ulp-embedded">ULP values for the embedded profile</a> when operating in the
embedded profile.
The reference value used to compute the ULP value of an arithmetic operation
is the infinitely precise result.
0 ulp is used for math functions that do not require rounding.</p>
</div>
<div class="paragraph">
<p>Defined minimum accuracy of single precision floating-point arithmetic
operations and builtins with <code>-cl-unsafe-math-optimizations</code> <a href="#unified-spec">requires</a> support for OpenCL C 2.0 or newer.</p>
</div>
<table id="table-float-ulp-relaxed" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 67. ULP Values for Single-Precision Built-in Math Functions With Unsafe Math Optimizations in the Full and Embedded Profiles</caption>
<colgroup>
<col style="width: 30%;">
<col style="width: 70%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Minimum Accuracy</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.0 / <em>x</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2.5 ulp for <em>x</em> in the domain of 2<sup>-126</sup> to 2<sup>126</sup> for the full
profile, and ≤ 3 ulp for <em>x</em> in the domain of 2<sup>-126</sup> to 2<sup>126</sup> for
the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> / <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2.5 ulp for <em>x</em> in the domain of 2<sup>-62</sup> to 2<sup>62</sup> and <em>y</em> in the
domain of 2<sup>-62</sup> to 2<sup>62</sup> for the full profile, and ≤ 3 ulp for <em>x</em> in
the domain of 2<sup>-62</sup> to 2<sup>62</sup> and <em>y</em> in the domain of 2<sup>-62</sup> to 2<sup>62</sup> for
the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acos</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4096 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acosh</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>log</strong>(<em>x</em> + <strong>sqrt</strong>(<em>x</em> * <em>x</em> - 1)).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acospi</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>acos</strong>(<em>x</em>) * <code>M_PI_F</code>.
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asin</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4096 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinh</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>log</strong>(<em>x</em> + <strong>sqrt</strong>(<em>x</em> * <em>x</em> + 1)).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinpi</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>asin</strong>(<em>x</em>) * <code>M_PI_F</code>.
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4096 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanh</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Defined for <em>x</em> in the domain (-1, 1).
For <em>x</em> in [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations may implement as <em>x</em>.
For <em>x</em> outside of [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations may implement as
0.5f * <strong>log</strong>((1.0f + <em>x</em>) / (1.0f - <em>x</em>)).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanpi</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>atan</strong>(<em>x</em>) * <code>M_1_PI_F</code>.
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2</strong>(<em>y</em>, <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>atan</strong>(<em>y</em> / <em>x</em>) for <em>x</em> &gt; 0,
<strong>atan</strong>(<em>y</em> / <em>x</em>) + <code>M_PI_F</code> for <em>x</em> &lt; 0 and <em>y</em> &gt; 0, and
<strong>atan</strong>(<em>y</em> / <em>x</em>) - <code>M_PI_F</code> for <em>x</em> &lt; 0 and <em>y</em> &lt; 0.
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2pi</strong>(<em>y</em>, <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>atan2</strong>(<em>y</em>, <em>x</em>) * <code>M_1_PI_F</code>.
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cbrt</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>rootn</strong>(<em>x</em>, 3).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cos</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For <em>x</em> in the domain [-π, π], the maximum absolute error
is ≤ 2<sup>-11</sup> and larger otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cosh</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Defined for <em>x</em> in the domain [-88, 88].
Derived implementations may implement as 0.5f * (<strong>exp</strong>(<em>x</em>) + <strong>exp</strong>(-<em>x</em>)).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cospi</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For <em>x</em> in the domain [-1, 1], the maximum absolute error is ≤
2<sup>-11</sup> and larger otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 + <strong>floor</strong>(<strong>fabs</strong>(2 * <em>x</em>)) ulp for the full profile, and ≤
4 + <strong>floor</strong>(<strong>fabs</strong>(2 * <em>x</em>)) ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp2</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 + <strong>floor</strong>(<strong>fabs</strong>(2 * <em>x</em>)) ulp for the full profile, and ≤
4 + <strong>floor</strong>(<strong>fabs</strong>(2 * <em>x</em>)) ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp10</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>exp2</strong>(<em>x</em> * <strong>log2</strong>(10)).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>expm1</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>exp</strong>(<em>x</em>) - 1.
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For <em>x</em> in the domain [0.5, 2] the maximum absolute error is ≤
2<sup>-21</sup>; otherwise the maximum error is ≤ 3 ulp for the full profile
and ≤ 4 ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log2</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For <em>x</em> in the domain [0.5, 2] the maximum absolute error is ≤
2<sup>-21</sup>; otherwise the maximum error is ≤ 3 ulp for the full profile
and ≤ 4 ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log10</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For <em>x</em> in the domain [0.5, 2] the maximum absolute error is ≤
2<sup>-21</sup>; otherwise the maximum error is ≤ 3 ulp for the full profile
and ≤ 4 ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log1p</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>log</strong>(<em>x</em> + 1).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pow</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Undefined for <em>x</em> = 0 and <em>y</em> = 0.
Undefined for <em>x</em> &lt; 0 and non-integer <em>y</em>.
Undefined for <em>x</em> &lt; 0 and <em>y</em> outside the domain [-2<sup>24</sup>, 2<sup>24</sup>].
For <em>x</em> &gt; 0 or <em>x</em> &lt; 0 and even <em>y</em>, derived implementations may implement as
<strong>exp2</strong>(<em>y</em> * <strong>log2</strong>(<strong>fabs</strong>(<em>x</em>))).
For <em>x</em> &lt; 0 and odd <em>y</em>, derived implementations may implement as
-<strong>exp2</strong>(<em>y</em> * <strong>log2</strong>(<strong>fabs</strong>(<em>x</em>)).
For <em>x</em> == 0 and non-zero <em>y</em>, for derived implementations may return zero.
For non-derived implementations, the error is ≤ 8192 ulp.
<sup class="footnote">[<a id="_footnoteref_116" class="footnote" href="#_footnotedef_116" title="View footnote.">116</a>]</sup></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pown</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Defined only for integer values of <em>y</em>.
Undefined for <em>x</em> = 0 and <em>y</em> = 0.
For <em>x</em> &gt;= 0 or <em>x</em> &lt; 0 and even <em>y</em>, derived implementations may implement as
<strong>exp2</strong>(<em>y</em> * <strong>log2</strong>(<strong>fabs</strong>(<em>x</em>))).
For <em>x</em> &lt; 0 and odd <em>y</em>, derived implementations may implement as
-<strong>exp2</strong>(<em>y</em> * <strong>log2</strong>(<strong>fabs</strong>(<em>x</em>))).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>powr</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Defined only for <em>x</em> &gt;= 0.
Undefined for <em>x</em> = 0 and <em>y</em> = 0.
Derived implementations may implement as <strong>exp2</strong>(<em>y</em> * <strong>log2</strong>(<em>x</em>)).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rootn</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Defined for <em>x</em> &gt; 0 when <em>y</em> is non-zero, derived implementations
may implement this case as <strong>exp2</strong>(<strong>log2</strong>(<em>x</em>) / <em>y</em>).
Defined for <em>x</em> &lt; 0 when <em>y</em> is odd, derived implementations
may implement this case as -<strong>exp2</strong>(<strong>log2</strong>(-<em>x</em>) / <em>y</em>).
Defined for <em>x</em> = +/-0 when <em>y</em> &gt; 0, derived implementations may
return +0 in this case.
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sin</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For <em>x</em> in the domain [-π, π], the maximum absolute error is
≤ 2<sup>-11</sup> and larger otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sincos</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ulp values as defined for <strong>sin</strong>(<em>x</em>) and <strong>cos</strong>(<em>x</em>).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinh</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Defined for <em>x</em> in the domain [-88,88].
For <em>x</em> in [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations
may implement as <em>x</em>.
For <em>x</em> outside of [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations
may implement as 0.5f * (<strong>exp</strong>(<em>x</em>) - <strong>exp</strong>(-<em>x</em>)).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinpi</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">For <em>x</em> in the domain [-1, 1], the maximum absolute error is ≤
2<sup>-11</sup> and larger otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tan</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as
<strong>sin</strong>(<em>x</em>) * (1.0f / <strong>cos</strong>(<em>x</em>)).
For non-derived implementations, the error is ≤ 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanh</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Defined for <em>x</em> in the domain [-∞, ∞].
For <em>x</em> in [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations
may implement as <em>x</em>.
For <em>x</em> outside of [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations
may implement as (<strong>exp</strong>(<em>x</em>) - <strong>exp</strong>(-<em>x</em>)) / (<strong>exp</strong>(<em>x</em>) + <strong>exp</strong>(-<em>x</em>)).
For non-derived implementations, the error is ≤ 8192 ULP.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanpi</strong>(<em>x</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Derived implementations may implement as <strong>tan</strong>(<em>x</em> * <code>M_PI_F</code>).
For non-derived implementations, the error is ≤ 8192 ulp for <em>x</em>
in the domain [-1, 1].</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> * <em>y</em> + <em>z</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implemented either as a correctly rounded <strong>fma</strong> or as a multiply and
an add both of which are correctly rounded.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following table describes the minimum accuracy of double-precision
floating-point arithmetic operations given as ULP values.
The reference value used to compute the ULP value of an arithmetic operation
is the infinitely precise result.
0 ulp is used for math functions that do not require rounding.</p>
</div>
<table id="table-ulp-double" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 68. ULP Values for Double-Precision Built-in Math Functions</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Min Accuracy - ULP values</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> + <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> - <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> * <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1.0 / <em>x</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>x</em> / <em>y</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acospi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2pi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acosh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cbrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ceil</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>clamp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>copysign</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cosh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cospi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cross</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">absolute error tolerance of 'max * max * (3 * FLT_EPSILON)' per vector component, where <em>max</em> is the maximum input operand magnitude</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>degrees</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>distance</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5.5 + 2n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">absolute error tolerance of 'max * max * (2n - 1) * FLT_EPSILON', for vector width <em>n</em> and maximum input operand magnitude <em>max</em> across all vector components</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>erfc</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>erf</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>expm1</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fabs</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fdim</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>floor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmod</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fract</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>frexp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>hypot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ilogb</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>length</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5.5 + n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ldexp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log1p</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>logb</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mad</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Any value allowed (infinite ulp)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>max</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>maxmag</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>min</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>minmag</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mix</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>modf</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>nan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>nextafter</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>normalize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4.5 + n ulp, for gentype with vector width <em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pow</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pown</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>powr</strong>(<em>x</em>, <em>y</em>)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>radians</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>remainder</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>remquo</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rint</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rootn</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>round</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rsqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sign</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sincos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp for sine and cosine values</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>smoothstep</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>step</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tgamma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">≤ 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>trunc</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>If the <code>cl_khr_<wbr>fp16</code> extension macro is supported,
the following table describes the minimum accuracy of half-precision
floating-point arithmetic operations given as ULP values.
The reference value used to compute the ULP value of an arithmetic operation
is the infinitely precise result.
0 ulp is used for math functions that do not require rounding.</p>
</div>
<table id="table-ulp-half-math" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 69. ULP Values for Half-Precision Floating-Point Arithmetic Operations</caption>
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Function</th>
<th class="tableblock halign-left valign-top">Min Accuracy - Full Profile</th>
<th class="tableblock halign-left valign-top">Min Accuracy - Embedded Profile</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong><em>x</em> + <em>y</em></strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong><em>x</em> - <em>y</em></strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong><em>x</em> * <em>y</em></strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>1.0 / <em>x</em></strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 1 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 1 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong><em>x</em> / <em>y</em></strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 1 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 1 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acosh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>acospi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>asinpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atanpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>atan2pi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cbrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ceil</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>clamp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>copysign</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cosh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cospi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>cross</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">absolute error tolerance of 'max * max * (3 * HALF_EPSILON)' per vector
component, where <em>max</em> is the maximum input operand magnitude</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>degrees</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>distance</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2n ulp, for gentype with vector width <em>n</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>dot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">absolute error tolerance of 'max * max * (2n - 1) * HALF_EPSILON', for
vector width <em>n</em> and maximum input operand magnitude <em>max</em> across all
vector components</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>erfc</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>erf</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>exp10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>expm1</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fabs</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fdim</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>floor</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmax</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fmod</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>fract</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>frexp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>hypot</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ilogb</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>ldexp</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>length</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 0.25 + 0.5n ulp, for gentype with vector width <em>n</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log2</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log10</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>log1p</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>logb</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mad</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>max</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>maxmag</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>min</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>minmag</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>mix</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>modf</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>nan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>nextafter</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>normalize</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 1 + n ulp, for gentype with vector width <em>n</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pow(x, y)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>pown(x, y)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>powr(x, y)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>radians</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>remainder</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>remquo</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp for the remainder, at least the lower 7 bits of the integral
quotient</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp for the remainder, at least the lower 7 bits of the integral
quotient</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rint</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rootn</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>round</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>rsqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;=1 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;=1 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sign</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sin</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sincos</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp for sine and cosine values</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp for sine and cosine values</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sinpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>smoothstep</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>sqrt</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 1.5 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 1.5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>step</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tan</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2.5 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanh</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tanpi</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 2 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>tgamma</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>trunc</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Correctly rounded</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<em>Implementations may perform floating-point operations on</em> <code>half</code>
<em>scalar or vector data types by converting the</em> <code>half</code> <em>values to single
precision floating-point values and performing the operation in single
precision floating-point.
In this case, the implementation will use the</em> <code>half</code> <em>scalar or vector data
type as a storage only format</em>.
</td>
</tr>
</table>
</div>
</div>
<div class="sect2">
<h3 id="edge-case-behavior"><a class="anchor" href="#edge-case-behavior"></a>7.5. Edge Case Behavior</h3>
<div class="paragraph">
<p>The edge case behavior of the <a href="#math-functions">math functions</a> shall
conform to <a href="#C99-spec">sections F.9 and G.6 of the C99 Specification</a>,
except <a href="#additional-requirements-beyond-c99-tc2">where noted below</a>.</p>
</div>
<div class="sect3">
<h4 id="additional-requirements-beyond-c99-tc2"><a class="anchor" href="#additional-requirements-beyond-c99-tc2"></a>7.5.1. Additional Requirements Beyond C99 TC2</h4>
<div class="paragraph">
<p>All functions that return a NaN should return a quiet NaN.</p>
</div>
<div class="paragraph">
<p><strong>half_&lt;funcname&gt;</strong> functions behave identically to the function of the same
name without the <strong>half_</strong> prefix.
They must conform to the same edge case requirements (<a href="#C99-spec">see
sections F.9 and G.6 of the C99 Specification</a>).
For other cases, except where otherwise noted, these single precision
functions are permitted to have up to 8192 ulps of error (as measured in the
single precision result), although better accuracy is encouraged.</p>
</div>
<div class="paragraph">
<p>The usual allowances for <a href="#relative-error-as-ulps">rounding error</a> or
<a href="#edge-case-behavior-in-flush-to-zero-mode">flushing behavior</a> shall not
apply for those values for which <a href="#C99-spec">section F.9 of the C99
Specification</a>, or the <a href="#additional-requirements-beyond-c99-tc2">additional
requirements</a> and <a href="#edge-case-behavior-in-flush-to-zero-mode">edge case
behavior</a> below (and similar sections for other floating-point precisions)
prescribe a result (e.g. <strong>ceil</strong>(-1 &lt; <em>x</em> &lt; 0) returns -0).
Those values shall produce exactly the prescribed answers, and no other.
Where the ± symbol is used, the sign shall be preserved.
For example, <strong>sin</strong>(±0) = ±0 shall be interpreted to mean
<strong>sin</strong>(+0) is +0 and <strong>sin</strong>(-0) is -0.</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>acospi</strong>(1) = +0.</p>
</li>
<li>
<p><strong>acospi</strong>(<em>x</em>) returns a NaN for |<em>x</em>| &gt; 1.</p>
</li>
<li>
<p><strong>asinpi</strong>(±0) = ±0.</p>
</li>
<li>
<p><strong>asinpi</strong>(<em>x</em>) returns a NaN for |<em>x</em>| &gt; 1.</p>
</li>
<li>
<p><strong>atanpi</strong>(±0) = ±0.</p>
</li>
<li>
<p><strong>atanpi</strong>(±∞) = ±0.5.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±0, -0) = ±1.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±0, +0) = ±0.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±0, <em>x</em>) returns ±1 for <em>x</em> &lt; 0.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±0, <em>x</em>) returns ±0 for <em>x</em> &gt; 0.</p>
</li>
<li>
<p><strong>atan2pi</strong>(<em>y</em>, ±0) returns -0.5 for <em>y</em> &lt; 0.</p>
</li>
<li>
<p><strong>atan2pi</strong>(<em>y</em>, ±0) returns 0.5 for <em>y</em> &gt; 0.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±_y_, -∞) returns ±1 for finite <em>y</em> &gt; 0.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±_y_, +∞) returns ±0 for finite <em>y</em> &gt; 0.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±∞, <em>x</em>) returns ±0.5 for finite <em>x</em>.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±∞, -∞) returns ±0.75.</p>
</li>
<li>
<p><strong>atan2pi</strong>(±∞, +∞) returns ±0.25.</p>
</li>
<li>
<p><strong>ceil</strong>(-1 &lt; <em>x</em> &lt; 0) returns -0.</p>
</li>
<li>
<p><strong>cospi</strong>(±0) returns 1</p>
</li>
<li>
<p><strong>cospi</strong>(<em>n</em> + 0.5) is +0 for any integer <em>n</em> where <em>n</em> + 0.5 is
representable.</p>
</li>
<li>
<p><strong>cospi</strong>(±∞) returns a NaN.</p>
</li>
<li>
<p><strong>exp10</strong>(-∞) returns +0.</p>
</li>
<li>
<p><strong>exp10</strong>(+∞) returns +∞.</p>
</li>
<li>
<p><strong>distance</strong>(<em>x</em>, <em>y</em>) calculates the distance from <em>x</em> to <em>y</em> without
overflow or extraordinary precision loss due to underflow.</p>
</li>
<li>
<p><strong>fdim</strong>(any, NaN) returns NaN.</p>
</li>
<li>
<p><strong>fdim</strong>(NaN, any) returns NaN.</p>
</li>
<li>
<p><strong>fmod</strong>(±0, NaN) returns NaN.</p>
</li>
<li>
<p><strong>frexp</strong>(±∞, <em>exp</em>) returns ±∞ and stores 0 in
<em>exp</em>.</p>
</li>
<li>
<p><strong>frexp</strong>(NaN, <em>exp</em>) returns the NaN and stores 0 in <em>exp</em>.</p>
</li>
<li>
<p><strong>fract</strong>(<em>x</em>, <em>iptr</em>) shall not return a value greater than or equal to
1.0, and shall not return a value less than 0.</p>
</li>
<li>
<p><strong>fract</strong>(+0, <em>iptr</em>) returns +0 and +0 in iptr.</p>
</li>
<li>
<p><strong>fract</strong>(-0, <em>iptr</em>) returns -0 and -0 in iptr.</p>
</li>
<li>
<p><strong>fract</strong>(+∞, <em>iptr</em>) returns +0 and +∞ in <em>iptr</em>.</p>
</li>
<li>
<p><strong>fract</strong>(-∞, <em>iptr</em>) returns -0 and -∞ in <em>iptr</em>.</p>
</li>
<li>
<p><strong>fract</strong>(NaN, <em>iptr</em>) returns the NaN and NaN in <em>iptr</em>.</p>
</li>
<li>
<p><strong>length</strong> calculates the length of a vector without overflow or
extraordinary precision loss due to underflow.</p>
</li>
<li>
<p><strong>lgamma_r</strong>(<em>x</em>, <em>signp</em>) returns 0 in <em>signp</em> if <em>x</em> is zero or a
negative integer.</p>
</li>
<li>
<p><strong>nextafter</strong>(-0, <em>y</em> &gt; 0) returns smallest positive denormal value.</p>
</li>
<li>
<p><strong>nextafter</strong>(+0, <em>y</em> &lt; 0) returns smallest negative denormal value.</p>
</li>
<li>
<p><strong>normalize</strong> shall reduce the vector to unit length, pointing in the
same direction without overflow or extraordinary precision loss due to
underflow.</p>
</li>
<li>
<p><strong>normalize</strong>(<em>v</em>) returns <em>v</em> if all elements of <em>v</em> are zero.</p>
</li>
<li>
<p><strong>normalize</strong>(<em>v</em>) returns a vector full of NaNs if any element is a NaN.</p>
</li>
<li>
<p><strong>normalize</strong>(<em>v</em>) for which any element in <em>v</em> is infinite shall proceed
as if the elements in <em>v</em> were replaced as follows:</p>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">for</span> <span class="p">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="o">/</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span>
<span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">isinf</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">?</span> <span class="n">copysign</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">:</span> <span class="mf">0.0</span> <span class="o">*</span> <span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">];</span></code></pre>
</div>
</div>
</li>
<li>
<p><strong>pow</strong>(±0, -∞) returns +∞</p>
</li>
<li>
<p><strong>pown</strong>(<em>x</em>, 0) is 1 for any <em>x</em>, even zero, NaN or infinity.</p>
</li>
<li>
<p><strong>pown</strong>(±0, <em>n</em>) is ±∞ for odd <em>n</em> &lt; 0.</p>
</li>
<li>
<p><strong>pown</strong>(±0, <em>n</em>) is +∞ for even <em>n</em> &lt; 0.</p>
</li>
<li>
<p><strong>pown</strong>(±0, <em>n</em>) is +0 for even <em>n</em> &gt; 0.</p>
</li>
<li>
<p><strong>pown</strong>(±0, <em>n</em>) is ±0 for odd <em>n</em> &gt; 0.</p>
</li>
<li>
<p><strong>powr</strong>(<em>x</em>, ±0) is 1 for finite <em>x</em> &gt; 0.</p>
</li>
<li>
<p><strong>powr</strong>(±0, <em>y</em>) is +∞ for finite <em>y</em> &lt; 0.</p>
</li>
<li>
<p><strong>powr</strong>(±0, -∞) is +∞.</p>
</li>
<li>
<p><strong>powr</strong>(±0, <em>y</em>) is +0 for <em>y</em> &gt; 0.</p>
</li>
<li>
<p><strong>powr</strong>(+1, <em>y</em>) is 1 for finite <em>y</em>.</p>
</li>
<li>
<p><strong>powr</strong>(<em>x</em>, <em>y</em>) returns NaN for <em>x</em> &lt; 0.</p>
</li>
<li>
<p><strong>powr</strong>(±0, ±0) returns NaN.</p>
</li>
<li>
<p><strong>powr</strong>(+∞, ±0) returns NaN.</p>
</li>
<li>
<p><strong>powr</strong>(+1, ±∞) returns NaN.</p>
</li>
<li>
<p><strong>powr</strong>(<em>x</em>, NaN) returns the NaN for <em>x</em> &gt;= 0.</p>
</li>
<li>
<p><strong>powr</strong>(NaN, <em>y</em>) returns the NaN.</p>
</li>
<li>
<p><strong>rint</strong>(-0.5 &lt;= <em>x</em> &lt; 0) returns -0.</p>
</li>
<li>
<p><strong>remquo</strong>(<em>x</em>, <em>y</em>, &amp;_quo_) returns a NaN and 0 in <em>quo</em> if <em>x</em> is
±∞, or if <em>y</em> is 0 and the other argument is non-NaN or if
either argument is a NaN.</p>
</li>
<li>
<p><strong>rootn</strong>(±0, <em>n</em>) is ±∞ for odd <em>n</em> &lt; 0.</p>
</li>
<li>
<p><strong>rootn</strong>(±0, <em>n</em>) is +∞ for even <em>n</em> &lt; 0.</p>
</li>
<li>
<p><strong>rootn</strong>(±0, <em>n</em>) is +0 for even <em>n</em> &gt; 0.</p>
</li>
<li>
<p><strong>rootn</strong>(±0, <em>n</em>) is ±0 for odd <em>n</em> &gt; 0.</p>
</li>
<li>
<p><strong>rootn</strong>(<em>x</em>, <em>n</em>) returns a NaN for <em>x</em> &lt; 0 and <em>n</em> is even.</p>
</li>
<li>
<p><strong>rootn</strong>(<em>x</em>, 0) returns a NaN.</p>
</li>
<li>
<p><strong>round</strong>(-0.5 &lt; <em>x</em> &lt; 0) returns -0.</p>
</li>
<li>
<p><strong>sinpi</strong>(±0) returns ±0.</p>
</li>
<li>
<p><strong>sinpi</strong>(+<em>n</em>) returns +0 for positive integers <em>n</em>.</p>
</li>
<li>
<p><strong>sinpi</strong>(-<em>n</em>) returns -0 for negative integers <em>n</em>.</p>
</li>
<li>
<p><strong>sinpi</strong>(±∞) returns a NaN.</p>
</li>
<li>
<p><strong>tanpi</strong>(±0) returns ±0.</p>
</li>
<li>
<p><strong>tanpi</strong>(±∞) returns a NaN.</p>
</li>
<li>
<p><strong>tanpi</strong>(<em>n</em>) is <strong>copysign</strong>(0.0, <em>n</em>) for even integers <em>n</em>.</p>
</li>
<li>
<p><strong>tanpi</strong>(<em>n</em>) is <strong>copysign</strong>(0.0, - <em>n</em>) for odd integers <em>n</em>.</p>
</li>
<li>
<p><strong>tanpi</strong>(<em>n</em> + 0.5) for even integer <em>n</em> is +∞ where <em>n</em> + 0.5 is
representable.</p>
</li>
<li>
<p><strong>tanpi</strong>(<em>n</em> + 0.5) for odd integer <em>n</em> is -∞ where <em>n</em> + 0.5 is
representable.</p>
</li>
<li>
<p><strong>trunc</strong>(-1 &lt; <em>x</em> &lt; 0) returns -0.
Binary file (standard input) matches</p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="changes-to-c99-tc2-behavior"><a class="anchor" href="#changes-to-c99-tc2-behavior"></a>7.5.2. Changes to C99 TC2 Behavior</h4>
<div class="paragraph">
<p><strong>modf</strong> behaves as though implemented by:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="kp">gentype</span> <span class="nf">modf</span><span class="p">(</span><span class="kp">gentype</span> <span class="n">value</span><span class="p">,</span> <span class="kp">gentype</span> <span class="o">*</span><span class="n">iptr</span><span class="p">)</span>
<span class="p">{</span>
<span class="o">*</span><span class="n">iptr</span> <span class="o">=</span> <span class="n">trunc</span><span class="p">(</span> <span class="n">value</span> <span class="p">);</span>
<span class="k">return</span> <span class="n">copysign</span><span class="p">(</span><span class="n">isinf</span><span class="p">(</span> <span class="n">value</span> <span class="p">)</span> <span class="o">?</span> <span class="mf">0.0</span> <span class="o">:</span> <span class="n">value</span> <span class="o">-</span> <span class="o">*</span><span class="n">iptr</span><span class="p">,</span> <span class="n">value</span><span class="p">);</span>
<span class="p">}</span></code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>rint</strong> always rounds according to round to nearest even rounding mode even
if the caller is in some other rounding mode.</p>
</div>
</div>
<div class="sect3">
<h4 id="edge-case-behavior-in-flush-to-zero-mode"><a class="anchor" href="#edge-case-behavior-in-flush-to-zero-mode"></a>7.5.3. Edge Case Behavior in Flush to Zero Mode</h4>
<div class="paragraph">
<p>If denormals are flushed to zero, then a function may return one of four
results:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Any conforming result for non-flush-to-zero mode</p>
</li>
<li>
<p>If the result given by 1.
is a sub-normal before rounding, it may be flushed to zero</p>
</li>
<li>
<p>Any non-flushed conforming result for the function if one or more of its
sub-normal operands are flushed to zero.</p>
</li>
<li>
<p>If the result of 3.
is a sub-normal before rounding, the result may be flushed to zero.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>In each of the above cases, if an operand or result is flushed to zero, the
sign of the zero is undefined.</p>
</div>
<div class="paragraph">
<p>If subnormals are flushed to zero, a device may choose to conform to the
following edge cases for <strong>nextafter</strong> instead of those listed in the
<a href="#additional-requirements-beyond-c99-tc2">additional requirements</a> section.</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>nextafter</strong>(+smallest normal, <em>y</em> &lt; +smallest normal) = +0.</p>
</li>
<li>
<p><strong>nextafter</strong>(-smallest normal, <em>y</em> &gt; -smallest normal) = -0.</p>
</li>
<li>
<p><strong>nextafter</strong>(-0, <em>y</em> &gt; 0) returns smallest positive normal value.</p>
</li>
<li>
<p><strong>nextafter</strong>(+0, <em>y</em> &lt; 0) returns smallest negative normal value.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For clarity, subnormals or denormals are defined to be the set of
representable numbers in the range 0 &lt; <em>x</em> &lt; <code>TYPE_MIN</code> and <code>-TYPE_MIN</code> &lt;
<em>x</em> &lt; -0.
They do not include ±0.
A non-zero number is said to be sub-normal before rounding if after
normalization, its radix-2 exponent is less than (<code>TYPE_MIN_EXP</code> - 1)
<sup class="footnote">[<a id="_footnoteref_117" class="footnote" href="#_footnotedef_117" title="View footnote.">117</a>]</sup>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="image-addressing-and-filtering"><a class="anchor" href="#image-addressing-and-filtering"></a>8. Image Addressing and Filtering</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Let w<sub>t</sub>, h<sub>t</sub> and d<sub>t</sub> be the width, height (or image array size for a 1D
image array) and depth (or image array size for a 2D image array) of the
image in pixels.
Let <em>coord.xy</em> (also referred to as (<em>s</em>, <em>t</em>)) or <em>coord.xyz</em> (also referred
to as (<em>s</em>, <em>t</em>, <em>r</em>)) be the coordinates specified to <strong>read_image{f|i|ui}</strong>.
The sampler specified in <strong>read_image{f|i|ui}</strong> is used to determine how to
sample the image and return an appropriate color.</p>
</div>
<div class="sect2">
<h3 id="image-coordinates"><a class="anchor" href="#image-coordinates"></a>8.1. Image Coordinates</h3>
<div class="paragraph">
<p>This affects the interpretation of image coordinates.
If image coordinates specified to <strong>read_image{f|i|ui}</strong> are normalized (as
specified in the sampler), the <em>s</em>, <em>t</em>, and <em>r</em> coordinate values are
multiplied by w<sub>t</sub>, h<sub>t,</sub> and d<sub>t</sub> respectively to generate the unnormalized
coordinate values.
For image arrays, the image array coordinate (i.e. <em>t</em> if it is a 1D image
array or <em>r</em> if it is a 2D image array) specified to <strong>read_image{f|i|ui}</strong>
must always be the un-normalized image coordinate value.</p>
</div>
<div class="paragraph">
<p>Let (<em>u</em>, <em>v</em>, <em>w</em>) represent the unnormalized image coordinate values.</p>
</div>
</div>
<div class="sect2">
<h3 id="addressing-and-filter-modes"><a class="anchor" href="#addressing-and-filter-modes"></a>8.2. Addressing and Filter Modes</h3>
<div class="paragraph">
<p>We first describe how the addressing and filter modes are applied to
generate the appropriate sample locations to read from the image if the
addressing mode is not <code>CLK_ADDRESS_REPEAT</code> nor
<code>CLK_ADDRESS_MIRRORED_REPEAT</code>.</p>
</div>
<div class="paragraph">
<p>After generating the image coordinate (<em>u</em>, <em>v</em>, <em>w</em>) we apply the appropriate
addressing and filter mode to generate the appropriate sample locations to
read from the image.</p>
</div>
<div class="paragraph">
<p>If values in (<em>u</em>, <em>v</em>, <em>w</em>) are <code>INF</code> or NaN, the behavior of
<strong>read_image{f|i|ui}</strong> is undefined.</p>
</div>
<div class="paragraph">
<p><strong>Filter Mode</strong> <code>CLK_FILTER_NEAREST</code></p>
</div>
<div class="paragraph">
<p>When filter mode is <code>CLK_FILTER_NEAREST</code>, the image element in the image
that is nearest (in Manhattan distance) to that specified by (<em>u</em>, <em>v</em>, <em>w</em>)
is obtained.
This means the image element at location (<em>i</em>, <em>j</em>, <em>k</em>) becomes the image
element value, where</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">i</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">u</span><span class="p">))</span>
<span class="n">j</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">w</span><span class="p">))</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>For a 3D image, the image element at location (<em>i</em>, <em>j</em>, <em>k</em>) becomes the
color value.
For a 2D image, the image element at location (<em>i</em>, <em>j</em>) becomes the color
value.</p>
</div>
<div class="paragraph">
<p>The following table describes the address_mode function.</p>
</div>
<table id="table-address-modes-texel-location" class="tableblock frame-all grid-all stretch">
<caption class="title">Table 70. Addressing modes to generate texel location</caption>
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Addressing Mode</th>
<th class="tableblock halign-left valign-top">Result of address_mode(coord)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CLK_ADDRESS_CLAMP_TO_EDGE</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">clamp (coord, 0, size - 1)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CLK_ADDRESS_CLAMP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">clamp (coord, -1, size)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>CLK_ADDRESS_NONE</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">coord</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <code>size</code> term in this table is w<sub>t</sub> for <em>u</em>, h<sub>t</sub> for <em>v</em> and d<sub>t</sub> for
<em>w</em>.</p>
</div>
<div class="paragraph">
<p>The <code>clamp</code> function used in this table is defined as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">clamp</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span> <span class="o">=</span> <span class="k">return</span> <span class="p">(</span><span class="n">a</span> <span class="o">&lt;</span> <span class="n">b</span><span class="p">)</span> <span class="o">?</span> <span class="n">b</span> <span class="o">:</span> <span class="p">((</span><span class="n">a</span> <span class="o">&gt;</span> <span class="n">c</span><span class="p">)</span> <span class="o">?</span> <span class="n">c</span> <span class="o">:</span> <span class="n">a</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>If the selected texel location (<em>i</em>, <em>j</em>, <em>k</em>) refers to a location outside
the image, the border color is used as the color value for this texel.</p>
</div>
<div class="paragraph">
<p><strong>Filter Mode</strong> <code>CLK_FILTER_LINEAR</code></p>
</div>
<div class="paragraph">
<p>When filter mode is <code>CLK_FILTER_LINEAR</code>, a 2×2 square of image
elements for a 2D image or a 2×2×2 cube of image elements for a
3D image is selected.
This 2×2 square or 2×2×2 cube is obtained as follows.</p>
</div>
<div class="paragraph">
<p>Let</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">i0</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">u</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">))</span>
<span class="n">j0</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">v</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">))</span>
<span class="n">k0</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">w</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">))</span>
<span class="n">i1</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">u</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">j1</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">v</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">k1</span> <span class="o">=</span> <span class="n">address_mode</span><span class="p">((</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">w</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">u</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">v</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">w</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>frac(x)</code> denotes the fractional part of x and is computed as <code>x -
floor(x)</code>.</p>
</div>
<div class="paragraph">
<p>For a 3D image, the image element value is found as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">T</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j0k0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j0k0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j1k0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j1k0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i0j0k1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i1j0k1</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i0j1k1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i1j1k1</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>T_ijk</code> is the image element at location (<em>i</em>, <em>j</em>, <em>k</em>) in the 3D image.</p>
</div>
<div class="paragraph">
<p>For a 2D image, the image element value is found as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">T</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">T_i0j1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">T_i1j1</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>T_ij</code> is the image element at location (<em>i</em>, <em>j</em>) in the 2D image.</p>
</div>
<div class="paragraph">
<p>If any of the selected <code>T_ijk</code> or <code>T_ij</code> in the above equations refers to a
location outside the image, the border color is used as the color value for
<code>T_ijk</code> or <code>T_ij</code>.</p>
</div>
<div class="paragraph">
<p>If the image channel type is <code>CL_FLOAT</code> or <code>CL_HALF_<wbr>FLOAT</code> and any of the
image elements <code>T_ijk</code> or <code>T_ij</code> is <code>INF</code> or NaN, the behavior of the built-in
image read function is undefined.</p>
</div>
<div class="paragraph">
<p>We now discuss how the addressing and filter modes are applied to generate
the appropriate sample locations to read from the image if the addressing
mode is <code>CLK_ADDRESS_REPEAT</code>.</p>
</div>
<div class="paragraph">
<p>If values in (<em>s</em>, <em>t</em>, <em>r</em>) are <code>INF</code> or NaN, the behavior of the built-in
image read functions is undefined.</p>
</div>
<div class="paragraph">
<p><strong>Filter Mode</strong> <code>CLK_FILTER_NEAREST</code></p>
</div>
<div class="paragraph">
<p>When filter mode is <code>CLK_FILTER_NEAREST</code>, the image element at location
(<em>i</em>, <em>j</em>, <em>k</em>) becomes the image element value, with <em>i</em>, <em>j</em>, and <em>k</em>
computed as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">u</span> <span class="o">=</span> <span class="p">(</span><span class="n">s</span> <span class="o">-</span> <span class="n">floor</span><span class="p">(</span><span class="n">s</span><span class="p">))</span> <span class="o">*</span> <span class="n">w_t</span>
<span class="n">i</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="n">i</span> <span class="o">&gt;</span> <span class="n">w_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">i</span> <span class="o">=</span> <span class="n">i</span> <span class="o">-</span> <span class="n">w_t</span>
<span class="n">v</span> <span class="o">=</span> <span class="p">(</span><span class="n">t</span> <span class="o">-</span> <span class="n">floor</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="o">*</span> <span class="n">h_t</span>
<span class="n">j</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="n">j</span> <span class="o">&gt;</span> <span class="n">h_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">j</span> <span class="o">=</span> <span class="n">j</span> <span class="o">-</span> <span class="n">h_t</span>
<span class="n">w</span> <span class="o">=</span> <span class="p">(</span><span class="n">r</span> <span class="o">-</span> <span class="n">floor</span><span class="p">(</span><span class="n">r</span><span class="p">))</span> <span class="o">*</span> <span class="n">d_t</span>
<span class="n">k</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">w</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="n">k</span> <span class="o">&gt;</span> <span class="n">d_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">k</span> <span class="o">-</span> <span class="n">d_t</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>For a 3D image, the image element at location (<em>i</em>, <em>j</em>, <em>k</em>) becomes the
color value.
For a 2D image, the image element at location (<em>i</em>, <em>j</em>) becomes the color
value.</p>
</div>
<div class="paragraph">
<p><strong>Filter Mode</strong> <code>CLK_FILTER_LINEAR</code></p>
</div>
<div class="paragraph">
<p>When filter mode is <code>CLK_FILTER_LINEAR</code>, a 2×2 square of image
elements for a 2D image or a 2×2×2 cube of image elements for a
3D image is selected.
This 2×2 square or 2×2×2 cube is obtained as follows.</p>
</div>
<div class="paragraph">
<p>Let</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">u</span> <span class="o">=</span> <span class="p">(</span><span class="n">s</span> <span class="o">-</span> <span class="n">floor</span><span class="p">(</span><span class="n">s</span><span class="p">))</span> <span class="o">*</span> <span class="n">w_t</span>
<span class="n">i0</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">u</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">i1</span> <span class="o">=</span> <span class="n">i0</span> <span class="o">+</span> <span class="mi">1</span>
<span class="k">if</span> <span class="p">(</span><span class="n">i0</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">i0</span> <span class="o">=</span> <span class="n">w_t</span> <span class="o">+</span> <span class="n">i0</span>
<span class="k">if</span> <span class="p">(</span><span class="n">i1</span> <span class="o">&gt;</span> <span class="n">w_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">i1</span> <span class="o">=</span> <span class="n">i1</span> <span class="o">-</span> <span class="n">w_t</span>
<span class="n">v</span> <span class="o">=</span> <span class="p">(</span><span class="n">t</span> <span class="o">-</span> <span class="n">floor</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="o">*</span> <span class="n">h_t</span>
<span class="n">j0</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">v</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">j1</span> <span class="o">=</span> <span class="n">j0</span> <span class="o">+</span> <span class="mi">1</span>
<span class="k">if</span> <span class="p">(</span><span class="n">j0</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">j0</span> <span class="o">=</span> <span class="n">h_t</span> <span class="o">+</span> <span class="n">j0</span>
<span class="k">if</span> <span class="p">(</span><span class="n">j1</span> <span class="o">&gt;</span> <span class="n">h_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">j1</span> <span class="o">=</span> <span class="n">j1</span> <span class="o">-</span> <span class="n">h_t</span>
<span class="n">w</span> <span class="o">=</span> <span class="p">(</span><span class="n">r</span> <span class="o">-</span> <span class="n">floor</span><span class="p">(</span><span class="n">r</span><span class="p">))</span> <span class="o">*</span> <span class="n">d_t</span>
<span class="n">k0</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">w</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">k1</span> <span class="o">=</span> <span class="n">k0</span> <span class="o">+</span> <span class="mi">1</span>
<span class="k">if</span> <span class="p">(</span><span class="n">k0</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">k0</span> <span class="o">=</span> <span class="n">d_t</span> <span class="o">+</span> <span class="n">k0</span>
<span class="k">if</span> <span class="p">(</span><span class="n">k1</span> <span class="o">&gt;</span> <span class="n">d_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">k1</span> <span class="o">=</span> <span class="n">k1</span> <span class="o">-</span> <span class="n">d_t</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">u</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">v</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">w</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>frac(x)</code> denotes the fractional part of x and is computed as <code>x -
floor(x)</code>.</p>
</div>
<div class="paragraph">
<p>For a 3D image, the image element value is found as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">T</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j0k0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j0k0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j1k0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j1k0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i0j0k1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i1j0k1</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i0j1k1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i1j1k1</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>T_ijk</code> is the image element at location (<em>i</em>, <em>j</em>, <em>k</em>) in the 3D image.</p>
</div>
<div class="paragraph">
<p>For a 2D image, the image element value is found as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">T</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">T_i0j1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">T_i1j1</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>T_ij</code> is the image element at location (<em>i</em>, <em>j</em>) in the 2D image.</p>
</div>
<div class="paragraph">
<p>If the image channel type is <code>CL_FLOAT</code> or <code>CL_HALF_<wbr>FLOAT</code> and any of the
image elements <code>T_ijk</code> or <code>T_ij</code> is <code>INF</code> or NaN, the behavior of the built-in
image read function is undefined.</p>
</div>
<div class="paragraph">
<p>We now discuss how the addressing and filter modes are applied to generate
the appropriate sample locations to read from the image if the addressing
mode is <code>CLK_ADDRESS_MIRRORED_REPEAT</code>.
The <code>CLK_ADDRESS_MIRRORED_REPEAT</code> addressing mode causes the image to be
read as if it is tiled at every integer seam with the interpretation of the
image data flipped at each integer crossing.
For example, the (<em>s</em>, <em>t</em>, <em>r</em>) coordinates between 2 and 3 are addressed
into the image as coordinates from 1 down to 0.
If values in (<em>s</em>, <em>t</em>, <em>r</em>) are <code>INF</code> or NaN, the behavior of the built-in
image read functions is undefined.</p>
</div>
<div class="paragraph">
<p><strong>Filter Mode</strong> <code>CLK_FILTER_NEAREST</code></p>
</div>
<div class="paragraph">
<p>When filter mode is <code>CLK_FILTER_NEAREST</code>, the image element at location
(<em>i</em>, <em>j</em>, <em>k</em>) becomes the image element value, with <em>i</em>, <em>j</em> and k computed
as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">s_prime</span> <span class="o">=</span> <span class="mf">2.0f</span> <span class="o">*</span> <span class="n">rint</span><span class="p">(</span><span class="mf">0.5f</span> <span class="o">*</span> <span class="n">s</span><span class="p">)</span>
<span class="n">s_prime</span> <span class="o">=</span> <span class="n">fabs</span><span class="p">(</span><span class="n">s</span> <span class="o">-</span> <span class="n">s_prime</span><span class="p">)</span>
<span class="n">u</span> <span class="o">=</span> <span class="n">s_prime</span> <span class="o">*</span> <span class="n">w_t</span>
<span class="n">i</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
<span class="n">i</span> <span class="o">=</span> <span class="n">min</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">w_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">t_prime</span> <span class="o">=</span> <span class="mf">2.0f</span> <span class="o">*</span> <span class="n">rint</span><span class="p">(</span><span class="mf">0.5f</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span>
<span class="n">t_prime</span> <span class="o">=</span> <span class="n">fabs</span><span class="p">(</span><span class="n">t</span> <span class="o">-</span> <span class="n">t_prime</span><span class="p">)</span>
<span class="n">v</span> <span class="o">=</span> <span class="n">t_prime</span> <span class="o">*</span> <span class="n">h_t</span>
<span class="n">j</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
<span class="n">j</span> <span class="o">=</span> <span class="n">min</span><span class="p">(</span><span class="n">j</span><span class="p">,</span> <span class="n">h_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">r_prime</span> <span class="o">=</span> <span class="mf">2.0f</span> <span class="o">*</span> <span class="n">rint</span><span class="p">(</span><span class="mf">0.5f</span> <span class="o">*</span> <span class="n">r</span><span class="p">)</span>
<span class="n">r_prime</span> <span class="o">=</span> <span class="n">fabs</span><span class="p">(</span><span class="n">r</span> <span class="o">-</span> <span class="n">r_prime</span><span class="p">)</span>
<span class="n">w</span> <span class="o">=</span> <span class="n">r_prime</span> <span class="o">*</span> <span class="n">d_t</span>
<span class="n">k</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">w</span><span class="p">)</span>
<span class="n">k</span> <span class="o">=</span> <span class="n">min</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">d_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>For a 3D image, the image element at location (<em>i</em>, <em>j</em>, <em>k</em>) becomes the
color value.
For a 2D image, the image element at location (<em>i</em>, <em>j</em>) becomes the color
value.</p>
</div>
<div class="paragraph">
<p><strong>Filter Mode</strong> <code>CLK_FILTER_LINEAR</code></p>
</div>
<div class="paragraph">
<p>When filter mode is <code>CLK_FILTER_LINEAR</code>, a 2×2 square of image
elements for a 2D image or a 2×2×2 cube of image elements for a
3D image is selected.
This 2×2 square or 2×2×2 cube is obtained as follows.</p>
</div>
<div class="paragraph">
<p>Let</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">s_prime</span> <span class="o">=</span> <span class="mf">2.0f</span> <span class="o">*</span> <span class="n">rint</span><span class="p">(</span><span class="mf">0.5f</span> <span class="o">*</span> <span class="n">s</span><span class="p">)</span>
<span class="n">s_prime</span> <span class="o">=</span> <span class="n">fabs</span><span class="p">(</span><span class="n">s</span> <span class="o">-</span> <span class="n">s_prime</span><span class="p">)</span>
<span class="n">u</span> <span class="o">=</span> <span class="n">s_prime</span> <span class="o">*</span> <span class="n">w_t</span>
<span class="n">i0</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">u</span> <span class="o">-</span> <span class="mf">0.5f</span><span class="p">)</span>
<span class="n">i1</span> <span class="o">=</span> <span class="n">i0</span> <span class="o">+</span> <span class="mi">1</span>
<span class="n">i0</span> <span class="o">=</span> <span class="n">max</span><span class="p">(</span><span class="n">i0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">i1</span> <span class="o">=</span> <span class="n">min</span><span class="p">(</span><span class="n">i1</span><span class="p">,</span> <span class="n">w_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">t_prime</span> <span class="o">=</span> <span class="mf">2.0f</span> <span class="o">*</span> <span class="n">rint</span><span class="p">(</span><span class="mf">0.5f</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span>
<span class="n">t_prime</span> <span class="o">=</span> <span class="n">fabs</span><span class="p">(</span><span class="n">t</span> <span class="o">-</span> <span class="n">t_prime</span><span class="p">)</span>
<span class="n">v</span> <span class="o">=</span> <span class="n">t_prime</span> <span class="o">*</span> <span class="n">h_t</span>
<span class="n">j0</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">v</span> <span class="o">-</span> <span class="mf">0.5f</span><span class="p">)</span>
<span class="n">j1</span> <span class="o">=</span> <span class="n">j0</span> <span class="o">+</span> <span class="mi">1</span>
<span class="n">j0</span> <span class="o">=</span> <span class="n">max</span><span class="p">(</span><span class="n">j0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">j1</span> <span class="o">=</span> <span class="n">min</span><span class="p">(</span><span class="n">j1</span><span class="p">,</span> <span class="n">h_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">r_prime</span> <span class="o">=</span> <span class="mf">2.0f</span> <span class="o">*</span> <span class="n">rint</span><span class="p">(</span><span class="mf">0.5f</span> <span class="o">*</span> <span class="n">r</span><span class="p">)</span>
<span class="n">r_prime</span> <span class="o">=</span> <span class="n">fabs</span><span class="p">(</span><span class="n">r</span> <span class="o">-</span> <span class="n">r_prime</span><span class="p">)</span>
<span class="n">w</span> <span class="o">=</span> <span class="n">r_prime</span> <span class="o">*</span> <span class="n">d_t</span>
<span class="n">k0</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">floor</span><span class="p">(</span><span class="n">w</span> <span class="o">-</span> <span class="mf">0.5f</span><span class="p">)</span>
<span class="n">k1</span> <span class="o">=</span> <span class="n">k0</span> <span class="o">+</span> <span class="mi">1</span>
<span class="n">k0</span> <span class="o">=</span> <span class="n">max</span><span class="p">(</span><span class="n">k0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">k1</span> <span class="o">=</span> <span class="n">min</span><span class="p">(</span><span class="n">k1</span><span class="p">,</span> <span class="n">d_t</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">u</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">v</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">frac</span><span class="p">(</span><span class="n">w</span> <span class="o">-</span> <span class="mf">0.5</span><span class="p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>frac(x)</code> denotes the fractional part of x and is computed as <code>x -
floor(x)</code>.</p>
</div>
<div class="paragraph">
<p>For a 3D image, the image element value is found as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">T</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j0k0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j0k0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j1k0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">c</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j1k0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i0j0k1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i1j0k1</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i0j1k1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">c</span> <span class="o">*</span> <span class="n">T_i1j1k1</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>T_ijk</code> is the image element at location (<em>i</em>, <em>j</em>, <em>k</em>) in the 3D image.</p>
</div>
<div class="paragraph">
<p>For a 2D image, the image element value is found as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">T</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0j0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">b</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i1j0</span>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">T_i0j1</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span> <span class="o">*</span> <span class="n">T_i1j1</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>T_ij</code> is the image element at location (<em>i</em>, <em>j</em>) in the 2D image.</p>
</div>
<div class="paragraph">
<p>For a 1D image, the image element value is found as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="n">T</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">a</span><span class="p">)</span> <span class="o">*</span> <span class="n">T_i0</span>
<span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">T_i1</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>where <code>T_i</code> is the image element at location (<em>i</em>) in the 1D image.</p>
</div>
<div class="paragraph">
<p>If the image channel type is <code>CL_FLOAT</code> or <code>CL_HALF_<wbr>FLOAT</code> and any of the
image elements <code>T_ijk</code> or <code>T_ij</code> is <code>INF</code> or NaN, the behavior of the built-in
image read function is undefined.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>If the sampler is specified as using unnormalized coordinates
(floating-point or integer coordinates), filter mode set to
<code>CLK_FILTER_NEAREST</code> and addressing mode set to one of the following modes -
<code>CLK_ADDRESS_NONE</code>, <code>CLK_ADDRESS_CLAMP_TO_EDGE</code> or <code>CLK_ADDRESS_CLAMP</code>, the
<a href="#addressing-and-filter-modes">location of the image element in the image</a>
given by (<em>i</em>, <em>j</em>, <em>k</em>) will be computed without any loss of precision.</p>
</div>
<div class="paragraph">
<p>For all other sampler combinations of normalized or unnormalized
coordinates, filter and addressing modes, the relative error or precision of
the addressing mode calculations and the image filter operation are not
defined by this revision of the OpenCL specification.
To ensure a minimum precision of image addressing and filter calculations
across any OpenCL device, for these sampler combinations, developers should
unnormalize the image coordinate in the kernel and implement the linear
filter in the kernel with appropriate calls to <strong>read_image{f|i|ui}</strong> with a
sampler that uses unnormalized coordinates, filter mode set to
<code>CLK_FILTER_NEAREST</code>, addressing mode set to <code>CLK_ADDRESS_NONE</code>,
<code>CLK_ADDRESS_CLAMP_TO_EDGE</code> <em>or</em> <code>CLK_ADDRESS_CLAMP</code>, and finally performing
the interpolation of color values read from the image to generate the
filtered color value.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="sect2">
<h3 id="conversion-rules"><a class="anchor" href="#conversion-rules"></a>8.3. Conversion Rules</h3>
<div class="paragraph">
<p>In this section we discuss conversion rules that are applied when reading
and writing images in a kernel.</p>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-normalized-integer-channel-data-types"><a class="anchor" href="#conversion-rules-for-normalized-integer-channel-data-types"></a>8.3.1. Conversion Rules for Normalized Integer Channel Data Types</h4>
<div class="paragraph">
<p>In this section we discuss converting normalized integer channel data types
to floating-point values and vice-versa.</p>
</div>
<div class="sect4">
<h5 id="converting-normalized-integer-channel-data-types-to-floating-point-values"><a class="anchor" href="#converting-normalized-integer-channel-data-types-to-floating-point-values"></a>8.3.1.1. Converting Normalized Integer Channel Data Types to Floating-point Values</h5>
<div class="paragraph">
<p>For images created with any of the following image channel data types,
<strong>read_imagef</strong> will convert the channel values from an unsigned integer to
normalized floating-point values in the range [<code>0.0f</code>, <code>1.0f</code>].</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_UNORM_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT16</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For images created with any of the following image channel data types,
<strong>read_imagef</strong> will convert the channel values from a signed integer to
normalized floating-point values in the range [<code>-1.0f</code>, <code>1.0f</code>].</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_SNORM_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_SNORM_<wbr>INT16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>These conversions are performed as follows:</p>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT8</code> (8-bit unsigned integer) → <code>float</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>float</code> value = <code>(float)c / 255.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT_<wbr>101010</code> (10-bit unsigned integer) → <code>float</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>float</code> value = <code>(float)c / 1023.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT16</code> (16-bit unsigned integer) → <code>float</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>float</code> value = <code>(float)c / 65535.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code> (10-bit unsigned integer) → <code>float</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>float</code> value = <code>(float)c / 1023.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code> (12-bit unsigned integer) → <code>float</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>float</code> value = <code>(float)c / 4095.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code> (14-bit unsigned integer) → <code>float</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>float</code> value = <code>(float)c / 16383.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_SNORM_<wbr>INT8</code> (8-bit signed integer) → <code>float</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>float</code> value = <strong>max</strong>(<code>-1.0f</code>, <code>(float)c / 127.0f</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_SNORM_<wbr>INT16</code> (16-bit signed integer) → <code>float</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>float</code> value = <strong>max</strong>(<code>-1.0f</code>, <code>(float)c / 32767.0f</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The precision of the above conversions is &lt;= 1.5 ulp except for the
following cases:</p>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT8</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0f</code> and</p>
</li>
<li>
<p>255 must convert to <code>1.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT_<wbr>101010</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0f</code> and</p>
</li>
<li>
<p>1023 must convert to <code>1.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT16</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0f</code> and</p>
</li>
<li>
<p>65535 must convert to <code>1.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code>:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0f</code>, and</p>
</li>
<li>
<p>1023 must convert to <code>1.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code>:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0f</code>, and</p>
</li>
<li>
<p>4095 must convert to <code>1.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code>:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0f</code>, and</p>
</li>
<li>
<p>16383 must convert to <code>1.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_SNORM_<wbr>INT8</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>-128 and -127 must convert to <code>-1.0f</code>,</p>
</li>
<li>
<p>0 must convert to <code>0.0f</code> and</p>
</li>
<li>
<p>127 must convert to <code>1.0f</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_SNORM_<wbr>INT16</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>-32768 and -32767 must convert to <code>-1.0f</code>,</p>
</li>
<li>
<p>0 must convert to <code>0.0f</code> and</p>
</li>
<li>
<p>32767 must convert to <code>1.0f</code></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="converting-normalized-integer-channel-data-types-to-half-precision-floating-point-values"><a class="anchor" href="#converting-normalized-integer-channel-data-types-to-half-precision-floating-point-values"></a>8.3.1.2. Converting Normalized Integer Channel Data Types to Half-Precision Floating-Point Values</h5>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The conversions described in this section require the <code>cl_khr_<wbr>fp16</code> extension.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>For images created with any of the following image channel data types,
<strong>read_imageh</strong> will convert the channel values from an
8-bit or 16-bit unsigned integer to normalized half-precision floating-point
values in the range [<code>0.0h</code>, <code>1.0h</code>].</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_UNORM_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT16</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For images created with any of the following image channel data types,
<strong>read_imageh</strong> will convert the channel values from a signed integer to
normalized half-precision floating-point values in the range [<code>-1.0h</code>, <code>1.0h</code>].</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_SNORM_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_SNORM_<wbr>INT16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>These conversions are performed as follows:</p>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT8</code> (8-bit unsigned integer) → <code>half</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>half</code> value = <code>round_to_half(c / 255)</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT_<wbr>101010</code> (10-bit unsigned integer) → <code>half</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>half</code> value = <code>round_to_half(c / 1023)</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT16</code> (16-bit unsigned integer) → <code>half</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>half</code> value = <code>round_to_half(c / 65535)</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code> (10-bit unsigned integer) → <code>half</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>half</code> value = <code>round_to_half(c / 1023)</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code> (12-bit unsigned integer) → <code>half</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>half</code> value = <code>round_to_half(c / 4095)</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code> (14-bit unsigned integer) → <code>half</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>half</code> value = <code>round_to_half(c / 16383)</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_SNORM_<wbr>INT8</code> (8-bit signed integer) → <code>half</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>half</code> value = <strong>max</strong>(<code>-1.0h</code>, <code>round_to_half(c / 127)</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>CL_SNORM_<wbr>INT16</code> (16-bit signed integer) → <code>half</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>normalized <code>half</code> value = <strong>max</strong>(<code>-1.0h</code>, <code>round_to_half(c / 32767)</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The precision of the above conversions is &lt;= 1.5 ulp except for the
following cases:</p>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT8</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0h</code> and</p>
</li>
<li>
<p>255 must convert to <code>1.0h</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT_<wbr>101010</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0h</code> and</p>
</li>
<li>
<p>1023 must convert to <code>1.0h</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT16</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0h</code> and</p>
</li>
<li>
<p>65535 must convert to <code>1.0h</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code>:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0h</code>, and</p>
</li>
<li>
<p>1023 must convert to <code>1.0h</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code>:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0h</code>, and</p>
</li>
<li>
<p>4095 must convert to <code>1.0h</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code>:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>0 must convert to <code>0.0h</code>, and</p>
</li>
<li>
<p>16383 must convert to <code>1.0h</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_SNORM_<wbr>INT8</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>-128 and -127 must convert to <code>-1.0h</code>,</p>
</li>
<li>
<p>0 must convert to <code>0.0h</code> and</p>
</li>
<li>
<p>127 must convert to <code>1.0h</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For <code>CL_SNORM_<wbr>INT16</code></p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>-32768 and -32767 must convert to <code>-1.0h</code>,</p>
</li>
<li>
<p>0 must convert to <code>0.0h</code> and</p>
</li>
<li>
<p>32767 must convert to <code>1.0h</code></p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="converting-floating-point-values-to-normalized-integer-channel-data-types"><a class="anchor" href="#converting-floating-point-values-to-normalized-integer-channel-data-types"></a>8.3.1.3. Converting Floating-Point Values to Normalized Integer Channel Data Types</h5>
<div class="paragraph">
<p>For images created with any of the following image channel data types,
<strong>write_imagef</strong> will convert the floating-point color value to an unsigned
integer.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_UNORM_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT16</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For images created with any of the following image channel data types,
<strong>write_imagef</strong> will convert the floating-point color value to a signed
integer.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_SNORM_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_SNORM_<wbr>INT16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The preferred method for how conversions from floating-point values to
normalized integer values are performed is as follows:</p>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT8</code> (8-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>convert_uchar_sat_rte</strong>(<code>f * 255.0f</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT_<wbr>101010</code> (10-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>min</strong>(<strong>convert_ushort_sat_rte</strong>(<code>f * 1023.0f</code>), <code>0x3ff</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT16</code> (16-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>convert_ushort_sat_rte</strong>(<code>f * 65535.0f</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code> (10-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>min</strong>(<strong>convert_ushort_sat_rte</strong>(<code>f * 1023.0f</code>), <code>1023</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code> (12-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>min</strong>(<strong>convert_ushort_sat_rte</strong>(<code>f * 4095.0f</code>), <code>4095</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code> (14-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>min</strong>(<strong>convert_ushort_sat_rte</strong>(<code>f * 16383.0f</code>), <code>16383</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_SNORM_<wbr>INT8</code> (8-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>convert_char_sat_rte</strong>(<code>f * 127.0f</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_SNORM_<wbr>INT16</code> (16-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>convert_short_sat_rte</strong>(<code>f * 32767.0f</code>)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Please refer to the <a href="#out-of-range-behavior">out-of-range behavior and
saturated conversion</a> rules.</p>
</div>
<div class="paragraph">
<p>OpenCL implementations may choose to approximate the rounding mode used in
the conversions described above.
If a rounding mode other than round to nearest even (<code>_rte</code>) is used, the
absolute error of the implementation dependant rounding mode vs.
the result produced by the round to nearest even rounding mode must be ≤
0.6.</p>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT8</code> (8-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_uchar_sat_rte</strong>(f * <code>255.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_uchar_sat_&lt;impl-rounding-mode&gt;</strong>(f * <code>255.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>preferred</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT_<wbr>101010</code> (10-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(f * <code>1023.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(f *
<code>1023.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>preferred</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT16</code> (16-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(f * <code>65535.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(f *
<code>65535.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>preferred</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code> (10-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(f * <code>1023.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(f *
<code>1023.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>preferred</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code> (12-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(f * <code>4095.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(f *
<code>4095.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>preferred</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code> (14-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(f * <code>16383.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(f *
<code>16383.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>preferred</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_SNORM_<wbr>INT8</code> (8-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_char_sat_rte</strong>(f * <code>127.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_char_sat_&lt;impl_rounding_mode&gt;</strong>(f * <code>127.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>preferred</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>float</code> → <code>CL_SNORM_<wbr>INT16</code> (16-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_short_sat_rte</strong>(f * <code>32767.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_short_sat_&lt;impl-rounding-mode&gt;</strong>(f *
<code>32767.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>preferred</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="converting-half-precision-floating-point-values-to-normalized-integer-channel-data-types"><a class="anchor" href="#converting-half-precision-floating-point-values-to-normalized-integer-channel-data-types"></a>8.3.1.4. Converting Half-Precision Floating-point Values to Normalized Integer Channel Data Types</h5>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The conversions described in this section require the <code>cl_khr_<wbr>fp16</code> extension.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>For images created with any of the following image channel data types,
<strong>write_imageh</strong> will convert the floating-point color value to an unsigned
integer.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_UNORM_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT16</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For images created with any of the following image channel data types,
<strong>write_imageh</strong> will convert the floating-point color value to a signed integer.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_SNORM_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_SNORM_<wbr>INT16</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The preferred conversion uses the round to nearest even (<code>_rte</code>) rounding
mode, but OpenCL implementations may choose to approximate the rounding mode
used in the conversions described below.
When approximate rounding is used instead of the preferred rounding, the
result of the conversion must satisfy the bound given below.</p>
</div>
<div class="paragraph">
<p><code>half</code> → <code>CL_UNORM_<wbr>INT8</code> (8-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>exact</sub> = <strong>max</strong>(<code>0</code>, <strong>min</strong>(<code>f * 255</code>, <code>255</code>))</p>
</li>
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_uchar_sat_rte</strong>(<code>f * 255.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_uchar_sat_&lt;impl-rounding-mode&gt;</strong>(<code>f * 255.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>exact</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>half</code> → <code>CL_UNORM_<wbr>INT_<wbr>101010</code> (10-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>exact</sub> = <strong>max</strong>(<code>0</code>, <strong>min</strong>(<code>f * 1023</code>, <code>1023</code>))</p>
</li>
<li>
<p>Let f<sub>preferred</sub> = <strong>min</strong>(<strong>convert_ushort_sat_rte</strong>(<code>f * 1023.0f</code>),
<code>1023</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(<code>f * 1023.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>exact</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>half</code> → <code>CL_UNORM_<wbr>INT16</code> (16-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>exact</sub> = <strong>max</strong>(<code>0</code>, <strong>min</strong>(<code>f * 65535</code>, <code>65535</code>))</p>
</li>
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(<code>f * 65535.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(<code>f *
65535.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>exact</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>half</code> → <code>CL_UNORM_<wbr>INT10X6_<wbr>EXT</code> (10-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>exact</sub> = <strong>max</strong>(<code>0</code>, <strong>min</strong>(<code>f * 1023</code>, <code>1023</code>))</p>
</li>
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(<code>f * 1023.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(<code>f *
1023.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>exact</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>half</code> → <code>CL_UNORM_<wbr>INT12X4_<wbr>EXT</code> (12-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>exact</sub> = <strong>max</strong>(<code>0</code>, <strong>min</strong>(<code>f * 4095</code>, <code>4095</code>))</p>
</li>
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(<code>f * 4095.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(<code>f *
4095.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>exact</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>half</code> → <code>CL_UNORM_<wbr>INT14X2_<wbr>EXT</code> (14-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>exact</sub> = <strong>max</strong>(<code>0</code>, <strong>min</strong>(<code>f * 16383</code>, <code>16383</code>))</p>
</li>
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_ushort_sat_rte</strong>(<code>f * 16383.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_ushort_sat_&lt;impl-rounding-mode&gt;</strong>(<code>f *
16383.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>exact</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>half</code> → <code>CL_SNORM_<wbr>INT8</code> (8-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>exact</sub> = <strong>max</strong>(<code>-128</code>, <strong>min</strong>(<code>f * 127</code>, <code>127</code>))</p>
</li>
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_char_sat_rte</strong>(<code>f * 127.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_char_sat_&lt;impl_rounding_mode&gt;</strong>(<code>f * 127.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>exact</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><code>half</code> → <code>CL_SNORM_<wbr>INT16</code> (16-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>Let f<sub>exact</sub> = <strong>max</strong>(<code>-32768</code>, <strong>min</strong>(<code>f * 32767</code>, <code>32767</code>))</p>
</li>
<li>
<p>Let f<sub>preferred</sub> = <strong>convert_short_sat_rte</strong>(<code>f * 32767.0f</code>)</p>
</li>
<li>
<p>Let f<sub>approx</sub> = <strong>convert_short_sat_&lt;impl-rounding-mode&gt;</strong>(<code>f * 32767.0f</code>)</p>
</li>
<li>
<p><strong>fabs</strong>(f<sub>exact</sub> - f<sub>approx</sub>) must be &lt;= 0.6</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-half-precision-floating-point-channel-data-type"><a class="anchor" href="#conversion-rules-for-half-precision-floating-point-channel-data-type"></a>8.3.2. Conversion Rules for Half-Precision Floating-Point Channel Data Type</h4>
<div class="paragraph">
<p>For images created with a channel data type of <code>CL_HALF_<wbr>FLOAT</code>, the
conversions from <code>half</code> to <code>float</code> are lossless (as described in
<a href="#the-half-data-type">"The half data type"</a>).
Conversions from <code>float</code> to <code>half</code> round the mantissa using the round to
nearest even or round to zero rounding mode.
Denormalized numbers for the <code>half</code> data type which may be generated when
converting a <code>float</code> to a <code>half</code> may be flushed to zero.
A <code>float</code> NaN must be converted to an appropriate NaN in the <code>half</code> type.
A <code>float</code> <code>INF</code> must be converted to an appropriate <code>INF</code> in the <code>half</code>
type.</p>
</div>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-floating-point-channel-data-type"><a class="anchor" href="#conversion-rules-for-floating-point-channel-data-type"></a>8.3.3. Conversion Rules for Floating-Point Channel Data Type</h4>
<div class="paragraph">
<p>The following rules apply for reading and writing images created with
channel data type of <code>CL_FLOAT</code>.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>NaNs may be converted to a NaN value(s) supported by the device.</p>
</li>
<li>
<p>Denorms can be flushed to zero.</p>
</li>
<li>
<p>All other values must be preserved.</p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-signed-and-unsigned-integer-channel-data-types"><a class="anchor" href="#conversion-rules-for-signed-and-unsigned-integer-channel-data-types"></a>8.3.4. Conversion Rules for Signed and Unsigned Integer Channel Data Types</h4>
<div class="paragraph">
<p>Calls to <strong>read_imagei</strong> with any of the following channel data type values return
the integer values stored in the image at specified location, after sign
extension to 32 bits for integer values smaller than 32 bits.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_SIGNED_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_SIGNED_<wbr>INT16</code></p>
</li>
<li>
<p><code>CL_SIGNED_<wbr>INT32</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Calls to <strong>read_imageui</strong> with any of the following channel data type values
return the integer values stored in the image at specified location, after zero
extension to 32 bits for integer values smaller than 32 bits.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>CL_UNSIGNED_<wbr>INT8</code></p>
</li>
<li>
<p><code>CL_UNSIGNED_<wbr>INT16</code></p>
</li>
<li>
<p><code>CL_UNSIGNED_<wbr>INT32</code></p>
</li>
<li>
<p><code>CL_UNSIGNED_<wbr>INT10X6_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNSIGNED_<wbr>INT12X4_<wbr>EXT</code></p>
</li>
<li>
<p><code>CL_UNSIGNED_<wbr>INT14X2_<wbr>EXT</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Calls to <strong>write_imagei</strong> will perform one of the following conversions:</p>
</div>
<div class="paragraph">
<p>32 bit signed integer → <code>CL_SIGNED_<wbr>INT8</code> (8-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>convert_char_sat</strong>(i)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>32 bit signed integer → <code>CL_SIGNED_<wbr>INT16</code> (16-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>convert_short_sat</strong>(i)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>32 bit signed integer → <code>CL_SIGNED_<wbr>INT32</code> (32-bit signed integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>no conversion is performed</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Calls to <strong>write_imageui</strong> will perform one of the following conversions:</p>
</div>
<div class="paragraph">
<p>32 bit unsigned integer → <code>CL_UNSIGNED_<wbr>INT8</code> (8-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>convert_uchar_sat</strong>(i)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>32 bit unsigned integer → <code>CL_UNSIGNED_<wbr>INT16</code> (16-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>convert_ushort_sat</strong>(i)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>32 bit unsigned integer → <code>CL_UNSIGNED_<wbr>INT32</code> (32-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>no conversion is performed</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>32 bit unsigned integer → <code>CL_UNSIGNED_<wbr>INT10X6_<wbr>EXT</code> (10-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>clamp</strong>(<strong>convert_ushort_sat</strong>(i), 0, 1023)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>32 bit unsigned integer → <code>CL_UNSIGNED_<wbr>INT12X4_<wbr>EXT</code> (12-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>clamp</strong>(<strong>convert_ushort_sat</strong>(i), 0, 4095)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>32 bit unsigned integer → <code>CL_UNSIGNED_<wbr>INT14X2_<wbr>EXT</code> (14-bit unsigned integer)</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><strong>clamp</strong>(<strong>convert_ushort_sat</strong>(i), 0, 16383)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The conversions described in this section must be correctly saturated.</p>
</div>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-srgba-and-sbgra-images"><a class="anchor" href="#conversion-rules-for-srgba-and-sbgra-images"></a>8.3.5. Conversion Rules for sRGBA and sBGRA Images</h4>
<div class="paragraph">
<p>Standard RGB data, which roughly displays colors in a linear ramp of
luminosity levels such that an average observer, under average viewing
conditions, can view them as perceptually equal steps on an average display.
All 0&#8217;s maps to <code>0.0f</code>, and all 1&#8217;s maps to <code>1.0f</code>.
The sequence of unsigned integer encodings between all 0&#8217;s and all 1&#8217;s
represent a nonlinear progression in the floating-point interpretation of
the numbers between <code>0.0f</code> to <code>1.0f</code>.
For more detail, see the <a href="#sRGB-spec">SRGB color standard</a>.</p>
</div>
<div class="paragraph">
<p>Conversion from sRGB space is automatically done by <strong>read_imagef</strong> built-in
functions if the image channel order is one of the sRGB values described
above.
When reading from an sRGB image, the conversion from sRGB to linear RGB is
performed before the filter specified in the sampler specified to
read_imagef is applied.
If the format has an alpha channel, the alpha data is stored in linear color
space.
Conversion to sRGB space is automatically done by <strong>write_imagef</strong> built-in
functions if the image channel order is one of the sRGB values described
above and the device supports writing to sRGB images.</p>
</div>
<div class="paragraph">
<p>If the format has an alpha channel, the alpha data is stored in linear color
space.</p>
</div>
<div class="paragraph">
<p>The following is the conversion rule for converting a normalized 8-bit
unsigned integer sRGB color value to a floating-point linear RGB color value
using <strong>read_imagef</strong>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="c1">// Convert the normalized 8-bit unsigned integer R, G and B channel values</span>
<span class="c1">// to a floating-point value (call it c) as per rules described in section</span>
<span class="c1">// 8.3.1.1.</span>
<span class="k">if</span> <span class="p">(</span><span class="n">c</span> <span class="o">&lt;=</span> <span class="mf">0.04045</span><span class="p">),</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">c</span> <span class="o">/</span> <span class="mf">12.92</span><span class="p">;</span>
<span class="k">else</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">powr</span><span class="p">((</span><span class="n">c</span> <span class="o">+</span> <span class="mf">0.055</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1.055</span><span class="p">,</span> <span class="mf">2.4</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The resulting floating-point value, if converted back to an sRGB value
without rounding to a 8-bit unsigned integer value, must be within 0.5 ulp
of the original sRGB value.</p>
</div>
<div class="paragraph">
<p>The following are the conversion rules for converting a linear RGB
floating-point color value (call it <em>c</em>) to a normalized 8-bit unsigned
integer sRGB value using <strong>write_imagef</strong>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight"><code data-lang="opencl_c"><span class="k">if</span> <span class="p">(</span><span class="n">c</span> <span class="n">is</span> <span class="n">NaN</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="mf">0.0</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">c</span> <span class="o">&gt;</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">;</span>
<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">c</span> <span class="o">&lt;</span> <span class="mf">0.0</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="mf">0.0</span><span class="p">;</span>
<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">c</span> <span class="o">&lt;</span> <span class="mf">0.0031308</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="mf">12.92</span> <span class="o">*</span> <span class="n">c</span><span class="p">;</span>
<span class="k">else</span>
<span class="n">c</span> <span class="o">=</span> <span class="mf">1.055</span> <span class="o">*</span> <span class="n">powr</span><span class="p">(</span><span class="n">c</span><span class="p">,</span> <span class="mf">1.0</span><span class="o">/</span><span class="mf">2.4</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.055</span><span class="p">;</span>
<span class="n">scaled_reference_result</span> <span class="o">=</span> <span class="n">c</span> <span class="o">*</span> <span class="mi">255</span>
<span class="n">channel_component</span> <span class="o">=</span> <span class="n">floor</span><span class="p">(</span><span class="n">scaled_reference_result</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">);</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The precision of the above conversion should be such that</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p><code>|generated_channel_component - scaled_reference_result|</code> ≤ 0.6</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>where <code>generated_channel_component</code> is the actual value that the
implementation produces and being checked for conformance.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="selecting-an-image-from-an-image-array"><a class="anchor" href="#selecting-an-image-from-an-image-array"></a>8.4. Selecting an Image From an Image Array</h3>
<div class="paragraph">
<p>Let (<em>u</em>, <em>v</em>, <em>w</em>) represent the unnormalized image coordinate values for
reading from and/or writing to a 2D image in a 2D image array.</p>
</div>
<div class="paragraph">
<p>When read using a sampler, the 2D image layer selected is computed as:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>layer = <strong>clamp</strong>(<strong>rint</strong>(<em>w</em>), 0, d<sub>t</sub> - 1)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>otherwise the layer selected is computed as:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>layer = <em>w</em></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>(since <em>w</em> is already an integer) and the result is undefined if <em>w</em> is not
one of the integers 0, 1, &#8230;&#8203; d<sub>t</sub> - 1.</p>
</div>
<div class="paragraph">
<p>Let (<em>u</em>, <em>v</em>) represent the unnormalized image coordinate values for reading
from and/or writing to a 1D image in a 1D image array.</p>
</div>
<div class="paragraph">
<p>When read using a sampler, the 1D image layer selected is computed as:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>layer = <strong>clamp</strong>(<strong>rint</strong>(<em>v</em>), 0, h<sub>t</sub> - 1)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>otherwise the layer selected is computed as:</p>
</div>
<div class="ulist none">
<ul class="none">
<li>
<p>layer = <em>v</em></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>(since <em>v</em> is already an integer) and the result is undefined if <em>v</em> is not
one of the integers 0, 1, &#8230;&#8203; h<sub>t</sub> - 1.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="references"><a class="anchor" href="#references"></a>9. Normative References</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a id="C99-spec"></a> &#8220;ISO/IEC 9899:1999 - Programming languages - C&#8221;, with
technical corrigenda TC1 and TC2,
<a href="https://www.iso.org/standard/29237.html" class="bare">https://www.iso.org/standard/29237.html</a> .
References are to sections of this specific version, referred to as the
&#8220;C99 Specification&#8221;, although other versions exist.</p>
</li>
<li>
<p><a id="C11-spec"></a> &#8220;ISO/IEC 9899:2011 - Information technology - Programming
languages - C&#8221;, <a href="https://www.iso.org/standard/57853.html" class="bare">https://www.iso.org/standard/57853.html</a> .
References are to sections of this specific version, referred to as the
&#8220;C11 Specification&#8221;, although other versions exist.</p>
</li>
<li>
<p><a id="opencl-spec"></a> &#8220;The OpenCL Specification, Version 3.0, Unified&#8221;,
<a href="https://www.khronos.org/registry/OpenCL/" class="bare">https://www.khronos.org/registry/OpenCL/</a> .
References are to sections and tables of this specific version, although
other versions exists.</p>
</li>
<li>
<p><a id="opencl-device-queries"></a> &#8220;Device Queries&#8221; are defined in the
<a href="#opencl-spec">OpenCL Specification</a> for <strong>clGetDeviceInfo</strong>, and the
individual queries are defined in the &#8220;OpenCL Device Queries&#8221; table
(4.3) of that Specification.</p>
</li>
<li>
<p><a id="opencl-channel-order"></a> &#8220;Image Channel Order&#8221; is
defined in the <a href="#opencl-spec">OpenCL Specification</a> in the &#8220;Image
Format Descriptor&#8221; section (5.3.1.1), and the individual channel orders
are defined in the &#8220;List of supported Image Channel Order Values&#8221;
table (5.6) of that Specification.</p>
</li>
<li>
<p><a id="opencl-channel-data-type"></a> &#8220;Image Channel
Data Type&#8221; is defined in the <a href="#opencl-spec">OpenCL Specification</a> in the
&#8220;Image Format Descriptor&#8221; section (5.3.1.1), and the individual
channel data types are defined in the "`List of supported Image Channel
Data Types" table (5.7) of that Specification.</p>
</li>
<li>
<p><a id="sRGB-spec"></a> &#8220;IEC 61966-2-1:1999 Multimedia systems and equipment -
Colour measurement and management - Part 2-1: Colour management -
Default RGB colour space - sRGB&#8221;,
<a href="https://webstore.iec.ch/publication/6169" class="bare">https://webstore.iec.ch/publication/6169</a> .</p>
</li>
<li>
<p><a id="embedded-c-spec"></a> &#8220;ISO/IEC TR 18037:2008 Programming languages -
C - Extensions to support embedded processors&#8221;,
<a href="https://www.iso.org/standard/51126.html" class="bare">https://www.iso.org/standard/51126.html</a> .
References are to sections of this specific version, referred to as the
&#8220;Embedded C Specification&#8221;, although other versions exist.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="changes_to_opencl"><a class="anchor" href="#changes_to_opencl"></a>Appendix A: Changes to OpenCL</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Changes to the OpenCL C specifications between successive versions are
summarized below.</p>
</div>
<div class="sect2">
<h3 id="_summary_of_changes_to_opencl_3_0"><a class="anchor" href="#_summary_of_changes_to_opencl_3_0"></a>Summary of Changes to OpenCL 3.0</h3>
<div class="paragraph">
<p>The first non-experimental version of the OpenCL 3.0 specifications was <strong>v3.0.5</strong>.</p>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.0.5</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Clarified that <code>memory_scope_all_devices</code> is supported only for OpenCL C 3.0 or newer.</p>
</li>
<li>
<p>Defined ULP overflow leniency.</p>
</li>
<li>
<p>Removed a confusing phrase about kernel argument pointer types.</p>
</li>
<li>
<p>Clarified usage of feature test macros pre-OpenCL C 3.0.</p>
</li>
<li>
<p>Clarified relationship between optional core features and extensions.</p>
</li>
<li>
<p>Deprecated the <code>__OPENCL_C_VERSION__</code> predefined macro and clarified possible values of the macro for different versions of OpenCL.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.0.6</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Clarified the argument to <strong>vec_step</strong> is not evaluated.</p>
</li>
<li>
<p>Improved description for pipe specifier.</p>
</li>
<li>
<p>Fixed parameter name in <strong>work_group_broadcast</strong> description.</p>
</li>
<li>
<p>Clarified that the size of a pipe is implementation-defined.</p>
</li>
<li>
<p>Moved descriptions of the identify value for exclusive scans.</p>
</li>
<li>
<p>Fixed several bugs and formatting in the fast math ULP tables.</p>
</li>
<li>
<p>Clarified the behavior of <strong>work_group_broadcast</strong>.</p>
</li>
<li>
<p>Clarified the minimum OpenCL C version for the <code>opencl_unroll_hint</code> attribute.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.0.7</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Clarified optionality support for double-precision literals.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.0.14</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Improved capitalization and hyphenation consistency throughout the specs, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/902">#902</a>.</p>
</li>
<li>
<p>Clarified that the <strong>nextafter</strong> built-in function works with all floating-point types, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/953">#953</a>.</p>
</li>
<li>
<p>Clarified that the async copy and wait group events built-in functions must be called within converged control flow, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1015">#1015</a>.</p>
</li>
<li>
<p>Removed unnecessary rounding mode text from the descriptions of the geometric and common functions, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1027">#1027</a>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.0.15</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Moved all KHR extension text out of the OpenCL Extension specification and into the main specifications.
The OpenCL Extension specification will be removed in a subsequent revision.</p>
</li>
<li>
<p>Fixed the derived formula for <code>atanh</code>, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1048">#1048</a>.</p>
</li>
<li>
<p>Removed an incorrect statement about geometric functions operating component-wise, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1137">#1137</a>.</p>
</li>
<li>
<p>Added new extension:</p>
<div class="ulist">
<ul>
<li>
<p><code>cl_khr_<wbr>kernel_<wbr>clock</code> (experimental)</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.0.16</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Documented the error bounds for a non-derived <code>atan2</code> implementation with unsafe math optimizations, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1073">#1073</a>.</p>
</li>
<li>
<p>Fixed a typo affecting <code>EPSILON</code> macros, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1225">#1225</a>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.0.17</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Fixed formatting issues in the builtins table for <code>ldexp</code> and <code>mix</code>, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1290">#1290</a>.</p>
</li>
<li>
<p>Updated the ULP requirements for the half-precision divide and reciprocal, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1293">#1293</a>.</p>
</li>
<li>
<p>Fixed a typo in the address space conversion example, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1322">#1322</a>.</p>
</li>
<li>
<p>Clarified the unsafe math accuracy requirements for the embedded profile, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1318">#1318</a>.</p>
</li>
<li>
<p>Clarified the data types that are supported for explicit conversions, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1340">#1340</a>.</p>
</li>
<li>
<p>Clarified image conversion rules for signed and unsigned image channel data types, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1348">#1348</a>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.0.18</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Fixed an incorrect argument type for the <strong>fast_distance</strong> function, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1374">#1374</a>.</p>
</li>
<li>
<p>Updated the ULP requirements for the half-precision square root, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1386">#1386</a>.</p>
</li>
<li>
<p>Updated the ULP requirements for the half-precision tangent, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1387">#1387</a>.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_summary_of_changes_from_opencl_3_0_to_opencl_3_1"><a class="anchor" href="#_summary_of_changes_from_opencl_3_0_to_opencl_3_1"></a>Summary of Changes from OpenCL 3.0 to OpenCL 3.1</h3>
<div class="paragraph">
<p>OpenCL 3.1 adds the OpenCL 3.1 C kernel language.</p>
</div>
<div class="paragraph">
<p>Other changes in OpenCL 3.1:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Added support for the <strong>z</strong> and <strong>t</strong> <code>printf</code> length specifiers, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/issues/654">#654</a>.</p>
</li>
<li>
<p>Removed a few references to SPIR-V that do not belong in OpenCL C spec, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1517">#1517</a>.</p>
</li>
<li>
<p>Fixed a typo for <code>fmin</code> for the <code>half</code> type, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1519">#1519</a>.</p>
</li>
<li>
<p>Removed the Extending Attribute Qualifiers section, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1532">#1532</a>.</p>
</li>
<li>
<p>Moved the documentation of cluster size restrictions to improve readability, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1535">#1535</a>.</p>
</li>
<li>
<p>Clarified behavior for NaN to integer saturated conversions, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1546">#1546</a>.</p>
</li>
<li>
<p>Promoted the following extensions to the core API:</p>
<div class="ulist">
<ul>
<li>
<p><code>cl_khr_<wbr>extended_<wbr>bit_<wbr>ops</code></p>
</li>
<li>
<p><code>cl_khr_<wbr>integer_<wbr>dot_<wbr>product</code></p>
</li>
<li>
<p><code>cl_khr_<wbr>subgroup_<wbr>extended_<wbr>types</code></p>
</li>
<li>
<p><code>cl_khr_<wbr>subgroup_<wbr>rotate</code></p>
</li>
<li>
<p><code>cl_khr_<wbr>subgroup_<wbr>shuffle</code></p>
</li>
<li>
<p><code>cl_khr_<wbr>subgroup_<wbr>shuffle_<wbr>relative</code></p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>Changes from <strong>v3.1.0</strong> to <strong>v3.1.1</strong>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Clarified that the version requirements in this OpenCL C spec are for the OpenCL C language version, not the OpenCL device or platform version, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1557">#1557</a>.</p>
</li>
<li>
<p>Clarified the description of the <code>andy</code> and <code>all</code> functions, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1561">#1561</a>.</p>
</li>
<li>
<p><code>cl_khr_<wbr>fp16</code></p>
<div class="ulist">
<ul>
<li>
<p>Clarified that the <code>halfn</code> vector data type is not a reserved data type when the extension is supported, see <a href="https://github.com/KhronosGroup/OpenCL-Docs/pull/1548">#1548</a>.</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div id="footnotes" style="max-width: 100%;">
<hr>
<div class="footnote" id="_footnotedef_1">
<a href="#_footnoteref_1">1</a>. When any scalar value is converted to <code>bool</code>, the result is 0 if the value compares equal to 0; otherwise, the result is 1.
</div>
<div class="footnote" id="_footnotedef_2">
<a href="#_footnoteref_2">2</a>. The <code>long</code>, <code>unsigned long</code> and <code>ulong</code> scalar types are optional types for EMBEDDED profile devices that are supported if the value of the <code>CL_DEVICE_<wbr>EXTENSIONS</code> device query contains <strong>cles_khr_int64</strong>. An OpenCL C 3.0 compiler must also define the <code>__opencl_c_<wbr>int64</code> feature macro unconditionally for FULL profile devices, or for EMBEDDED profile devices that support these types.
</div>
<div class="footnote" id="_footnotedef_3">
<a href="#_footnoteref_3">3</a>. The <code>double</code> scalar type is an optional type that is supported if the value of the <code>CL_DEVICE_<wbr>DOUBLE_<wbr>FP_<wbr>CONFIG</code> device query is not zero. If this is the case then an OpenCL C 3.0 compiler must also define the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_4">
<a href="#_footnoteref_4">4</a>. This is a 32-bit type if the value of the <code>CL_DEVICE_<wbr>ADDRESS_<wbr>BITS</code> device query is 32-bits, and a 64-bit type if the value of the query is 64-bits.
</div>
<div class="footnote" id="_footnotedef_5">
<a href="#_footnoteref_5">5</a>. <a href="#unified-spec">Requires</a> support for OpenCL C 1.2 or above. Also see extension <code>cl_khr_<wbr>fp64</code>.
</div>
<div class="footnote" id="_footnotedef_6">
<a href="#_footnoteref_6">6</a>. Built-in vector data types are supported by the OpenCL implementation even if the underlying compute device does not natively support any or all of the vector data types. They are to be converted by the device compiler to appropriate instructions that use underlying built-in types supported natively by the compute device. Refer to Appendix B in the OpenCL API specification for a description of the order of the components of a vector type in memory.
</div>
<div class="footnote" id="_footnotedef_7">
<a href="#_footnoteref_7">7</a>. The <code>long<em>n</em></code> and <code>ulong<em>n</em></code> vector types are optional types for EMBEDDED profile devices that are supported if the value of the <code>CL_DEVICE_<wbr>EXTENSIONS</code> device query contains <strong>cles_khr_int64</strong>. An OpenCL C 3.0 compiler must also define the <code>__opencl_c_<wbr>int64</code> feature macro unconditionally for FULL profile devices, or for EMBEDDED profile devices that support these types.
</div>
<div class="footnote" id="_footnotedef_8">
<a href="#_footnoteref_8">8</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_9">
<a href="#_footnoteref_9">9</a>. The <code>double<em>n</em></code> vector type is an optional type that is supported if the value of the <code>CL_DEVICE_<wbr>DOUBLE_<wbr>FP_<wbr>CONFIG</code> device query is not zero. If this is the case then an OpenCL C 3.0 compiler must also define the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_10">
<a href="#_footnoteref_10">10</a>. Refer to the detailed description of the built-in <a href="#image-read-and-write-functions">Image Read and Write Functions</a> that use this type.
</div>
<div class="footnote" id="_footnotedef_11">
<a href="#_footnoteref_11">11</a>. That is, for the purpose of applying type-based aliasing rules, a built-in vector data type will be considered equivalent to the corresponding array type.
</div>
<div class="footnote" id="_footnotedef_12">
<a href="#_footnoteref_12">12</a>. Unless the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_13">
<a href="#_footnoteref_13">13</a>. Unless the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_14">
<a href="#_footnoteref_14">14</a>. Only if 64-bit integers are supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>int64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_15">
<a href="#_footnoteref_15">15</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_16">
<a href="#_footnoteref_16">16</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_17">
<a href="#_footnoteref_17">17</a>. For conversions to floating-point format, when a finite source value exceeds the maximum representable finite floating-point destination value, the rounding mode will affect whether the result is the maximum finite floating-point value or infinity of same sign as the source value, per IEEE-754 rules for rounding.
</div>
<div class="footnote" id="_footnotedef_18">
<a href="#_footnoteref_18">18</a>. In addition, some other extensions to the C language designed to support a particular vector ISA (e.g. AltiVecâ„¢, CELL Broadband Engineâ„¢ Architecture) use such conversions in conjunction with swizzle operators to achieve type un-conversion. So as to support legacy code of this type, <strong>as_typen</strong>() allows conversions between vectors of the same size but different numbers of elements, even though the behavior of this sort of conversion is not likely to be portable except to other OpenCL implementations for the same hardware architecture.<br> AltiVec is a trademark of Motorola Inc.<br> Cell Broadband Engine is a trademark of Sony Computer Entertainment, Inc.
</div>
<div class="footnote" id="_footnotedef_19">
<a href="#_footnoteref_19">19</a>. Unless the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_20">
<a href="#_footnoteref_20">20</a>. While the union is intended to reflect the organization of data in memory, the <strong>as_type</strong>() and <strong>as_type<em>n</em></strong>() constructs are intended to reflect the organization of data in register. The <strong>as_type</strong>() and <strong>as_type<em>n</em></strong>() constructs are intended to compile to no instructions on devices that use a shared register file designed to operate on both the operand and result types. Note that while differences in memory organization are expected to largely be limited to those arising from endianness, the register based representation may also differ due to size of the element in register. For example, an architecture may load a <code>char</code> into a 32-bit register, or a <code>char</code> vector into a SIMD vector register with fixed 32-bit element size. If the element count does not match, then the implementation should pick a data representation that most closely matches what would happen if an appropriate result type operator was applied to a register containing data of the source type. If the number of elements matches, then the <strong>as_type<em>n</em></strong>() should faithfully reproduce the behavior expected from a similar data type reinterpretation using memory/unions. So, for example if an implementation stores all single precision data as <code>double</code> in register, it should implement <strong>as_int</strong>(<code>float</code>) by first down-converting the <code>double</code> to single precision and then (if necessary) moving the single precision bits to a register suitable for operating on integer data. If data stored in different address spaces do not have the same endianness, then the &#8220;dominant endianness&#8221; of the device should prevail.
</div>
<div class="footnote" id="_footnotedef_21">
<a href="#_footnoteref_21">21</a>. This is different from the standard integer conversion rank described in <a href="#C99-spec">section 6.3.1.1 of the C99 Specification</a>.
</div>
<div class="footnote" id="_footnotedef_22">
<a href="#_footnoteref_22">22</a>. The pre- and post- increment operators may have unexpected behavior on floating-point values and are therefore not supported for floating-point scalar and vector built-in types. For example, if variable <em>a</em> has type <code>float</code> and holds the value <code>0x1.0p25f</code>, then <code><em>a</em>++</code> returns <code>0x1.0p25f</code>.<br> Also, <code>(<em>a</em>++)--</code> is not guaranteed to return <em>a</em>, if <em>a</em> has fractional value.<br> In non-default rounding modes, <code>(<em>a</em>++)--</code> may produce the same result as <code><em>a</em>++</code> or <code><em>a</em>--</code> for large <em>a</em>.
</div>
<div class="footnote" id="_footnotedef_23">
<a href="#_footnoteref_23">23</a>. To test whether any or all elements in the result of a vector relational operator test <em>true</em>, for example to use in the context in an <strong>if ( )</strong> statement, please see the <a href="#relational-functions"><strong>any</strong> and <strong>all</strong> built-ins</a>.
</div>
<div class="footnote" id="_footnotedef_24">
<a href="#_footnoteref_24">24</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_25">
<a href="#_footnoteref_25">25</a>. To test whether any or all elements in the result of a vector relational operator test <em>true</em>, for example to use in the context in an <strong>if ( )</strong> statement, please see the <a href="#relational-functions"><strong>any</strong> and <strong>all</strong> built-ins</a>.
</div>
<div class="footnote" id="_footnotedef_26">
<a href="#_footnoteref_26">26</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_27">
<a href="#_footnoteref_27">27</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_28">
<a href="#_footnoteref_28">28</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_29">
<a href="#_footnoteref_29">29</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_30">
<a href="#_footnoteref_30">30</a>. Integer promotion is described in <a href="#C99-spec">section 6.3.1.1 of the C99 Specification</a>.
</div>
<div class="footnote" id="_footnotedef_31">
<a href="#_footnoteref_31">31</a>. Variable length arrays are <a href="#restrictions-variable-length">not supported in OpenCL C</a>.
</div>
<div class="footnote" id="_footnotedef_32">
<a href="#_footnoteref_32">32</a>. Except for 3-component vectors whose size is defined as 4 times the size of each scalar component.
</div>
<div class="footnote" id="_footnotedef_33">
<a href="#_footnoteref_33">33</a>. Bit-field struct members are <a href="#restrictions-bitfield">not supported in OpenCL C</a>.
</div>
<div class="footnote" id="_footnotedef_34">
<a href="#_footnoteref_34">34</a>. Among the invalid values for dereferencing a pointer by the unary <strong>*</strong> operator are a null pointer, an address inappropriately aligned for the type of object pointed to, and the address of an object after the end of its lifetime. If <strong>*P</strong> is an l-value and <strong>T</strong> is the name of an object pointer type, <strong>*(T)P</strong> is an l-value that has a type compatible with that to which <strong>T</strong> points.
</div>
<div class="footnote" id="_footnotedef_35">
<a href="#_footnoteref_35">35</a>. Thus, <strong>&amp;*E</strong> is equivalent to <strong>E</strong> (even if <strong>E</strong> is a null pointer), and <strong>&amp;(E1[E2])</strong> is equivalent to <strong>E1) + (E2</strong>. It is always true that if <strong>E</strong> is an l-value that is a valid operand of the unary <strong>&amp;</strong> operator, <strong>*&amp;E</strong> is an l-value equal to <strong>E</strong>.
</div>
<div class="footnote" id="_footnotedef_36">
<a href="#_footnoteref_36">36</a>. Implicit in autovectorization is the assumption that any libraries called from the <code>__kernel</code> must be recompilable at run time to handle cases where the compiler decides to merge or separate workitems. This probably means that such libraries can never be hard coded binaries or that hard coded binaries must be accompanied either by source or some retargetable intermediate representation. This may be a code security question for some.
</div>
<div class="footnote" id="_footnotedef_37">
<a href="#_footnoteref_37">37</a>. Unless the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_38">
<a href="#_footnoteref_38">38</a>. When OpenCL C is compiled offline, <code>__OPENCL_VERSION__</code> may be defined and may substitute any implementation-defined integer value.
</div>
<div class="footnote" id="_footnotedef_39">
<a href="#_footnoteref_39">39</a>. This syntax is already part of the clang source tree on which most vendors have based their OpenCL implementations. Additionally, blocks based closures are supported by the clang open source C compiler as well as Mac OS X&#8217;s C and Objective C compilers. Specifically, Mac OS X&#8217;s Grand Central Dispatch allows applications to queue tasks as a block.
</div>
<div class="footnote" id="_footnotedef_40">
<a href="#_footnoteref_40">40</a>. OpenCL C <a href="#restrictions">does not allow function pointers</a> primarily because it is difficult or expensive to implement generic indirections to executable code in many hardware architectures that OpenCL targets. OpenCL C&#8217;s design of Blocks is intended to respect that same condition, yielding the restrictions listed here. As such, Blocks allow a form of dynamically enqueued function scheduling without providing a form of runtime synchronous dynamic dispatch analogous to function pointers.
</div>
<div class="footnote" id="_footnotedef_41">
<a href="#_footnoteref_41">41</a>. I.e. the <em>global_work_size</em> values specified to <strong>clEnqueueNDRangeKernel</strong> are not evenly divisible by the <em>local_work_size</em> values for each dimension.
</div>
<div class="footnote" id="_footnotedef_42">
<a href="#_footnoteref_42">42</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_43">
<a href="#_footnoteref_43">43</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_44">
<a href="#_footnoteref_44">44</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_45">
<a href="#_footnoteref_45">45</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_46">
<a href="#_footnoteref_46">46</a>. <strong>fmin</strong> and <strong>fmax</strong> behave as defined by C99 and may not match the IEEE 754-2008 definition for <strong>minNum</strong> and <strong>maxNum</strong> with regard to signaling NaNs. Specifically, signaling NaNs may behave as quiet NaNs.
</div>
<div class="footnote" id="_footnotedef_47">
<a href="#_footnoteref_47">47</a>. The <strong>min</strong>() operator is there to prevent <strong>fract</strong>(-small) from returning 1.0. It returns the largest positive floating-point number less than 1.0.
</div>
<div class="footnote" id="_footnotedef_48">
<a href="#_footnoteref_48">48</a>. The user is cautioned that for some usages, e.g. <strong>mad</strong>(a, b, -a*b), the definition of <strong>mad</strong>() is loose enough in the embedded profile or with half-precision arguments that almost any result is allowed from <strong>mad</strong>() for some values of a and b.
</div>
<div class="footnote" id="_footnotedef_49">
<a href="#_footnoteref_49">49</a>. Only if 64-bit integers are supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>int64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_50">
<a href="#_footnoteref_50">50</a>. Frequently vector operations need n + 1 bits temporarily to calculate a result. The <strong>rhadd</strong> instruction gives you an extra bit without needing to upsample and downsample. This can be a profound performance win.
</div>
<div class="footnote" id="_footnotedef_51">
<a href="#_footnoteref_51">51</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_52">
<a href="#_footnoteref_52">52</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_53">
<a href="#_footnoteref_53">53</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_54">
<a href="#_footnoteref_54">54</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_55">
<a href="#_footnoteref_55">55</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_56">
<a href="#_footnoteref_56">56</a>. If an implementation extends this specification to support IEEE-754 flags or exceptions, then all built-in functions defined in the following table shall proceed without raising the <em>invalid</em> floating-point exception when one or more of the operands are NaNs.
</div>
<div class="footnote" id="_footnotedef_57">
<a href="#_footnoteref_57">57</a>. Only if 64-bit integers are supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>int64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_58">
<a href="#_footnoteref_58">58</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_59">
<a href="#_footnoteref_59">59</a>. This definition means that the behavior of select and the ternary operator for vector and scalar types is dependent on different interpretations of the bit pattern of <em>c</em>.
</div>
<div class="footnote" id="_footnotedef_60">
<a href="#_footnoteref_60">60</a>. Only if 64-bit integers are supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>int64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_61">
<a href="#_footnoteref_61">61</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_62">
<a href="#_footnoteref_62">62</a>. <strong>vload3</strong> and <strong>vload_half3</strong> read (<em>x</em>, <em>y</em>, <em>z</em>) components from address <code>(<em>p</em> + (<em>offset</em> * 3))</code> into a 3-component vector. <strong>vstore3</strong> and <strong>vstore_half3</strong> write (<em>x</em>, <em>y</em>, <em>z</em>) components from a 3-component vector to address <code>(<em>p</em> + (<em>offset</em> * 3))</code>. In addition, <strong>vloada_half3</strong> reads (<em>x</em>, <em>y</em>, <em>z</em>) components from address <code>(<em>p</em> + (<em>offset</em> * 4))</code> into a 3-component vector and <strong>vstorea_half3</strong> writes (<em>x</em>, <em>y</em>, <em>z</em>) components from a 3-component vector to address <code>(<em>p</em> + (<em>offset</em> * 4))</code>. Whether <strong>vloada_half3</strong> and <strong>vstorea_half3</strong> read/write padding data between the third vector element and the next alignment boundary is implementation-defined. The <strong>vloada_</strong> and <strong>vstorea_</strong> variants are provided to access data that is aligned to the size of the vector, and are intended to enable performance on hardware that can take advantage of the increased alignment.
</div>
<div class="footnote" id="_footnotedef_63">
<a href="#_footnoteref_63">63</a>. Refer to the description and restrictions for <a href="#memory-scope"><code>memory_scope</code></a>.
</div>
<div class="footnote" id="_footnotedef_64">
<a href="#_footnoteref_64">64</a>. Only if 64-bit integers are supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>int64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_65">
<a href="#_footnoteref_65">65</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_66">
<a href="#_footnoteref_66">66</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_67">
<a href="#_footnoteref_67">67</a>. <strong>async_work_group_copy</strong> and <strong>async_work_group_strided_copy</strong> for 3-component vector types behave as <strong>async_work_group_copy</strong> and <strong>async_work_group_strided_copy</strong> respectively for 4-component vector types.
</div>
<div class="footnote" id="_footnotedef_68">
<a href="#_footnoteref_68">68</a>. The <a href="#C11-spec">C11</a> consume operation is not supported.
</div>
<div class="footnote" id="_footnotedef_69">
<a href="#_footnoteref_69">69</a>. The atomic_long and atomic_ulong types are supported if the <code>cl_khr_<wbr>int64_<wbr>base_<wbr>atomics</code> and <code>cl_khr_<wbr>int64_<wbr>extended_<wbr>atomics</code> extensions are supported and have been enabled. If this is the case then an OpenCL C 3.0 compiler must also define the <code>__opencl_c_<wbr>int64</code> feature.
</div>
<div class="footnote" id="_footnotedef_70">
<a href="#_footnoteref_70">70</a>. The <code>atomic_double</code> type is only supported if double precision is supported and the <code>cl_khr_<wbr>int64_<wbr>base_<wbr>atomics</code> and <code>cl_khr_<wbr>int64_<wbr>extended_<wbr>atomics</code> extensions are supported and have been enabled. If this is the case then an OpenCL C 3.0 compiler must also define the <code>__opencl_c_<wbr>fp64</code> feature.
</div>
<div class="footnote" id="_footnotedef_71">
<a href="#_footnoteref_71">71</a>. If the device address space is 64-bits, the data types <code>atomic_intptr_t</code>, <code>atomic_uintptr_t</code>, <code>atomic_size_t</code> and <code>atomic_ptrdiff_t</code> are supported if the <code>cl_khr_<wbr>int64_<wbr>base_<wbr>atomics</code> and <code>cl_khr_<wbr>int64_<wbr>extended_<wbr>atomics</code> extensions are supported and have been enabled.
</div>
<div class="footnote" id="_footnotedef_72">
<a href="#_footnoteref_72">72</a>. This spurious failure enables implementation of compare-and-exchange on a broader class of machines, e.g. load-locked store-conditional machines.
</div>
<div class="footnote" id="_footnotedef_73">
<a href="#_footnoteref_73">73</a>. Only if 64-bit integers are supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>int64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_74">
<a href="#_footnoteref_74">74</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_75">
<a href="#_footnoteref_75">75</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_76">
<a href="#_footnoteref_76">76</a>. Note that <strong>0</strong> is taken as a flag, not as the beginning of a field width.
</div>
<div class="footnote" id="_footnotedef_77">
<a href="#_footnoteref_77">77</a>. The results of all floating conversions of a negative zero, and of negative values that round to zero, include a minus sign.
</div>
<div class="footnote" id="_footnotedef_78">
<a href="#_footnoteref_78">78</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_79">
<a href="#_footnoteref_79">79</a>. When applied to infinite and NaN values, the <strong>-</strong>, <strong>+</strong>, and <em>space</em> flag characters have their usual meaning; the <strong>#</strong> and <strong>0</strong> flag characters have no effect.
</div>
<div class="footnote" id="_footnotedef_80">
<a href="#_footnoteref_80">80</a>. Binary implementations can choose the hexadecimal digit to the left of the decimal-point character so that subsequent digits align to nibble (4-bit) boundaries.
</div>
<div class="footnote" id="_footnotedef_81">
<a href="#_footnoteref_81">81</a>. No special provisions are made for multibyte characters. The behavior of <strong>printf</strong> with the <strong>s</strong> conversion specifier is undefined if the argument value is not a pointer to a literal string.
</div>
<div class="footnote" id="_footnotedef_82">
<a href="#_footnoteref_82">82</a>. This is similar to the <code>GL_ADDRESS_CLAMP_TO_BORDER</code> addressing mode.
</div>
<div class="footnote" id="_footnotedef_83">
<a href="#_footnoteref_83">83</a>. Note that the built-in function calls to read images with a sampler are not supported for <code>image1d_buffer_t</code> image types.
</div>
<div class="footnote" id="_footnotedef_84">
<a href="#_footnoteref_84">84</a>. Although <code>CL_UNORM_<wbr>INT_<wbr>101010_<wbr>2</code> was added in OpenCL 2.1, because there was no OpenCL C 2.1 this image channel order <a href="#unified-spec">requires</a> OpenCL 3.0.
</div>
<div class="footnote" id="_footnotedef_85">
<a href="#_footnoteref_85">85</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_86">
<a href="#_footnoteref_86">86</a>. Only if 64-bit integers are supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>int64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_87">
<a href="#_footnoteref_87">87</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_88">
<a href="#_footnoteref_88">88</a>. The <code>half</code> scalar and vector types can only be used if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled. The <code>double</code> scalar and vector types can only be used if <code>double</code> precision is supported, e.g. for OpenCL C 3.0 the <code>__opencl_c_<wbr>fp64</code> feature macro is present.
</div>
<div class="footnote" id="_footnotedef_89">
<a href="#_footnoteref_89">89</a>. The <code>half</code> scalar and vector types can only be used if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled. The <code>double</code> scalar and vector types can only be used if <code>double</code> precision is supported, e.g. for OpenCL C 3.0 the <code>__opencl_c_<wbr>fp64</code> feature macro is present.
</div>
<div class="footnote" id="_footnotedef_90">
<a href="#_footnoteref_90">90</a>. The <code>half</code> scalar and vector types can only be used if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled. The <code>double</code> scalar and vector types can only be used if <code>double</code> precision is supported, e.g. for OpenCL C 3.0 the <code>__opencl_c_<wbr>fp64</code> feature macro is present.
</div>
<div class="footnote" id="_footnotedef_91">
<a href="#_footnoteref_91">91</a>. Implementations are not required to honor this flag. Implementations may not schedule kernel launch earlier than the point specified by this flag, however.
</div>
<div class="footnote" id="_footnotedef_92">
<a href="#_footnoteref_92">92</a>. Immediate meaning not side effects resulting from child kernels. The side effects would include stores to <code>global</code> memory and pipe reads and writes.
</div>
<div class="footnote" id="_footnotedef_93">
<a href="#_footnoteref_93">93</a>. This acts as a memory synchronization point between work-items in a work-group and child kernels enqueued by work-items in the work-group.
</div>
<div class="footnote" id="_footnotedef_94">
<a href="#_footnoteref_94">94</a>. Only if 64-bit integers are supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>int64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_95">
<a href="#_footnoteref_95">95</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_96">
<a href="#_footnoteref_96">96</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_97">
<a href="#_footnoteref_97">97</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_98">
<a href="#_footnoteref_98">98</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_99">
<a href="#_footnoteref_99">99</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_100">
<a href="#_footnoteref_100">100</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_101">
<a href="#_footnoteref_101">101</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_102">
<a href="#_footnoteref_102">102</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_103">
<a href="#_footnoteref_103">103</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_104">
<a href="#_footnoteref_104">104</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_105">
<a href="#_footnoteref_105">105</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_106">
<a href="#_footnoteref_106">106</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_107">
<a href="#_footnoteref_107">107</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_108">
<a href="#_footnoteref_108">108</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_109">
<a href="#_footnoteref_109">109</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_110">
<a href="#_footnoteref_110">110</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_111">
<a href="#_footnoteref_111">111</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_112">
<a href="#_footnoteref_112">112</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_113">
<a href="#_footnoteref_113">113</a>. Only if the <code>cl_khr_<wbr>fp16</code> extension is supported and has been enabled.
</div>
<div class="footnote" id="_footnotedef_114">
<a href="#_footnoteref_114">114</a>. Only if double precision is supported. In OpenCL C 3.0 this will be indicated by the presence of the <code>__opencl_c_<wbr>fp64</code> feature macro.
</div>
<div class="footnote" id="_footnotedef_115">
<a href="#_footnoteref_115">115</a>. Except for the embedded profile where either round to zero or round to nearest rounding mode may be supported for single precision floating-point.
</div>
<div class="footnote" id="_footnotedef_116">
<a href="#_footnoteref_116">116</a>. On some implementations, <strong>powr</strong>() or <strong>pown</strong>() may perform faster than <strong>pow</strong>(). If <em>x</em> is known to be &gt;= 0, consider using <strong>powr</strong>() in place of <strong>pow</strong>(), or if <em>y</em> is known to be an integer, consider using <strong>pown</strong>() in place of <strong>pow</strong>().
</div>
<div class="footnote" id="_footnotedef_117">
<a href="#_footnoteref_117">117</a>. Here <code>TYPE_MIN</code> and <code>TYPE_MIN_EXP</code> should be substituted by constants appropriate to the floating-point type under consideration, such as <code>FLT_MIN</code> and <code>FLT_MIN_EXP</code> for <code>float</code>.
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>
</body>
</html>