|
Geogram Version 1.9.7
A programming library of geometric algorithms
|
Types and functions for memory manipulation. More...
#include <geogram/basic/common.h>#include <geogram/basic/assert.h>#include <geogram/basic/numeric.h>#include <geogram/basic/argused.h>#include <vector>#include <string.h>#include <stdlib.h>#include <unistd.h>Go to the source code of this file.
Classes | |
| struct | GEO::Memory::PointAlignment< DIM > |
| Defines the memory alignment of points in a vector. More... | |
| struct | GEO::Memory::PointAlignment< 2 > |
| PointAlignment specialization for points of dimension 2. More... | |
| struct | GEO::Memory::PointAlignment< 3 > |
| PointAlignment specialization for points of dimension 3. More... | |
| struct | GEO::Memory::PointAlignment< 4 > |
| PointAlignment specialization for points of dimension 4. More... | |
| struct | GEO::Memory::PointAlignment< 6 > |
| PointAlignment specialization for points of dimension 6. More... | |
| struct | GEO::Memory::PointAlignment< 8 > |
| PointAlignment specialization for points of dimension 8. More... | |
| class | GEO::Memory::aligned_allocator< T, ALIGN > |
| An allocator that performs aligned memory allocations. More... | |
| struct | GEO::Memory::aligned_allocator< T, ALIGN >::rebind< U > |
| Defines the same allocator for other types. More... | |
| class | GEO::vector< T > |
| Vector with aligned memory allocation. More... | |
| class | GEO::vector< bool > |
| Specialization of vector for elements of type bool. More... | |
Namespaces | |
| namespace | GEO |
| Global Vorpaline namespace. | |
| namespace | GEO::Memory |
| Utilities for memory management. | |
Macros | |
| #define | GEO_HAS_BIG_STACK |
| #define | GEO_MEMORY_ALIGNMENT 64 |
| Default memory alignment for efficient vector operations. | |
| #define | geo_dim_alignment(dim) GEO::Memory::PointAlignment<dim>::value |
| Gets a point alignment. | |
| #define | geo_assume_aligned(var, alignment) *(void**) (&var) = __builtin_assume_aligned(var, alignment) |
| Informs the compiler that a given pointer is memory-aligned. | |
| #define | geo_aligned_alloca(size) GEO::Memory::align(alloca(size + GEO_MEMORY_ALIGNMENT - 1)) |
| Allocates aligned memory on the stack. | |
Typedefs | |
| typedef unsigned char | GEO::Memory::byte |
| Unsigned byte type. | |
| typedef unsigned char | GEO::Memory::word8 |
| Unsigned 8 bits integer. | |
| typedef unsigned short | GEO::Memory::word16 |
| Unsigned 16 bits integer. | |
| typedef unsigned int | GEO::Memory::word32 |
| Unsigned 32 bits integer. | |
| typedef byte * | GEO::Memory::pointer |
| Pointer to unsigned byte(s) | |
| typedef void(* | GEO::Memory::function_pointer) () |
| Generic function pointer. | |
Functions | |
| void | GEO::Memory::clear (void *addr, size_t size) |
| Clears a memory block. | |
| void | GEO::Memory::copy (void *to, const void *from, size_t size) |
| Copies a memory block. | |
| pointer | GEO::Memory::function_pointer_to_generic_pointer (function_pointer fptr) |
| Converts a function pointer to a generic pointer. | |
| function_pointer | GEO::Memory::generic_pointer_to_function_pointer (pointer ptr) |
| Converts a generic pointer to a function pointer. | |
| function_pointer | GEO::Memory::generic_pointer_to_function_pointer (void *ptr) |
| Converts a generic pointer to a function pointer. | |
| void * | GEO::Memory::aligned_malloc (size_t size, size_t alignment=GEO_MEMORY_ALIGNMENT) |
| Allocates aligned memory. | |
| void | GEO::Memory::aligned_free (void *p) |
| Deallocates aligned memory. | |
| bool | GEO::Memory::is_aligned (void *p, size_t alignment=GEO_MEMORY_ALIGNMENT) |
| Checks whether a pointer is aligned. | |
| void * | GEO::Memory::align (void *p) |
| Returns the smallest aligned memory address from p. | |
| template<typename T1 , int A1, typename T2 , int A2> | |
| bool | GEO::Memory::operator== (const aligned_allocator< T1, A1 > &, const aligned_allocator< T2, A2 > &) |
| Tests whether two aligned_allocators are equal. | |
| template<typename T1 , int A1, typename T2 , int A2> | |
| bool | GEO::Memory::operator!= (const aligned_allocator< T1, A1 > &, const aligned_allocator< T2, A2 > &) |
| Tests whether two aligned_allocators are different. | |
Types and functions for memory manipulation.
Definition in file memory.h.
| #define geo_aligned_alloca | ( | size | ) | GEO::Memory::align(alloca(size + GEO_MEMORY_ALIGNMENT - 1)) |
Allocates aligned memory on the stack.
Allocates size bytes on the stack. The returned address is guaranteed to be aligned on GEO_MEMORY_ALIGNMENT bytes. To guarantee the memory alignment, the function may allocate more than size, but not more than GEO_MEMORY_ALIGNMENT - 1.
| [in] | size | Number of bytes to allocate. |
size bytes. | #define geo_assume_aligned | ( | var, | |
| alignment | |||
| ) | *(void**) (&var) = __builtin_assume_aligned(var, alignment) |
Informs the compiler that a given pointer is memory-aligned.
It helps the compiler vectorizing loops, i.e. generating SSE/AVX/... code.
| [in] | var | a pointer variable in the current scope |
| [in] | alignment | the memory alignment (must be a power of 2) |
| #define geo_dim_alignment | ( | dim | ) | GEO::Memory::PointAlignment<dim>::value |
Gets a point alignment.
This gives the alignment of a point of dimension dim within an array of points aligned on GEO_MEMORY_ALIGNMENT bytes
| [in] | dim | the dimension of the point |