Skip to content

Commit 30ad174

Browse files
author
Anastasia Stulova
committed
[Docs] Document C++ for OpenCL 2021 support in clang.
Along with the new language mode this commit contains misc small updates for OpenCL 3 and GitHub issues for OpenCL. Differential Revision: https://reviews.llvm.org/D116271
1 parent cb9ccd3 commit 30ad174

File tree

2 files changed

+50
-24
lines changed

2 files changed

+50
-24
lines changed

clang/docs/OpenCLSupport.rst

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ OpenCL Support
1818
==================
1919

2020
Clang has complete support of OpenCL C versions from 1.0 to 2.0.
21+
There is an ongoing work to support :ref:`OpenCL 3.0 <opencl_300>`.
2122

2223
Clang also supports :ref:`the C++ for OpenCL kernel language <cxx_for_opencl_impl>`.
2324

24-
There is an ongoing work to support :ref:`OpenCL 3.0 <opencl_300>`.
25-
26-
There are also other :ref:`new and experimental features <opencl_experimenal>` available.
25+
There are also other :ref:`new and experimental features <opencl_experimenal>`
26+
available.
2727

28-
For general issues and bugs with OpenCL in clang refer to `Bugzilla
29-
<https://bugs.llvm.org/buglist.cgi?component=OpenCL&list_id=172679&product=clang&resolution=--->`__.
28+
For general issues and bugs with OpenCL in clang refer to `the GitHub issue
29+
list
30+
<https://github.com/llvm/llvm-project/issues?q=is%3Aopen+is%3Aissue+label%3Aopencl>`__.
3031

3132
Internals Manual
3233
================
@@ -127,7 +128,7 @@ To enable modules for OpenCL:
127128

128129
.. code-block:: console
129130
130-
$ clang -target spir-unknown-unknown -c -emit-llvm -Xclang -finclude-default-header -fmodules -fimplicit-module-maps -fm odules-cache-path=<path to the generated module> test.cl
131+
$ clang -target spir-unknown-unknown -c -emit-llvm -Xclang -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=<path to the generated module> test.cl
131132
132133
Another way to circumvent long parsing latency for the OpenCL builtin
133134
declarations is to use mechanism enabled by :ref:`-fdeclare-opencl-builtins
@@ -319,24 +320,32 @@ specified in the Clang's source code.
319320
C++ for OpenCL Implementation Status
320321
====================================
321322

322-
Clang implements language version 1.0 published in `the official
323+
Clang implements language versions 1.0 and 2021 published in `the official
323324
release of C++ for OpenCL Documentation
324-
<https://github.com/KhronosGroup/OpenCL-Docs/releases/tag/cxxforopencl-v1.0-r2>`_.
325+
<https://github.com/KhronosGroup/OpenCL-Docs/releases/tag/cxxforopencl-docrev2021.12>`_.
325326

326327
Limited support of experimental C++ libraries is described in the :ref:`experimental features <opencl_experimenal>`.
327328

328-
Bugzilla bugs for this functionality are typically prefixed
329+
GitHub issues for this functionality are typically prefixed
329330
with '[C++4OpenCL]' - click `here
330-
<https://bugs.llvm.org/buglist.cgi?component=OpenCL&list_id=204139&product=clang&query_format=advanced&resolution=---&short_desc=%5BC%2B%2B4OpenCL%5D&short_desc_type=allwordssubstr>`__
331+
<https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+%5BC%2B%2B4OpenCL%5D>`__
331332
to view the full bug list.
332333

333334

334335
Missing features or with limited support
335336
----------------------------------------
336337

337-
- IR generation for global destructors is incomplete (See:
338+
- Support of C++ for OpenCL 2021 is currently in experimental phase. Refer to
339+
:ref:`OpenCL 3.0 status <opencl_300>` for details of common missing
340+
functionality from OpenCL 3.0.
341+
342+
- IR generation for non-trivial global destructors is incomplete (See:
338343
`PR48047 <https://llvm.org/PR48047>`_).
339344

345+
- Support of `destrutors with non-default address spaces
346+
<https://www.khronos.org/opencl/assets/CXX_for_OpenCL.html#_construction_initialization_and_destruction>`_
347+
is incomplete (See: `D109609 <https://reviews.llvm.org/D109609>`_).
348+
340349
.. _opencl_300:
341350

342351
OpenCL C 3.0 Usage
@@ -408,8 +417,8 @@ Experimental features
408417
Clang provides the following new WIP features for the developers to experiment
409418
and provide early feedback or contribute with further improvements.
410419
Feel free to contact us on `cfe-dev
411-
<https://lists.llvm.org/mailman/listinfo/cfe-dev>`_ or via `Bugzilla
412-
<https://bugs.llvm.org/>`__.
420+
<https://lists.llvm.org/mailman/listinfo/cfe-dev>`_ or file `a GitHub issue
421+
<https://github.com/llvm/llvm-project/issues/new>`_.
413422

414423
.. _opencl_experimental_cxxlibs:
415424

clang/docs/UsersManual.rst

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ specific section:
4141
variants depending on base language.
4242
- :ref:`C++ Language <cxx>`
4343
- :ref:`Objective C++ Language <objcxx>`
44-
- :ref:`OpenCL Kernel Language <opencl>`: OpenCL C v1.0, v1.1, v1.2, v2.0,
45-
plus C++ for OpenCL.
44+
- :ref:`OpenCL Kernel Language <opencl>`: OpenCL C 1.0, 1.1, 1.2, 2.0, 3.0,
45+
and C++ for OpenCL 1.0 and 2021.
4646

4747
In addition to these base languages and their dialects, Clang supports a
4848
broad variety of language extensions, which are documented in the
@@ -3321,20 +3321,25 @@ implementation of `OpenCL C++
33213321
<https://www.khronos.org/registry/OpenCL/specs/2.2/pdf/OpenCL_Cxx.pdf>`_ and
33223322
there is no plan to support it in clang in any new releases in the near future.
33233323

3324-
3325-
Clang currently supports C++ for OpenCL v1.0.
3324+
Clang currently supports C++ for OpenCL 1.0 and 2021.
33263325
For detailed information about this language refer to the C++ for OpenCL
33273326
Programming Language Documentation available
33283327
in `the latest build
33293328
<https://www.khronos.org/opencl/assets/CXX_for_OpenCL.html>`_
33303329
or in `the official release
3331-
<https://github.com/KhronosGroup/OpenCL-Docs/releases/tag/cxxforopencl-v1.0-r2>`_.
3330+
<https://github.com/KhronosGroup/OpenCL-Docs/releases/tag/cxxforopencl-docrev2021.12>`_.
33323331

33333332
To enable the C++ for OpenCL mode, pass one of following command line options when
3334-
compiling ``.cl`` file ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-cl-std=clc++1.0``,
3335-
``-cl-std=CLC++1.0``, ``-std=clc++``, ``-std=CLC++``, ``-std=clc++1.0`` or
3336-
``-std=CLC++1.0``.
3333+
compiling ``.clcpp`` file:
3334+
3335+
- C++ for OpenCL 1.0: ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-cl-std=clc++1.0``,
3336+
``-cl-std=CLC++1.0``, ``-std=clc++``, ``-std=CLC++``, ``-std=clc++1.0`` or
3337+
``-std=CLC++1.0``.
3338+
3339+
- C++ for OpenCL 2021: ``-cl-std=clc++2021``, ``-cl-std=CLC++2021``,
3340+
``-std=clc++2021``, ``-std=CLC++2021``.
33373341

3342+
Example of use:
33383343
.. code-block:: c++
33393344

33403345
template<class T> T add( T x, T y )
@@ -3351,15 +3356,27 @@ compiling ``.cl`` file ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-cl-std=clc++1.0`
33513356

33523357
.. code-block:: console
33533358
3354-
clang -cl-std=clc++ test.cl
3359+
clang -cl-std=clc++1.0 test.clcpp
3360+
33553361
3356-
Alternatively, files with ``.clcpp`` extension are compiled with the C++ for OpenCL
3357-
mode.
3362+
By default, files with ``.clcpp`` extension are compiled with the C++ for
3363+
OpenCL 1.0 mode.
33583364

33593365
.. code-block:: console
33603366
33613367
clang test.clcpp
33623368
3369+
For backward compatibility files with ``.cl`` extensions can also be compiled
3370+
in C++ for OpenCL mode but the desirable language mode must be activated with
3371+
a flag.
3372+
3373+
.. code-block:: console
3374+
3375+
clang -cl-std=clc++ test.cl
3376+
3377+
Support of C++ for OpenCL 2021 is currently in experimental phase, refer to
3378+
:doc:`OpenCLSupport` for more details.
3379+
33633380
C++ for OpenCL kernel sources can also be compiled online in drivers supporting
33643381
`cl_ext_cxx_for_opencl
33653382
<https://www.khronos.org/registry/OpenCL/extensions/ext/cl_ext_cxx_for_opencl.html>`_

0 commit comments

Comments
 (0)