7#include <kernel/util/memory_aux.hpp>
8#include <kernel/util/random.hpp>
18 #ifndef FEAT_HAVE_CUDA
25 #ifndef FEAT_HAVE_CUDA
34 if(bytes <= std::size_t(0))
39 ::memset(ptr,
value, bytes);
44 if(bytes <= std::size_t(0))
51 seed =
reinterpret_cast<std::uint64_t
>(ptr);
57 std::uint64_t* x =
reinterpret_cast<std::uint64_t*
>(ptr);
58 std::size_t n = bytes / 8u;
59 for(std::size_t i = 0; i < n; ++i, ++x)
63 std::size_t bytes_left = bytes & 0x7u;
66 std::uint64_t t = rng.
next();
67 ::memcpy(x, &t, bytes_left);
73 if(bytes <= std::size_t(0))
83 XASSERTM((dst < src) || ((
const char*)src + bytes <= dst),
"source and destination memory regions overlap");
84 XASSERTM((src < dst) || ((
const char*)dst + bytes <= src),
"source and destination memory regions overlap");
86 ::memcpy(dst, src, bytes);
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Pseudo-Random Number Generator.
uint64_t next()
Returns the next number in the stream.
void memcopy_main(void *dst, const void *src, std::size_t bytes)
Copies a region of a main memory block into another main memory block.
void memset_main(void *ptr, int value, std::size_t bytes)
Formats all bytes of a memory block in main memory to a given value.
void free_main(void *ptr)
Frees a memory block in main heap memory allocated by alloc_main.
void memset_random_main(void *ptr, std::size_t bytes, std::uint64_t seed=0u)
Formats all bytes of a memory block in main memory to random values.
void * alloc_main(std::size_t bytes)
Allocate a memory block in main heap memory.
@ value
specifies whether the space should supply basis function values