From 3af3fe10defbca4b8f6fcfc754d8aa898da0f371 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Mon, 21 Mar 2022 16:14:02 -0400 Subject: [PATCH] SWDEV-307185 - Move memory allocation under device layer It can be too early to allocate memory at the begining of Device::create() under PAL Change-Id: I4bd76db7be3f6fb246243ea68022d8b0f860471d --- rocclr/device/device.cpp | 5 ----- rocclr/device/pal/paldevice.cpp | 5 +++++ rocclr/device/rocm/rocdevice.cpp | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/rocclr/device/device.cpp b/rocclr/device/device.cpp index 6fba96eb71..4ab49c40ad 100644 --- a/rocclr/device/device.cpp +++ b/rocclr/device/device.cpp @@ -522,11 +522,6 @@ bool Device::create(const Isa &isa) { if (nullptr == vaCacheMap_) { return false; } - if (amd::IS_HIP) { - // Allocate initial heap for device memory allocator - static constexpr size_t HeapBufferSize = 1024 * Ki; - heap_buffer_ = createMemory(HeapBufferSize); - } return true; } diff --git a/rocclr/device/pal/paldevice.cpp b/rocclr/device/pal/paldevice.cpp index e0f7cb6669..8f41e69c52 100644 --- a/rocclr/device/pal/paldevice.cpp +++ b/rocclr/device/pal/paldevice.cpp @@ -1151,6 +1151,11 @@ bool Device::initializeHeapResources() { return false; } xferQueue_->enableSyncedBlit(); + if (amd::IS_HIP) { + // Allocate initial heap for device memory allocator + static constexpr size_t HeapBufferSize = 1024 * Ki; + heap_buffer_ = createMemory(HeapBufferSize); + } } return true; } diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index 5591ef9d32..de73e7e9c7 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -784,6 +784,12 @@ bool Device::create() { } } + if (amd::IS_HIP) { + // Allocate initial heap for device memory allocator + static constexpr size_t HeapBufferSize = 1024 * Ki; + heap_buffer_ = createMemory(HeapBufferSize); + } + return true; }