From 57df1b348f75d4698e60f9dd6497fc3ef8b09039 Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Wed, 18 Dec 2024 07:25:37 +0000 Subject: [PATCH] SWDEV-508982 - [6.4 Preview] - Handle hipMemPoolCreate, hipMemPoolDestory & hipDeviceSetMemPool during stream capture. Change-Id: Ia195442041803896df814798c3d2053c0ba7770c --- hipamd/src/hip_mempool.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hipamd/src/hip_mempool.cpp b/hipamd/src/hip_mempool.cpp index bb63edc9f7..ec9d58cf85 100644 --- a/hipamd/src/hip_mempool.cpp +++ b/hipamd/src/hip_mempool.cpp @@ -59,7 +59,11 @@ hipError_t hipDeviceSetMemPool(int device, hipMemPool_t mem_pool) { if ((mem_pool == nullptr) || (device >= g_devices.size())) { HIP_RETURN(hipErrorInvalidValue); } - + if (DEBUG_HIP_7_PREVIEW & amd::CHANGE_HIP_STREAM_CAPTURE_API) { + if (!hip::tls.capture_streams_.empty() || !g_captureStreams.empty()) { + HIP_RETURN(hipErrorStreamCaptureUnsupported); + } + } auto poolDevice = reinterpret_cast(mem_pool)->Device(); if (poolDevice->deviceId() != device) { HIP_RETURN(hipErrorInvalidDevice); @@ -328,7 +332,11 @@ hipError_t hipMemPoolCreate(hipMemPool_t* mem_pool, const hipMemPoolProps* pool_ if (IS_WINDOWS && pool_props->handleTypes == hipMemHandleTypePosixFileDescriptor) { HIP_RETURN(hipErrorInvalidValue); } - + if (DEBUG_HIP_7_PREVIEW & amd::CHANGE_HIP_STREAM_CAPTURE_API) { + if (!hip::tls.capture_streams_.empty() || !g_captureStreams.empty()) { + HIP_RETURN(hipErrorStreamCaptureUnsupported); + } + } auto device = g_devices[pool_props->location.id]; auto pool = new hip::MemoryPool(device, pool_props); if (pool == nullptr) { @@ -344,6 +352,11 @@ hipError_t hipMemPoolDestroy(hipMemPool_t mem_pool) { if (mem_pool == nullptr) { HIP_RETURN(hipErrorInvalidValue); } + if (DEBUG_HIP_7_PREVIEW & amd::CHANGE_HIP_STREAM_CAPTURE_API) { + if (!hip::tls.capture_streams_.empty() || !g_captureStreams.empty()) { + HIP_RETURN(hipErrorStreamCaptureUnsupported); + } + } hip::MemoryPool* hip_mem_pool = reinterpret_cast(mem_pool); if (!IsMemPoolValid(hip_mem_pool)) {