Skip to content

Commit 168cb44

Browse files
committed
Set platform pointer during first allocation
Signed-off-by: Steffen Larsen <[email protected]>
1 parent b671e7b commit 168cb44

File tree

4 files changed

+5
-12
lines changed

4 files changed

+5
-12
lines changed

sycl/include/CL/sycl/detail/resource_pool.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,6 @@ class __SYCL_EXPORT ResourcePool {
178178
assert(MAllocCount == 0 && "Not all resources have returned to the pool.");
179179
}
180180

181-
/// Sets the platform of the resource pool.
182-
void setPlatform(const std::shared_ptr<platform_impl> &Platform) {
183-
assert(MPlatform == nullptr && "Platform of pool has already been set.");
184-
MPlatform = Platform;
185-
}
186-
187181
/// Returns true if the resource pool is enabled and false otherwise.
188182
///
189183
/// \return a boolean value specifying whether the pool is enabled.

sycl/source/detail/context_impl.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ context_impl::context_impl(const device &Device, async_handler AsyncHandler,
3030
: MAsyncHandler(AsyncHandler), MDevices(1, Device), MContext(nullptr),
3131
MPlatform(), MPropList(PropList), MHostContext(Device.is_host()) {
3232
MKernelProgramCache.setContextPtr(this);
33-
MAuxiliaryResourcePool.setPlatform(MPlatform);
3433
}
3534

3635
context_impl::context_impl(const std::vector<cl::sycl::device> Devices,
@@ -62,7 +61,6 @@ context_impl::context_impl(const std::vector<cl::sycl::device> Devices,
6261
}
6362

6463
MKernelProgramCache.setContextPtr(this);
65-
MAuxiliaryResourcePool.setPlatform(MPlatform);
6664
}
6765

6866
context_impl::context_impl(RT::PiContext PiContext, async_handler AsyncHandler,
@@ -101,7 +99,6 @@ context_impl::context_impl(RT::PiContext PiContext, async_handler AsyncHandler,
10199
getPlugin().call<PiApiKind::piContextRetain>(MContext);
102100
}
103101
MKernelProgramCache.setContextPtr(this);
104-
MAuxiliaryResourcePool.setPlatform(MPlatform);
105102
}
106103

107104
cl_context context_impl::get() const {

sycl/source/detail/resource_pool.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ ResourcePool::FreeEntry ResourcePool::getOrAllocateEntry(
4040
const size_t Size, const std::shared_ptr<context_impl> &ContextImplPtr,
4141
void *DataPtr, bool *IsNewEntry) {
4242
assert(Size && "Size must be greater than 0");
43-
assert(ContextImplPtr->getPlatformImpl() == MPlatform &&
44-
"Context platform does not match the resource pool platform.");
43+
4544
{
4645
std::lock_guard<std::mutex> Lock{MMutex};
4746

47+
// Store platform to allow future freeing.
48+
if (!MPlatform)
49+
MPlatform = ContextImplPtr->getPlatformImpl();
50+
4851
// Find the free entry with the smallest suitable size.
4952
auto FoundFreeEntry = MFreeEntries.upper_bound(Size - 1);
5053

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3951,7 +3951,6 @@
39513951
?setPitches@?$image_impl@$00@detail@sycl@cl@@AEAAXXZ
39523952
?setPitches@?$image_impl@$01@detail@sycl@cl@@AEAAXXZ
39533953
?setPitches@?$image_impl@$02@detail@sycl@cl@@AEAAXXZ
3954-
?setPlatform@ResourcePool@detail@sycl@cl@@QEAAXAEBV?$shared_ptr@Vplatform_impl@detail@sycl@cl@@@std@@@Z
39553954
?setStateExplicitKernelBundle@handler@sycl@cl@@AEAAXXZ
39563955
?setStateSpecConstSet@handler@sycl@cl@@AEAAXXZ
39573956
?setType@handler@sycl@cl@@AEAAXW4CGTYPE@CG@detail@23@@Z

0 commit comments

Comments
 (0)