Change MemoryManager::allocateGraphicsMemoryInPreferredPool() signature.

Remove allocateMemory param.
Add AllocationFlags and DeviceIndex params.

Change-Id: I3ba048f8ea9840a047a3222dc1e97be2105c2222
This commit is contained in:
Venevtsev, Igor
2018-09-17 14:03:37 +02:00
committed by sys_ocldev
parent f1e6fb6e5f
commit 7c94409ce8
16 changed files with 112 additions and 285 deletions

View File

@@ -1,26 +1,12 @@
/*
* Copyright (c) 2017 - 2018, Intel Corporation
* Copyright (C) 2017-2018 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* SPDX-License-Identifier: MIT
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/mem_obj/buffer.h"
#include "runtime/mem_obj/mem_obj_helper.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
@@ -161,7 +147,10 @@ Buffer *Buffer::create(Context *context,
}
if (!memory) {
memory = memoryManager->allocateGraphicsMemoryInPreferredPool(allocateMemory, hostPtr, static_cast<size_t>(size), allocationType);
AllocationFlags allocFlags = MemObjHelper::getAllocationFlags(flags);
DeviceIndex deviceIndex = MemObjHelper::getDeviceIndex(flags);
allocFlags.flags.allocateMemory = allocateMemory;
memory = memoryManager->allocateGraphicsMemoryInPreferredPool(allocFlags, deviceIndex, hostPtr, static_cast<size_t>(size), allocationType);
}
if (allocateMemory) {
@@ -176,8 +165,10 @@ Buffer *Buffer::create(Context *context,
allocationType = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
zeroCopyAllowed = false;
copyMemoryFromHostPtr = true;
allocateMemory = true;
memory = memoryManager->allocateGraphicsMemoryInPreferredPool(allocateMemory, nullptr, static_cast<size_t>(size), allocationType);
AllocationFlags allocFlags = MemObjHelper::getAllocationFlags(flags);
DeviceIndex deviceIndex = MemObjHelper::getDeviceIndex(flags);
allocFlags.flags.allocateMemory = true;
memory = memoryManager->allocateGraphicsMemoryInPreferredPool(allocFlags, deviceIndex, nullptr, static_cast<size_t>(size), allocationType);
}
}

View File

@@ -1,23 +1,8 @@
/*
* Copyright (c) 2018, Intel Corporation
* Copyright (C) 2018 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* SPDX-License-Identifier: MIT
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/mem_obj/mem_obj_helper.h"
@@ -28,4 +13,12 @@ bool MemObjHelper::checkExtraMemFlagsForBuffer(cl_mem_flags flags) {
return true;
}
AllocationFlags MemObjHelper::getAllocationFlags(cl_mem_flags flags) {
return AllocationFlags(); // Initialized by default constructor
}
DeviceIndex MemObjHelper::getDeviceIndex(cl_mem_flags flags) {
return DeviceIndex(0);
}
} // namespace OCLRT

View File

@@ -1,28 +1,14 @@
/*
* Copyright (c) 2018, Intel Corporation
* Copyright (C) 2018 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* SPDX-License-Identifier: MIT
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "CL/cl.h"
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/memory_manager/memory_manager.h"
namespace OCLRT {
@@ -42,6 +28,10 @@ class MemObjHelper {
static bool checkExtraMemFlagsForBuffer(cl_mem_flags flags);
static AllocationFlags getAllocationFlags(cl_mem_flags flags);
static DeviceIndex getDeviceIndex(cl_mem_flags flags);
static bool checkMemFlagsForSubBuffer(cl_mem_flags flags) {
const cl_mem_flags allValidFlags =
CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY |

View File

@@ -1,27 +1,13 @@
/*
* Copyright (c) 2017 - 2018, Intel Corporation
* Copyright (C) 2017-2018 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* SPDX-License-Identifier: MIT
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/context/context.h"
#include "runtime/mem_obj/pipe.h"
#include "runtime/mem_obj/mem_obj_helper.h"
#include "runtime/helpers/get_info.h"
#include "runtime/memory_manager/memory_manager.h"
@@ -62,8 +48,11 @@ Pipe *Pipe::create(Context *context,
DEBUG_BREAK_IF(!memoryManager);
while (true) {
AllocationFlags allocFlags = MemObjHelper::getAllocationFlags(flags);
DeviceIndex deviceIndex = MemObjHelper::getDeviceIndex(flags);
allocFlags.flags.allocateMemory = true;
auto size = static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace);
GraphicsAllocation *memory = memoryManager->allocateGraphicsMemoryInPreferredPool(true, nullptr, size, GraphicsAllocation::AllocationType::PIPE);
GraphicsAllocation *memory = memoryManager->allocateGraphicsMemoryInPreferredPool(allocFlags, deviceIndex, nullptr, size, GraphicsAllocation::AllocationType::PIPE);
if (!memory) {
errcodeRet = CL_OUT_OF_HOST_MEMORY;
break;