CuInterval is a CUDA interval arithmetic library. It includes all fundamental and set-based interval operations of the IEEE Standard for Interval Arithmetic. Other flavors, including decorations are not supported.
The following operations are implemented as CUDA kernels. All operations are correctly-rounded, given the limitations of the precision of the underlying CUDA operation. The tightest interval is always a subset of the computed interval. The lower and upper bounds of the basic operations are at most 3 ulps away from the lower and upper bounds of the tightest interval, respectively. The error for a particular operation is given below.
Basic Operations
| Operation | Function Description | Error [ulps] |
|---|---|---|
| pos | 0 | |
| neg | 0 | |
| add | 0 | |
| sub | 0 | |
| mul | 0 | |
| div | 0 | |
| recip | 0 | |
| sqr | 0 | |
| sqrt | 0 | |
| fma | 0 |
Power functions
| Operation | Function Description | Error [ulps] |
|---|---|---|
| pown | 1 | |
| pow | 1 | |
| rootn | 2 | |
| cbrt | 1 | |
| exp | 3 | |
| exp2 | 3 | |
| exp10 | 3 | |
| expm1 | 3 | |
| log | 3 | |
| log2 | 3 | |
| log10 | 3 | |
| log1p | 3 |
Trigonometric functions
| Operation | Function Description | Error [ulps] |
|---|---|---|
| sin | 2 | |
| cos | 2 | |
| tan | 3 | |
| asin | 3 | |
| acos | 3 | |
| atan | 3 | |
| atan2 | 3 | |
| cot | 2 | |
| sinpi | 3 | |
| cospi | 3 |
Hyperbolic functions
| Operation | Function Description | Error [ulps] |
|---|---|---|
| sinh | 3 | |
| cosh | 2 | |
| tanh | 2 | |
| asinh | 3 | |
| acosh | 3 | |
| atanh | 3 | |
| coth | 3 |
Special functions
| Operation | Function Description | Error [ulps] |
|---|---|---|
| erf | 2 | |
| erfc | 5 |
Integer functions
| Operation | Function Description | Error [ulps] |
|---|---|---|
| sign | 0 | |
| ceil | 0 | |
| floor | 0 | |
| trunc | 0 | |
| roundTiesToEven | 0 | |
| roundTiesToAway | 0 |
Absmax functions
| Operation | Function Description | Error [ulps] |
|---|---|---|
| abs | 0 | |
| min | 0 | |
| max | 0 |
Numeric functions
| Operation | Function Description | Error [ulps] |
|---|---|---|
| inf | 0 | |
| sup | 0 | |
| mid | 0 | |
| wid | 0 | |
| rad | 0 | |
| mag | 0 | |
| mig | 0 |
Boolean functions
| Operation | Function Description | Error [ulps] |
|---|---|---|
| equal | 0 | |
| subset | 0 | |
| interior | 0 | |
| disjoint | 0 | |
| isEmpty | 0 | |
| isEntire | 0 | |
| less | 0 | |
| strictLess | 0 | |
| precedes | 0 | |
| strictPrecedes | 0 | |
| isMember | 0 | |
| isSingleton | 0 | |
| isCommonInterval | 0 |
Set operations
| Operation | Function Description | Error [ulps] |
|---|---|---|
| intersection | 0 | |
| convexHull | 0 |
Cancellative add and subtract
| Operation | Function Description | Error [ulps] |
|---|---|---|
| cancelMinus | 0 | |
| cancelPlus | 0 |
Please make sure that you have installed everything mentioned in the section Build Requirements.
Every release creates a single-header version. The latest one can directly be downloaded using, e.g.:
wget https://github.com/neilkichler/cuinterval/releases/download/v0.2.1/cuinterval.cuhYou can grab the latest header-only version from the releases page.
git clone https://github.com/neilkichler/cuinterval.git
cd cuinterval
cmake --preset release
cmake --build build
cmake --install buildCPMAddPackage("gh:neilkichler/cuinterval@0.2.1")include(FetchContent)
FetchContent_Declare(
cuinterval
GIT_REPOSITORY https://github.com/neilkichler/cuinterval.git
GIT_TAG v0.2.1
)
FetchContent_MakeAvailable(cuinterval)In either case, you can link to the library using:
target_link_libraries(${PROJECT_NAME} PUBLIC cuinterval)Important
When using CUDA in a CMake project, make sure that it configures the CUDA_ARCHITECTURES property using
set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES native)where native could be replaced by specific versions, see the CMake docs for more information.
Also, currently nvcc requires relaxed constexpr support which can be enabled using
target_compile_options(${PROJECT_NAME} PUBLIC "$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:--expt-relaxed-constexpr>")Have a look at the examples folder.
The documentation is available here.
We use C++20, CMake 3.25.2+, Ninja (optional), and a recent C++ (GCC 13+, Clang 17+) and CUDA (12.5.1+) compiler.
Other configurations might work but are not tested.
apt install cmake gcc ninja-buildmodule load CMake CUDA GCC Ninjacmake --workflow --preset devcmake --preset debug
cmake --build --preset debug
ctest --preset debugcmake -S . -B build -GNinja
cmake --build build
./build/tests/tests