OpenVDB 13.0.0

Loading...
Searching...
No Matches
nanovdb::util Namespace Reference

## Namespaces
namespace | morphology
namespace | impl

## Classes
class | Split
class | Range
class | Range< 1, T >
class | Range< 2, T >
class | Range< 3, T >
class | Timer
struct | is_same
| C++11 implementation of std::is_same. More...
struct | is_same< T0, T1 >
struct | is_same< T, T >
struct | is_floating_point
| C++11 implementation of std::is_floating_point. More...
struct | enable_if
| C++11 implementation of std::enable_if. More...
struct | enable_if< true, T >
struct | disable_if
struct | disable_if< true, T >
struct | is_const
struct | is_const< const T >
struct | is_pointer
| Trait used to identify template parameter that are pointers. More...
struct | is_pointer< T * >
| Template specialization of pointers. More...
struct | conditional
| C++11 implementation of std::conditional. More...
struct | conditional< false, TrueT, FalseT >
| Template specialization of conditional. More...
struct | remove_const
| Trait use to const from type. Default implementation is just a pass-through. More...
struct | remove_const< const T >
| Template specialization of trait class use to remove const qualifier type from a type. More...
struct | remove_reference
| Trait use to remove reference, i.e. "&", qualifier from a type. Default implementation is just a pass-through. More...
struct | remove_reference< T & >
| Template specialization of trait class use to remove reference, i.e. "&", qualifier from a type. More...
struct | remove_pointer
| Trait use to remove pointer, i.e. "*", qualifier from a type. Default implementation is just a pass-through. More...
struct | remove_pointer< T * >
| Template specialization of trait class use to to remove pointer, i.e. "*", qualifier from a type. More...
struct | match_const
| Trait used to transfer the const-ness of a reference type to another type. More...
struct | match_const< T, const ReferenceT >
| Template specialization used to transfer the const-ness of a reference type to another type. More...
struct | is_specialization
| Metafunction used to determine if the first template parameter is a specialization of the class template given in the second template parameter. More...
struct | is_specialization< TemplateType< Args... >, TemplateType >

## Typedefs
using | Range1D = Range<1, size_t>
using | Range2D = Range<2, size_t>
using | Range3D = Range<3, size_t>
template<bool Test, typename T = void>
using | enable_if_t = typename enable_if<Test, T>::type
template<bool Test, typename T = void>
using | disable_if_t = typename disable_if<Test, T>::type
template<bool Test, class TrueT, class FalseT>
using | conditional_t = typename conditional<Test, TrueT, FalseT>::type
template<typename T>
using | remove_const_t = typename remove_const<T>::type
template<typename T>
using | remove_reference_t = typename remove_const<T>::type
template<typename T>
using | remove_pointer_t = typename remove_pointer<T>::type
template<typename T, typename ReferenceT>
using | match_const_t = typename match_const<T, ReferenceT>::type

## Functions
template<typename RangeT, typename FuncT>
void | forEach (RangeT range, const FuncT &func)
| simple wrapper for tbb::parallel_for with a naive std fallback
template<typename FuncT>
void | forEach (size_t begin, size_t end, size_t grainSize, const FuncT &func)
| Simple wrapper for the function defined above.
template<template< typename... > class ContainerT, typename... T, typename FuncT>
void | forEach (const ContainerT< T... > &c, const FuncT &func)
| Simple wrapper for the function defined above, which works with std::containers.
template<template< typename... > class ContainerT, typename... T, typename FuncT>
void | forEach (const ContainerT< T... > &c, size_t grainSize, const FuncT &func)
| Simple wrapper for the function defined above, which works with std::containers.
template<typename Func, typename... Rest>
int | invoke (const Func &taskFunc1, Rest... taskFuncN)
template<typename T, typename OpT = std::plus<T>>
T | prefixSum (std::vector< T > &vec, bool threaded=true, OpT op=OpT())
| Computes inclusive prefix sum of a vector.
template<typename T, typename Op>
void | inclusiveScan (T *array, size_t size, const T &identity, bool threaded, Op op)
| An inclusive scan includes in[i] when computing out[i].
template<typename RangeT, typename T, typename FuncT, typename JoinT>
T | reduce (RangeT range, const T &identity, const FuncT &func, const JoinT &join)
template<typename T, typename FuncT, typename JoinT>
T | reduce (size_t begin, size_t end, size_t grainSize, const T &identity, const FuncT &func, const JoinT &join)
| Simple wrapper to the function defined above.
template<template< typename... > class ContainerT, typename... ArgT, typename T, typename FuncT, typename JoinT>
T | reduce (const ContainerT< ArgT... > &c, const T &identity, const FuncT &func, const JoinT &join)
| Simple wrapper that works with std::containers.
template<template< typename... > class ContainerT, typename... ArgT, typename T, typename FuncT, typename JoinT>
T | reduce (const ContainerT< ArgT... > &c, size_t grainSize, const T &identity, const FuncT &func, const JoinT &join)
| Simple wrapper that works with std::containers.
template<typename T>
T && | declval () noexcept
| Minimal implementation of std::declval, which converts any type `T` to.
bool | empty (const char *str)
| tests if a c-string `str` is empty, that is its first value is '\0'
size_t | strlen (const char *str)
| length of a c-sting, excluding '\0'.
char * | strcpy (char *dst, const char *src)
| Copy characters from `src` to `dst`.
char * | strncpy (char *dst, const char *src, size_t max)
| Copies the first num characters of `src` to `dst`. If the end of the source C string (which is signaled by a null-character) is found before `max` characters have been copied, `dst` is padded with zeros until a total of `max` characters have been written to it.
char * | strcpy (char *dst, int num, int bas=10)
| converts a number to a string using a specific base
char * | strcat (char *dst, const char *src)
| Appends a copy of the character string pointed to by `src` to the end of the character string pointed to by `dst` on the device.
char * | strcat (char *dst, int num, int bas=10)
| concatenates a number after a string using a specific base
int | strcmp (const char *lhs, const char *rhs)
| Compares two null-terminated byte strings lexicographically.
bool | streq (const char *lhs, const char *rhs)
| Test if two null-terminated byte strings are the same.
template<typename T, typename... Types>
char * | sprint (char *dst, T var1, Types... var2)
| prints a variable number of string and/or numbers to a destination string
static void * | memzero (void *dst, size_t byteCount)
| Zero initialization of memory.
static int64_t | PtrDiff (const void *p, const void *q)
| Compute the distance, in bytes, between two pointers, dist = p - q.
template<typename DstT = void>
static DstT * | PtrAdd (void *p, int64_t offset)
| Adds a byte offset to a non-const pointer to produce another non-const pointer.
template<typename DstT = void>
static const DstT * | PtrAdd (const void *p, int64_t offset)
| Adds a byte offset to a const pointer to produce another const pointer.
uint32_t | findLowestOn (uint32_t v)
| Returns the index of the lowest, i.e. least significant, on bit in the specified 32 bit word.
uint32_t | findLowestOn (uint64_t v)
| Returns the index of the lowest, i.e. least significant, on bit in the specified 64 bit word.
uint32_t | findHighestOn (uint32_t v)
| Returns the index of the highest, i.e. most significant, on bit in the specified 32 bit word.
uint32_t | findHighestOn (uint64_t v)
| Returns the index of the highest, i.e. most significant, on bit in the specified 64 bit word.
uint32_t | countOn (uint64_t v)

## Variables
template<typename T0, typename T1, typename ... T>
static constexpr bool | is_same_v = is_same<T0, T1, T...>::value
template<typename T>
static constexpr bool | is_floating_point_v = is_floating_point<T>::value
template<typename T>
static constexpr bool | is_const_v = is_const<T>::value
template<typename T>
static constexpr bool | is_pointer_v = is_pointer<T>::value

## Typedef Documentation

## ◆ conditional_t

template<bool Test, class TrueT, class FalseT>

using conditional_t = typename conditional<Test, TrueT, FalseT>::type

## ◆ disable_if_t

template<bool Test, typename T = void>

using disable_if_t = typename disable_if<Test, T>::type

## ◆ enable_if_t

template<bool Test, typename T = void>

using enable_if_t = typename enable_if<Test, T>::type

## ◆ match_const_t

template<typename T, typename ReferenceT>

using match_const_t = typename match_const<T, ReferenceT>::type

## ◆ Range1D

using Range1D = Range<1, size_t>

## ◆ Range2D

using Range2D = Range<2, size_t>

## ◆ Range3D

using Range3D = Range<3, size_t>

## ◆ remove_const_t

template<typename T>

using remove_const_t = typename remove_const<T>::type

## ◆ remove_pointer_t

template<typename T>

using remove_pointer_t = typename remove_pointer<T>::type

## ◆ remove_reference_t

template<typename T>

using remove_reference_t = typename remove_const<T>::type

## Function Documentation

## ◆ countOn()

uint32_t countOn | ( | uint64_t | v | ) |
| inline

Returns
  Number of bits that are on in the specified 64-bit word

## ◆ declval()

template<typename T>

T && declval | ( |  | ) |
| noexcept

Minimal implementation of std::declval, which converts any type `T` to.

a reference type, making it possible to use member functions in the operand of the decltype specifier without the need to go through constructors.

Template Parameters

  T | Template type to be converted to T&&

Returns
  T&&

Warning
  Unlike std::declval, this version does not work when T = void! However, NVRTC does not like std::declval, so we provide our own implementation.

## ◆ empty()

bool empty | ( | const char * | str | ) |
| inline

tests if a c-string `str` is empty, that is its first value is '\0'

Parameters

  str | c-string to be tested for null termination

Returns
  true if str[0] = '\0'

## ◆ findHighestOn() [1/2]

uint32_t findHighestOn | ( | uint32_t | v | ) |
| inline

Returns the index of the highest, i.e. most significant, on bit in the specified 32 bit word.

Warning
  Assumes that at least one bit is set in the word, i.e. v != uint32_t(0)!

## ◆ findHighestOn() [2/2]

uint32_t findHighestOn | ( | uint64_t | v | ) |
| inline

Returns the index of the highest, i.e. most significant, on bit in the specified 64 bit word.

Warning
  Assumes that at least one bit is set in the word, i.e. v != uint32_t(0)!

## ◆ findLowestOn() [1/2]

uint32_t findLowestOn | ( | uint32_t | v | ) |
| inline

Returns the index of the lowest, i.e. least significant, on bit in the specified 32 bit word.

Warning
  Assumes that at least one bit is set in the word, i.e. v != uint32_t(0)!

## ◆ findLowestOn() [2/2]

uint32_t findLowestOn | ( | uint64_t | v | ) |
| inline

Returns the index of the lowest, i.e. least significant, on bit in the specified 64 bit word.

Warning
  Assumes that at least one bit is set in the word, i.e. v != uint32_t(0)!

## ◆ forEach() [1/4]

template<template< typename... > class ContainerT, typename... T, typename FuncT>

void forEach | ( | const ContainerT< T... > & | c,
|  | const FuncT & | func )
| inline

Simple wrapper for the function defined above, which works with std::containers.

## ◆ forEach() [2/4]

template<template< typename... > class ContainerT, typename... T, typename FuncT>

void forEach | ( | const ContainerT< T... > & | c,
|  | size_t | grainSize,
|  | const FuncT & | func )
| inline

Simple wrapper for the function defined above, which works with std::containers.

## ◆ forEach() [3/4]

template<typename RangeT, typename FuncT>

void forEach | ( | RangeT | range,
|  | const FuncT & | func )
| inline

simple wrapper for tbb::parallel_for with a naive std fallback

Parameters

  range | Range, CoordBBox, tbb::blocked_range, blocked_range2D, or blocked_range3D.
  func | functor with the signature [](const RangeT&){...},

std::vector<int> array(100);
auto func = [&array](auto &r){for (auto i=r.begin(); i!=r.end(); ++i) array[i]=i;};
forEach(array, func);
nanovdb::util::forEach
void forEach(RangeT range, const FuncT &func)
simple wrapper for tbb::parallel_for with a naive std fallback
Definition ForEach.h:42

## ◆ forEach() [4/4]

template<typename FuncT>

void forEach | ( | size_t | begin,
|  | size_t | end,
|  | size_t | grainSize,
|  | const FuncT & | func )
| inline

Simple wrapper for the function defined above.

## ◆ inclusiveScan()

template<typename T, typename Op>

void inclusiveScan | ( | T * | array,
|  | size_t | size,
|  | const T & | identity,
|  | bool | threaded,
|  | Op | op )

An inclusive scan includes in[i] when computing out[i].

Note
  Inclusive prefix operation: for (i=1; i<N; ++i) vec[i] = Op(vec[i],vec[i-1])

## ◆ invoke()

template<typename Func, typename... Rest>

int invoke | ( | const Func & | taskFunc1,
|  | Rest... | taskFuncN )

Returns
  1 for serial, 2 for tbb multi-threading, and 3 for std multi-threading

## ◆ memzero()

void * memzero | ( | void * | dst,
|  | size_t | byteCount )
| inline static

Zero initialization of memory.

Parameters

  dst | pointer to destination
  byteCount | number of bytes to be initialized to zero

Returns
  destination pointer `dst`

## ◆ prefixSum()

template<typename T, typename OpT = std::plus<T>>

T prefixSum | ( | std::vector< T > & | vec,
|  | bool | threaded = true,
|  | OpT | op = OpT() )

Computes inclusive prefix sum of a vector.

Template Parameters

  T | Type of the elements in the input/out vector
  OpT | Type of operation performed on each element (defaults to sum)

Parameters

  vec | input and output vector
  threaded | if true multi-threading is used

Note
  Inclusive prefix sum: for (i=1; i<N; ++i) vec[i] += vec[i-1]

Returns
  sum of all input elements, which is also the last element of the inclusive prefix sum

## ◆ PtrAdd() [1/2]

template<typename DstT = void>

const DstT * PtrAdd | ( | const void * | p,
|  | int64_t | offset )
| inline static

Adds a byte offset to a const pointer to produce another const pointer.

Template Parameters

  DstT | Type of the return pointer (defaults to void)

Parameters

  p | const input pointer, assumed to NOT be NULL
  offset | signed byte offset

Returns
  a const pointer defined as the offset of a const input pointer

## ◆ PtrAdd() [2/2]

template<typename DstT = void>

DstT * PtrAdd | ( | void * | p,
|  | int64_t | offset )
| inline static

Adds a byte offset to a non-const pointer to produce another non-const pointer.

Template Parameters

  DstT | Type of the return pointer (defaults to void)

Parameters

  p | non-const input pointer, assumed to NOT be NULL
  offset | signed byte offset

Returns
  a non-const pointer defined as the offset of an input pointer

## ◆ PtrDiff()

int64_t PtrDiff | ( | const void * | p,
|  | const void * | q )
| inline static

Compute the distance, in bytes, between two pointers, dist = p - q.

Parameters

  p | fist pointer, assumed to NOT be NULL
  q | second pointer, assumed to NOT be NULL

Returns
  signed distance between pointer, p - q, addresses in units of bytes

## ◆ reduce() [1/4]

template<template< typename... > class ContainerT, typename... ArgT, typename T, typename FuncT, typename JoinT>

T reduce | ( | const ContainerT< ArgT... > & | c,
|  | const T & | identity,
|  | const FuncT & | func,
|  | const JoinT & | join )
| inline

Simple wrapper that works with std::containers.

## ◆ reduce() [2/4]

template<template< typename... > class ContainerT, typename... ArgT, typename T, typename FuncT, typename JoinT>

T reduce | ( | const ContainerT< ArgT... > & | c,
|  | size_t | grainSize,
|  | const T & | identity,
|  | const FuncT & | func,
|  | const JoinT & | join )
| inline

Simple wrapper that works with std::containers.

## ◆ reduce() [3/4]

template<typename RangeT, typename T, typename FuncT, typename JoinT>

T reduce | ( | RangeT | range,
|  | const T & | identity,
|  | const FuncT & | func,
|  | const JoinT & | join )
| inline

Returns
  reduction

Parameters

  range | RangeT can be Range<dim,T>, CoordBBox, tbb::blocked_range, blocked_range2D, or blocked_range3D.
  identity | initial value
  func | functor with signature T FuncT::operator()(const RangeT& range, const T& a) const
  join | functor with the signature T JoinT::operator()(const T& a, const T& b) const std::vector<int> array(100, 1); auto func = [&array](auto &r, int a){for (auto i=r.begin(); i!=r.end(); ++i) a+=array[i]; return a;}; int sum = reduce(array, 0, func, [](int a, int b){return a + b;}); nanovdb::util::reduce T reduce(RangeT range, const T &identity, const FuncT &func, const JoinT &join) Definition Reduce.h:43

## ◆ reduce() [4/4]

template<typename T, typename FuncT, typename JoinT>

T reduce | ( | size_t | begin,
|  | size_t | end,
|  | size_t | grainSize,
|  | const T & | identity,
|  | const FuncT & | func,
|  | const JoinT & | join )
| inline

Simple wrapper to the function defined above.

## ◆ sprint()

template<typename T, typename... Types>

char * sprint | ( | char * | dst,
|  | T | var1,
|  | Types... | var2 )
| inline

prints a variable number of string and/or numbers to a destination string

## ◆ strcat() [1/2]

char * strcat | ( | char * | dst,
|  | const char * | src )
| inline

Appends a copy of the character string pointed to by `src` to the end of the character string pointed to by `dst` on the device.

Parameters

  dst | pointer to the null-terminated byte string to append to.
  src | pointer to the null-terminated byte string to copy from.

Returns
  pointer to the character array being appended to.

Note
  Emulates the behaviour of std::strcat, except this version also runs on the GPU.

## ◆ strcat() [2/2]

char * strcat | ( | char * | dst,
|  | int | num,
|  | int | bas = 10 )
| inline

concatenates a number after a string using a specific base

Parameters

  dst | null terminated destination string
  num | signed number to be concatenated after `dst`
  bas | base used when converting `num` to a string

Returns
  destination string `dst`

## ◆ strcmp()

int strcmp | ( | const char * | lhs,
|  | const char * | rhs )
| inline

Compares two null-terminated byte strings lexicographically.

Parameters

  lhs | pointer to the null-terminated byte strings to compare
  rhs | pointer to the null-terminated byte strings to compare

Returns
  Negative value if `lhs` appears before `rhs` in lexicographical order. Zero if `lhs` and `rhs` compare equal. Positive value if `lhs` appears after `rhs` in lexicographical order.

Note
  Emulates the behaviour of std::strcmp, except this version also runs on the GPU.

## ◆ strcpy() [1/2]

char * strcpy | ( | char * | dst,
|  | const char * | src )
| inline

Copy characters from `src` to `dst`.

Parameters

  dst | pointer to the destination string.
  src | pointer to the null-terminated source string.

Returns
  destination string `dst`.

Note
  Emulates the behaviour of std::strcpy, except this version also runs on the GPU.

## ◆ strcpy() [2/2]

char * strcpy | ( | char * | dst,
|  | int | num,
|  | int | bas = 10 )
| inline

converts a number to a string using a specific base

Parameters

  dst | destination string
  num | signed number to be concatenated after `dst`
  bas | base used when converting `num` to a string

Returns
  destination string `dst`

Note
  Emulates the behaviour of itoa, except this verion also works on the GPU.

## ◆ streq()

bool streq | ( | const char * | lhs,
|  | const char * | rhs )
| inline

Test if two null-terminated byte strings are the same.

Parameters

  lhs | pointer to the null-terminated byte strings to compare
  rhs | pointer to the null-terminated byte strings to compare

Returns
  true if the two c-strings are identical

## ◆ strlen()

size_t strlen | ( | const char * | str | ) |
| inline

length of a c-sting, excluding '\0'.

Parameters

  str | c-string

Returns
  the number of characters that precede the terminating null character.

## ◆ strncpy()

char * strncpy | ( | char * | dst,
|  | const char * | src,
|  | size_t | max )
| inline

Copies the first num characters of `src` to `dst`. If the end of the source C string (which is signaled by a null-character) is found before `max` characters have been copied, `dst` is padded with zeros until a total of `max` characters have been written to it.

Parameters

  dst | destination string
  src | source string
  max | maximum number of character in destination string

Returns
  destination string `dst`

Warning
  if strncpy(dst, src, max)[max-1]!='\0' then `src` has more characters than `max` and the return string needs to be manually null-terminated, i.e. strncpy(dst, src, max)[max-1]='\0'

## Variable Documentation

## ◆ is_const_v

template<typename T>

bool is_const_v = is_const<T>::value
| static constexpr

## ◆ is_floating_point_v

template<typename T>

bool is_floating_point_v = is_floating_point<T>::value
| static constexpr

## ◆ is_pointer_v

template<typename T>

bool is_pointer_v = is_pointer<T>::value
| static constexpr

## ◆ is_same_v

template<typename T0, typename T1, typename ... T>

bool is_same_v = is_same<T0, T1, T...>::value
| static constexpr