Skip to content

Commit

Permalink
Reduce unnecessary copies of memory properties
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Kopryk <[email protected]>
  • Loading branch information
KamilKoprykIntel authored and Compute-Runtime-Automation committed Jun 24, 2022
1 parent a20c0b7 commit 83cab52
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
9 changes: 4 additions & 5 deletions opencl/source/mem_obj/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ValidateInputAndCreateBufferFunc validateInputAndCreateBuffer = Buffer::validate
} // namespace BufferFunctions

Buffer::Buffer(Context *context,
MemoryProperties memoryProperties,
const MemoryProperties &memoryProperties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand Down Expand Up @@ -175,7 +175,7 @@ Buffer *Buffer::create(Context *context,
}

Buffer *Buffer::create(Context *context,
MemoryProperties memoryProperties,
const MemoryProperties &memoryProperties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand Down Expand Up @@ -456,7 +456,7 @@ Buffer *Buffer::createSharedBuffer(Context *context, cl_mem_flags flags, Sharing
return sharedBuffer;
}

void Buffer::checkMemory(MemoryProperties memoryProperties,
void Buffer::checkMemory(const MemoryProperties &memoryProperties,
size_t size,
void *hostPtr,
cl_int &errcodeRet,
Expand Down Expand Up @@ -506,7 +506,6 @@ void Buffer::checkMemory(MemoryProperties memoryProperties,
errcodeRet = CL_INVALID_HOST_PTR;
}
}
return;
}

AllocationType Buffer::getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties, Context &context,
Expand Down Expand Up @@ -669,7 +668,7 @@ bool Buffer::isReadWriteOnCpuPreferred(void *ptr, size_t size, const Device &dev
}

Buffer *Buffer::createBufferHw(Context *context,
MemoryProperties memoryProperties,
const MemoryProperties &memoryProperties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand Down
16 changes: 8 additions & 8 deletions opencl/source/mem_obj/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MemoryManager;
struct EncodeSurfaceStateArgs;

using BufferCreatFunc = Buffer *(*)(Context *context,
MemoryProperties memoryProperties,
const MemoryProperties &memoryProperties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand Down Expand Up @@ -79,7 +79,7 @@ class Buffer : public MemObj {
cl_int &errcodeRet);

static Buffer *create(Context *context,
MemoryProperties properties,
const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand All @@ -92,7 +92,7 @@ class Buffer : public MemObj {
MultiGraphicsAllocation multiGraphicsAllocation);

static Buffer *createBufferHw(Context *context,
MemoryProperties memoryProperties,
const MemoryProperties &memoryProperties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand Down Expand Up @@ -163,11 +163,11 @@ class Buffer : public MemObj {

bool isCompressed(uint32_t rootDeviceIndex) const;

static bool validateHandleType(MemoryProperties &memoryProperties, UnifiedSharingMemoryDescription &extMem);
static bool validateHandleType(const MemoryProperties &memoryProperties, UnifiedSharingMemoryDescription &extMem);

protected:
Buffer(Context *context,
MemoryProperties memoryProperties,
const MemoryProperties &memoryProperties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand All @@ -180,7 +180,7 @@ class Buffer : public MemObj {

Buffer();

static void checkMemory(MemoryProperties memoryProperties,
static void checkMemory(const MemoryProperties &memoryProperties,
size_t size,
void *hostPtr,
cl_int &errcodeRet,
Expand All @@ -202,7 +202,7 @@ template <typename GfxFamily>
class BufferHw : public Buffer {
public:
BufferHw(Context *context,
MemoryProperties memoryProperties,
const MemoryProperties &memoryProperties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand All @@ -219,7 +219,7 @@ class BufferHw : public Buffer {
bool isReadOnlyArgument, const Device &device, bool useGlobalAtomics, bool areMultipleSubDevicesInContext) override;

static Buffer *create(Context *context,
MemoryProperties memoryProperties,
const MemoryProperties &memoryProperties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size,
Expand Down
2 changes: 1 addition & 1 deletion opencl/source/mem_obj/buffer_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "opencl/source/mem_obj/buffer.h"

namespace NEO {
bool Buffer::validateHandleType(MemoryProperties &memoryProperties, UnifiedSharingMemoryDescription &extMem) {
bool Buffer::validateHandleType(const MemoryProperties &memoryProperties, UnifiedSharingMemoryDescription &extMem) {
if (memoryProperties.handleType == static_cast<uint64_t>(UnifiedSharingHandleType::LinuxFd)) {
extMem.type = UnifiedSharingHandleType::LinuxFd;
return true;
Expand Down
2 changes: 1 addition & 1 deletion opencl/source/mem_obj/buffer_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "opencl/source/mem_obj/buffer.h"

namespace NEO {
bool Buffer::validateHandleType(MemoryProperties &memoryProperties, UnifiedSharingMemoryDescription &extMem) {
bool Buffer::validateHandleType(const MemoryProperties &memoryProperties, UnifiedSharingMemoryDescription &extMem) {
if (memoryProperties.handleType == static_cast<uint64_t>(UnifiedSharingHandleType::Win32Nt)) {
extMem.type = UnifiedSharingHandleType::Win32Nt;
return true;
Expand Down
2 changes: 1 addition & 1 deletion opencl/test/unit_test/mem_obj/buffer_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ TEST_P(NoHostPtr, GivenNoHostPtrWhenHwBufferCreationFailsThenReturnNullptr) {
bufferFuncsBackup[i] = bufferFactory[i];
bufferFactory[i].createBufferFunction =
[](Context *,
MemoryProperties,
const MemoryProperties &,
cl_mem_flags,
cl_mem_flags_intel,
size_t,
Expand Down
2 changes: 1 addition & 1 deletion shared/source/helpers/memory_properties_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MemoryPropertiesHelper {
};

static AllocationProperties getAllocationProperties(
uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
uint32_t rootDeviceIndex, const MemoryProperties &memoryProperties, bool allocateMemory, size_t size,
AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo,
DeviceBitfield subDevicesBitfieldParam, bool deviceOnlyVisibilty);

Expand Down
2 changes: 1 addition & 1 deletion shared/source/helpers/memory_properties_helpers_base.inl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace NEO {

AllocationProperties MemoryPropertiesHelper::getAllocationProperties(
uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
uint32_t rootDeviceIndex, const MemoryProperties &memoryProperties, bool allocateMemory, size_t size,
AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo,
DeviceBitfield subDevicesBitfieldParam, bool deviceOnlyVisibilty) {

Expand Down

0 comments on commit 83cab52

Please sign in to comment.