File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -318,6 +318,9 @@ class program_impl {
318
318
// / Tells whether a specialization constant has been set for this program.
319
319
bool hasSetSpecConstants () const { return !SpecConstRegistry.empty (); }
320
320
321
+ // / \return true if caching is allowed for this program.
322
+ bool is_cacheable () const { return MProgramAndKernelCachingAllowed; }
323
+
321
324
private:
322
325
// Deligating Constructor used in Implementation.
323
326
program_impl (ContextImplPtr Context, pi_native_handle InteropProgram,
@@ -368,9 +371,6 @@ class program_impl {
368
371
// / \return a vector of devices managed by the plugin.
369
372
vector_class<RT::PiDevice> get_pi_devices () const ;
370
373
371
- // / \return true if caching is allowed for this program.
372
- bool is_cacheable () const { return MProgramAndKernelCachingAllowed; }
373
-
374
374
// / \param Options is a string containing OpenCL C build options.
375
375
// / \return true if caching is allowed for this program and build options.
376
376
static bool is_cacheable_with_options (const string_class &Options) {
Original file line number Diff line number Diff line change @@ -1804,6 +1804,18 @@ cl_int ExecCGCommand::enqueueImp() {
1804
1804
assert (ExecKernel->MSyclKernel ->get_info <info::kernel::context>() ==
1805
1805
Context);
1806
1806
Kernel = ExecKernel->MSyclKernel ->getHandleRef ();
1807
+
1808
+ auto SyclProg = detail::getSyclObjImpl (
1809
+ ExecKernel->MSyclKernel ->get_info <info::kernel::program>());
1810
+ if (SyclProg->is_cacheable ()) {
1811
+ RT::PiKernel FoundKernel = nullptr ;
1812
+ std::tie (FoundKernel, KernelMutex) =
1813
+ detail::ProgramManager::getInstance ().getOrCreateKernel (
1814
+ ExecKernel->MOSModuleHandle ,
1815
+ ExecKernel->MSyclKernel ->get_info <info::kernel::context>(),
1816
+ ExecKernel->MKernelName , SyclProg.get ());
1817
+ assert (FoundKernel == Kernel);
1818
+ }
1807
1819
} else {
1808
1820
std::tie (Kernel, KernelMutex) =
1809
1821
detail::ProgramManager::getInstance ().getOrCreateKernel (
@@ -1873,6 +1885,7 @@ cl_int ExecCGCommand::enqueueImp() {
1873
1885
1874
1886
pi_result Error = PI_SUCCESS;
1875
1887
if (KernelMutex != nullptr ) {
1888
+ // For cacheable kernels, we use per-kernel mutex
1876
1889
std::lock_guard<std::mutex> Lock (*KernelMutex);
1877
1890
Error = SetKernelParamsAndLaunch ();
1878
1891
} else {
You can’t perform that action at this time.
0 commit comments