OpenCL - Interface allowing R to use OpenCL
Package R docs
NEWS for the OpenCL package
o Adjust header declaration for ocl_get_device_info_entry.
o Windows: for single-arch R fall back to $OCL/lib/OpenCL.lib
o Clean up superfluous class comparisons.
o Change the name of the package dynamic object to R_OpenCL
to avoid name conflict on Windows. (#6, #20, thanks to
o Windows: accept OCLLIB instead of OCL64LIB for single-arch R.
Update INSTALL documentation to be more specific about the
defaults and installation (#17).
o added (non-exported) .oclDeviceInfoEntry() for diagnostics
which allows the retrieval of any device information entries.
o added support for dynamic __local memory buffers as arguments
to kernel via the clLocal() function -- see documentation for
o Update oclRun() example to explicitly cast in order to avoid
ambiguity errors in built-ins on macOS.
o Use correct error()/warning() for build logs in compiled
programs. Output from the OpenCL compilation is now included
in the error/warning. (#13)
o Use more verbose, textual representation of OpenCL errors.
o Added full support for subsetting and subassignment for clBuffers.
Note that only contiguous operations (e.g. x[5:8] = 0) can be performed
natively, any other index will result in the entire buffer being
emerged and the operation done in R (CPU).
o Added mode= parameter to as.clBuffer() to ensure specific type
of the buffer. This is ofen required when passing buffers to
kernel since the kernel code must match teh buffer type.
o Improved oclRun() example to explicitly use numeric buffer for
reasons explained above. Previously, passing integer input
would result in integer buffer which does not match the kernel
o added buffer memory tracking and automatic garbage collection triggers.
See oclMemLimits() help for details. (#8)
o added native symbol registration
o fix issue with R API in R-devel
o OpenCL context and command queue can be persisted, allowing to keep data
between calls. The context also remembers whether to default to single-
or double-precision for numeric vectors.
o Data can stay on the OpenCL device (GPU) between kernel calls. This is
extremely valuable when working with discrete GPUs connected over a
relatively slow PCIe connection.
o A single-precision data type is no longer required. The conversion takes
place when transferring the data to the OpenCL device. On the R side,
data remains in numeric vectors.
o Kernels are executed asynchronously and possibly out-of-order, if the
OpenCL implementation allows it. Synchronization need not to be done
manually and happens without the user knowing: OpenCL events
corresponding to a kernel execution are attached to the output buffer.
Following kernel executions having the buffer as input then wait for the
event, hence for the preceding kernel execution to finish. Likewise,
reads from buffers wait on the attached event as well.
o OpenCL device information is amended by maximum frequency. Also the list
of extensions is broken down to make it easier searchable.
o By default, we choose GPU devices. CPU devices usually don't make a lot
of sense. Also, if there are multiple GPU devices available - think of
a notebook with integrated and discrete GPU - we try to choose the
o There are now several tests covering most of the functionality.
o Windows configuration has been simplified. On Windows, you
have to set the OCL environemnt variable to the root of the
OpenCL SDK. By default the CPPFLAGS and LIBS will be
constrcuted from that location depending on whether 32-bit or
64-bit binaries are produced by appending lib/x64/OpenCL.lib
or lib/x86/OpenCL.lib respecitvely. Includes are assumed to be
in the includes directory. All of the above can be overridden
by setting OCLINC to the necessary pre-processor flags and
OCL32LIB or OCL64LIB for 32-bit and 64-bit linker flags.
(Note that OCL must still be set even if you override all
o devices with very long extensions strings could cause error
on retrieval. Fixed with larger static buffer.
(Thanks to Valerio Aimale again)
o Improve error reporting by always including the OpenCL
o fix a bug causing device enumeration to use the default
device for device count regradless of the specified type.
This affects only systems with more than one type of device.
(Thanks to Valerio Aimale for reporting)
o added dim argument to oclRun() which allows multidimensional
indexing (up to 3d) in the kernel. The dimensions can be
obtained in the kernel via get_global_size() and the index
values with get_global_id(). Note that using index vectors
instead of multidimensional indexing may perform better
depending on the device. The default is to use single
dimension (dim=size) which is the same as previous versions of
o add precision="best" in oclSimpleKernel which switches
automatically to double-precision if supported by the device
o kernels objects are now less cryptic - they implement
print(), names() and $ methods for access to their attributes.
o add the support for asynchronous calls, i.e., execution
parallel to the CPU or multiple parallel GPU operations.
This is done by using x <- oclRun(..., wait=FALSE) to
dispatch the kernel and then oclResult(x) to collect the
o minor cleanup
o improve memory management and clean up on error in oclRun()
o use CL_MEM_USE_HOST_PTR instead of clEnqueueWriteBuffer() for
better performance on large input vectors
o add support for native single precision representation
(see ?clFloat and native.result argument in oclRun())
o added INSTALL file with links to common OpenCL implementations
o first public release
includes support for single and double precision computations
as well as simple kernels (one output vector, arbitrary input)