Skip to content

Commit

Permalink
Partially revert 53b8f12 on linux (#460) (#467)
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.

(cherry picked from commit cf95b33)
  • Loading branch information
wenju-he authored Jul 31, 2023
1 parent cf77b19 commit 9606e0a
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 @@ -199,7 +199,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 @@ -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<true> compileGuard{*compileMutex};
#endif
// Parse options
optionsParser.processOptions(pszOptions, pszOptionsEx);

Expand Down Expand Up @@ -329,6 +334,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 9606e0a

Please sign in to comment.