From cf95b338d14685e4f3402ab1828bef31d48f1fd6 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. --- common_clang.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common_clang.cpp b/common_clang.cpp index 426235ba..4b2579cc 100644 --- a/common_clang.cpp +++ b/common_clang.cpp @@ -212,7 +212,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 @@ -224,6 +226,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); @@ -342,6 +347,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders, err_ostream.flush(); } { +#ifndef _WIN32 + llvm::sys::SmartScopedLock compileGuard{*compileMutex}; +#endif if (pBinaryResult) { *pBinaryResult = pResult.release(); }