Skip to content

Commit

Permalink
Partially revert 53b8f12 on linux (intel#460)
Browse files Browse the repository at this point in the history
The issue in 53b8f12 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.
  • Loading branch information
wenju-he committed Jul 28, 2023
1 parent c16a7ad commit 0d495e5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common_clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders,
CommonClangInitialize();

try {
#ifdef _WIN32
llvm::sys::SmartScopedLock<true> compileGuard{*compileMutex};
#endif
std::unique_ptr<OCLFEBinaryResult> pResult(new OCLFEBinaryResult());

// Create the clang compiler
Expand All @@ -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<true> compileGuard{*compileMutex};
#endif
// Parse options
optionsParser.processOptions(pszOptions, pszOptionsEx);

Expand Down Expand Up @@ -357,6 +362,9 @@ Compile(const char *pszProgramSource, const char **pInputHeaders,
err_ostream.flush();
}
{
#ifndef _WIN32
llvm::sys::SmartScopedLock<true> compileGuard{*compileMutex};
#endif
if (pBinaryResult) {
*pBinaryResult = pResult.release();
}
Expand Down

0 comments on commit 0d495e5

Please sign in to comment.