diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index c816a100e1..b687d5c411 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -794,6 +794,6 @@ void CommandStreamReceiverHw::handleEventsTimestampPacketTags(LinearS template void CommandStreamReceiverHw::createScratchSpaceAllocation(size_t requiredScratchSizeInBytes) { - scratchAllocation = getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, nullptr, requiredScratchSizeInBytes, GraphicsAllocation::AllocationType::SCRATCH_SURFACE); + scratchAllocation = getMemoryManager()->allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, requiredScratchSizeInBytes, GraphicsAllocation::AllocationType::SCRATCH_SURFACE); } } // namespace OCLRT diff --git a/runtime/kernel/kernel.cpp b/runtime/kernel/kernel.cpp index 09bb2413c0..fe54f72ff5 100644 --- a/runtime/kernel/kernel.cpp +++ b/runtime/kernel/kernel.cpp @@ -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 "kernel.h" @@ -270,7 +255,7 @@ cl_int Kernel::initialize() { retVal = CL_OUT_OF_RESOURCES; break; } - privateSurface = device.getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, nullptr, static_cast(privateSurfaceSize), GraphicsAllocation::AllocationType::PRIVATE_SURFACE); + privateSurface = device.getMemoryManager()->allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, static_cast(privateSurfaceSize), GraphicsAllocation::AllocationType::PRIVATE_SURFACE); if (privateSurface == nullptr) { retVal = CL_OUT_OF_RESOURCES; break; diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index ca824657a8..2a5260c55a 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -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), allocationType); + AllocationFlags allocFlags = MemObjHelper::getAllocationFlags(flags); + DeviceIndex deviceIndex = MemObjHelper::getDeviceIndex(flags); + allocFlags.flags.allocateMemory = allocateMemory; + memory = memoryManager->allocateGraphicsMemoryInPreferredPool(allocFlags, deviceIndex, hostPtr, static_cast(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), allocationType); + AllocationFlags allocFlags = MemObjHelper::getAllocationFlags(flags); + DeviceIndex deviceIndex = MemObjHelper::getDeviceIndex(flags); + allocFlags.flags.allocateMemory = true; + memory = memoryManager->allocateGraphicsMemoryInPreferredPool(allocFlags, deviceIndex, nullptr, static_cast(size), allocationType); } } diff --git a/runtime/mem_obj/mem_obj_helper.cpp b/runtime/mem_obj/mem_obj_helper.cpp index 941e363f22..280e14e0b1 100644 --- a/runtime/mem_obj/mem_obj_helper.cpp +++ b/runtime/mem_obj/mem_obj_helper.cpp @@ -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 diff --git a/runtime/mem_obj/mem_obj_helper.h b/runtime/mem_obj/mem_obj_helper.h index f4e48e70d7..8a6c4545d1 100644 --- a/runtime/mem_obj/mem_obj_helper.h +++ b/runtime/mem_obj/mem_obj_helper.h @@ -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 | diff --git a/runtime/mem_obj/pipe.cpp b/runtime/mem_obj/pipe.cpp index 726229ed18..3884196c64 100644 --- a/runtime/mem_obj/pipe.cpp +++ b/runtime/mem_obj/pipe.cpp @@ -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(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; diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index 4a710d3686..f1e158c525 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -1,23 +1,8 @@ /* - * 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/memory_manager/memory_manager.h" @@ -446,11 +431,11 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, bool alloc return true; } -GraphicsAllocation *MemoryManager::allocateGraphicsMemoryInPreferredPool(bool allocateMemory, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) { +GraphicsAllocation *MemoryManager::allocateGraphicsMemoryInPreferredPool(AllocationFlags flags, DeviceIndex deviceIndex, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) { AllocationData allocationData; AllocationStatus status = AllocationStatus::Error; - getAllocationData(allocationData, allocateMemory, hostPtr, size, type); + getAllocationData(allocationData, flags.flags.allocateMemory, hostPtr, size, type); UNRECOVERABLE_IF(allocationData.type == GraphicsAllocation::AllocationType::IMAGE || allocationData.type == GraphicsAllocation::AllocationType::SHARED_RESOURCE); GraphicsAllocation *allocation = nullptr; diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index e3911f5dae..64325a6cc8 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -1,23 +1,8 @@ /* - * 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. */ #pragma once @@ -61,6 +46,35 @@ enum AllocationOrigin { INTERNAL_ALLOCATION }; +struct AllocationFlags { + union { + struct { + uint32_t allocateMemory : 1; + uint32_t flushL3RequiredForRead : 1; + uint32_t flushL3RequiredForWrite : 1; + uint32_t reserved : 29; + } flags; + uint32_t allFlags; + }; + + static_assert(sizeof(AllocationFlags::flags) == sizeof(AllocationFlags::allFlags), ""); + + AllocationFlags() { + allFlags = 0; + flags.flushL3RequiredForRead = 1; + flags.flushL3RequiredForWrite = 1; + } + + AllocationFlags(bool allocateMemory) { + allFlags = 0; + flags.flushL3RequiredForRead = 1; + flags.flushL3RequiredForWrite = 1; + flags.allocateMemory = allocateMemory; + } +}; + +using DeviceIndex = uint32_t; + struct AllocationData { union { struct { @@ -142,7 +156,7 @@ class MemoryManager { virtual GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) = 0; - MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryInPreferredPool(bool allocateMemory, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type); + MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryInPreferredPool(AllocationFlags flags, DeviceIndex deviceIndex, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type); GraphicsAllocation *allocateGraphicsMemoryForSVM(size_t size, bool coherent); diff --git a/runtime/program/printf_handler.cpp b/runtime/program/printf_handler.cpp index 35dfa7b2e8..ec4ab9932b 100644 --- a/runtime/program/printf_handler.cpp +++ b/runtime/program/printf_handler.cpp @@ -1,23 +1,8 @@ /* - * 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 "printf_handler.h" @@ -52,7 +37,7 @@ void PrintfHandler::prepareDispatch(const MultiDispatchInfo &multiDispatchInfo) return; } kernel = multiDispatchInfo.peekMainKernel(); - printfSurface = device.getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, nullptr, printfSurfaceSize, GraphicsAllocation::AllocationType::PRINTF_SURFACE); + printfSurface = device.getMemoryManager()->allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, printfSurfaceSize, GraphicsAllocation::AllocationType::PRINTF_SURFACE); *reinterpret_cast(printfSurface->getUnderlyingBuffer()) = printfSurfaceInitialDataSize; diff --git a/runtime/program/process_gen_binary.cpp b/runtime/program/process_gen_binary.cpp index f3ed31c54e..6d2a937e49 100644 --- a/runtime/program/process_gen_binary.cpp +++ b/runtime/program/process_gen_binary.cpp @@ -1,23 +1,8 @@ /* - * 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 "patch_list.h" @@ -867,7 +852,7 @@ cl_int Program::parseProgramScopePatchList() { surfaceSize = patch.InlineDataSize; headerSize = sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo); - constantSurface = pDevice->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, nullptr, surfaceSize, GraphicsAllocation::AllocationType::CONSTANT_SURFACE); + constantSurface = pDevice->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, surfaceSize, GraphicsAllocation::AllocationType::CONSTANT_SURFACE); memcpy_s(constantSurface->getUnderlyingBuffer(), surfaceSize, (cl_char *)pPatch + headerSize, surfaceSize); pCurPatchListPtr = ptrOffset(pCurPatchListPtr, surfaceSize); @@ -889,7 +874,7 @@ cl_int Program::parseProgramScopePatchList() { surfaceSize = patch.InlineDataSize; globalVarTotalSize += (size_t)surfaceSize; headerSize = sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo); - globalSurface = pDevice->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, nullptr, surfaceSize, GraphicsAllocation::AllocationType::GLOBAL_SURFACE); + globalSurface = pDevice->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, surfaceSize, GraphicsAllocation::AllocationType::GLOBAL_SURFACE); memcpy_s(globalSurface->getUnderlyingBuffer(), surfaceSize, (cl_char *)pPatch + headerSize, surfaceSize); pCurPatchListPtr = ptrOffset(pCurPatchListPtr, surfaceSize); diff --git a/runtime/program/program.cpp b/runtime/program/program.cpp index bd77c22d99..a8e2cbf817 100644 --- a/runtime/program/program.cpp +++ b/runtime/program/program.cpp @@ -1,23 +1,8 @@ /* - * 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 "program.h" @@ -389,7 +374,7 @@ void Program::allocateBlockPrivateSurfaces() { if (privateSize > 0 && blockKernelManager->getPrivateSurface(i) == nullptr) { privateSize *= getDevice(0).getDeviceInfo().computeUnitsUsedForScratch * info->getMaxSimdSize(); - auto *privateSurface = this->executionEnvironment.memoryManager->allocateGraphicsMemoryInPreferredPool(true, nullptr, static_cast(privateSize), GraphicsAllocation::AllocationType::PRIVATE_SURFACE); + auto *privateSurface = this->executionEnvironment.memoryManager->allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, static_cast(privateSize), GraphicsAllocation::AllocationType::PRIVATE_SURFACE); blockKernelManager->pushPrivateSurface(privateSurface, i); } } diff --git a/unit_tests/gtpin/gtpin_tests.cpp b/unit_tests/gtpin/gtpin_tests.cpp index cdb38967f1..6cdbad375e 100644 --- a/unit_tests/gtpin/gtpin_tests.cpp +++ b/unit_tests/gtpin/gtpin_tests.cpp @@ -1,23 +1,8 @@ /* - * 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" @@ -135,12 +120,12 @@ class MockMemoryManagerWithFailures : public OsAgnosticMemoryManager { public: using OsAgnosticMemoryManager::OsAgnosticMemoryManager; - GraphicsAllocation *allocateGraphicsMemoryInPreferredPool(bool allocateMemory, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) override { + GraphicsAllocation *allocateGraphicsMemoryInPreferredPool(AllocationFlags flags, DeviceIndex deviceIndex, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) override { if (failAllAllocationsInPreferredPool) { failAllAllocationsInPreferredPool = false; return nullptr; } - return OsAgnosticMemoryManager::allocateGraphicsMemoryInPreferredPool(allocateMemory, hostPtr, size, type); + return OsAgnosticMemoryManager::allocateGraphicsMemoryInPreferredPool(flags, deviceIndex, hostPtr, size, type); } bool failAllAllocationsInPreferredPool = false; }; diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index 28c7480334..8d950c5d40 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -1,23 +1,8 @@ /* - * 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 "gmock/gmock.h" @@ -109,9 +94,9 @@ INSTANTIATE_TEST_CASE_P( class GMockMemoryManagerFailFirstAllocation : public MockMemoryManager { public: - MOCK_METHOD4(allocateGraphicsMemoryInPreferredPool, GraphicsAllocation *(bool allocateMemory, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type)); - GraphicsAllocation *baseallocateGraphicsMemoryInPreferredPool(bool allocateMemory, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) { - return MockMemoryManager::allocateGraphicsMemoryInPreferredPool(allocateMemory, hostPtr, size, type); + MOCK_METHOD5(allocateGraphicsMemoryInPreferredPool, GraphicsAllocation *(AllocationFlags flags, DeviceIndex deviceIndex, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type)); + GraphicsAllocation *baseallocateGraphicsMemoryInPreferredPool(AllocationFlags flags, DeviceIndex deviceIndex, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) { + return MockMemoryManager::allocateGraphicsMemoryInPreferredPool(flags, deviceIndex, hostPtr, size, type); } }; @@ -128,7 +113,7 @@ TEST(Buffer, givenReadOnlyHostPtrMemoryWhenBufferIsCreatedWithReadOnlyFlagsThenB MockContext ctx(device.get()); // First fail simulates error for read only memory allocation - EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillOnce(::testing::Return(nullptr)) .WillRepeatedly(::testing::Invoke(memoryManager, &GMockMemoryManagerFailFirstAllocation::baseallocateGraphicsMemoryInPreferredPool)); @@ -159,7 +144,7 @@ TEST(Buffer, givenReadOnlyHostPtrMemoryWhenBufferIsCreatedWithReadOnlyFlagsAndSe // First fail simulates error for read only memory allocation // Second fail returns nullptr - EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(::testing::Return(nullptr)); cl_int retVal; @@ -184,7 +169,7 @@ TEST(Buffer, givenReadOnlyHostPtrMemoryWhenBufferIsCreatedWithKernelWriteFlagThe MockContext ctx(device.get()); // First fail simulates error for read only memory allocation - EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillOnce(::testing::Return(nullptr)); cl_int retVal; @@ -204,7 +189,7 @@ TEST(Buffer, givenNullPtrWhenBufferIsCreatedWithKernelReadOnlyFlagsThenBufferAll MockContext ctx(device.get()); // First fail simulates error for read only memory allocation - EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillOnce(::testing::Return(nullptr)); cl_int retVal; @@ -222,13 +207,13 @@ TEST(Buffer, givenNullptrPassedToBufferCreateWhenAllocationIsNotSystemMemoryPool device->injectMemoryManager(memoryManager); MockContext ctx(device.get()); - auto allocateNonSystemGraphicsAllocation = [memoryManager](bool allocateMemory, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) -> GraphicsAllocation * { + auto allocateNonSystemGraphicsAllocation = [memoryManager](AllocationFlags flags, DeviceIndex deviceIndex, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) -> GraphicsAllocation * { auto allocation = memoryManager->allocateGraphicsMemory(size, MemoryConstants::pageSize, false, false); reinterpret_cast(allocation)->overrideMemoryPool(MemoryPool::SystemCpuInaccessible); return allocation; }; - EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillOnce(::testing::Invoke(allocateNonSystemGraphicsAllocation)); cl_int retVal = 0; diff --git a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp index b50f4f5ea4..8974bb2d78 100644 --- a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp @@ -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/memory_manager/os_agnostic_memory_manager.h" @@ -281,7 +266,7 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenGraphicsMemoryAllocationInDevicePo memoryManager.failInDevicePool = true; - auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(true, nullptr, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER); + auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER); ASSERT_NE(nullptr, allocation); EXPECT_TRUE(memoryManager.allocationCreated); EXPECT_EQ(MemoryPool::System4KBPages, allocation->getMemoryPool()); @@ -292,7 +277,7 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenGraphicsMemoryAllocationInDevicePo TEST(MemoryManagerTest, givenMemoryManagerWhenBufferTypeIsPassedThenAllocateGraphicsMemoryInPreferredPoolCanAllocateInDevicePool) { MockMemoryManager memoryManager(false); - auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(true, nullptr, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER); + auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER); EXPECT_NE(nullptr, allocation); memoryManager.freeGraphicsMemory(allocation); } @@ -302,7 +287,7 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenBufferTypeIsPassedAndAllocateInDev memoryManager.failInDevicePoolWithError = true; - auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(true, nullptr, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER); + auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER); ASSERT_EQ(nullptr, allocation); EXPECT_FALSE(memoryManager.allocationInDevicePoolCreated); diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 40345ebf46..f839031eda 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -1,23 +1,8 @@ /* - * 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/event/event.h" @@ -1176,11 +1161,11 @@ TEST(OsAgnosticMemoryManager, GivenEnabled64kbPagesWhenHostMemoryAllocationIsCre DebugManager.flags.Enable64kbpages.set(true); OsAgnosticMemoryManager memoryManager(true, false); - GraphicsAllocation *galloc = memoryManager.allocateGraphicsMemoryInPreferredPool(true, nullptr, 64 * 1024, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); + GraphicsAllocation *galloc = memoryManager.allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, 64 * 1024, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); EXPECT_NE(nullptr, galloc); memoryManager.freeGraphicsMemory(galloc); - galloc = memoryManager.allocateGraphicsMemoryInPreferredPool(true, nullptr, 64 * 1024, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); + galloc = memoryManager.allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, 64 * 1024, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); EXPECT_NE(nullptr, galloc); EXPECT_NE(nullptr, galloc->getUnderlyingBuffer()); EXPECT_EQ(0u, (uintptr_t)galloc->getUnderlyingBuffer() % MemoryConstants::pageSize64k); diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index e0f9bf0d08..3980e71e56 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -1,23 +1,8 @@ /* - * 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/gmm_helper/gmm.h" @@ -1957,7 +1942,7 @@ TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemor WddmMemoryManager memoryManager64k(true, false, wddm.get()); EXPECT_EQ(0, wddm->createAllocationResult.called); - GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemoryInPreferredPool(true, nullptr, static_cast(MemoryConstants::pageSize64k), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); + GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemoryInPreferredPool(AllocationFlags(true), 0, nullptr, static_cast(MemoryConstants::pageSize64k), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY); EXPECT_EQ(1, wddm->createAllocationResult.called); EXPECT_NE(nullptr, galloc); EXPECT_EQ(true, galloc->isLocked());