CMake configuration and wrapper library
This (large) MR implements a wrapper library for Bandicoot and adds a CMake build system based on Armadillo's. Some bullet points describing the changes:
-
All OpenCL and CUDA library calls are wrapped with
coot_wrapper()
. This works the same way asarma_wrapper()
in Armadillo; ifCOOT_USE_WRAPPER
is defined, thencoot_wrapper(func)
expands towrapper_func()
, which is just a function that callsfunc()
directly, found insrc/wrapper_*.cpp
. IfCOOT_USE_WRAPPER
is not defined, thencoot_wrapper(func)
just expands tofunc()
and the user will need to directly link against whatever library providesfunc()
. -
All OpenCL and CUDA functions we wrap are defined in
bandicoot_bits/opencl/def_*.hpp
andbandicoot_bits/cuda/def_*.hpp
, respectively. -
The CMake configuration, by default, will search for both backends, and set the default preferring CUDA. (The rationale being that if CUDA is available, it'll likely be faster than the OpenCL driver that nvidia provides.)
-
The CMake configuration has a handful of useful variables:
FIND_OPENCL=(ON/OFF)
FIND_CUDA=(ON/OFF)
DEFAULT_BACKEND=(CL_BACKEND/CUDA_BACKEND)
BUILD_TESTS=(ON/OFF)
-
Since MAGMA requires some BLAS and LAPACK functions, the CMake configuration from Armadillo has been adapted and the
ALLOW_FLEXIBLAS_LINUX
,ALLOW_OPENBLAS_MACOS
,ALLOW_BLAS_LAPACK_MACOS
, and other related configuration variables are included. -
If
BUILD_TESTS
is set toON
, thenbandicoot_test
will be created. This is just thetests/main
program that used to be created via Makefile.ctest
is integrated and can be used. -
The act of linking
bandicoot_test
is a test for the wrapper library itself, asbandicoot_test
specifically links only against the wrapper library. -
This CMake configuration is not yet battle-tested, and I suspect there will be some small changes here and there to handle unexpected situations. (I guess that's true about all code, ever, but in any case I specifically highlight it here to say I am not yet 100% confident this will work everywhere.)