From 9606e0a469afdad08d4dc832bf9994622de18a19 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Mon, 31 Jul 2023 18:36:59 +0800 Subject: [PATCH] Partially revert 53b8f126 on linux (#460) (#467) 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 d5f0362b..a153661f 100644 --- a/common_clang.cpp +++ b/common_clang.cpp @@ -199,7 +199,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 @@ -211,6 +213,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); @@ -329,6 +334,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, err_ostream.flush(); } { +#ifndef _WIN32 + llvm::sys::SmartScopedLock compileGuard{*compileMutex}; +#endif if (pBinaryResult) { *pBinaryResult = pResult.release(); }