Skip to content

Commit

Permalink
Partially revert 53b8f12 on linux (#460) (#462)
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 Jun 13, 2023
1 parent a7c9499 commit 6d22310
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions opencl_clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,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 @@ -220,6 +222,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 @@ -336,6 +341,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 6d22310

Please sign in to comment.