diff options
author | Evgueni Petrov <evgueni.s.petrov@gmail.com> | 2022-02-10 16:47:00 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:00 +0300 |
commit | 6bde7c5def28273dc3eb4b26959d640ce52e5d2f (patch) | |
tree | b83306b6e37edeea782e9eed673d89286c4fef35 | |
parent | 19d7d7947f95423df4b50d3a6e858cd689db06ed (diff) | |
download | ydb-6bde7c5def28273dc3eb4b26959d640ce52e5d2f.tar.gz |
Restoring authorship annotation for Evgueni Petrov <evgueni.s.petrov@gmail.com>. Commit 2 of 2.
-rw-r--r-- | contrib/libs/cxxsupp/openmp/kmp_alloc.c | 30 | ||||
-rw-r--r-- | contrib/libs/ya.make | 2 | ||||
-rw-r--r-- | library/cpp/threading/local_executor/local_executor.cpp | 36 | ||||
-rw-r--r-- | library/cpp/threading/local_executor/local_executor.h | 302 | ||||
-rw-r--r-- | library/python/testing/yatest_common/yatest/common/network.py | 8 | ||||
-rw-r--r-- | util/system/cpu_id.cpp | 56 | ||||
-rw-r--r-- | util/system/cpu_id_ut.cpp | 4 | ||||
-rw-r--r-- | util/thread/lfqueue.h | 2 |
8 files changed, 220 insertions, 220 deletions
diff --git a/contrib/libs/cxxsupp/openmp/kmp_alloc.c b/contrib/libs/cxxsupp/openmp/kmp_alloc.c index 2a084d36f5..4e4656c6e8 100644 --- a/contrib/libs/cxxsupp/openmp/kmp_alloc.c +++ b/contrib/libs/cxxsupp/openmp/kmp_alloc.c @@ -17,18 +17,18 @@ #include "kmp_wrapper_malloc.h" #include "kmp_io.h" -#ifdef __clang__ -#if __has_feature(address_sanitizer) -extern "C" { // sanitizers API -void __lsan_ignore_object(const void* p); -} -#else -#define __lsan_ignore_object(p) -#endif -#else -#define __lsan_ignore_object(p) -#endif - +#ifdef __clang__ +#if __has_feature(address_sanitizer) +extern "C" { // sanitizers API +void __lsan_ignore_object(const void* p); +} +#else +#define __lsan_ignore_object(p) +#endif +#else +#define __lsan_ignore_object(p) +#endif + // Disable bget when it is not used #if KMP_USE_BGET @@ -1619,9 +1619,9 @@ ___kmp_allocate_align( size_t size, size_t alignment KMP_SRC_LOC_DECL ) #else descr.ptr_allocated = malloc_src_loc( descr.size_allocated KMP_SRC_LOC_PARM ); #endif - - __lsan_ignore_object(descr.ptr_allocated); // espetrov@yandex-team.ru: asan considers descr.ptr_allocated leaked because of address alignment arithmetics - + + __lsan_ignore_object(descr.ptr_allocated); // espetrov@yandex-team.ru: asan considers descr.ptr_allocated leaked because of address alignment arithmetics + KE_TRACE( 10, ( " malloc( %d ) returned %p\n", (int) descr.size_allocated, diff --git a/contrib/libs/ya.make b/contrib/libs/ya.make index ffff42353f..9c4640fdcf 100644 --- a/contrib/libs/ya.make +++ b/contrib/libs/ya.make @@ -73,7 +73,7 @@ RECURSE( flatbuffers64 flatbuffers64/flatc flatbuffers64/samples - fmath + fmath fmt fontconfig fp16 diff --git a/library/cpp/threading/local_executor/local_executor.cpp b/library/cpp/threading/local_executor/local_executor.cpp index 17f4fc636b..1d3fbb4bf4 100644 --- a/library/cpp/threading/local_executor/local_executor.cpp +++ b/library/cpp/threading/local_executor/local_executor.cpp @@ -84,8 +84,8 @@ namespace { class TLocalRangeExecutor: public NPar::ILocallyExecutable { TIntrusivePtr<NPar::ILocallyExecutable> Exec; - alignas(64) TAtomic Counter; - alignas(64) TAtomic WorkerCount; + alignas(64) TAtomic Counter; + alignas(64) TAtomic WorkerCount; int LastId; void LocalExec(int) override { @@ -106,7 +106,7 @@ namespace { { } bool DoSingleOp() { - const int id = AtomicAdd(Counter, 1) - 1; + const int id = AtomicAdd(Counter, 1) - 1; if (id >= LastId) return false; Exec->LocalExec(id); @@ -116,7 +116,7 @@ namespace { void WaitComplete() { while (AtomicGet(WorkerCount) > 0) RegularYield(); - } + } int GetRangeSize() const { return Max<int>(LastId - Counter, 0); } @@ -130,10 +130,10 @@ public: TLockFreeQueue<TSingleJob> JobQueue; TLockFreeQueue<TSingleJob> MedJobQueue; TLockFreeQueue<TSingleJob> LowJobQueue; - alignas(64) TSystemEvent HasJob; + alignas(64) TSystemEvent HasJob; TAtomic ThreadCount{0}; - alignas(64) TAtomic QueueSize{0}; + alignas(64) TAtomic QueueSize{0}; TAtomic MPQueueSize{0}; TAtomic LPQueueSize{0}; TAtomic ThreadId{0}; @@ -231,7 +231,7 @@ void NPar::TLocalExecutor::TImpl::LaunchRange(TIntrusivePtr<TLocalRangeExecutor> return; } AtomicAdd(*queueSize, count); - jobQueue->EnqueueAll(TVector<TSingleJob>{size_t(count), TSingleJob(rangeExec, 0)}); + jobQueue->EnqueueAll(TVector<TSingleJob>{size_t(count), TSingleJob(rangeExec, 0)}); HasJob.Signal(); } @@ -269,13 +269,13 @@ void NPar::TLocalExecutor::Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, Impl_->HasJob.Signal(); } -void NPar::ILocalExecutor::Exec(TLocallyExecutableFunction exec, int id, int flags) { +void NPar::ILocalExecutor::Exec(TLocallyExecutableFunction exec, int id, int flags) { Exec(new TFunctionWrapper(std::move(exec)), id, flags); } void NPar::TLocalExecutor::ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) { Y_ASSERT(lastId >= firstId); - if (TryExecRangeSequentially([=] (int id) { exec->LocalExec(id); }, firstId, lastId, flags)) { + if (TryExecRangeSequentially([=] (int id) { exec->LocalExec(id); }, firstId, lastId, flags)) { return; } auto rangeExec = MakeIntrusive<TLocalRangeExecutor>(std::move(exec), firstId, lastId); @@ -305,18 +305,18 @@ void NPar::TLocalExecutor::ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int } } -void NPar::ILocalExecutor::ExecRange(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { - if (TryExecRangeSequentially(exec, firstId, lastId, flags)) { - return; - } +void NPar::ILocalExecutor::ExecRange(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { + if (TryExecRangeSequentially(exec, firstId, lastId, flags)) { + return; + } ExecRange(new TFunctionWrapper(exec), firstId, lastId, flags); } -void NPar::ILocalExecutor::ExecRangeWithThrow(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { +void NPar::ILocalExecutor::ExecRangeWithThrow(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { Y_VERIFY((flags & WAIT_COMPLETE) != 0, "ExecRangeWithThrow() requires WAIT_COMPLETE to wait if exceptions arise."); - if (TryExecRangeSequentially(exec, firstId, lastId, flags)) { - return; - } + if (TryExecRangeSequentially(exec, firstId, lastId, flags)) { + return; + } TVector<NThreading::TFuture<void>> currentRun = ExecRangeWithFutures(exec, firstId, lastId, flags); for (auto& result : currentRun) { result.GetValueSync(); // Exception will be rethrown if exists. If several exception - only the one with minimal id is rethrown. @@ -324,7 +324,7 @@ void NPar::ILocalExecutor::ExecRangeWithThrow(TLocallyExecutableFunction exec, i } TVector<NThreading::TFuture<void>> -NPar::ILocalExecutor::ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { +NPar::ILocalExecutor::ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags) { TFunctionWrapperWithPromise* execWrapper = new TFunctionWrapperWithPromise(exec, firstId, lastId); TVector<NThreading::TFuture<void>> out = execWrapper->GetFutures(); ExecRange(execWrapper, firstId, lastId, flags); diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h index cbde5c62f4..c1c824f67c 100644 --- a/library/cpp/threading/local_executor/local_executor.h +++ b/library/cpp/threading/local_executor/local_executor.h @@ -2,7 +2,7 @@ #include <library/cpp/threading/future/future.h> -#include <util/generic/cast.h> +#include <util/generic/cast.h> #include <util/generic/fwd.h> #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> @@ -26,11 +26,11 @@ namespace NPar { // using TLocallyExecutableFunction = std::function<void(int)>; - class ILocalExecutor: public TNonCopyable { + class ILocalExecutor: public TNonCopyable { public: - ILocalExecutor() = default; - virtual ~ILocalExecutor() = default; - + ILocalExecutor() = default; + virtual ~ILocalExecutor() = default; + enum EFlags : int { HIGH_PRIORITY = 0, MED_PRIORITY = 1, @@ -38,60 +38,60 @@ namespace NPar { PRIORITY_MASK = 3, WAIT_COMPLETE = 4 }; - - // Add task for further execution. - // - // @param exec Task description. - // @param id Task argument. - // @param flags Bitmask composed by `HIGH_PRIORITY`, `MED_PRIORITY`, `LOW_PRIORITY` - // and `WAIT_COMPLETE`. - virtual void Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, int flags) = 0; - - // Add tasks range for further execution. - // - // @param exec Task description. - // @param firstId, lastId Task arguments [firstId, lastId) - // @param flags Same as for `Exec`. - virtual void ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) = 0; - - // 0-based ILocalExecutor worker thread identification - virtual int GetWorkerThreadId() const noexcept = 0; - virtual int GetThreadCount() const noexcept = 0; - + + // Add task for further execution. + // + // @param exec Task description. + // @param id Task argument. + // @param flags Bitmask composed by `HIGH_PRIORITY`, `MED_PRIORITY`, `LOW_PRIORITY` + // and `WAIT_COMPLETE`. + virtual void Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, int flags) = 0; + + // Add tasks range for further execution. + // + // @param exec Task description. + // @param firstId, lastId Task arguments [firstId, lastId) + // @param flags Same as for `Exec`. + virtual void ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) = 0; + + // 0-based ILocalExecutor worker thread identification + virtual int GetWorkerThreadId() const noexcept = 0; + virtual int GetThreadCount() const noexcept = 0; + // Describes a range of tasks with parameters from integer range [FirstId, LastId). // class TExecRangeParams { - public: - template <typename TFirst, typename TLast> - TExecRangeParams(TFirst firstId, TLast lastId) - : FirstId(SafeIntegerCast<int>(firstId)) - , LastId(SafeIntegerCast<int>(lastId)) - { - Y_ASSERT(LastId >= FirstId); + public: + template <typename TFirst, typename TLast> + TExecRangeParams(TFirst firstId, TLast lastId) + : FirstId(SafeIntegerCast<int>(firstId)) + , LastId(SafeIntegerCast<int>(lastId)) + { + Y_ASSERT(LastId >= FirstId); SetBlockSize(1); - } + } // Partition tasks into `blockCount` blocks of approximately equal size, each of which // will be executed as a separate bigger task. // - template <typename TBlockCount> - TExecRangeParams& SetBlockCount(TBlockCount blockCount) { + template <typename TBlockCount> + TExecRangeParams& SetBlockCount(TBlockCount blockCount) { Y_ASSERT(SafeIntegerCast<int>(blockCount) > 0 || FirstId == LastId); BlockSize = FirstId == LastId ? 0 : CeilDiv(LastId - FirstId, SafeIntegerCast<int>(blockCount)); BlockCount = BlockSize == 0 ? 0 : CeilDiv(LastId - FirstId, BlockSize); BlockEqualToThreads = false; - return *this; - } + return *this; + } // Partition tasks into blocks of approximately `blockSize` size, each of which will // be executed as a separate bigger task. // - template <typename TBlockSize> - TExecRangeParams& SetBlockSize(TBlockSize blockSize) { + template <typename TBlockSize> + TExecRangeParams& SetBlockSize(TBlockSize blockSize) { Y_ASSERT(SafeIntegerCast<int>(blockSize) > 0 || FirstId == LastId); - BlockSize = SafeIntegerCast<int>(blockSize); + BlockSize = SafeIntegerCast<int>(blockSize); BlockCount = BlockSize == 0 ? 0 : CeilDiv(LastId - FirstId, BlockSize); BlockEqualToThreads = false; - return *this; - } + return *this; + } // Partition tasks into thread count blocks of approximately equal size, each of which // will be executed as a separate bigger task. // @@ -99,27 +99,27 @@ namespace NPar { BlockEqualToThreads = true; return *this; } - int GetBlockCount() const { + int GetBlockCount() const { Y_ASSERT(!BlockEqualToThreads); - return BlockCount; - } - int GetBlockSize() const { + return BlockCount; + } + int GetBlockSize() const { Y_ASSERT(!BlockEqualToThreads); - return BlockSize; - } + return BlockSize; + } bool GetBlockEqualToThreads() { return BlockEqualToThreads; } - - const int FirstId = 0; - const int LastId = 0; - - private: + + const int FirstId = 0; + const int LastId = 0; + + private: int BlockSize; int BlockCount; bool BlockEqualToThreads; - }; - + }; + // `Exec` and `ExecRange` versions that accept functions. // void Exec(TLocallyExecutableFunction exec, int id, int flags); @@ -136,26 +136,26 @@ namespace NPar { TVector<NThreading::TFuture<void>> ExecRangeWithFutures(TLocallyExecutableFunction exec, int firstId, int lastId, int flags); template <typename TBody> - static inline auto BlockedLoopBody(const TExecRangeParams& params, const TBody& body) { + static inline auto BlockedLoopBody(const TExecRangeParams& params, const TBody& body) { return [=](int blockId) { const int blockFirstId = params.FirstId + blockId * params.GetBlockSize(); const int blockLastId = Min(params.LastId, blockFirstId + params.GetBlockSize()); - for (int i = blockFirstId; i < blockLastId; ++i) { - body(i); - } - }; - } - - template <typename TBody> + for (int i = blockFirstId; i < blockLastId; ++i) { + body(i); + } + }; + } + + template <typename TBody> inline void ExecRange(TBody&& body, TExecRangeParams params, int flags) { - if (TryExecRangeSequentially(body, params.FirstId, params.LastId, flags)) { + if (TryExecRangeSequentially(body, params.FirstId, params.LastId, flags)) { return; } if (params.GetBlockEqualToThreads()) { params.SetBlockCount(GetThreadCount() + ((flags & WAIT_COMPLETE) != 0)); // ThreadCount or ThreadCount+1 depending on WaitFlag - } + } ExecRange(BlockedLoopBody(params, body), 0, params.GetBlockCount(), flags); - } + } template <typename TBody> inline void ExecRangeBlockedWithThrow(TBody&& body, int firstId, int lastId, int batchSizeOrZeroForAutoBatchSize, int flags) { @@ -185,97 +185,97 @@ namespace NPar { } } - template <typename TBody> - static inline bool TryExecRangeSequentially(TBody&& body, int firstId, int lastId, int flags) { - if (lastId == firstId) { - return true; - } - if ((flags & WAIT_COMPLETE) && lastId - firstId == 1) { - body(firstId); - return true; - } - return false; - } + template <typename TBody> + static inline bool TryExecRangeSequentially(TBody&& body, int firstId, int lastId, int flags) { + if (lastId == firstId) { + return true; + } + if ((flags & WAIT_COMPLETE) && lastId - firstId == 1) { + body(firstId); + return true; + } + return false; + } + }; + + // `TLocalExecutor` provides facilities for easy parallelization of existing code and cycles. + // + // Examples: + // Execute one task with medium priority and wait for it completion. + // ``` + // LocalExecutor().Run(4); + // TEvent event; + // LocalExecutor().Exec([](int) { + // SomeFunc(); + // event.Signal(); + // }, 0, TLocalExecutor::MED_PRIORITY); + // + // SomeOtherCode(); + // event.WaitI(); + // ``` + // + // Execute range of tasks with medium priority. + // ``` + // LocalExecutor().Run(4); + // LocalExecutor().ExecRange([](int id) { + // SomeFunc(id); + // }, TExecRangeParams(0, 10), TLocalExecutor::WAIT_COMPLETE | TLocalExecutor::MED_PRIORITY); + // ``` + // + class TLocalExecutor final: public ILocalExecutor { + public: + using EFlags = ILocalExecutor::EFlags; + + // Creates executor without threads. You'll need to explicitly call `RunAdditionalThreads` + // to add threads to underlying thread pool. + // + TLocalExecutor(); + ~TLocalExecutor(); + + int GetQueueSize() const noexcept; + int GetMPQueueSize() const noexcept; + int GetLPQueueSize() const noexcept; + void ClearLPQueue(); + + // 0-based TLocalExecutor worker thread identification + int GetWorkerThreadId() const noexcept override; + int GetThreadCount() const noexcept override; + + // **Add** threads to underlying thread pool. + // + // @param threadCount Number of threads to add. + void RunAdditionalThreads(int threadCount); + + // Add task for further execution. + // + // @param exec Task description. + // @param id Task argument. + // @param flags Bitmask composed by `HIGH_PRIORITY`, `MED_PRIORITY`, `LOW_PRIORITY` + // and `WAIT_COMPLETE`. + void Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, int flags) override; + + // Add tasks range for further execution. + // + // @param exec Task description. + // @param firstId, lastId Task arguments [firstId, lastId) + // @param flags Same as for `Exec`. + void ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) override; + + using ILocalExecutor::Exec; + using ILocalExecutor::ExecRange; + + private: + class TImpl; + THolder<TImpl> Impl_; }; - // `TLocalExecutor` provides facilities for easy parallelization of existing code and cycles. - // - // Examples: - // Execute one task with medium priority and wait for it completion. - // ``` - // LocalExecutor().Run(4); - // TEvent event; - // LocalExecutor().Exec([](int) { - // SomeFunc(); - // event.Signal(); - // }, 0, TLocalExecutor::MED_PRIORITY); - // - // SomeOtherCode(); - // event.WaitI(); - // ``` - // - // Execute range of tasks with medium priority. - // ``` - // LocalExecutor().Run(4); - // LocalExecutor().ExecRange([](int id) { - // SomeFunc(id); - // }, TExecRangeParams(0, 10), TLocalExecutor::WAIT_COMPLETE | TLocalExecutor::MED_PRIORITY); - // ``` - // - class TLocalExecutor final: public ILocalExecutor { - public: - using EFlags = ILocalExecutor::EFlags; - - // Creates executor without threads. You'll need to explicitly call `RunAdditionalThreads` - // to add threads to underlying thread pool. - // - TLocalExecutor(); - ~TLocalExecutor(); - - int GetQueueSize() const noexcept; - int GetMPQueueSize() const noexcept; - int GetLPQueueSize() const noexcept; - void ClearLPQueue(); - - // 0-based TLocalExecutor worker thread identification - int GetWorkerThreadId() const noexcept override; - int GetThreadCount() const noexcept override; - - // **Add** threads to underlying thread pool. - // - // @param threadCount Number of threads to add. - void RunAdditionalThreads(int threadCount); - - // Add task for further execution. - // - // @param exec Task description. - // @param id Task argument. - // @param flags Bitmask composed by `HIGH_PRIORITY`, `MED_PRIORITY`, `LOW_PRIORITY` - // and `WAIT_COMPLETE`. - void Exec(TIntrusivePtr<ILocallyExecutable> exec, int id, int flags) override; - - // Add tasks range for further execution. - // - // @param exec Task description. - // @param firstId, lastId Task arguments [firstId, lastId) - // @param flags Same as for `Exec`. - void ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) override; - - using ILocalExecutor::Exec; - using ILocalExecutor::ExecRange; - - private: - class TImpl; - THolder<TImpl> Impl_; - }; - static inline TLocalExecutor& LocalExecutor() { return *Singleton<TLocalExecutor>(); } template <typename TBody> - inline void ParallelFor(ILocalExecutor& executor, ui32 from, ui32 to, TBody&& body) { - ILocalExecutor::TExecRangeParams params(from, to); + inline void ParallelFor(ILocalExecutor& executor, ui32 from, ui32 to, TBody&& body) { + ILocalExecutor::TExecRangeParams params(from, to); params.SetBlockCountToThreadCount(); executor.ExecRange(std::forward<TBody>(body), params, TLocalExecutor::WAIT_COMPLETE); } @@ -287,7 +287,7 @@ namespace NPar { template <typename TBody> inline void AsyncParallelFor(ui32 from, ui32 to, TBody&& body) { - ILocalExecutor::TExecRangeParams params(from, to); + ILocalExecutor::TExecRangeParams params(from, to); params.SetBlockCountToThreadCount(); LocalExecutor().ExecRange(std::forward<TBody>(body), params, 0); } diff --git a/library/python/testing/yatest_common/yatest/common/network.py b/library/python/testing/yatest_common/yatest/common/network.py index ce3074dcb2..37bcb1b8e0 100644 --- a/library/python/testing/yatest_common/yatest/common/network.py +++ b/library/python/testing/yatest_common/yatest/common/network.py @@ -71,7 +71,7 @@ class PortManager(object): retries -= 1 result_port = self.get_tcp_port() - if not self.is_port_free(result_port, socket.SOCK_DGRAM): + if not self.is_port_free(result_port, socket.SOCK_DGRAM): self.release_port(result_port) # Don't try to _capture_port(), it's already captured in the get_tcp_port() return result_port @@ -163,7 +163,7 @@ class PortManager(object): with self._lock: return self._capture_port_no_lock(port, sock_type) - def is_port_free(self, port, sock_type=socket.SOCK_STREAM): + def is_port_free(self, port, sock_type=socket.SOCK_STREAM): sock = socket.socket(socket.AF_INET6, sock_type) try: sock.bind(('::', port)) @@ -189,14 +189,14 @@ class PortManager(object): filelock = library.python.filelock.FileLock(os.path.join(self._sync_dir, str(port))) if not filelock.acquire(blocking=False): return False - if self.is_port_free(port, sock_type): + if self.is_port_free(port, sock_type): self._filelocks[port] = filelock return True else: filelock.release() return False - if self.is_port_free(port, sock_type): + if self.is_port_free(port, sock_type): self._filelocks[port] = filelock return True if filelock: diff --git a/util/system/cpu_id.cpp b/util/system/cpu_id.cpp index 70157f3bac..598c71f4d9 100644 --- a/util/system/cpu_id.cpp +++ b/util/system/cpu_id.cpp @@ -139,23 +139,23 @@ bool NX86::HaveOSXSAVE() noexcept { } bool NX86::HaveAVX() noexcept { -#if defined(_x86_) - // http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf +#if defined(_x86_) + // http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf // https://bugs.chromium.org/p/chromium/issues/detail?id=375968 return HaveOSXSAVE() // implies HaveXSAVE() && (_xgetbv(0) & 6u) == 6u // XMM state and YMM state are enabled by OS && ((TX86CpuInfo(0x1).ECX >> 28) & 1u); // AVX bit #else - return false; + return false; #endif } bool NX86::HaveFMA() noexcept { - return HaveAVX() && ((TX86CpuInfo(0x1).ECX >> 12) & 1u); -} - + return HaveAVX() && ((TX86CpuInfo(0x1).ECX >> 12) & 1u); +} + bool NX86::HaveAVX2() noexcept { - return HaveAVX() && ((TX86CpuInfo(0x7, 0).EBX >> 5) & 1u); + return HaveAVX() && ((TX86CpuInfo(0x7, 0).EBX >> 5) & 1u); } bool NX86::HaveBMI1() noexcept { @@ -167,80 +167,80 @@ bool NX86::HaveBMI2() noexcept { } bool NX86::HaveAVX512F() noexcept { -#if defined(_x86_) - // https://software.intel.com/en-us/articles/how-to-detect-knl-instruction-support +#if defined(_x86_) + // https://software.intel.com/en-us/articles/how-to-detect-knl-instruction-support return HaveOSXSAVE() // implies HaveXSAVE() && (_xgetbv(0) & 6u) == 6u // XMM state and YMM state are enabled by OS && ((_xgetbv(0) >> 5) & 7u) == 7u // ZMM state is enabled by OS && TX86CpuInfo(0x0).EAX >= 0x7 // leaf 7 is present && ((TX86CpuInfo(0x7).EBX >> 16) & 1u); // AVX512F bit -#else - return false; -#endif +#else + return false; +#endif } bool NX86::HaveAVX512DQ() noexcept { - return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 17) & 1u); + return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 17) & 1u); } bool NX86::HaveRDSEED() noexcept { - return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 18) & 1u); + return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 18) & 1u); } bool NX86::HaveADX() noexcept { - return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 19) & 1u); + return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 19) & 1u); } bool NX86::HaveAVX512IFMA() noexcept { - return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 21) & 1u); + return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 21) & 1u); } bool NX86::HavePCOMMIT() noexcept { - return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 22) & 1u); + return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 22) & 1u); } bool NX86::HaveCLFLUSHOPT() noexcept { - return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 23) & 1u); + return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 23) & 1u); } bool NX86::HaveCLWB() noexcept { - return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 24) & 1u); + return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 24) & 1u); } bool NX86::HaveAVX512PF() noexcept { - return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 26) & 1u); + return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 26) & 1u); } bool NX86::HaveAVX512ER() noexcept { - return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 27) & 1u); + return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 27) & 1u); } bool NX86::HaveAVX512CD() noexcept { - return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 28) & 1u); + return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 28) & 1u); } bool NX86::HaveSHA() noexcept { - return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 29) & 1u); + return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).EBX >> 29) & 1u); } bool NX86::HaveAVX512BW() noexcept { - return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 30) & 1u); + return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 30) & 1u); } bool NX86::HaveAVX512VL() noexcept { - return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 31) & 1u); + return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).EBX >> 31) & 1u); } bool NX86::HavePREFETCHWT1() noexcept { - return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).ECX >> 0) & 1u); + return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x7, 0).ECX >> 0) & 1u); } bool NX86::HaveAVX512VBMI() noexcept { - return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).ECX >> 1) & 1u); + return HaveAVX512F() && ((TX86CpuInfo(0x7, 0).ECX >> 1) & 1u); } bool NX86::HaveRDRAND() noexcept { - return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x1).ECX >> 30) & 1u); + return TX86CpuInfo(0x0).EAX >= 0x7 && ((TX86CpuInfo(0x1).ECX >> 30) & 1u); } const char* CpuBrand(ui32* store) noexcept { diff --git a/util/system/cpu_id_ut.cpp b/util/system/cpu_id_ut.cpp index 743a1a5bfa..68f1f8aac7 100644 --- a/util/system/cpu_id_ut.cpp +++ b/util/system/cpu_id_ut.cpp @@ -163,10 +163,10 @@ void ExecutePOPCNTInstruction() { } void ExecuteBMI1Instruction() { - __asm__ __volatile__("tzcnt %%eax, %%eax\n" + __asm__ __volatile__("tzcnt %%eax, %%eax\n" : : - : "eax"); + : "eax"); } void ExecuteBMI2Instruction() { diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h index ccfedc167a..ab523631e4 100644 --- a/util/thread/lfqueue.h +++ b/util/thread/lfqueue.h @@ -69,7 +69,7 @@ class TLockFreeQueue: public TNonCopyable { n = keepNext; } } - + alignas(64) TRootNode* volatile JobQueue; alignas(64) volatile TAtomic FreememCounter; alignas(64) volatile TAtomic FreeingTaskCounter; |