diff options
author | Dmitry Baksheev <dbakshee@yandex.ru> | 2022-02-10 16:48:12 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:12 +0300 |
commit | 0e38f1d675a0b3d02016acf698e8d04c0b224047 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 | |
parent | 17fe552c0aa936de030b2b72934d9688ab9bb1c6 (diff) | |
download | ydb-0e38f1d675a0b3d02016acf698e8d04c0b224047.tar.gz |
Restoring authorship annotation for Dmitry Baksheev <dbakshee@yandex.ru>. Commit 2 of 2.
-rw-r--r-- | build/plugins/_unpickler.py | 8 | ||||
-rw-r--r-- | build/scripts/compile_cuda.py | 38 | ||||
-rw-r--r-- | build/scripts/link_dyn_lib.py | 6 | ||||
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h | 6 | ||||
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/type_traits | 2 | ||||
-rw-r--r-- | contrib/libs/cxxsupp/openmp/kmp_runtime.c | 2 | ||||
-rw-r--r-- | contrib/tools/ya.make | 2 | ||||
-rw-r--r-- | library/cpp/lfalloc/lf_allocX64.h | 6 | ||||
-rw-r--r-- | library/cpp/threading/local_executor/local_executor.h | 66 | ||||
-rw-r--r-- | library/cpp/threading/local_executor/ut/local_executor_ut.cpp | 90 |
10 files changed, 113 insertions, 113 deletions
diff --git a/build/plugins/_unpickler.py b/build/plugins/_unpickler.py index 721f9f58e4..e01e7b3118 100644 --- a/build/plugins/_unpickler.py +++ b/build/plugins/_unpickler.py @@ -4,10 +4,10 @@ sys.dont_write_bytecode = True import argparse import base64 -try: - import cPickle as pickle -except Exception: - import pickle +try: + import cPickle as pickle +except Exception: + import pickle import _common as common diff --git a/build/scripts/compile_cuda.py b/build/scripts/compile_cuda.py index 00486b4926..c0bec50b2a 100644 --- a/build/scripts/compile_cuda.py +++ b/build/scripts/compile_cuda.py @@ -2,7 +2,7 @@ import sys import subprocess import os import collections -import re +import re import tempfile @@ -72,17 +72,17 @@ def main(): for prefix in skip_prefix_list: cflags = [i for i in cflags if not i.startswith(prefix)] - if not is_clang(command): - def good(arg): - if arg.startswith('--target='): - return False - if arg in ('-Wno-exceptions', - '-Wno-inconsistent-missing-override'): - return False - return True - cflags = filter(good, cflags) - - cpp_args = [] + if not is_clang(command): + def good(arg): + if arg.startswith('--target='): + return False + if arg in ('-Wno-exceptions', + '-Wno-inconsistent-missing-override'): + return False + return True + cflags = filter(good, cflags) + + cpp_args = [] compiler_args = [] # NVCC requires particular MSVC versions which may differ from the version @@ -104,10 +104,10 @@ def main(): if not value: value = cflags_queue.popleft() if arg[1] == 'I': - cpp_args.append('-I{}'.format(value)) + cpp_args.append('-I{}'.format(value)) elif arg[1] == 'B': # todo: delete "B" flag check when cuda stop to use gcc pass - continue + continue match = re.match(r'[-/]D(.*)', arg) if match: @@ -118,13 +118,13 @@ def main(): if vc_root and define.startswith('Y_MSVC_INCLUDE'): define = os.path.expandvars('Y_MSVC_INCLUDE={}/include'.format(vc_root)) cpp_args.append('-D' + define.replace('\\', '/')) - continue + continue - compiler_args.append(arg) + compiler_args.append(arg) - command += cpp_args - if compiler_args: - command += ['--compiler-options', ','.join(compiler_args)] + command += cpp_args + if compiler_args: + command += ['--compiler-options', ','.join(compiler_args)] # --keep is necessary to prevent nvcc from embedding nvcc pid in generated # symbols. It makes nvcc use the original file name as the prefix in the diff --git a/build/scripts/link_dyn_lib.py b/build/scripts/link_dyn_lib.py index f0510e0756..23487f5c1e 100644 --- a/build/scripts/link_dyn_lib.py +++ b/build/scripts/link_dyn_lib.py @@ -88,7 +88,7 @@ def fix_gnu_param(arch, ex): else: d[item['lang']].append(item['sym']) - with tempfile.NamedTemporaryFile(mode='wt', delete=False) as f: + with tempfile.NamedTemporaryFile(mode='wt', delete=False) as f: if version: f.write('{} {{\nglobal:\n'.format(version)) else: @@ -205,8 +205,8 @@ if __name__ == '__main__': sys.exit(proc.returncode) if opts.soname and opts.soname != opts.target: - if os.path.exists(opts.soname): - os.unlink(opts.soname) + if os.path.exists(opts.soname): + os.unlink(opts.soname) os.link(opts.target, opts.soname) diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h b/contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h index ef0c34825e..e32bcf9073 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h +++ b/contrib/libs/cxxsupp/libcxx/include/__support/win32/atomic_win32.h @@ -29,7 +29,7 @@ namespace __atomic { template <typename _Tp> _Tp __create(); template <typename _Tp, typename _Td> -enable_if_t<sizeof(__create<_Tp>() = __create<_Td>()), char> +enable_if_t<sizeof(__create<_Tp>() = __create<_Td>()), char> __test_atomic_assignable(int); template <typename _Tp, typename _Up> __two __test_atomic_assignable(...); @@ -92,7 +92,7 @@ static inline _Out __msvc_cast(_Tp __val) { char* from = reinterpret_cast<char*>(&__val); while (to != end) { *to++ = *from++; - } + } return __result; } @@ -210,7 +210,7 @@ static inline void __msvc_atomic_store64(volatile __int64* __a, __int64 __val, _InterlockedExchange64(__a, __val); #endif } -#endif +#endif } template <typename _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/type_traits b/contrib/libs/cxxsupp/libcxx/include/type_traits index db776c17c0..8c91522074 100644 --- a/contrib/libs/cxxsupp/libcxx/include/type_traits +++ b/contrib/libs/cxxsupp/libcxx/include/type_traits @@ -2757,7 +2757,7 @@ inline constexpr bool is_destructible_v = __is_destructible(_Tp); #if defined(_LIBCPP_COMPILER_MSVC) template <typename _Tp> -struct is_destructible : integral_constant<bool, __is_destructible(_Tp)> {}; +struct is_destructible : integral_constant<bool, __is_destructible(_Tp)> {}; #else diff --git a/contrib/libs/cxxsupp/openmp/kmp_runtime.c b/contrib/libs/cxxsupp/openmp/kmp_runtime.c index b112de83ca..4749934808 100644 --- a/contrib/libs/cxxsupp/openmp/kmp_runtime.c +++ b/contrib/libs/cxxsupp/openmp/kmp_runtime.c @@ -6212,7 +6212,7 @@ __kmp_register_library_startup( // Attention! Falling to the next case. That's intentional. case 1 : { // Neighbor is alive. // Check it is allowed. - char * duplicate_ok = __kmp_env_get( "KMP_DUPLICATE_LIB_OK" ); + char * duplicate_ok = __kmp_env_get( "KMP_DUPLICATE_LIB_OK" ); if ( ! __kmp_str_match_true( duplicate_ok ) ) { // That's not allowed. Issue fatal error. __kmp_msg( diff --git a/contrib/tools/ya.make b/contrib/tools/ya.make index caad422657..750911c587 100644 --- a/contrib/tools/ya.make +++ b/contrib/tools/ya.make @@ -37,7 +37,7 @@ RECURSE( sancov sqlite3 swig - tf + tf tpce-benchmark tpch-benchmark tre diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index c0ed5ec169..fd2a906d6f 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -135,9 +135,9 @@ static bool EnableDefrag = true; template <class T> inline T* DoCas(T* volatile* target, T* exchange, T* compare) { -#if defined(__has_builtin) && __has_builtin(__sync_val_compare_and_swap) - return __sync_val_compare_and_swap(target, compare, exchange); -#elif defined(_WIN32) +#if defined(__has_builtin) && __has_builtin(__sync_val_compare_and_swap) + return __sync_val_compare_and_swap(target, compare, exchange); +#elif defined(_WIN32) #ifdef _64_ return (T*)_InterlockedCompareExchange64((__int64*)target, (__int64)exchange, (__int64)compare); #else diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h index dd75382ba1..c1c824f67c 100644 --- a/library/cpp/threading/local_executor/local_executor.h +++ b/library/cpp/threading/local_executor/local_executor.h @@ -21,11 +21,11 @@ namespace NPar { virtual void LocalExec(int id) = 0; }; - // Alternative and simpler way of describing a job for executor. Function argument has the - // same meaning as `id` in `ILocallyExecutable::LocalExec`. - // - using TLocallyExecutableFunction = std::function<void(int)>; - + // Alternative and simpler way of describing a job for executor. Function argument has the + // same meaning as `id` in `ILocallyExecutable::LocalExec`. + // + using TLocallyExecutableFunction = std::function<void(int)>; + class ILocalExecutor: public TNonCopyable { public: ILocalExecutor() = default; @@ -157,34 +157,34 @@ namespace NPar { ExecRange(BlockedLoopBody(params, body), 0, params.GetBlockCount(), flags); } - template <typename TBody> - inline void ExecRangeBlockedWithThrow(TBody&& body, int firstId, int lastId, int batchSizeOrZeroForAutoBatchSize, int flags) { - if (firstId >= lastId) { - return; - } - const int threadCount = Max(GetThreadCount(), 1); - const int batchSize = batchSizeOrZeroForAutoBatchSize - ? batchSizeOrZeroForAutoBatchSize - : (lastId - firstId + threadCount - 1) / threadCount; - const int batchCount = (lastId - firstId + batchSize - 1) / batchSize; - const int batchCountPerThread = (batchCount + threadCount - 1) / threadCount; - auto states = ExecRangeWithFutures( - [=](int threadId) { - for (int batchIdPerThread = 0; batchIdPerThread < batchCountPerThread; ++batchIdPerThread) { - int batchId = batchIdPerThread * threadCount + threadId; - int begin = firstId + batchId * batchSize; - int end = Min(begin + batchSize, lastId); - for (int i = begin; i < end; ++i) { - body(i); - } - } - }, - 0, threadCount, flags); - for (auto& state: states) { - state.GetValueSync(); // Re-throw exception if any. - } - } - + template <typename TBody> + inline void ExecRangeBlockedWithThrow(TBody&& body, int firstId, int lastId, int batchSizeOrZeroForAutoBatchSize, int flags) { + if (firstId >= lastId) { + return; + } + const int threadCount = Max(GetThreadCount(), 1); + const int batchSize = batchSizeOrZeroForAutoBatchSize + ? batchSizeOrZeroForAutoBatchSize + : (lastId - firstId + threadCount - 1) / threadCount; + const int batchCount = (lastId - firstId + batchSize - 1) / batchSize; + const int batchCountPerThread = (batchCount + threadCount - 1) / threadCount; + auto states = ExecRangeWithFutures( + [=](int threadId) { + for (int batchIdPerThread = 0; batchIdPerThread < batchCountPerThread; ++batchIdPerThread) { + int batchId = batchIdPerThread * threadCount + threadId; + int begin = firstId + batchId * batchSize; + int end = Min(begin + batchSize, lastId); + for (int i = begin; i < end; ++i) { + body(i); + } + } + }, + 0, threadCount, flags); + for (auto& state: states) { + state.GetValueSync(); // Re-throw exception if any. + } + } + template <typename TBody> static inline bool TryExecRangeSequentially(TBody&& body, int firstId, int lastId, int flags) { if (lastId == firstId) { diff --git a/library/cpp/threading/local_executor/ut/local_executor_ut.cpp b/library/cpp/threading/local_executor/ut/local_executor_ut.cpp index a169edc2ec..ac5737717c 100644 --- a/library/cpp/threading/local_executor/ut/local_executor_ut.cpp +++ b/library/cpp/threading/local_executor/ut/local_executor_ut.cpp @@ -324,48 +324,48 @@ Y_UNIT_TEST(NestedParallelExceptionsDoNotLeak) { } } ; - -Y_UNIT_TEST_SUITE(ExecLargeRangeWithThrow){ - - constexpr int LARGE_COUNT = 128 * (1 << 20); - - static auto IsValue(char v) { - return [=](char c) { return c == v; }; - } - - Y_UNIT_TEST(ExecLargeRangeNoExceptions) { - TVector<char> tasks(LARGE_COUNT); - - TLocalExecutor localExecutor; - localExecutor.RunAdditionalThreads(DefaultThreadsCount); - - localExecutor.ExecRangeBlockedWithThrow([&tasks](int i) { - tasks[i] = 1; - }, 0, tasks.size(), 0, TLocalExecutor::EFlags::WAIT_COMPLETE); - UNIT_ASSERT(AllOf(tasks, IsValue(1))); - - - localExecutor.ExecRangeBlockedWithThrow([&tasks](int i) { - tasks[i] += 1; - }, 0, tasks.size(), 128, TLocalExecutor::EFlags::WAIT_COMPLETE); - UNIT_ASSERT(AllOf(tasks, IsValue(2))); - } - - Y_UNIT_TEST(ExecLargeRangeWithException) { - TVector<char> tasks(LARGE_COUNT); - - TLocalExecutor localExecutor; - localExecutor.RunAdditionalThreads(DefaultThreadsCount); - - Fill(tasks.begin(), tasks.end(), 0); - UNIT_ASSERT_EXCEPTION( - localExecutor.ExecRangeBlockedWithThrow([&tasks](int i) { - tasks[i] += 1; - if (i == LARGE_COUNT / 2) { - throw TTestException(); - } - }, 0, tasks.size(), 0, TLocalExecutor::EFlags::WAIT_COMPLETE), - TTestException - ); - } -}; + +Y_UNIT_TEST_SUITE(ExecLargeRangeWithThrow){ + + constexpr int LARGE_COUNT = 128 * (1 << 20); + + static auto IsValue(char v) { + return [=](char c) { return c == v; }; + } + + Y_UNIT_TEST(ExecLargeRangeNoExceptions) { + TVector<char> tasks(LARGE_COUNT); + + TLocalExecutor localExecutor; + localExecutor.RunAdditionalThreads(DefaultThreadsCount); + + localExecutor.ExecRangeBlockedWithThrow([&tasks](int i) { + tasks[i] = 1; + }, 0, tasks.size(), 0, TLocalExecutor::EFlags::WAIT_COMPLETE); + UNIT_ASSERT(AllOf(tasks, IsValue(1))); + + + localExecutor.ExecRangeBlockedWithThrow([&tasks](int i) { + tasks[i] += 1; + }, 0, tasks.size(), 128, TLocalExecutor::EFlags::WAIT_COMPLETE); + UNIT_ASSERT(AllOf(tasks, IsValue(2))); + } + + Y_UNIT_TEST(ExecLargeRangeWithException) { + TVector<char> tasks(LARGE_COUNT); + + TLocalExecutor localExecutor; + localExecutor.RunAdditionalThreads(DefaultThreadsCount); + + Fill(tasks.begin(), tasks.end(), 0); + UNIT_ASSERT_EXCEPTION( + localExecutor.ExecRangeBlockedWithThrow([&tasks](int i) { + tasks[i] += 1; + if (i == LARGE_COUNT / 2) { + throw TTestException(); + } + }, 0, tasks.size(), 0, TLocalExecutor::EFlags::WAIT_COMPLETE), + TTestException + ); + } +}; |