OpenCL API, OpenCL C, Extensions, SPIR-V Environment Specs, Ref page, and C++ for OpenCL doc sources.
= OpenCL^(TM)^ Specification Build Instructions and Notes :toc2: :toclevels: 1
The most useful parts of this document are the <>, <>, and notes on installing <<depends, Software
[[intro]] == Introduction
This repository contains the source and tool chain used to generate the formal OpenCL API, OpenCL C, OpenCL Extensions, OpenCL SPIR-V Environment, OpenCL C++ Specifications, as well as the OpenCL 2.2 Reference Pages and documentation for the C++ for OpenCL kernel language.
This file describes the repository structure, tools, and build instructions needed.
[[source]] == Source Code
The OpenCL specifications are maintained by members of the Khronos Group's OpenCL Working Group, in the https://github.com/KhronosGroup/OpenCL-Docs[OpenCL-Docs Github repository]. The documents are all in https://asciidoctor.org/[Asciidoctor] format.
Contributions via pull requests on Github are welcome. Pull requests must be provided under the same <> as the specification source. You'll be prompted with a one-time "
click-through" Contributor's License Agreement (CLA) dialog as part of submitting your pull request or other contribution to GitHub.
We intend to maintain a linear history on the GitHub
[[repo]] == Repository Structure
|==== | File | Description |
README.adoc| This file |
Makefile| GNU Makefile used to build HTML and PDF spec targets |
katex/| KaTeX math renderer for HTML outputs |
OpenCL_API.txt| Main source file for the OpenCL API Specification |
api/| Individual sections of the API Specification |
OpenCL_C.txt| Main source file for the OpenCL C Specification |
c/| Individual sections of the C Specification |
OpenCL_Cxx.txt| Main source file for the OpenCL C++ Specification |
cxx/| Individual sections of the C++ Specification |
OpenCL_Env.txt| Main source file for the OpenCL SPIR-V Environment Specification |
env/| Individual sections of the Environment Specification |
OpenCL_Ext.txt| Main source file for the OpenCL Extensions Specification |
ext/| Individual sections of the Extensions Specification |
CXX_for_OpenCL.txt| Main source file for the C++ for OpenCL Documentation |
cxx4opencl/| Individual sections of the C++ for OpenCL Documentation |
images/| Shared images, used by all specs |
man/| Static reference page sources |====
[[building]] == Building The Specifications and Reference Pages
If you have installed all <>, you should be able to build both HTML and PDF outputs for all specifications by:
Other Makefile targets are available for building the different outputs for each Specification:
|==== | Target | Builds | html | HTML outputs for all specifications | pdf | PDF outputs for all specifications | | | api | HTML and PDF outputs for API Specification | apihtml | HTML outputs for API Specification | apipdf | PDF outputs for API Specification | | | c | HTML and PDF outputs for C Specification | chtml | HTML outputs for C Specification | cpdf | PDF outputs for C Specification | | | cxx | HTML and PDF outputs for C++ Specification | cxxhtml | HTML outputs for C++ Specification | cxxpdf | PDF outputs for C++ Specification | | | env | HTML and PDF outputs for SPIR-V Environment Specification | envhtml | HTML outputs for Environment Specification | envpdf | PDF outputs for Environment Specification | | | ext | HTML and PDF outputs for Extensions Specification | exthtml | HTML outputs for Extensions Specification | extpdf | PDF outputs for Extensions Specification | | | cxx4opencl | HTML and PDF outputs for C++ for OpenCL Documentation | cxx4openclhtml | HTML outputs for C++ for OpenCL Documentation | cxx4openclpdf | PDF outputs for C++ for OpenCL Documentation | | | manhtmlpages | HTML outputs for Reference Pages |====
The specification targets are generated in
out/html/for HTML targets, and
out/pdf/for PDF targets. The reference page target is generated in
out/man/html/. If a different output directory is desired, set the Makefile variable OUTDIR on the command line. For example,
These targets generate a variety of output documents in the directory specified by the Makefile variable
Once you have the basic build working, an appropriate parallelization option to make, such as
may significantly speed up building multiple specs. The asciidoctor HTML build is very fast, even for the whole Specification, but PDF builds may take several minutes.
[[refpage-install]] == Reference Page Installation
Most of the reference pages are extracted from the OpenCL API and OpenCL C Specifications, although some are static. While anyone can generate reference page sets for themselves, Khronos publishes them via the
masterbranch of the https://www.khronos.org/registry/OpenCL/sdk/2.2/docs/man/[OpenCL Registry].
When the OpenCL Specification Editor is updating the published reference pages, it is easiest to have local repository clones of this repository (OpenCL-Docs) as well as OpenCL-Registry. Update the pages in the local registry clone via
This creates the HTML output pages under
sdk/2.2/docs/man/html, and copies the KaTeX package to
sdk/2.2/docs/katex. To publish, commit those changes to the registry repository and push it to github.
[[styles]] == Our stylesheets
We use a modified version of the Asciidoctor 'colony' theme. This theme is maintained internally to Khronos and the resulting CSS is under
[[equations]] == Imbedding Equations
Where possible, equations should be written using straight asciidoc markup using the eq role. This covers many common equations and is faster than the alternatives.
For more complex equations, such as multi-case statements, matrices, and complex fractions, equations should be written using the latexmath: inline and block macros. The contents of the latexmath: blocks should be LaTeX math notation. LaTeX math markup delimiters are now inserted by the asciidoctor toolchain.
LaTeX math is passed through unmodified to all HTML output forms, which is subsequently rendered with the KaTeX engine when the html is loaded. A local copy of the KaTeX release is kept in
katex/and copied to the HTML output directory during spec generation. Math is processed into SVGs via
asciidoctor-mathematicalfor PDF output.
The following caveats apply:
&can currently be used only in +++[latexmath]+++ block macros, not in +++latexmath:+++ inline macros. Instead use
&is an alignment construct for multiline equations, and should only appear in block macros anyway.
See the "
Vulkan Documentation and Extensions" document in the https://www.khronos.org/registry/vulkan/specs/1.0/styleguide.html[Khronos Vulkan Registry] for more details of supported LaTeX math constructs in our toolchain.
[[anchors]] == Asciidoc Anchors And Xrefs
In asciidoctor, sections can have anchors (labels) applied with the following syntax:
In general the anchor should immediately precede the chapter or section title and should use the form '+++[[chapter-section-label]]+++'.
Cross-references to those anchors can then be generated with, for example,
See the <> section for discussion of the SPIR-V intermediate
You can also add anchors on arbitrary paragraphs, using a similar naming scheme.
[[depends]] == Software Dependencies
This section describes the software components used by the OpenCL spec toolchain.
Before building the OpenCL specs, you must install the following tools:
git symbolic-ref --short HEAD**
git log -1 --format="%H"
The following Ruby Gems and platform package dependencies must also be installed. This process is described in more detail for individual platforms and environment managers below. Please read the remainder of this document (other than platform-specific parts you don't use) completely before trying to install.
katex/, and need not be installed from github.
coderaygems are needed if you don't intend to build PDF versions of the spec and supporting documents.
While it's easier to install just the toolchain components for HTML builds, people submitting MRs with substantial changes to the Specifications are responsible for verifying that their branches build both
Platform-specific toolchain instructions follow:
[[depends-windows]] === Windows (General)
Most of the dependencies on Linux packages are light enough that it's possible to build the spec natively in Windows, but it means bypassing the makefile and calling functions directly. This might be solved in future. For now, there are three options for Windows users: Ubuntu / Windows 10, MinGW, or Cygwin.
[[depends-ubuntu]] ==== Ubuntu / Windows 10
When using the "
Ubuntu Subsystem" for Windows 10, most dependencies can be installed via apt-get:
sudo apt-get -qq -y install build-essential python3 git cmake bison flex \ libffi-dev libgmp-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev \
The default ruby packages on Ubuntu are fairly out of date. Ubuntu only provides
ruby2.0- the latter is multiple revisions behind the current stable branch, and would require wrangling to get the makefile working with it.
Luckily, there are better options; either https://rvm.io[rvm] or https://github.com/rbenv/rbenv[rbenv] is recommended to install a more recent version.
sudo apt-get remove *packagename*) all existing Ruby and asciidoctor infrastructure on your machine before trying to use rvm or rbenv for the first time.
dpkg -l | egrep 'asciidoctor|ruby|rbenv|rvm'will give you a list of candidate package names to remove. ** If you already have a favorite Ruby package manager, ignore this advice, and just install the required OS packages and gems.
rbenvare mutually incompatible. They both rely on inserting shims and
$PATHmodifications in your bash shell. If you already have one of these installed and are familiar with it, it's best to stay with that one. One of the editors, who is new to Ruby, found
rbenvfar more comprehensible than
rvm. The other editor likes
rvmbetter. ** Neither
rbenvwork, out of the box, when invoked from non-Bash shells like tcsh. This can be hacked up by setting the right environment variables and PATH additions based on a bash environment.
.gitattributesat the top of the vulkan tree in the 1.0 branch forces such scripts to be checked out with the proper line endings on non-Linux platforms. If you add new scripts whose names don't end in
.sh, they should be included in .gitattributes as well. ====
[[depends-ubuntu-rbenv]] ===== Ubuntu/Windows 10 Using Rbenv
Rbenv is a lighter-weight Ruby environment manager with less functionality than rvm. Its primary task is to manage different Ruby versions, while rvm has additional functionality such as managing "
gemsets" that is irrelevant to our needs.
A complete installation script for the toolchain on Ubuntu for Windows, developed on an essentially out-of-the-box environment, follows. If you try this, don't try to execute the entire thing at once. Do each step separately in case of errors we didn't encounter.
ruby_buildand by toolchain components.
sudo apt-get install autoconf bison build-essential libssl-dev \ libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev \ libffi-dev libgdbm3 libgdbm-dev cmake libgmp-dev libxml2 \ libxml2-dev flex pkg-config libglib2.0-dev \ libcairo-dev libpango1.0-dev libgdk-pixbuf2.0-dev \ libpangocairo-1.0
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bashrc
echo 'eval "$(rbenv init -)"' >> .bashrc
-loption, since the modifications
type rbenvshould print 'rbenv is a function' followed by code.
ruby_buildplugin from https://github.com/rbenv/ruby-build
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.3.3
echo "2.3.3" > ~/.rbenv/version
gem install asciidoctor -v 1.5.8 gem install coderay -v 1.1.1 gem install ttfunk -v 1.5.1 gem install asciidoctor-pdf -v 1.5.0
[[depends-ubuntu-rvm]] ===== Ubuntu/Windows 10 Using RVM
Here are (sparser) instructions for using rvm to setup version 2.3.x:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \curl -sSL https://get.rvm.io | bash -s stable --ruby source ~/.rvm/scripts/rvm rvm install ruby-2.3
NOTE: Windows 10 Bash will need to be launched with the "-l" option appended, so that it runs a login shell; otherwise RVM won't function correctly on future launches.
[[depends-ubuntu-sys]] ===== Ubuntu 16.04 using system Ruby
The Ubuntu 16.04.1 default Ruby install (version 2.3.1) seems to be up-to-date enough to run all the required gems, but also needs the
ruby-devpackage installed through the package manager.
In addition, the library
/var/lib/gems/2.3.0/gems/mathematical-1.6.7/ext/mathematical/lib/liblasem.sohas to be copied or linked into a directory where the loader can find it. This requirement appears to be due to a problem with the asciidoctor-mathematical build process.
[[depends-mingw]] ==== MinGW
MinGW can be obtained here: http://www.mingw.org/
Once the installer has run its initial setup, following the http://www.mingw.org/wiki/Getting_Started[instructions on the website], you should install the
msys-basepackage allows you to use a bash terminal from windows with whatever is normally in your path on Windows, as well as the unix tools installed by MinGW.
In the native Windows environment, you should also install the following native packages:
Once this is setup, and the necessary <> are installed, launch the
msysbash shell, and navigate to the spec Makefile. From there, you'll need to set
PYTHON=to the location of your python executable for version 3.x before your make command - but otherwise everything other than pdf builds should just work.
NOTE: Building the PDF spec via this path has not yet been tested but may be possible - liblasem is the main issue and it looks like there is now a mingw32 build of it available.
[[depends-cygwin]] ==== Cygwin
When installing Cygwin, you should install the following packages via
// "curl" is only used to download fonts, can be done in another way autoconf bison cmake curl flex gcc-core gcc-g++ ghostscript git libbz2-devel libcairo-devel libcairo2 libffi-devel libgdkpixbuf2.0-devel libgmp-devel libiconv libiconv-devel liblasem0.4-devel libpango1.0-devel libpango1.00 libxml2 libxml2-devel make python3 ruby
NOTE: Native versions of some of these packages are usable, but care should be taken for incompatibilities with various parts of cygwin - e.g. paths. Ruby in particular is unable to resolve Windows paths correctly via the native version. Python and Git for Windows can be used, though for Python you'll need to set the path to it via the PYTHON environment variable, before calling make.
When it comes to installing the mathematical ruby gem, there are two things that will require tweaking to get it working. Firstly, instead of:
You should use
The latter causes it to use the lasem package already installed, rather than trying to build a fresh one.
The mathematical gem also looks for "liblasem" rather than "liblasem0.4" as installed by the lasem0.4-devel package, so it is necessary to add a symlink to your /lib directory using:
<> are not installed to a location that is in your path normally. Gems are installed to
~/bin/- you should add this to your path before calling make:
Finally, you'll need to manually install fonts for lasem via the following commands:
mkdir /usr/share/fonts/truetype cd /usr/share/fonts/truetype curl -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmex10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmmi10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmr10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmsy10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/esint10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/eufm10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msam10.ttf \
[[depends-osx]] === Mac OS X
Mac OS X should work in the same way as for ubuntu by using the Homebrew package manager, with the exception that you can simply install the ruby package via
brewrather than using a ruby-specific version manager.
You'll likely also need to install additional fonts for the PDF build via mathematical, which you can do with:
cd ~/Library/Fonts curl -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmex10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmmi10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmr10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmsy10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/esint10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/eufm10.ttf \ -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msam10.ttf \
Then install the required <>.
[[depends-linux]] === Linux (Debian, Ubuntu, etc.)
The instructions for the <> installation are generally applicable to native Linux environments using Debian packages, such as Debian and Ubuntu, although the exact list of packages to install may differ.
Other distributions using different package managers, such as RPM (Fedora) and Yum (SuSE) will have different requirements.
rvmis neccessary, since the system Ruby packages are often well out of date.
Once the environment manager, Ruby, and
ruby_buildhave been installed, install the required <>.
[[depends-gems]] === Ruby Gems
The following ruby gems can be installed directly via the
gem installcommand, once the platform is set up:
gem install asciidoctor -v 1.5.8 gem install coderay -v 1.1.1 gem install ttfunk -v 1.5.1
gem install asciidoctor-pdf -v 1.5.0
[[license]] == License
The specification Asciidoctor source files are licensed under the Creative Commons Attribution 4.0 International License; see https://creativecommons.org/licenses/by/4.0/
Additional source files used to build the specification are under a mixture of Apache 2.0 and MIT licenses. See the LICENSE file for details.
The official Specification HTML and PDF output documents are posted in the https://www.khronos.org/registry/OpenCL[OpenCL Registry]. These Specifications are placed under the proprietary Khronos specification copyright and license.
OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.
[[history]] == Revision History