stdgpu/bit.h Source File — stdgpu Latest documentation (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef STDGPU_BIT_H

17#define STDGPU_BIT_H

18

28#include <type_traits>

29

32

33namespace stdgpu

34{

35

42template <typename T, STDGPU_DETAIL_OVERLOAD_IF(std::is_unsigned_v)>

45

52template <typename T, STDGPU_DETAIL_OVERLOAD_IF(std::is_unsigned_v)>

55

62template <typename T, STDGPU_DETAIL_OVERLOAD_IF(std::is_unsigned_v)>

65

76template <typename T, STDGPU_DETAIL_OVERLOAD_IF(std::is_unsigned_v)>

78bit_mod(const T number, const T divider) noexcept;

79

88template <typename T, STDGPU_DETAIL_OVERLOAD_IF(std::is_unsigned_v)>

91

100template <typename T, STDGPU_DETAIL_OVERLOAD_IF(std::is_unsigned_v)>

103

110template <typename To,

111 typename From,

112 STDGPU_DETAIL_OVERLOAD_IF(sizeof(To) == sizeof(From) && std::is_trivially_copyable_v &&

113 std::is_trivially_copyable_v)>

116

117}

118

119#include <stdgpu/impl/bit_detail.h>

120

121#endif

STDGPU_HOST_DEVICE T bit_ceil(const T number) noexcept

Computes the smallest power of two which is larger or equal than the given number.

STDGPU_HOST_DEVICE T bit_floor(const T number) noexcept

Computes the largest power of two which is smaller or equal than the given number.

STDGPU_HOST_DEVICE int popcount(const T number) noexcept

Counts the number of set bits in the number.

STDGPU_HOST_DEVICE T bit_width(const T number) noexcept

Computes the smallest number of bits to represent the given number.

STDGPU_HOST_DEVICE T bit_mod(const T number, const T divider) noexcept

Computes the modulus of the given number and a power of two divider.

STDGPU_HOST_DEVICE bool has_single_bit(const T number) noexcept

Determines whether the number is a power of two.

STDGPU_HOST_DEVICE To bit_cast(const From &object) noexcept

Reinterprets the object of the given type as an instance of the desired type.

#define STDGPU_HOST_DEVICE

Platform-independent host device function annotation.

Definition: platform.h:77