Skip to content

Commit 1e137bb

Browse files
committed
wip
1 parent 51b4dcc commit 1e137bb

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

unified-runtime/source/adapters/cuda/context.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ urContextCreate(uint32_t DeviceCount, const ur_device_handle_t *phDevices,
4545
try {
4646
ContextPtr = std::unique_ptr<ur_context_handle_t_>(
4747
new ur_context_handle_t_{phDevices, DeviceCount});
48+
ContextPtr->RefCount.retain();
4849
*phContext = ContextPtr.release();
4950
} catch (ur_result_t Err) {
5051
return Err;
@@ -83,7 +84,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextGetInfo(
8384

8485
UR_APIEXPORT ur_result_t UR_APICALL
8586
urContextRelease(ur_context_handle_t hContext) {
86-
if (!hContext->RefCount.release()) {
87+
if (hContext->RefCount.release()) {
8788
return UR_RESULT_SUCCESS;
8889
}
8990
hContext->invokeExtendedDeleters();

unified-runtime/source/adapters/cuda/context.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct ur_context_handle_t_ : ur::cuda::handle_base {
9797
umf_memory_pool_handle_t MemoryPoolHost = nullptr;
9898

9999
ur_context_handle_t_(const ur_device_handle_t *Devs, uint32_t NumDevices)
100-
: handle_base(), Devices{Devs, Devs + NumDevices}, RefCount{1} {
100+
: handle_base(), Devices{Devs, Devs + NumDevices}, RefCount(0) {
101101
// Create UMF CUDA memory provider for the host memory
102102
// (UMF_MEMORY_TYPE_HOST) from any device (Devices[0] is used here, because
103103
// it is guaranteed to exist).

unified-runtime/source/adapters/cuda/kernel.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ struct ur_kernel_handle_t_ : ur::cuda::handle_base {
256256
ur_context_handle_t Context)
257257
: handle_base(), Function{Func},
258258
FunctionWithOffsetParam{FuncWithOffsetParam}, Name{Name},
259-
Context{Context}, Program{Program}, RefCount{1} {
259+
Context{Context}, Program{Program} {
260260
urProgramRetain(Program);
261261
urContextRetain(Context);
262262

unified-runtime/source/adapters/cuda/memory.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,17 @@ struct ur_mem_handle_t_ : ur::cuda::handle_base {
345345
/// Constructs the UR mem handler for a non-typed allocation ("buffer")
346346
ur_mem_handle_t_(ur_context_handle_t Ctxt, ur_mem_flags_t MemFlags,
347347
BufferMem::AllocMode Mode, void *HostPtr, size_t Size)
348-
: handle_base(), Context{Ctxt}, RefCount{1}, MemFlags{MemFlags},
348+
: handle_base(), Context{Ctxt}, MemFlags{MemFlags},
349349
HaveMigratedToDeviceSinceLastWrite(Context->Devices.size(), false),
350350
Mem{std::in_place_type<BufferMem>, Ctxt, this, Mode, HostPtr, Size} {
351351
urContextRetain(Context);
352352
};
353353

354354
// Subbuffer constructor
355355
ur_mem_handle_t_(ur_mem_handle_t Parent, size_t SubBufferOffset)
356-
: handle_base(), Context{Parent->Context}, RefCount{1},
357-
MemFlags{Parent->MemFlags}, HaveMigratedToDeviceSinceLastWrite(
358-
Parent->Context->Devices.size(), false),
356+
: handle_base(), Context{Parent->Context}, MemFlags{Parent->MemFlags},
357+
HaveMigratedToDeviceSinceLastWrite(Parent->Context->Devices.size(),
358+
false),
359359
Mem{BufferMem{std::get<BufferMem>(Parent->Mem)}} {
360360
auto &SubBuffer = std::get<BufferMem>(Mem);
361361
SubBuffer.Parent = Parent;
@@ -376,7 +376,7 @@ struct ur_mem_handle_t_ : ur::cuda::handle_base {
376376
ur_mem_handle_t_(ur_context_handle_t Ctxt, ur_mem_flags_t MemFlags,
377377
ur_image_format_t ImageFormat, ur_image_desc_t ImageDesc,
378378
void *HostPtr)
379-
: handle_base(), Context{Ctxt}, RefCount{1}, MemFlags{MemFlags},
379+
: handle_base(), Context{Ctxt}, MemFlags{MemFlags},
380380
HaveMigratedToDeviceSinceLastWrite(Context->Devices.size(), false),
381381
Mem{std::in_place_type<SurfaceMem>,
382382
Ctxt,

unified-runtime/source/adapters/cuda/program.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ struct ur_program_handle_t_ : ur::cuda::handle_base {
5050

5151
ur_program_handle_t_(ur_context_handle_t Context, ur_device_handle_t Device)
5252
: handle_base(), Module{nullptr}, Binary{}, BinarySizeInBytes{0},
53-
RefCount{1}, Context{Context}, Device{Device},
54-
KernelReqdWorkGroupSizeMD{}, KernelMaxWorkGroupSizeMD{},
55-
KernelMaxLinearWorkGroupSizeMD{}, KernelReqdSubGroupSizeMD{} {
53+
Context{Context}, Device{Device}, KernelReqdWorkGroupSizeMD{},
54+
KernelMaxWorkGroupSizeMD{}, KernelMaxLinearWorkGroupSizeMD{},
55+
KernelReqdSubGroupSizeMD{} {
5656
urContextRetain(Context);
5757

5858
// When the log is queried we use strnlen(InfoLog), so it needs to be

unified-runtime/source/adapters/cuda/sampler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct ur_sampler_handle_t_ : ur::cuda::handle_base {
3434
ur_context_handle_t Context;
3535

3636
ur_sampler_handle_t_(ur_context_handle_t Context)
37-
: handle_base(), RefCount(1), Props(0), MinMipmapLevelClamp(0.0f),
37+
: handle_base(), Props(0), MinMipmapLevelClamp(0.0f),
3838
MaxMipmapLevelClamp(0.0f), MaxAnisotropy(0.0f), Context(Context) {}
3939

4040
ur_bool_t isNormalizedCoords() const noexcept {

0 commit comments

Comments
 (0)