blob: 4207d3ae90b70d21675fb91db64d353afc2b83e7 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
"http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
<refentry>
<refentryinfo>
<keywordset>
<keyword>
Preprocessor Directives and Macros
</keyword>
</keywordset>
</refentryinfo>
<refmeta>
<refentrytitle>Preprocessor Directives and Macros</refentrytitle>
<refmiscinfo>
<copyright>
<year>2007-2009</year>
<holder>The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and/or associated documentation files (the
"Materials"), to deal in the Materials without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Materials, and to
permit persons to whom the Materials are furnished to do so, subject to
the condition that this copyright notice and permission notice shall be included
in all copies or substantial portions of the Materials.</holder>
</copyright>
</refmiscinfo>
<manvolnum>2</manvolnum>
</refmeta>
<!-- ================================ SYNOPSIS -->
<refnamediv id="Preprocessor Directives and Macros">
<refname>Preprocessor Directives and Macros</refname>
<refpurpose>
Preprocessor Directives and Macros.
</refpurpose>
</refnamediv>
<!-- ALTERNATIVE SYNTAX SYNOPSIS (NON-FUNCTION) -->
<refsect2 id="synopsis">
<title>
</title>
<informaltable frame="none">
<tgroup cols="1" align="left" colsep="0" rowsep="0">
<colspec colname="col1" colnum="1" />
<tbody>
<row>
<entry>
# <function>pragma</function> <varname>pp-tokens</varname><subscript>opt</subscript> <emphasis>new-line</emphasis>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect2>
<!-- ================================ DESCRIPTION -->
<refsect1 id="description"><title>Description</title>
<para>
The preprocessing directives defined by the C99 specification are supported.
</para>
<para>
A <function># pragma</function> directive where the preprocessing token <constant>OPENCL</constant> (used instead of <constant>STDC</constant>) does not immediately follow <function>pragma</function> in the directive (prior to any macro replacement) causes the implementation to behave in an implementation-defined manner. The behavior might cause translation to fail or cause the translator or the resulting program to behave in a non-conforming manner. Any such <function>pragma</function> that is not recognized by the implementation is ignored. If the preprocessing token <constant>OPENCL</constant> does immediately follow <function>pragma</function> in the directive (prior to any macro replacement), then no macro replacement is performed on the directive, and the directive shall have one of the following forms whose meanings are described elsewhere:
</para>
<para>
<literallayout><constant> #pragma OPENCL <citerefentry><refentrytitle>FP_CONTRACT</refentrytitle></citerefentry> <replaceable>on-off-switch</replaceable>
<replaceable>on-off-switch</replaceable>: one of ON OFF DEFAULT
#pragma OPENCL <citerefentry><refentrytitle>EXTENSION</refentrytitle></citerefentry> extensionname : behavior
#pragma OPENCL EXTENSION all : behavior</constant></literallayout>
</para>
<para>
The following predefined macro names are available.
</para>
<itemizedlist mark="disc">
<listitem>
<constant>__FILE__</constant> The presumed name of the current source file (a character string literal).
</listitem>
<listitem>
<code>__LINE__</code> The presumed line number (within the current source file) of the current source line (an integer constant).
</listitem>
<listitem>
<code>__OPENCL_VERSION__</code> substitutes an integer reflecting the version number of the OpenCL supported by the OpenCL device. The version of OpenCL described in this document will have <code>__OPENCL_VERSION__</code> substitute the integer 100.
</listitem>
<listitem>
<code>__ENDIAN_LITTLE__</code> is used to determine if the OpenCL device is a little endian architecture or a big endian architecture (an integer constant of 1 if device is little endian and is undefined otherwise). Also refer to CL_DEVICE_ENDIAN_LITTLE specified in the table of OpenCL Device Queries for <citerefentry><refentrytitle>clGetDeviceInfo</refentrytitle></citerefentry>.
</listitem>
<listitem>
<code>__ROUNDING_MODE__</code> is used to determine the current rounding mode and is set to rte. The <code>__ROUNDING_MODE__</code> only affects the rounding mode of conversions to a <type>float</type> type.
<code>__kernel_exec(X, type<replaceable>n</replaceable>)</code> (and <code>kernel_exec(X, type<replaceable>n</replaceable>))</code> is defined as follows:
<para>
<literallayout> <code>__kernel __attribute__((work_group_size_hint(X, 1, 1)))</code> \
<code>__attribute__((vec_type_hint(type<replaceable>n</replaceable>)))</code></literallayout>
</para>
</listitem>
<listitem>
<code>__IMAGE_SUPPORT__</code> is used to determine if the OpenCL device supports images. This is an integer constant of 1 if images are supported and is undefined otherwise. Also refer to CL_DEVICE_IMAGE_SUPPORT specified in the table of OpenCL Device Queries for <citerefentry><refentrytitle>clGetDeviceInfo</refentrytitle></citerefentry><!--table 4.3-->.
</listitem>
<listitem>
<code>__FAST_RELAXED_MATH__</code> is used to determine if the cl-fast-relaxed-math optimization option is specified in build options given to <citerefentry><refentrytitle>clBuildProgram</refentrytitle></citerefentry>.
This is an integer constant of 1 if the cl-fast-relaxed-math build option is specified and is undefined otherwise. The macro names defined by the C99 specification but not currently supported by OpenCL are
reserved for future use.
</listitem>
</itemizedlist>
</refsect1>
<!-- ================================ EXAMPLE -->
<!-- DO NOT DELETE IN CASE AN EXAMPLE IS ADDED IN THE FUTURE -->
<!--
<refsect2 id="example1">
<title>
Example
</title>
<informaltable frame="none">
<tgroup cols="1" align="left" colsep="0" rowsep="0">
<colspec colname="col1" colnum="1" />
<tbody>
<row>
<entry>
Example goes here - it will be set in "code" type with white space preserved.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect2>
-->
<!-- ================================ SPECIFICATION -->
<!-- Set the "uri" attribute in the <olink /> element to the "named destination" for the PDF page
-->
<refsect1 id="specification"><title>Specification</title>
<para>
<imageobject>
<imagedata fileref="pdficon_small1.gif" format="gif" />
</imageobject>
<olink uri="preprocessorDirectives">OpenCL Specification</olink>
</para>
</refsect1>
<!-- ================================ ALSO SEE -->
<refsect1 id="seealso"><title>Also see</title>
<para>
<citerefentry><refentrytitle>clBuildProgram</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>FP_CONTRACT</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>EXTENSION</refentrytitle></citerefentry>
</para>
</refsect1>
<!-- ============================== COPYRIGHT -->
<!-- Content included from copyright.inc.xsl -->
<refsect3 id="Copyright"><title></title>
<imageobject>
<imagedata fileref="KhronosLogo.jpg" format="jpg" />
</imageobject>
<para />
</refsect3>
</refentry>