From 1c41f908a9a3ed1ca4f68ef8b5a009f7853a01b6 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Mon, 12 Jun 2023 16:16:31 +0800 Subject: [PATCH] Partially revert 53b8f126 on linux (#460) The issue in 53b8f126 isn't observed on linux. This allows parallel execution of clang::ExecuteCompilerInvocation and parallel execution of llvm::writeSpirv. This improves performance of multi-threaded OpenCL tests on linux. (cherry picked from commit cf95b338d14685e4f3402ab1828bef31d48f1fd6) --- common_clang.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common_clang.cpp b/common_clang.cpp index f33f0918..d7ee616b 100644 --- a/common_clang.cpp +++ b/common_clang.cpp @@ -217,7 +217,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, CommonClangInitialize(); try { +#ifdef _WIN32 llvm::sys::SmartScopedLock compileGuard{*compileMutex}; +#endif std::unique_ptr pResult(new OCLFEBinaryResult()); // Create the clang compiler @@ -229,6 +231,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, // Prepare error log llvm::raw_string_ostream err_ostream(pResult->getLogRef()); { +#ifndef _WIN32 + llvm::sys::SmartScopedLock compileGuard{*compileMutex}; +#endif // Parse options optionsParser.processOptions(pszOptions, pszOptionsEx); @@ -357,6 +362,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, err_ostream.flush(); } { +#ifndef _WIN32 + llvm::sys::SmartScopedLock compileGuard{*compileMutex}; +#endif if (pBinaryResult) { *pBinaryResult = pResult.release(); }