SWDEV-311271 - Correct the error codes in mempool
Change-Id: Iacf8ad2cc454dfe53ccdb47c08d871b24ecf4107
[ROCm/clr commit: 1d8562eb7d]
This commit is contained in:
@@ -303,8 +303,13 @@ hipError_t hipMemPoolCreate(hipMemPool_t* mem_pool, const hipMemPoolProps* pool_
|
||||
(pool_props->location.id >= g_devices.size())) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
if (IS_WINDOWS && pool_props->handleTypes == hipMemHandleTypePosixFileDescriptor) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
auto device = g_devices[pool_props->location.id];
|
||||
auto pool = new hip::MemoryPool(device, pool_props->handleTypes != hipMemHandleTypeNone);
|
||||
auto pool = new hip::MemoryPool(device, pool_props);
|
||||
if (pool == nullptr) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
@@ -376,11 +381,14 @@ hipError_t hipMemPoolExportToShareableHandle(
|
||||
hipMemAllocationHandleType handle_type,
|
||||
unsigned int flags) {
|
||||
HIP_INIT_API(hipMemPoolExportToShareableHandle, shared_handle, mem_pool, handle_type, flags);
|
||||
if (mem_pool == nullptr || shared_handle == nullptr || flags == -1) {
|
||||
if (mem_pool == nullptr || shared_handle == nullptr || flags != 0) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
auto mpool = reinterpret_cast<hip::MemoryPool*>(mem_pool);
|
||||
if ((handle_type != mpool->Properties().handleTypes) || (handle_type == hipMemHandleTypeNone)) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
auto handle = mpool->Export();
|
||||
if (!handle) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
@@ -397,7 +405,11 @@ hipError_t hipMemPoolImportFromShareableHandle(
|
||||
hipMemAllocationHandleType handle_type,
|
||||
unsigned int flags) {
|
||||
HIP_INIT_API(hipMemPoolImportFromShareableHandle, mem_pool, shared_handle, handle_type, flags);
|
||||
if (mem_pool == nullptr || shared_handle == nullptr || flags == -1) {
|
||||
if (mem_pool == nullptr || shared_handle == nullptr || flags != 0) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
if (handle_type == hipMemHandleTypeNone) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ class MemoryPool : public amd::ReferenceCountedObject {
|
||||
SharedAccess access_[kMaxMgpuAccess]; //!< The list of devices for access
|
||||
};
|
||||
|
||||
MemoryPool(hip::Device* device, bool interprocess = false)
|
||||
MemoryPool(hip::Device* device, const hipMemPoolProps* props = nullptr)
|
||||
: busy_heap_(device),
|
||||
free_heap_(device),
|
||||
lock_pool_ops_("Pool operations", true),
|
||||
@@ -208,7 +208,16 @@ class MemoryPool : public amd::ReferenceCountedObject {
|
||||
state_.event_dependencies_ = 1;
|
||||
state_.opportunistic_ = 1;
|
||||
state_.internal_dependencies_ = 1;
|
||||
state_.interprocess_ = interprocess;
|
||||
if (props != nullptr) {
|
||||
properties_ = *props;
|
||||
} else {
|
||||
properties_ = {.allocType = hipMemAllocationTypePinned,
|
||||
.handleTypes = hipMemHandleTypeNone,
|
||||
.location = {.type = hipMemLocationTypeDevice, .id = device_->deviceId()},
|
||||
.win32SecurityAttributes = nullptr,
|
||||
.reserved = {}};
|
||||
}
|
||||
state_.interprocess_ = properties_.handleTypes != hipMemHandleTypeNone;
|
||||
}
|
||||
|
||||
virtual ~MemoryPool() {
|
||||
@@ -282,6 +291,9 @@ class MemoryPool : public amd::ReferenceCountedObject {
|
||||
/// Imports memory pool from an OS specific handle
|
||||
bool Import(amd::Os::FileDesc handle);
|
||||
|
||||
/// Returns properties of this memory pool
|
||||
const hipMemPoolProps& Properties() const { return properties_; }
|
||||
|
||||
/// Accessors for the pool state
|
||||
bool EventDependencies() const { return (state_.event_dependencies_) ? true : false; }
|
||||
bool Opportunistic() const { return (state_.opportunistic_) ? true : false; }
|
||||
@@ -308,7 +320,8 @@ class MemoryPool : public amd::ReferenceCountedObject {
|
||||
uint32_t value_;
|
||||
} state_;
|
||||
|
||||
amd::Monitor lock_pool_ops_; //!< Access to the pool must be lock protected
|
||||
hipMemPoolProps properties_; //!< Properties of the memory pool
|
||||
amd::Monitor lock_pool_ops_; //!< Access to the pool must be lock protected
|
||||
std::map<hip::Device*, hipMemAccessFlags> access_map_; //!< Map of access to the pool from devices
|
||||
hip::Device* device_; //!< Hip device the heap will reside
|
||||
SharedMemPool* shared_; //!< Pointer to shared memory for IPC
|
||||
|
||||
مرجع در شماره جدید
Block a user