Skip to content

Commit

Permalink
Remove OCL object from MemoryProperties 2/n
Browse files Browse the repository at this point in the history
Wire in MemoryPropertiesFlags support to checkMemory

Related-To: NEO-3132
Change-Id: Ib3762cc05999c4541a9ea7d33427052c237dd018
Signed-off-by: Krzysztof Gibala <[email protected]>
  • Loading branch information
kgibala authored and Compute-Runtime-Automation committed Aug 9, 2019
1 parent 4d8e808 commit 26774a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions runtime/mem_obj/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/hw_helper.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/memory_properties_flags_helpers.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/helpers/validators.h"
#include "runtime/mem_obj/mem_obj_helper.h"
Expand Down Expand Up @@ -151,7 +152,8 @@ Buffer *Buffer::create(Context *context,
memoryManager->isLocalMemorySupported(),
HwHelper::get(context->getDevice(0)->getHardwareInfo().platform.eRenderCoreFamily).obtainRenderBufferCompressionPreference(size));

checkMemory(properties.flags, size, hostPtr, errcodeRet, alignementSatisfied, copyMemoryFromHostPtr, memoryManager);
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
checkMemory(memoryProperties, size, hostPtr, errcodeRet, alignementSatisfied, copyMemoryFromHostPtr, memoryManager);

if (errcodeRet != CL_SUCCESS) {
return nullptr;
Expand Down Expand Up @@ -323,7 +325,7 @@ Buffer *Buffer::createSharedBuffer(Context *context, cl_mem_flags flags, Sharing
return sharedBuffer;
}

void Buffer::checkMemory(cl_mem_flags flags,
void Buffer::checkMemory(MemoryPropertiesFlags memoryProperties,
size_t size,
void *hostPtr,
cl_int &errcodeRet,
Expand All @@ -340,13 +342,13 @@ void Buffer::checkMemory(cl_mem_flags flags,
}

if (hostPtr) {
if (!(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))) {
if (!(memoryProperties.useHostPtr || memoryProperties.copyHostPtr)) {
errcodeRet = CL_INVALID_HOST_PTR;
return;
}
}

if (flags & CL_MEM_USE_HOST_PTR) {
if (memoryProperties.useHostPtr) {
if (hostPtr) {
auto fragment = memoryManager->getHostPtrManager()->getFragment(hostPtr);
if (fragment && fragment->driverAllocation) {
Expand All @@ -364,7 +366,7 @@ void Buffer::checkMemory(cl_mem_flags flags,
}
}

if (flags & CL_MEM_COPY_HOST_PTR) {
if (memoryProperties.copyHostPtr) {
if (hostPtr) {
copyMemoryFromHostPtr = true;
} else {
Expand Down
3 changes: 2 additions & 1 deletion runtime/mem_obj/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "runtime/memory_manager/memory_constants.h"

#include "igfxfmid.h"
#include "memory_properties_flags.h"

namespace NEO {
class Buffer;
Expand Down Expand Up @@ -139,7 +140,7 @@ class Buffer : public MemObj {

Buffer();

static void checkMemory(cl_mem_flags flags,
static void checkMemory(MemoryPropertiesFlags memoryProperties,
size_t size,
void *hostPtr,
cl_int &errcodeRet,
Expand Down

0 comments on commit 26774a2

Please sign in to comment.