From 0ef73d15c41eee2a76d0dd0733f3f45a2e310178 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 23 Jan 2020 16:13:57 -0500
Subject: [PATCH] P4 to Git Change 2062258 by cpaquot@cpaquot-ocl-lc-lnx on
2020/01/23 16:04:59
SWDEV-145570 - [hip] hipMallocManaged
Basic implementation of hipMallocManaged behaving like hipHostMalloc for hipMemAttachGlobal.
Return hipErrorInvalidValue for the hipMemAttachHost for now.
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/hip/hip_hcc.def.in#39 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_hcc.map.in#37 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_memory.cpp#97 edit
[ROCm/hip commit: 2fb1d6a60424686d4ed1b880eb728afcc2f9a158]
---
projects/hip/api/hip/hip_hcc.def.in | 1 +
projects/hip/api/hip/hip_hcc.map.in | 1 +
projects/hip/api/hip/hip_memory.cpp | 11 +++++++++++
3 files changed, 13 insertions(+)
diff --git a/projects/hip/api/hip/hip_hcc.def.in b/projects/hip/api/hip/hip_hcc.def.in
index fd51a5701a..54492eb48e 100644
--- a/projects/hip/api/hip/hip_hcc.def.in
+++ b/projects/hip/api/hip/hip_hcc.def.in
@@ -75,6 +75,7 @@ hipIpcOpenMemHandle
hipMalloc
hipMalloc3D
hipMalloc3DArray
+hipMallocManaged
hipArrayCreate
hipArray3DCreate
hipMallocArray
diff --git a/projects/hip/api/hip/hip_hcc.map.in b/projects/hip/api/hip/hip_hcc.map.in
index c0e2bf9458..554da1d41b 100644
--- a/projects/hip/api/hip/hip_hcc.map.in
+++ b/projects/hip/api/hip/hip_hcc.map.in
@@ -76,6 +76,7 @@ global:
hipMalloc;
hipMalloc3D;
hipMalloc3DArray;
+ hipMallocManaged;
hipArrayCreate;
hipArray3DCreate;
hipMallocArray;
diff --git a/projects/hip/api/hip/hip_memory.cpp b/projects/hip/api/hip/hip_memory.cpp
index 9cd5034eeb..a61b4d83e1 100644
--- a/projects/hip/api/hip/hip_memory.cpp
+++ b/projects/hip/api/hip/hip_memory.cpp
@@ -214,6 +214,17 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) {
HIP_RETURN(ihipMalloc(ptr, sizeBytes, ihipFlags));
}
+hipError_t hipMallocManaged(void** devPtr, size_t size,
+ unsigned int flags) {
+ HIP_INIT_API(hipMallocManaged, devPtr, size, flags);
+
+ if (flags != hipMemAttachGlobal) {
+ HIP_RETURN(hipErrorInvalidValue);
+ }
+
+ HIP_RETURN(ihipMalloc(devPtr, size, CL_MEM_SVM_FINE_GRAIN_BUFFER));
+}
+
hipError_t hipFree(void* ptr) {
HIP_INIT_API(hipFree, ptr);