Easy solution for fast image oriented computations, without losing control.
BoltView is a C++ template library for parallel image processing on GPU and CPU. It provides basic datastructures for image storage and manipulation and meta-algorithms for construction of higher level image processing algorithms.
Main goals are:
- Zero-overhead image processing abstractions
- Provide tools covering most frequently occuring patterns in image processing
- Absolute control over resources (no behind the curtain allocations)
- Provide reasonable default execution patterns for algorithm execution on GPU
- Hide CUDA API complexities, but still provide access to the low level facilities.
- Provide tools usable in both host and device code
The key datastructure concepts are image and image view whose responsiblities are resource lifetime management resp. image data access.
Instead of long introduction, you can check a following snipped where you can see the basic coding style present in code using the BoltView library. The main idea lies in using of two concepts: images and views. Images manage the resources - memory of different kinds (host, device, unified, texture). Views provide access to image data and in most cases only views are passed as input/output parameters to BoltView algorithms.
// Allocate 200x200 float image in RAM
bolt::HostImage<float, 2> host_image(200, 200);
// Allocate 200x200 float image on GPU
bolt::DeviceImage<float, 2> device_image(host_image.size());
// The algorithm will take an image view and execute lambda function
// for each pixel in the input image view.
// Since the image view is for the device image the algorithm will be executed on GPU.
// Two parameters passed to lamda are reference to current pixel value and 2D pixel index.
bolt::forEachPosition(
view(device_image),
/*lambda that can be executed on both host and device*/
[](auto &value, auto position) BOLT_DECL_HYBRID {
float distance = norm(position - Int2(100, 100));
if (distance == 0) {
value = 1.0f;
} else {
value = sin(distance) / distance;
}
}
// get data from GPU to RAM
bolt::copy(constView(device_image), view(host_image));There are several libraries that focus on similar tasks. BoltView does not try mimic any of these other tools as its goal is different and provides utilities not present in the other projects. We will list some of these projects here with short comparison and advantage/disadvantage listings.
STL like library for data processing on GPU. It is distributed together with CUDA SDK. BoltView uses provides tools for interoperabilty with the Thrust library and also uses it internally.
Pros:
- High level and efficient API
Cons:
- Covers only 1D datastructures
- Does not directly support unified memory
Pros:
- Easy to use - high level API
- Available also for other parallelization technologies (CUDA, OpenCL)
- Large set of algorithms ready to use
Cons:
- Hard to access the low level facilities
GIL served as a primary inspiration for the choice of the basic image and image view concepts.
Pros:
- Clean API
Cons:
- Focuses mainly on 2D images
- Supports algorithm execution only on the CPU
Here you can check an overview of basic examples provided with the BoltView library. Each tries to present a simple usage pattern for the concepts used.
For non-commercial use, the library is available under the AGLPL license. For commercial use, please contact us at boltview@eyen.se for licesing options.
The library is header only, so its usage in your project should be quite straightforward. You have several options:
- Download an install package from the release page - this will put the headers in the system
includedir and cmake config files into systemsharedir. - Download the sources or clone the repository and do following:
cd <boltview_root_dir> mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=<your_preffered_install_directory> make -j<choose number of processes> #this will compile the unit tests make install
BoltView has several dependencies:
- CUDA
- Boost
- CMake
- FFTW
- Threading Building Blocks (TBB) - optional
Minimal CMakeLists.txt for your project can look like this:
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(MyProject LANGUAGES CXX CUDA)
find_package(BoltView REQUIRED)
find_package(Boost 1.53.0 COMPONENTS system filesystem program_options REQUIRED)
add_executable(maypp main.cu)
target_compile_features(maypp INTERFACE cxx_std_14)
target_link_libraries(maypp Boost::program_options Boost::filesystem BoltView::bolt)
boltview@eyen.se