zuochunwei commented on a change in pull request #8042: URL: https://github.com/apache/incubator-doris/pull/8042#discussion_r805559865
########## File path: be/src/service/doris_main.cpp ########## @@ -74,6 +78,194 @@ static void thrift_output(const char* x) { } // namespace doris +// These code is referenced from clickhouse +// It is used to check the SIMD instructions +enum class InstructionFail +{ + NONE = 0, + SSE3 = 1, + SSSE3 = 2, + SSE4_1 = 3, + SSE4_2 = 4, + POPCNT = 5, + AVX = 6, + AVX2 = 7, + AVX512 = 8 +}; + +#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) + +auto instruction_fail_to_string(InstructionFail fail) +{ + switch (fail) + { +#define ret(x) return std::make_tuple(STDERR_FILENO, x, ARRAY_SIZE(x) - 1) + case InstructionFail::NONE: + ret("NONE"); + case InstructionFail::SSE3: + ret("SSE3"); + case InstructionFail::SSSE3: + ret("SSSE3"); + case InstructionFail::SSE4_1: + ret("SSE4.1"); + case InstructionFail::SSE4_2: + ret("SSE4.2"); + case InstructionFail::POPCNT: + ret("POPCNT"); + case InstructionFail::AVX: + ret("AVX"); + case InstructionFail::AVX2: + ret("AVX2"); + case InstructionFail::AVX512: + ret("AVX512"); + } + __builtin_unreachable(); +} + + +sigjmp_buf jmpbuf; + +[[noreturn]] void sig_ill_check_handler(int, siginfo_t *, void *) +{ + siglongjmp(jmpbuf, 1); +} + +/// Check if necessary SSE extensions are available by trying to execute some sse instructions. +/// If instruction is unavailable, SIGILL will be sent by kernel. +void check_required_instructions_impl(volatile InstructionFail & fail) Review comment: 因为用了sigsetjmp和siglongjmp,在异步信号的环境下,使用volatile确保每次都是都从内存里读取fail变量的值,而不用寄存器里的缓存吧 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org