From ed4d007e3cfb012671e09723c160dbc2e3d98d54 Mon Sep 17 00:00:00 2001 From: nodchip Date: Sat, 8 Aug 2020 18:21:38 +0900 Subject: [PATCH] Fixed a bug that the training data generator crahses on memory allocation. --- src/misc.h | 2 +- src/nnue/trainer/trainer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/misc.h b/src/misc.h index fe5990e0..9ea57fa8 100644 --- a/src/misc.h +++ b/src/misc.h @@ -271,7 +271,7 @@ public: template AlignedAllocator(const AlignedAllocator&) {} - T* allocate(std::size_t n) { return (T*)std_aligned_alloc(n * sizeof(T), alignof(T)); } + T* allocate(std::size_t n) { return (T*)std_aligned_alloc(alignof(T), n * sizeof(T)); } void deallocate(T* p, std::size_t n) { std_aligned_free(p); } }; diff --git a/src/nnue/trainer/trainer.h b/src/nnue/trainer/trainer.h index b42cb4fa..4b467041 100644 --- a/src/nnue/trainer/trainer.h +++ b/src/nnue/trainer/trainer.h @@ -111,7 +111,7 @@ IntType Round(double value) { // make_shared with alignment template std::shared_ptr MakeAlignedSharedPtr(ArgumentTypes&&... arguments) { - const auto ptr = new(std_aligned_alloc(sizeof(T), alignof(T))) + const auto ptr = new(std_aligned_alloc(alignof(T), sizeof(T))) T(std::forward(arguments)...); return std::shared_ptr(ptr, AlignedDeleter()); }