cnorxz/src/include/memory/allocator.h
Christian Zimmermann eee1805f88
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
get intrinsics vector size from environment + compile with avx -> works
2023-11-20 00:41:37 +01:00

54 lines
957 B
C++

#ifndef __cxz_allocator__
#define __cxz_allocator__
#include <cstdlib>
#include <new>
#include <vector>
#include <cstdint>
#include <cassert>
#include <iostream>
#include "base/types.h"
#include "base/intrin.h"
#define MIB_SIZE 1024*1024 // 1MiB
#define WARN_SIZE MIB_SIZE*100 // 100 MiB
namespace CNORXZ
{
template <typename T>
class Allocator
{
public:
typedef T value_type;
static constexpr SizeT type_size = sizeof(T);
static constexpr SizeT N = MAX_VSIZE;
struct VX
{
alignas(N) char x[N];
};
Allocator() = default;
template <typename U>
Allocator(const Allocator<U>& x) {}
T* allocate(SizeT n);
void deallocate(T* p, SizeT n);
};
template <class T, class U>
bool operator==(const Allocator<T>& a, const Allocator<U>& b);
template <class T, class U>
bool operator!=(const Allocator<T>& a, const Allocator<U>& b);
} // namespace CNORXZ
#endif