Skip to content

[Rcpp-devel] On Developing Header Packages

4 messages · Charles Determan, JJ Allaire, Romain Francois +1 more

#
This is probably the best place I can think of to ask this question if
perhaps not completely on topic.  Some quick context:

I am exploring GPGPU computing and with my 'open-source' mindset I quickly
gravitated to using OpenCL.  Thankfully, many wonderful programmers have
already begun creating libraries to make this language better and faster.
One such library is the clBLAS library which essentially implements BLAS
routines for OpenCL enabled devices. Naturally, I would like to use this
library but I don't like the idea of telling users to install a dependency
outside of R and would rather have them install another package.
Therefore, I have it in my head to create a header package for the clBLAS
library to be used by anyone exploring OpenCL programming within R.

This leads me to my two general questions that I hope others can comment.

1.  What are developers thoughts regarding the 'packaging' of various C++
header libraries?  I know this has be very successfully done with the 'BH'
package but is this considered an exception or an example?

2. If it is encouraged to create such header packages are there any
guidelines or standards that should be followed?  Is there an expected
structure?  I can look at the 'BH' package and go from there but it would
be nice if the R(cpp) community had some collective opinion about this.

Regards,
Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150407/94edfa2b/attachment.html>
#
I think that header-only packages (where possible) are definitely
preferable within the R package ecosystem because it allows you to
sidestep a lot of build configuration and runtime linking complexity.

The rub is that some libraries simply can't be made header-only,
especially if they make use of static data. I was able to convert the
TinyThread library to header-only by simply prefacing all
function/method definitions with the inline keyword. However that was
a pretty small library so I'm not sure you'd have the same easy time
of it with a larger library like clBLAS.
On Tue, Apr 7, 2015 at 2:37 PM, Charles Determan <cdetermanjr at gmail.com> wrote:
#
I would definitely second that. This eliminates a whole class of hard to deal with issues. 

Even Rcpp IMO should really just be header only. 

Romain

Envoy? de mon iPhone
#
On 7 April 2015 at 14:51, JJ Allaire wrote:
| I think that header-only packages (where possible) are definitely
| preferable within the R package ecosystem because it allows you to
| sidestep a lot of build configuration and runtime linking complexity.
| 
| The rub is that some libraries simply can't be made header-only,
| especially if they make use of static data. I was able to convert the
| TinyThread library to header-only by simply prefacing all
| function/method definitions with the inline keyword. However that was
| a pretty small library so I'm not sure you'd have the same easy time
| of it with a larger library like clBLAS.

That may be the case:

edd at max:~$ apt-cache search lib|grep OpenCL
ocl-icd-dbg - Debug symbols for the generic OpenCL ICD Loader
ocl-icd-libopencl1 - Generic OpenCL ICD Loader
ocl-icd-opencl-dev - OpenCL development files
nvidia-libopencl1-304 - NVIDIA OpenCL Driver and ICD Loader library
nvidia-libopencl1-304-updates - NVIDIA OpenCL Driver and ICD Loader library
nvidia-libopencl1-331 - NVIDIA OpenCL Driver and ICD Loader library
nvidia-libopencl1-331-updates - NVIDIA OpenCL Driver and ICD Loader library
nvidia-opencl-dev - NVIDIA OpenCL development files
python-pyopencl - Python module to access OpenCL parallel computation API
python-pyopencl-dbg - Python module to access OpenCL API (debug extensions)
python-pyopencl-doc - module to access OpenCL parallel computation API (documentation)
python3-pyopencl - Python 3 module to access OpenCL parallel computation API
python3-pyopencl-dbg - Python 3 module to access OpenCL API (debug extensions)
beignet - Intel OpenCL library
beignet-dev - Intel OpenCL library
libclc-dev - OpenCL C language implementation - development files
libclc-ptx - OpenCL C language implementation - ptx support
libclc-r600 - OpenCL C language implementation - r600 support
libopencv-ocl2.4 - computer vision OpenCL support library
libopentk-cil-dev - Open Toolkit wrapper for OpenGL, OpenAL and OpenCL - Dev files
libopentk1.0-cil - Open Toolkit wrapper for OpenGL, OpenAL and OpenCL - Assemblies
libviennacl-dev - Scientific computing library written in C++ based on OpenCL
monodoc-opentk-manual - Open Toolkit wrapper for OpenGL, OpenAL and OpenCL - Docs
edd at max:~$ 

This shows that eg the Python OpenCL bindings come with a full debug library,
something Debian frequently does for normal shared libraries (ie we create
r-base-core-dbg for debug support R, but eg I never bothered to do the same
for r-mathlib).

So while no exhaustive "proof" of any kind, based on this JJ's talk of "a
rub" may be on to something.

Dirk