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 authored Jun 12, 2023
1 parent 53b8f12 commit cf95b33
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 @@ -212,7 +212,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 @@ -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<true> compileGuard{*compileMutex};
#endif
// Parse options
optionsParser.processOptions(pszOptions, pszOptionsEx);

Expand Down Expand Up @@ -342,6 +347,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 cf95b33

Please sign in to comment.