blob: b937922357ff6fe79e693cb1d771bfd70bb5d679 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="AsciiDoc 8.6.9">
<title>The OpenCL Extension Specification</title>
<style type="text/css">
/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
/* Default font. */
body {
font-family: Georgia,serif;
}
/* Title font. */
h1, h2, h3, h4, h5, h6,
div.title, caption.title,
thead, p.table.header,
#toctitle,
#author, #revnumber, #revdate, #revremark,
#footer {
font-family: Arial,Helvetica,sans-serif;
}
body {
margin: 1em 5% 1em 5%;
}
a {
color: blue;
text-decoration: underline;
}
a:visited {
color: fuchsia;
}
em {
font-style: italic;
color: navy;
}
strong {
font-weight: bold;
color: #083194;
}
h1, h2, h3, h4, h5, h6 {
color: #527bbd;
margin-top: 1.2em;
margin-bottom: 0.5em;
line-height: 1.3;
}
h1, h2, h3 {
border-bottom: 2px solid silver;
}
h2 {
padding-top: 0.5em;
}
h3 {
float: left;
}
h3 + * {
clear: left;
}
h5 {
font-size: 1.0em;
}
div.sectionbody {
margin-left: 0;
}
hr {
border: 1px solid silver;
}
p {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
ul, ol, li > p {
margin-top: 0;
}
ul > li { color: #aaa; }
ul > li > * { color: black; }
.monospaced, code, pre {
font-family: "Courier New", Courier, monospace;
font-size: inherit;
color: navy;
padding: 0;
margin: 0;
}
pre {
white-space: pre-wrap;
}
#author {
color: #527bbd;
font-weight: bold;
font-size: 1.1em;
}
#email {
}
#revnumber, #revdate, #revremark {
}
#footer {
font-size: small;
border-top: 2px solid silver;
padding-top: 0.5em;
margin-top: 4.0em;
}
#footer-text {
float: left;
padding-bottom: 0.5em;
}
#footer-badges {
float: right;
padding-bottom: 0.5em;
}
#preamble {
margin-top: 1.5em;
margin-bottom: 1.5em;
}
div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
margin-top: 1.0em;
margin-bottom: 1.5em;
}
div.admonitionblock {
margin-top: 2.0em;
margin-bottom: 2.0em;
margin-right: 10%;
color: #606060;
}
div.content { /* Block element content. */
padding: 0;
}
/* Block element titles. */
div.title, caption.title {
color: #527bbd;
font-weight: bold;
text-align: left;
margin-top: 1.0em;
margin-bottom: 0.5em;
}
div.title + * {
margin-top: 0;
}
td div.title:first-child {
margin-top: 0.0em;
}
div.content div.title:first-child {
margin-top: 0.0em;
}
div.content + div.title {
margin-top: 0.0em;
}
div.sidebarblock > div.content {
background: #ffffee;
border: 1px solid #dddddd;
border-left: 4px solid #f0f0f0;
padding: 0.5em;
}
div.listingblock > div.content {
border: 1px solid #dddddd;
border-left: 5px solid #f0f0f0;
background: #f8f8f8;
padding: 0.5em;
}
div.quoteblock, div.verseblock {
padding-left: 1.0em;
margin-left: 1.0em;
margin-right: 10%;
border-left: 5px solid #f0f0f0;
color: #888;
}
div.quoteblock > div.attribution {
padding-top: 0.5em;
text-align: right;
}
div.verseblock > pre.content {
font-family: inherit;
font-size: inherit;
}
div.verseblock > div.attribution {
padding-top: 0.75em;
text-align: left;
}
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
div.verseblock + div.attribution {
text-align: left;
}
div.admonitionblock .icon {
vertical-align: top;
font-size: 1.1em;
font-weight: bold;
text-decoration: underline;
color: #527bbd;
padding-right: 0.5em;
}
div.admonitionblock td.content {
padding-left: 0.5em;
border-left: 3px solid #dddddd;
}
div.exampleblock > div.content {
border-left: 3px solid #dddddd;
padding-left: 0.5em;
}
div.imageblock div.content { padding-left: 0; }
span.image img { border-style: none; vertical-align: text-bottom; }
a.image:visited { color: white; }
dl {
margin-top: 0.8em;
margin-bottom: 0.8em;
}
dt {
margin-top: 0.5em;
margin-bottom: 0;
font-style: normal;
color: navy;
}
dd > *:first-child {
margin-top: 0.1em;
}
ul, ol {
list-style-position: outside;
}
ol.arabic {
list-style-type: decimal;
}
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;
}
div.compact ul, div.compact ol,
div.compact p, div.compact p,
div.compact div, div.compact div {
margin-top: 0.1em;
margin-bottom: 0.1em;
}
tfoot {
font-weight: bold;
}
td > div.verse {
white-space: pre;
}
div.hdlist {
margin-top: 0.8em;
margin-bottom: 0.8em;
}
div.hdlist tr {
padding-bottom: 15px;
}
dt.hdlist1.strong, td.hdlist1.strong {
font-weight: bold;
}
td.hdlist1 {
vertical-align: top;
font-style: normal;
padding-right: 0.8em;
color: navy;
}
td.hdlist2 {
vertical-align: top;
}
div.hdlist.compact tr {
margin: 0;
padding-bottom: 0;
}
.comment {
background: yellow;
}
.footnote, .footnoteref {
font-size: 0.8em;
}
span.footnote, span.footnoteref {
vertical-align: super;
}
#footnotes {
margin: 20px 0 20px 0;
padding: 7px 0 0 0;
}
#footnotes div.footnote {
margin: 0 0 5px 0;
}
#footnotes hr {
border: none;
border-top: 1px solid silver;
height: 1px;
text-align: left;
margin-left: 0;
width: 20%;
min-width: 100px;
}
div.colist td {
padding-right: 0.5em;
padding-bottom: 0.3em;
vertical-align: top;
}
div.colist td img {
margin-top: 0.3em;
}
@media print {
#footer-badges { display: none; }
}
#toc {
margin-bottom: 2.5em;
}
#toctitle {
color: #527bbd;
font-size: 1.1em;
font-weight: bold;
margin-top: 1.0em;
margin-bottom: 0.1em;
}
div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
margin-top: 0;
margin-bottom: 0;
}
div.toclevel2 {
margin-left: 2em;
font-size: 0.9em;
}
div.toclevel3 {
margin-left: 4em;
font-size: 0.9em;
}
div.toclevel4 {
margin-left: 6em;
font-size: 0.9em;
}
span.aqua { color: aqua; }
span.black { color: black; }
span.blue { color: blue; }
span.fuchsia { color: fuchsia; }
span.gray { color: gray; }
span.green { color: green; }
span.lime { color: lime; }
span.maroon { color: maroon; }
span.navy { color: navy; }
span.olive { color: olive; }
span.purple { color: purple; }
span.red { color: red; }
span.silver { color: silver; }
span.teal { color: teal; }
span.white { color: white; }
span.yellow { color: yellow; }
span.aqua-background { background: aqua; }
span.black-background { background: black; }
span.blue-background { background: blue; }
span.fuchsia-background { background: fuchsia; }
span.gray-background { background: gray; }
span.green-background { background: green; }
span.lime-background { background: lime; }
span.maroon-background { background: maroon; }
span.navy-background { background: navy; }
span.olive-background { background: olive; }
span.purple-background { background: purple; }
span.red-background { background: red; }
span.silver-background { background: silver; }
span.teal-background { background: teal; }
span.white-background { background: white; }
span.yellow-background { background: yellow; }
span.big { font-size: 2em; }
span.small { font-size: 0.6em; }
span.underline { text-decoration: underline; }
span.overline { text-decoration: overline; }
span.line-through { text-decoration: line-through; }
div.unbreakable { page-break-inside: avoid; }
/*
* xhtml11 specific
*
* */
div.tableblock {
margin-top: 1.0em;
margin-bottom: 1.5em;
}
div.tableblock > table {
border: 3px solid #527bbd;
}
thead, p.table.header {
font-weight: bold;
color: #527bbd;
}
p.table {
margin-top: 0;
}
/* Because the table frame attribute is overriden by CSS in most browsers. */
div.tableblock > table[frame="void"] {
border-style: none;
}
div.tableblock > table[frame="hsides"] {
border-left-style: none;
border-right-style: none;
}
div.tableblock > table[frame="vsides"] {
border-top-style: none;
border-bottom-style: none;
}
/*
* html5 specific
*
* */
table.tableblock {
margin-top: 1.0em;
margin-bottom: 1.5em;
}
thead, p.tableblock.header {
font-weight: bold;
color: #527bbd;
}
p.tableblock {
margin-top: 0;
}
table.tableblock {
border-width: 3px;
border-spacing: 0px;
border-style: solid;
border-color: #527bbd;
border-collapse: collapse;
}
th.tableblock, td.tableblock {
border-width: 1px;
padding: 4px;
border-style: solid;
border-color: #527bbd;
}
table.tableblock.frame-topbot {
border-left-style: hidden;
border-right-style: hidden;
}
table.tableblock.frame-sides {
border-top-style: hidden;
border-bottom-style: hidden;
}
table.tableblock.frame-none {
border-style: hidden;
}
th.tableblock.halign-left, td.tableblock.halign-left {
text-align: left;
}
th.tableblock.halign-center, td.tableblock.halign-center {
text-align: center;
}
th.tableblock.halign-right, td.tableblock.halign-right {
text-align: right;
}
th.tableblock.valign-top, td.tableblock.valign-top {
vertical-align: top;
}
th.tableblock.valign-middle, td.tableblock.valign-middle {
vertical-align: middle;
}
th.tableblock.valign-bottom, td.tableblock.valign-bottom {
vertical-align: bottom;
}
/*
* manpage specific
*
* */
body.manpage h1 {
padding-top: 0.5em;
padding-bottom: 0.5em;
border-top: 2px solid silver;
border-bottom: 2px solid silver;
}
body.manpage h2 {
border-style: none;
}
body.manpage div.sectionbody {
margin-left: 3em;
}
@media print {
body.manpage div#toc { display: none; }
}
@media screen {
body {
max-width: 50em; /* approximately 80 characters wide */
margin-left: 16em;
}
#toc {
position: fixed;
top: 0;
left: 0;
bottom: 0;
width: 13em;
padding: 0.5em;
padding-bottom: 1.5em;
margin: 0;
overflow: auto;
border-right: 3px solid #f8f8f8;
background-color: white;
}
#toc .toclevel1 {
margin-top: 0.5em;
}
#toc .toclevel2 {
margin-top: 0.25em;
display: list-item;
color: #aaaaaa;
}
#toctitle {
margin-top: 0.5em;
}
}
</style>
<script type="text/javascript">
/*<![CDATA[*/
var asciidoc = { // Namespace.
/////////////////////////////////////////////////////////////////////
// Table Of Contents generator
/////////////////////////////////////////////////////////////////////
/* Author: Mihai Bazon, September 2002
* http://students.infoiasi.ro/~mishoo
*
* Table Of Content generator
* Version: 0.4
*
* Feel free to use this script under the terms of the GNU General Public
* License, as long as you do not remove or alter this notice.
*/
/* modified by Troy D. Hanson, September 2006. License: GPL */
/* modified by Stuart Rackham, 2006, 2009. License: GPL */
// toclevels = 1..4.
toc: function (toclevels) {
function getText(el) {
var text = "";
for (var i = el.firstChild; i != null; i = i.nextSibling) {
if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
text += i.data;
else if (i.firstChild != null)
text += getText(i);
}
return text;
}
function TocEntry(el, text, toclevel) {
this.element = el;
this.text = text;
this.toclevel = toclevel;
}
function tocEntries(el, toclevels) {
var result = new Array;
var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
// Function that scans the DOM tree for header elements (the DOM2
// nodeIterator API would be a better technique but not supported by all
// browsers).
var iterate = function (el) {
for (var i = el.firstChild; i != null; i = i.nextSibling) {
if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
var mo = re.exec(i.tagName);
if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
}
iterate(i);
}
}
}
iterate(el);
return result;
}
var toc = document.getElementById("toc");
if (!toc) {
return;
}
// Delete existing TOC entries in case we're reloading the TOC.
var tocEntriesToRemove = [];
var i;
for (i = 0; i < toc.childNodes.length; i++) {
var entry = toc.childNodes[i];
if (entry.nodeName.toLowerCase() == 'div'
&& entry.getAttribute("class")
&& entry.getAttribute("class").match(/^toclevel/))
tocEntriesToRemove.push(entry);
}
for (i = 0; i < tocEntriesToRemove.length; i++) {
toc.removeChild(tocEntriesToRemove[i]);
}
// Rebuild TOC entries.
var entries = tocEntries(document.getElementById("content"), toclevels);
for (var i = 0; i < entries.length; ++i) {
var entry = entries[i];
if (entry.element.id == "")
entry.element.id = "_toc_" + i;
var a = document.createElement("a");
a.href = "#" + entry.element.id;
a.appendChild(document.createTextNode(entry.text));
var div = document.createElement("div");
div.appendChild(a);
div.className = "toclevel" + entry.toclevel;
toc.appendChild(div);
}
if (entries.length == 0)
toc.parentNode.removeChild(toc);
},
/////////////////////////////////////////////////////////////////////
// Footnotes generator
/////////////////////////////////////////////////////////////////////
/* Based on footnote generation code from:
* http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
*/
footnotes: function () {
// Delete existing footnote entries in case we're reloading the footnodes.
var i;
var noteholder = document.getElementById("footnotes");
if (!noteholder) {
return;
}
var entriesToRemove = [];
for (i = 0; i < noteholder.childNodes.length; i++) {
var entry = noteholder.childNodes[i];
if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
entriesToRemove.push(entry);
}
for (i = 0; i < entriesToRemove.length; i++) {
noteholder.removeChild(entriesToRemove[i]);
}
// Rebuild footnote entries.
var cont = document.getElementById("content");
var spans = cont.getElementsByTagName("span");
var refs = {};
var n = 0;
for (i=0; i<spans.length; i++) {
if (spans[i].className == "footnote") {
n++;
var note = spans[i].getAttribute("data-note");
if (!note) {
// Use [\s\S] in place of . so multi-line matches work.
// Because JavaScript has no s (dotall) regex flag.
note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
spans[i].innerHTML =
"[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
"' title='View footnote' class='footnote'>" + n + "</a>]";
spans[i].setAttribute("data-note", note);
}
noteholder.innerHTML +=
"<div class='footnote' id='_footnote_" + n + "'>" +
"<a href='#_footnoteref_" + n + "' title='Return to text'>" +
n + "</a>. " + note + "</div>";
var id =spans[i].getAttribute("id");
if (id != null) refs["#"+id] = n;
}
}
if (n == 0)
noteholder.parentNode.removeChild(noteholder);
else {
// Process footnoterefs.
for (i=0; i<spans.length; i++) {
if (spans[i].className == "footnoteref") {
var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
href = href.match(/#.*/)[0]; // Because IE return full URL.
n = refs[href];
spans[i].innerHTML =
"[<a href='#_footnote_" + n +
"' title='View footnote' class='footnote'>" + n + "</a>]";
}
}
}
},
install: function(toclevels) {
var timerId;
function reinstall() {
asciidoc.footnotes();
if (toclevels) {
asciidoc.toc(toclevels);
}
}
function reinstallAndRemoveTimer() {
clearInterval(timerId);
reinstall();
}
timerId = setInterval(reinstall, 500);
if (document.addEventListener)
document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
else
window.onload = reinstallAndRemoveTimer;
}
}
asciidoc.install(2);
/*]]>*/
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
MathML: { extensions: ["content-mathml.js"] },
tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] }
});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body class="book">
<div id="header">
<h1>The OpenCL Extension Specification</h1>
<span id="author">Khronos OpenCL Working Group</span><br>
<span id="revnumber">version v2.2-3</span>
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</div>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>Copyright 2008-2017 The Khronos Group.</p></div>
<div class="paragraph"><p>This specification is protected by copyright laws and contains material proprietary
to the Khronos Group, Inc. 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 Group.</p></div>
<div class="paragraph"><p>Khronos Group 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 IP 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">https://www.khronos.org/adopters</a>.</p></div>
<div class="paragraph"><p>Khronos Group 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 the Khronos Group, 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>Vulkan is a registered trademark and Khronos, OpenXR, SPIR, SPIR-V, SYCL, WebGL,
WebCL, OpenVX, OpenVG, EGL, COLLADA, glTF, NNEF, OpenKODE, OpenKCAM, StreamInput,
OpenWF, OpenSL ES, OpenMAX, OpenMAX AL, OpenMAX IL, OpenMAX DL, OpenML and DevU are
trademarks of the Khronos Group Inc. ASTC is a trademark of ARM Holdings PLC,
OpenCL is a trademark of Apple Inc. and OpenGL and OpenML are registered trademarks
and the OpenGL ES and OpenGL SC logos are trademarks of Silicon Graphics
International 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="optional-extensions">Optional Extensions</h2>
<div class="sectionbody">
<div class="paragraph"><p>This document describes the list of optional features supported by OpenCL 2.2. Optional extensions may be supported by some OpenCL devices. Optional extensions are not required to be supported by a conformant OpenCL implementation, but are expected to be widely available; they define functionality that is likely to move into the required feature set in a future revision of the OpenCL specification. A brief description of how OpenCL extensions are defined is provided below.</p></div>
<div class="paragraph"><p>For OpenCL extensions approved by the OpenCL working group, the following naming conventions are used:</p></div>
<div class="ulist"><ul>
<li>
<p>
A unique <em>name string</em> of the form "<strong>cl_khr_&lt;<em>name</em>&gt;</strong>" is associated with each extension. If the extension is supported by an implementation, this string will be present in the implementation&#8217;s CL_PLATFORM_EXTENSIONS string or CL_DEVICE_EXTENSIONS string.
</p>
</li>
<li>
<p>
All API functions defined by the extension will have names of the form <strong>cl&lt;<em>function_name</em>&gt;KHR</strong>.
</p>
</li>
<li>
<p>
All enumerants defined by the extension will have names of the form <strong>CL_&lt;<em>enum_name</em>&gt;_KHR.</strong>
</p>
</li>
</ul></div>
<div class="paragraph"><p>OpenCL extensions approved by the OpenCL working group can be <em>promoted</em> to required core features in later revisions of OpenCL. When this occurs, the extension specifications are merged into the core specification. Functions and enumerants that are part of such promoted extensions will have the <strong>KHR</strong> affix removed. OpenCL implementations of such later revisions must also export the name strings of promoted extensions in the CL_PLATFORM_EXTENSIONS or CL_DEVICE_EXTENSIONS string, and support the <strong>KHR</strong>-affixed versions of functions and enumerants as a transition aid.</p></div>
<div class="paragraph"><p>For vendor extensions, the following naming conventions are used:</p></div>
<div class="ulist"><ul>
<li>
<p>
A unique <em>name string</em> of the form "<strong>cl_&lt;<em>vendor_name</em>&gt;_&lt;<em>name&gt;</em></strong>" is associated with each extension. If the extension is supported by an implementation, this string will be present in the implementation&#8217;s CL_PLATFORM_EXTENSIONS string or CL_DEVICE_EXTENSIONS string.
</p>
</li>
<li>
<p>
All API functions defined by the vendor extension will have names of the form <strong>cl&lt;<em>function_name</em>&gt;&lt;<em>vendor_name</em>&gt;</strong>.
</p>
</li>
<li>
<p>
All enumerants defined by the vendor extension will have names of the form <strong>CL_&lt;<em>enum_name</em>&gt;_&lt;<em>vendor_name</em>&gt;.</strong>
</p>
</li>
</ul></div>
<div class="sect2">
<h3 id="compiler-directives-for-optional-extensions">Compiler Directives for Optional Extensions</h3>
<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"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#pragma</span></span> <span style="color: #008080">OPENCL</span> EXTENSION <span style="color: #990000">&lt;</span>extension_name<span style="color: #990000">&gt;</span> <span style="color: #990000">:</span> <span style="color: #990000">&lt;</span>behavior<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#pragma</span></span> OPENCL <span style="color: #008080">EXTENSION</span> all <span style="color: #990000">:</span> <span style="color: #990000">&lt;</span>behavior<span style="color: #990000">&gt;</span></tt></pre></div></div>
<div class="paragraph"><p>where <em>extension_name</em> is the name of the extension. The <em>extension_name</em> will have names of the form <strong>cl_khr_&lt;<em>name</em>&gt;</strong> for an extension approved by the OpenCL working group and will have names of the form <strong>cl_&lt;<em>vendor_name</em>&gt;_&lt;<em>name</em>&gt;</strong> for vendor extensions. 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"
style="
width:100%;
">
<col style="width:25%;">
<col style="width:75%;">
<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><span class="monospaced">#pragma OPENCL EXTENSION</span></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><span class="monospaced">#pragma OPENCL EXTENSION</span></strong> if the extension <em>extension_name</em> is not supported.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The <strong><span class="monospaced">#pragma OPENCL EXTENSION</span></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"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#pragma</span></span> OPENCL <span style="color: #008080">EXTENSION</span> all <span style="color: #990000">:</span> disable</tt></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 <span class="monospaced">#define</span> that matches the extension name string. This <span class="monospaced">#define</span> would be
available in the language if and only if the extension is supported on a given implementation.</p></div>
<div class="paragraph"><p><strong>Example</strong>:</p></div>
<div class="paragraph"><p>An extension which adds the extension string "<strong><span class="monospaced">cl_khr_3d_image_writes</span></strong>" should also add a preprocessor <span class="monospaced">#define</span> called <strong><span class="monospaced">cl_khr_3d_image_writes</span></strong>. A kernel can now use this preprocessor <span class="monospaced">#define</span> to do something like:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_3d_image_writes
<span style="font-style: italic"><span style="color: #9A1900">// do something using the extension</span></span>
<span style="font-weight: bold"><span style="color: #000080">#else</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// do something else or #error!</span></span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span></tt></pre></div></div>
</div>
<div class="sect2">
<h3 id="getting-opencl-api-extension-function-pointers">Getting OpenCL API Extension Function Pointers</h3>
<div class="paragraph"><p>The function <span class="footnote"><br>[Since there is no way to qualify the query with a device, the function pointer
returned must work for all implementations of that extension on different devices for a platform. The behavior of calling a device extension function on a device not supporting that extension is undefined.]<br></span></p></div>
<div class="paragraph"><p></p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">clGetExtensionFunctionAddressForPlatform</span></span><span style="color: #990000">(</span><span style="color: #008080">cl_platform_id</span> platform<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #009900">char</span> <span style="color: #990000">*</span>funcname<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>returns the address of the extension function named by <em>funcname</em> for a given <em>platform</em> The pointer returned should be cast to a function pointer type matching the extension function’s definition defined in the appropriate extension specification and header file. A return value of NULL indicates that the specified function does not exist for the implementation or <em>platform</em> is not a valid platform. A non-NULL return value for <strong>clGetExtensionFunctionAddressForPlatform</strong> does not guarantee that an extension function is actually supported by the platform. The application must also make a corresponding query using <strong>clGetPlatformInfo</strong>(platform, CL_PLATFORM_EXTENSIONS, &#8230;) or <strong>clGetDeviceInfo</strong>(device, CL_DEVICE_EXTENSIONS, &#8230;) to determine if an extension is supported by the OpenCL implementation.</p></div>
<div class="paragraph"><p><strong>clGetExtensionFunctionAddressForPlatform</strong> may not be queried for core (non-extension) functions in OpenCL. For functions that are queryable with <strong>clGetExtensionFunctionAddressForPlatform</strong>, implementations may choose to also export those functions statically from the object libraries implementing those functions. However, portable applications cannot rely on this behavior.</p></div>
<div class="paragraph"><p>Function pointer typedefs must be declared for all extensions that add API entrypoints. These typedefs are a required part of the extension interface, to be provided in an appropriate header (such as cl_ext.h if the extension is an OpenCL extension, or cl_gl_ext.h if the extension is an OpenCL / OpenGL sharing extension).</p></div>
<div class="paragraph"><p>The following convention must be followed for all extensions affecting the host API:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#ifndef</span></span> extension_name
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> extension_name <span style="color: #993399">1</span>
<span style="font-style: italic"><span style="color: #9A1900">// all data typedefs, token #defines, prototypes, and</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// function pointer typedefs for this extension</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// function pointer typedefs must use the</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// following naming convention</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">CL_API_ENTRY</span> return_type
<span style="color: #990000">(</span><span style="color: #008080">CL_API_CALL</span> <span style="color: #990000">*</span>clExtensionFunctionNameTAG_fn<span style="color: #990000">)(...);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span> <span style="font-style: italic"><span style="color: #9A1900">// _extension_name_</span></span></tt></pre></div></div>
<div class="paragraph"><p>where <span class="monospaced">TAG</span> can be <span class="monospaced">KHR</span>, <span class="monospaced">EXT</span> or <span class="monospaced">vendor-specific</span>.</p></div>
<div class="paragraph"><p>Consider, for example, the <strong>cl_khr_gl_sharing</strong> extension. This extension would add the following to cl_gl_ext.h:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#ifndef</span></span> cl_khr_gl_sharing
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> cl_khr_gl_sharing <span style="color: #993399">1</span>
<span style="font-style: italic"><span style="color: #9A1900">// all data typedefs, token #defines, prototypes, and</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// function pointer typedefs for this extension</span></span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR <span style="color: #990000">-</span><span style="color: #993399">1000</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR <span style="color: #993399">0x2006</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CL_DEVICES_FOR_GL_CONTEXT_KHR <span style="color: #993399">0x2007</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CL_GL_CONTEXT_KHR <span style="color: #993399">0x2008</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CL_EGL_DISPLAY_KHR <span style="color: #993399">0x2009</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CL_GLX_DISPLAY_KHR <span style="color: #993399">0x200A</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CL_WGL_HDC_KHR <span style="color: #993399">0x200B</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CL_CGL_SHAREGROUP_KHR <span style="color: #993399">0x200C</span>
<span style="font-style: italic"><span style="color: #9A1900">// function pointer typedefs must use the</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// following naming convention</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">CL_API_ENTRY</span> cl_int
<span style="color: #990000">(</span><span style="color: #008080">CL_API_CALL</span> <span style="color: #990000">*</span>clGetGLContextInfoKHR_fn<span style="color: #990000">)(</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> cl_context_properties <span style="color: #990000">*</span> <span style="font-style: italic"><span style="color: #9A1900">/* properties */</span></span><span style="color: #990000">,</span>
cl_gl_context_info <span style="font-style: italic"><span style="color: #9A1900">/* param_name */</span></span><span style="color: #990000">,</span>
size_t <span style="font-style: italic"><span style="color: #9A1900">/* param_value_size */</span></span><span style="color: #990000">,</span>
<span style="color: #009900">void</span> <span style="color: #990000">*</span> <span style="font-style: italic"><span style="color: #9A1900">/* param_value */</span></span><span style="color: #990000">,</span>
size_t <span style="color: #990000">*</span> <span style="font-style: italic"><span style="color: #9A1900">/*param_value_size_ret*/</span></span><span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span> <span style="font-style: italic"><span style="color: #9A1900">// cl_khr_gl_sharing</span></span></tt></pre></div></div>
<div style="page-break-after:always"></div>
</div>
<div class="sect2">
<h3 id="cl_khr_fp16">Half Precision Floating-Point</h3>
<div class="paragraph"><p>This section describes the <strong>cl_khr_fp16</strong> extension. This extension adds support for half scalar and vector types as built-in types that can be used for arithmetic operations, conversions etc.</p></div>
<div class="sect3">
<h4 id="cl_khr_fp16-additions-to-chapter-6-of-the-opencl-2.0-specification">Additions to Chapter 6 of the OpenCL 2.0 C Specification</h4>
<div class="paragraph"><p>The list of built-in scalar, and vector data types defined in <em>tables 6.1</em>, and <em>6.2</em> are extended to include the following:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<col style="width:25%;">
<col style="width:75%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type</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>half2</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A 2-component half-precision floating-point vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half3</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A 3-component half-precision floating-point vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half4</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A 4-component half-precision floating-point vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half8</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A 8-component half-precision floating-point vector.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half16</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A 16-component half-precision floating-point vector.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The built-in vector data types for <span class="monospaced">halfn</span> 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 types for <span class="monospaced">halfn</span> as defined in the OpenCL C programming language and the corresponding data type available to the application:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type in OpenCL Language</strong> </th>
<th class="tableblock halign-left valign-top" ><strong>API type for application</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half2</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>cl_half2</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half 3</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>cl_half3</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half 4</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>cl_half4</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half 8</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>cl_half8</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>half16</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>cl_half16</strong></p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The relational, equality, logical and logical unary operators described in <em>section 6.3</em> can be used with <span class="monospaced">half</span> scalar and <span class="monospaced">halfn</span> vector types and shall produce a scalar <span class="monospaced">int</span> and vector <span class="monospaced">shortn</span> result respectively.</p></div>
<div class="paragraph"><p>The OpenCL compiler accepts an h and H suffix on floating point literals, indicating the literal is typed as a half.</p></div>
<div class="sect4">
<h5 id="cl_khr_fp16-conversions">Conversions</h5>
<div class="paragraph"><p>The implicit conversion rules specified in <em>section 6.2.1</em> now include the <span class="monospaced">half</span> scalar and <span class="monospaced">halfn</span> vector data types.</p></div>
<div class="paragraph"><p>The explicit casts described in <em>section 6.2.2</em> are extended to take a <span class="monospaced">half</span> scalar data type and a <span class="monospaced">halfn</span> vector data type.</p></div>
<div class="paragraph"><p>The explicit conversion functions described in <em>section 6.2.3</em> are extended to take a <span class="monospaced">half</span> scalar data type and a <span class="monospaced">halfn</span> vector data type.</p></div>
<div class="paragraph"><p>The <span class="monospaced">as_typen()</span> function for re-interpreting types as described in <em>section 6.2.4.2</em> is extended to allow conversion-free casts between <span class="monospaced">shortn</span>, <span class="monospaced">ushortn</span>, and <span class="monospaced">halfn</span> scalar and vector data types.</p></div>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16-math-functions">Math Functions</h5>
<div class="paragraph"><p>The built-in math functions defined in <em>table 6.8</em> (also listed below) are extended to include appropriate versions of functions that take <span class="monospaced">half</span>, and <span class="monospaced">half{2|3|4|8|16}</span> as arguments and return values. <span class="monospaced">gentype</span> now also includes <span class="monospaced">half</span>, <span class="monospaced">half2</span>, <span class="monospaced">half3</span>, <span class="monospaced">half4</span>, <span class="monospaced">half8</span>, and <span class="monospaced">half16</span>.</p></div>
<div class="paragraph"><p>For any specific use of a function, the actual type has to be the same for all arguments and the return type.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 1. <em>Half Precision Built-in Math Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">gentype <strong>acos</strong> (gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Arc cosine function.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">gentype <strong>acosh</strong> (gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Inverse hyperbolic cosine.</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 <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Arc sine function.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">gentype <strong>asinh</strong> (gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Inverse hyperbolic sine.</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.</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>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">gentype <strong>atanh</strong> (gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Hyperbolic arc tangent.</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 <em>x</em>)</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 <em>x</em>)</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.</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 consine.</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 <em>x</em>)</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 <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Error function encountered in integrating the normal distribution.</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- e exponential of <em>x</em>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">gentype <strong>exp2</strong> (gentype <em>x</em>)</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 <em>x</em>)</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 <em>x</em>)</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 x is less than or equal to y.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">gentype <strong>floor</strong> (gentype <em>x</em>)</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.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">gentype <strong>fmax</strong> (gentype x, gentype y)<br>
gentype <strong>fmax</strong> (gentype <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>
gentype <strong>fmin</strong> (gentype <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.</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>, 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>), 0x1.ffcp-1f ).<br>
<br>
<strong>floor</strong>(x) is returned in <em>iptr</em>.</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>, 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 float 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> (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">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>
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 <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>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>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>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> approximates <em>a</em> * <em>b</em> + <em>c</em>. Whether or how the product of <em>a</em> * <em>b</em> is rounded and how supernormal or subnormal intermediate products are handled is not defined. <strong>mad</strong> is intended to be used where speed is preferred over accuracy<span class="footnote"><br>[The user is cautioned that for some usages, e.g. <strong>mad</strong>(a, b, -a*b), the half precision definition of <strong>mad</strong>() is loose enough that almost any result is allowed from <strong>mad</strong>() for some values of a and b.]<br></span>.</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></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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><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">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 half-precision 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">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">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 <em>x</em>)</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">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 <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>sin</strong> (gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Compute sine.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><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 x. The computed sine is the return value and computed cosine is returned in <em>cosval</em>.</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.</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 <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>tan</strong> (gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Compute tangent.</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.</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 <em>x</em>)</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 <em>x</em>)</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 <strong>FP_FAST_FMA_HALF</strong> macro indicates whether the <strong>fma()</strong> family of functions are fast compared with direct code for half precision floating-point. If defined, the <strong>FP_FAST_FMA_HALF</strong> macro shall indicate that the <strong>fma()</strong> function generally executes about as fast as, or faster than, a multiply and an add of <strong>half</strong> 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"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_DIG <span style="color: #993399">3</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MANT_DIG <span style="color: #993399">11</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX_10_EXP <span style="color: #990000">+</span><span style="color: #993399">4</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX_EXP <span style="color: #990000">+</span><span style="color: #993399">16</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN_10_EXP <span style="color: #990000">-</span><span style="color: #993399">4</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN_EXP <span style="color: #990000">-</span><span style="color: #993399">13</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_RADIX <span style="color: #993399">2</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX <span style="color: #993399">0x1</span><span style="color: #990000">.</span>ffcp15h
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>14h
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_EPSILON <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>10h</tt></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"
style="
width:100%;
">
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Macro in OpenCL Language</strong> </th>
<th class="tableblock halign-left valign-top" ><strong>Macro for application</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_DIG</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_DIG</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_MANT_DIG</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_MANT_DIG</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_MAX_10_EXP</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_MAX_10_EXP</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_MAX_EXP</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_MAX_EXP</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_MIN_10_EXP</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_MIN_10_EXP</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_MIN_EXP</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_MIN_EXP</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_RADIX</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_RADIX</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_MAX</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_MAX</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_MIN</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_MIN</strong></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>HALF_EPSILSON</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><strong>CL_HALF_EPSILON</strong></p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The following constants are also available. They are of type <span class="monospaced">half</span> and are accurate within the precision of the <span class="monospaced">half</span> type.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Constant</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>M_E_H</strong></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"><strong>M_LOG2E_H</strong></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"><strong>M_LOG10E_H</strong></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"><strong>M_LN2_H</strong></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"><strong>M_LN10_H</strong></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"><strong>M_PI_H</strong></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"><strong>M_PI_2_H</strong></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"><strong>M_PI_4_H</strong></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"><strong>M_1_PI_H</strong></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"><strong>M_2_PI_H</strong></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"><strong>M_2_SQRTPI_H</strong></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"><strong>M_SQRT2_H</strong></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"><strong>M_SQRT1_2_H</strong></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 1 / √2</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16-common-functions">Common Functions<span class="footnote"><br>[The half precision <strong>mix</strong> and <strong>smoothstep</strong> functions can be implemented using contractions such as <strong>mad</strong> or <strong>fma</strong>.]<br></span></h5>
<div class="paragraph"><p>The built-in common functions defined in <em>table 6.12</em> (also listed below) are extended to include appropriate versions of functions that take <span class="monospaced">half</span>, <span class="monospaced">and half{2|3|4|8|16}</span> as arguments and return values. gentype now also includes <span class="monospaced">half</span>, <span class="monospaced">half2</span>, <span class="monospaced">half3</span>, <span class="monospaced">half4</span>, <span class="monospaced">half8</span> and <span class="monospaced">half16</span>. These are described below.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 2. <em>Half Precision Built-in Common Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">gentype <strong>clamp</strong> (<br>
gentype <em>x</em>, gentype <em>minval</em>, gentype <em>maxval</em>)<br>
<br>
gentype <strong>clamp</strong> (<br>
gentype <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>min</strong>(<strong>max</strong>(<em>x</em>, <em>minval</em>), <em>maxval</em>).<br>
<br>
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,<br>
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>
gentype <strong>max</strong> (gentype <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> and <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>
gentype <strong>min</strong> (gentype <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> and <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>
gentype <strong>mix</strong> (gentype <em>x</em>, gentype <em>y</em>, half <em>a</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Returns the linear blend of <em>x</em> and <em>y</em> implemented as:<br>
<br>
<em>x</em> + (<em>y</em><em>x)</em> * <em>a</em><br>
<br>
<em>a</em> must be a value in the range 0.0 &#8230; 1.0. If <em>a</em> is not in the range 0.0 &#8230; 1.0, the return values are undefined.</p></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>
gentype <strong>step</strong> (half <em>edge</em>, gentype <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> (<br>
gentype <em>edge0</em>, gentype <em>edge1</em>, gentype <em>x</em>)<br>
<br>
gentype <strong>smoothstep</strong> (<br>
half <em>edge0</em>, half <em>edge1</em>, gentype <em>x</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">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.<br>
<br>
This is equivalent to:<br>
<br>
gentype <em>t</em>;<br>
<em>t</em> = clamp ((<em>x</em><em>edge0</em>) / (<em>edge1</em><em>edge0</em>), 0, 1);<br>
return <em>t</em> * <em>t</em> * (3 – 2 * <em>t</em>);<br>
<br>
Results are undefined if <em>edge0</em> &gt;= <em>edge1</em>.</p></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 class="sect4">
<h5 id="cl_khr_fp16-geometric-functions">Geometric Functions<span class="footnote"><br>[The half precision geometric functions can be implemented using contractions such as <strong>mad</strong> or <strong>fma</strong>.]<br></span></h5>
<div class="paragraph"><p>The built-in geometric functions defined in <em>table 6.13</em> (also listed below) are extended to include appropriate versions of functions that take half, and half{2|3|4} as arguments and return values. gentype now also includes half, half2, half3 and half4. These are described below.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 3. <em>Half Precision Built-in Geometric Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">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 the result will be 0.0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half <strong>dot</strong> (gentype <em>p0</em>, gentype <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">half <strong>distance</strong> (gentype <em>p0</em>, gentype <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">half <strong>length</strong> (gentype <em>p</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Return the length of vector x, i.e.,<br>
sqrt( <em>p.x</em><sup>2</sup> + <em>p.y</em><sup>2</sup> + &#8230; )</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">gentype <strong>normalize</strong> (gentype <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>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16-relational-functions">Relational Functions</h5>
<div class="paragraph"><p>The scalar and vector relational functions described in <em>table 6.14</em> are extended to include versions that take <span class="monospaced">half</span>, <span class="monospaced">half2</span>, <span class="monospaced">half3</span>, <span class="monospaced">half4</span>, <span class="monospaced">half8</span> and <span class="monospaced">half16</span> as arguments.</p></div>
<div class="paragraph"><p>The relational and equality operators (&lt;, &lt;=, &gt;, &gt;=, !=, ==) can be used with <span class="monospaced">halfn</span> vector types and shall produce a vector <span class="monospaced">shortn</span> result as described in <em>section 6.3</em>.</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> shall return a 0 if the specified relation is <em>false</em> and a 1 if the specified relation is true 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>
<div class="paragraph"><p>The functions described in <em>table 6.14</em> are extended to include the <span class="monospaced">halfn</span> vector types.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 4. <em>Half Precision Relational Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">int <strong>isequal</strong> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isequal</strong> (half<em>n x</em>, half<em>n 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> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isnotequal</strong> (half<em>n x</em>, half<em>n 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> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isgreater</strong> (half<em>n x</em>, half<em>n 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> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isgreaterequal</strong> (half<em>n x</em>, half<em>n 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> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isless</strong> (half<em>n x</em>, half<em>n 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> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>islessequal</strong> (half<em>n x</em>, half<em>n 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> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>islessgreater</strong> (half<em>n x</em>, half<em>n y</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Returns the component-wise compare of (<em>x_ &lt; _y</em>) || (<em>x_ &gt; _y</em>) .</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><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> (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> (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> (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> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isordered</strong> (half<em>n x</em>, half<em>n 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> (half <em>x</em>, half <em>y</em>)<br>
short<em>n</em> <strong>isunordered</strong> (half<em>n x</em>, half<em>n 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 a NaN, and zero otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">int <strong>signbit</strong> (half)<br>
short<em>n</em> <strong>signbit</strong> (half<em>n</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 the half is set else returns 0. The vector version of the function returns the following for each component in half<em>n</em>: -1
(i.e all bits set) if the sign bit in the half is set else returns 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half<em>n</em> <strong>bitselect</strong> (half<em>n a</em>, half<em>n b</em>, half<em>n 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">half<em>n</em> <strong>select</strong> (half<em>n a</em>, half<em>n b</em>, short<em>n</em> <em>c</em>)<br>
half<em>n</em> <strong>select</strong> (half<em>n a</em>, half<em>n b</em>, ushort<em>n</em> <em>c</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For each component,<br>
<em>result[i]</em> = if MSB of <em>c[i]</em> is set ? <em>b[i]</em> : <em>a[i]</em>.<br></p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16-vector-data-load-and-store-functions">Vector Data Load and Store Functions</h5>
<div class="paragraph"><p>The vector data load (<strong>vload<em>n</em></strong>) and store (<strong>vstore<em>n</em></strong>) functions described in <em>table 6.14</em> (also listed below) are extended to include versions that read from or write to half scalar or vector values. The generic type <span class="monospaced">gentype</span> is extended to include <span class="monospaced">half</span>. The generic type <span class="monospaced">gentypen</span> is extended to include <span class="monospaced">half</span>, <span class="monospaced">half2</span>, <span class="monospaced">half3</span> <span class="footnote"><br>[<strong>vload3</strong> reads <em>x</em>, <em>y</em>, <em>z</em> components from address (<em>p</em> + (<em>offset</em> * 3)) into a 3-component vector and <strong>vstore3</strong> writes <em>x</em>, <em>y</em>, <em>z</em> components from a 3-component vector to address (<em>p</em> + (<em>offset</em> * 3)).]<br></span>, <span class="monospaced">half4</span>, <span class="monospaced">half8</span>, and <span class="monospaced">half16</span>.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 5. <em>Half Precision Vector Data Load and Store Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">gentype<em>n</em> <strong>vload<em>n</em></strong><br>
(size_t <em>offset</em>, const gentype *<em>p</em>)<br>
<br>
gentype<em>n</em> <strong>vload<em>n</em></strong><br>
(size_t <em>offset</em>, const constant gentype *<em>p</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Return sizeof (gentype<em>n</em>) bytes of data read from address (<em>p</em> + (<em>offset * n</em>)). The read address computed as (<em>p</em> + (<em>offset * n</em>)) must be 16-bit aligned.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">void <strong>vstore<em>n</em></strong> (<br>
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 sizeof (gentype<em>n</em>) bytes given by <em>data</em> to address (<em>p</em> + (<em>offset * n</em>)). The write address computed as (<em>p</em> + (<em>offset * n</em>)) must be 16-bit aligned.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16-async-copies-from-global-to-local-memory-local-to-global-memory-and-prefetch">Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch</h5>
<div class="paragraph"><p>The OpenCL C programming language implements the following functions that provide asynchronous copies between global and local memory and a prefetch from global memory.</p></div>
<div class="paragraph"><p>The generic type <span class="monospaced">gentype</span> is extended to include <span class="monospaced">half</span>, <span class="monospaced">half2</span>, <span class="monospaced">half3</span>, <span class="monospaced">half4</span>, <span class="monospaced">half8</span>, and <span class="monospaced">half16</span>.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 6. <em>Half Precision Built-in Async Copy and Prefetch Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">event_t <strong>async_work_group_copy</strong> (<br>
<em>local gentype <em>*dst</em>, const </em>global gentype *<em>src</em>,<br>
size_t <em>num_gentypes</em>, event_t <em>event</em>)<br>
<br>
event_t <strong>async_work_group_copy</strong> (<br>
<em>global gentype <em>*dst</em>, const </em>local gentype *<em>src</em>,<br>
size_t <em>num_gentypes</em>, event_t <em>event</em>)</p></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>. The async copy 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.<br>
<br>
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.<br>
<br>
If <em>event</em> argument is not zero, the event object supplied in <em>event</em> argument will be returned.<br>
<br>
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" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">event_t <strong>async_work_group_strided_copy</strong> (<br>
<em>local gentype <em>*dst</em>, const </em>global gentype *<em>src</em>,<br>
size_t <em>num_gentypes</em>, size_t <em>src_stride</em>, event_t <em>event</em>)<br>
<br>
event_t <strong>async_work_group_strided_copy</strong> (<br>
<em>global gentype <em>*dst</em>, const </em>local gentype *<em>src</em>,<br>
size_t <em>num_gentypes</em>, size_t <em>dst_stride</em>, event_t <em>event</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Perform an async gather of <em>num_gentypes</em> gentype elements from <em>src</em> to <em>dst</em>. The <em>src_stride</em> is the stride in elements for each gentype element read from <em>src</em>. The async gather 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.<br>
<br>
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.<br>
<br>
If <em>event</em> argument is not zero, the event object supplied in <em>event</em> argument will be returned.<br>
<br>
This function does not perform any implicit synchronization of source data such as using a <strong>barrier</strong> before performing the copy.<br>
<br>
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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">void <strong>wait_group_events</strong> (<br>
int <em>num_events</em>, event_t *<em>event_list</em>)</p></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.<br>
<br>
This function must be encountered by all work-items in a work-group executing the kernel with the same <em>num_events</em> and event objects specified in <em>event_list</em>; otherwise the results are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">void <strong>prefetch</strong> (<br>
const <em>_global gentype *_p</em>, size_t <em>num_gentypes</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Prefetch <em>num_gentypes</em> * sizeof(gentype) 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>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16-image-read-and-write-functions">Image Read and Write Functions</h5>
<div class="paragraph"><p>The image read and write functions defined in <em>tables 6.23</em>, <em>6.24</em> and <em>6.25</em> are extended to support image color values that are a <span class="monospaced">half</span> type.</p></div>
</div>
<div class="sect4">
<h5 id="_built_in_image_read_functions">Built-in Image Read Functions</h5>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 7. <em>Half Precision Built-in Image Read Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">half4 <strong>read_imageh</strong> (<br>
read_only image2d_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
int2 <em>coord</em>)<br>
<br>
half4 <strong>read_imageh</strong> (<br>
read_only image2d_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
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>.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to one of the pre-defined packed formats, CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with <em>image_channel_data_type</em> set to CL_HALF_FLOAT.<br>
<br>
The <strong>read_imageh</strong> calls that take integer coordinates must use a sampler with filter mode set to CLK_FILTER_NEAREST, normalized coordinates set to CLK_NORMALIZED_COORDS_FALSE and addressing mode set to CLK_ADDRESS_CLAMP_TO_EDGE, CLK_ADDRESS_CLAMP or CLK_ADDRESS_NONE; otherwise the values returned are undefined.<br>
<br>
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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half4 <strong>read_imageh</strong> (<br>
read_only image3d_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
int4 <em>coord</em> )<br>
<br>
half4 <strong>read_imageh</strong> (<br>
read_only image3d_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
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.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong>returns half precision floating-point values for image objects created with <em>image_channel_data_type</em> set to CL_HALF_FLOAT.<br>
<br>
The <strong>read_imageh</strong> calls that take integer coordinates must use a sampler with filter mode set to CLK_FILTER_NEAREST, normalized coordinates set to CLK_NORMALIZED_COORDS_FALSE and addressing mode set to CLK_ADDRESS_CLAMP_TO_EDGE, CLK_ADDRESS_CLAMP or CLK_ADDRESS_NONE; otherwise the values returned are undefined.<br>
<br>
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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half4 <strong>read_imageh</strong> (<br>
read_only image2d_array_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
int4 <em>coord</em>)<br>
<br>
half4 <strong>read_imageh</strong> (<br>
read_only image2d_array_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
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>.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with image_channel_data_type set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with image_channel_data_type set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with image_channel_data_type set to CL_HALF_FLOAT.<br>
<br>
The <strong>read_imageh</strong> calls that take integer coordinates must use a sampler with filter mode set to CLK_FILTER_NEAREST, normalized coordinates set to CLK_NORMALIZED_COORDS_FALSE and addressing mode set to CLK_ADDRESS_CLAMP_TO_EDGE, CLK_ADDRESS_CLAMP or CLK_ADDRESS_NONE; otherwise the values returned are undefined.<br>
<br>
Values returned by <strong>read_imageh</strong> for image objects with image_channel_data_type values not specified in the description above are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half4 <strong>read_imageh</strong> (<br>
read_only image1d_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
int <em>coord</em>)<br>
<br>
half4 <strong>read_imageh</strong> (<br>
read_only image1d_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
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>.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with <em>image_channel_data_type</em> set to CL_HALF_FLOAT.<br>
<br>
The <strong>read_imageh</strong> calls that take integer coordinates must use a sampler with filter mode set to CLK_FILTER_NEAREST, normalized coordinates set to CLK_NORMALIZED_COORDS_FALSE and addressing mode set to CLK_ADDRESS_CLAMP_TO_EDGE, CLK_ADDRESS_CLAMP or CLK_ADDRESS_NONE; otherwise the values returned are undefined.<br>
<br>
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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half4 <strong>read_imageh</strong> (<br>
read_only image1d_array_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
int2 <em>coord</em>)<br>
<br>
half4 <strong>read_imageh</strong> (<br>
read_only image1d_array_t <em>image</em>,<br>
sampler_t <em>sampler</em>,<br>
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>.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with image_channel_data_type set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with image_channel_data_type set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with image_channel_data_type set to CL_HALF_FLOAT.<br>
<br>
The <strong>read_imageh</strong> calls that take integer coordinates must use a sampler with filter mode set to CLK_FILTER_NEAREST, normalized coordinates set to CLK_NORMALIZED_COORDS_FALSE and addressing mode set to CLK_ADDRESS_CLAMP_TO_EDGE, CLK_ADDRESS_CLAMP or CLK_ADDRESS_NONE; otherwise the values returned are undefined.
<br>
Values returned by <strong>read_imageh</strong> for image objects with image_channel_data_type values not specified in the description above are undefined.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="_built_in_image_sampler_less_read_functions">Built-in Image Sampler-less Read Functions</h5>
<div class="paragraph"><p><em>aQual</em> in Table 6.24 refers to one of the access qualifiers. For sampler-less read functions this may be <em>read_only</em> or <em>read_write</em>.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 8. <em>Half Precision Built-in Image Sampler-less Read Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">half4 <strong>read_imageh</strong> (<br>
<em>aQual</em> image2d_t <em>image</em>,<br>
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>.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with <em>image_channel_data_type</em> set to CL_HALF_FLOAT.<br>
<br>
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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half4 <strong>read_imageh</strong> (<br>
<em>aQual</em> image3d_t <em>image</em>,<br>
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.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to CL_SNORM_INT8, or CL_SNORM_INT16.
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with <em>image_channel_data_type</em> set to CL_HALF_FLOAT.<br>
<br>
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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half4 <strong>read_imageh</strong> (<br>
<em>aQual</em> image2d_array_t <em>image</em>,<br>
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>.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with <em>image_channel_data_type</em> set to CL_HALF_FLOAT.<br>
<br>
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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half4 <strong>read_imageh</strong> (<br>
<em>aQual</em> image1d_t <em>image</em>,<br>
int <em>coord</em>)<br>
<br>
half4 <strong>read_imageh</strong> (<br>
<em>aQual</em> image1d_buffer_t <em>image</em>,<br>
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>.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with <em>image_channel_data_type</em> set to CL_HALF_FLOAT.<br>
<br>
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></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half4 <strong>read_imageh</strong> (<br>
<em>aQual</em> image1d_array_t <em>image</em>,<br>
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>.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to one of the pre-defined packed formats or CL_UNORM_INT8, or CL_UNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <em>image_channel_data_type</em> set to CL_SNORM_INT8, or CL_SNORM_INT16.<br>
<br>
<strong>read_imageh</strong> returns half precision floating-point values for image objects created with <em>image_channel_data_type</em> set to CL_HALF_FLOAT.<br>
<br>
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></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="_built_in_image_write_functions">Built-in Image Write Functions</h5>
<div class="paragraph"><p><em>aQual</em> in Table 6.25 refers to one of the access qualifiers. For write functions this may be <em>write_only</em> or <em>read_write</em>.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 9. <em>Half Precision Built-in Image Write Functions</em></caption>
<col style="width:50%;">
<col style="width:50%;">
<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">void <strong>write_imageh</strong> (<br>
<em>aQual</em> image2d_t <em>image</em>,<br>
int2 <em>coord</em>,<br>
half4 <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 specified by <em>image</em>.<br>
<br>
Appropriate data format conversion to the specified image format is done before writing the color value. <em>x</em> &amp; <em>y</em> are considered to be unnormalized coordinates and must be in the range 0 &#8230; width – 1, and 0 &#8230; height – 1.<br>
<br>
<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 CL_SNORM_INT8, CL_UNORM_INT8, CL_SNORM_INT16, CL_UNORM_INT16 or CL_HALF_FLOAT.<br>
<br>
The behavior of <strong>write_imageh</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 &#8230; width – 1, 0 &#8230; height – 1) respectively, is undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">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>)</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>.<br>
<br>
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 &#8230; image width – 1, 0 &#8230; image height – 1 and 0 &#8230; image number of layers – 1.<br>
<br>
<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 CL_SNORM_INT8, CL_UNORM_INT8, CL_SNORM_INT16, CL_UNORM_INT16 or CL_HALF_FLOAT.<br>
<br>
The behavior of <strong>write_imageh</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, z</em>) coordinate values that are not in the range (0 &#8230; image width – 1, 0 &#8230; image height – 1, 0 &#8230; image number of layers – 1), respectively, is undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">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>
<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>)</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 unnormalized coordinates and must be in the range 0 &#8230; image width – 1.<br>
<br>
<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 CL_SNORM_INT8, CL_UNORM_INT8, CL_SNORM_INT16, CL_UNORM_INT16 or CL_HALF_FLOAT. 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.<br>
<br>
The behavior of <strong>write_imageh</strong> for image objects created with <em>image_channel_data_type</em> values not specified in the description above or with coordinate values that is not in the range (0 &#8230; image width – 1), is undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">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>)</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 &#8230; image width – 1 and 0 &#8230; image number of layers – 1.<br>
<br>
<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 CL_SNORM_INT8, CL_UNORM_INT8, CL_SNORM_INT16, CL_UNORM_INT16 or CL_HALF_FLOAT. 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.<br>
<br>
The behavior of <strong>write_imageh</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 &#8230; image width – 1, 0 &#8230; image number of layers – 1), respectively, is undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">void <strong>write_imageh</strong> (<br>
<em>aQual</em> image3d_t <em>image</em>,<br>
int4 <em>coord</em>,<br>
half4 <em>color</em>)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Write color value to location specified by coord.xyz in the 3D image object specified by <em>image</em>.<br>
<br>
Appropriate data format conversion to the specified image format is done before writing the color value. coord.x, coord.y and coord.z are considered to be unnormalized coordinates and must be in the range 0 &#8230; image width – 1, 0 &#8230; image height – 1 and 0 &#8230; image depth – 1.<br>
<br>
<strong>write_imageh</strong> can only be used with image objects created with image_channel_data_type set to one of the pre-defined packed formats or set to CL_SNORM_INT8, CL_UNORM_INT8, CL_SNORM_INT16, CL_UNORM_INT16 or CL_HALF_FLOAT.<br>
<br>
The behavior of <strong>write_imageh</strong> for image objects created with image_channel_data_type values not specified in the description above or with (x, y, z) coordinate values that are not in the range (0 &#8230; image width – 1, 0 &#8230; image height – 1, 0 &#8230; image depth – 1), respectively, is undefined.<br>
<br>
NOTE: This built-in function is only available in the cl_khr_3d_image_writes extension is also supported by the device.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16-ieee754-compliance">IEEE754 Compliance</h5>
<div class="paragraph"><p>The following table entry describes the additions to <em>table 4.3,</em> which
allows applications to query the configuration information using
<strong>clGetDeviceInfo</strong> for an OpenCL device that supports half precision
floating-point.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<col style="width:25%;">
<col style="width:25%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Op-code</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Return Type</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Description</strong></th>
</tr>
</thead>