Welcome to mirror list, hosted at ThFree Co, Russian Federation.

aligned.h - github.com/marian-nmt/intgemm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 44889d1694c9dae5e7dc2acf342cf1c4b357c66f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

// Define allocation like:
// free_ptr<Integer> quantized(AlignedArray<Integer>(rows * cols));
// This is only used by tests.

#include <memory>

namespace intgemm {

struct DeleteWithFree {
  template <class T> void operator() (T *t) const {
    std::free(const_cast<std::remove_const_t<T>* >(t));
  }
};
template <class T> using free_ptr = std::unique_ptr<T, DeleteWithFree>;
// Return memory suitably aligned for SIMD.
template <class T> T* AlignedArray(std::size_t size) {
  return static_cast<T*>(aligned_alloc(64, size * sizeof(T)));
}

} // namespace intgemm