mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 06:17:49 +00:00
Use dynamic allocation for evaluation scratch TLS buffer.
fixes #3946 an issue related with the toolchain as found in xcode 12 on macOS,
related to previous commit 5f781d36.
closes https://github.com/official-stockfish/Stockfish/pull/3950
No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
5f781d366e
commit
174b038bf3
@@ -21,6 +21,8 @@
|
|||||||
#ifndef NNUE_ARCHITECTURE_H_INCLUDED
|
#ifndef NNUE_ARCHITECTURE_H_INCLUDED
|
||||||
#define NNUE_ARCHITECTURE_H_INCLUDED
|
#define NNUE_ARCHITECTURE_H_INCLUDED
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "nnue_common.h"
|
#include "nnue_common.h"
|
||||||
|
|
||||||
#include "features/half_ka_v2_hm.h"
|
#include "features/half_ka_v2_hm.h"
|
||||||
@@ -88,9 +90,7 @@ struct Network
|
|||||||
|
|
||||||
std::int32_t propagate(const TransformedFeatureType* transformedFeatures)
|
std::int32_t propagate(const TransformedFeatureType* transformedFeatures)
|
||||||
{
|
{
|
||||||
constexpr uint64_t alignment = CacheLineSize;
|
struct alignas(CacheLineSize) Buffer
|
||||||
|
|
||||||
struct Buffer
|
|
||||||
{
|
{
|
||||||
alignas(CacheLineSize) decltype(fc_0)::OutputBuffer fc_0_out;
|
alignas(CacheLineSize) decltype(fc_0)::OutputBuffer fc_0_out;
|
||||||
alignas(CacheLineSize) decltype(ac_0)::OutputBuffer ac_0_out;
|
alignas(CacheLineSize) decltype(ac_0)::OutputBuffer ac_0_out;
|
||||||
@@ -104,12 +104,13 @@ struct Network
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(ALIGNAS_ON_STACK_VARIABLES_BROKEN)
|
#if defined(__clang__) && (__APPLE__)
|
||||||
static thread_local char bufferRaw[sizeof(Buffer) + alignment];
|
// workaround for a bug reported with xcode 12
|
||||||
static thread_local char* bufferRawAligned = align_ptr_up<alignment>(&bufferRaw[0]);
|
static thread_local auto tlsBuffer = std::make_unique<Buffer>();
|
||||||
static thread_local Buffer& buffer = *(new (bufferRawAligned) Buffer);
|
// Access TLS only once, cache result.
|
||||||
|
Buffer& buffer = *tlsBuffer;
|
||||||
#else
|
#else
|
||||||
alignas(alignment) static thread_local Buffer buffer;
|
alignas(CacheLineSize) static thread_local Buffer buffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fc_0.propagate(transformedFeatures, buffer.fc_0_out);
|
fc_0.propagate(transformedFeatures, buffer.fc_0_out);
|
||||||
|
|||||||
Reference in New Issue
Block a user