From 24b928303bd617b91eeb1585dbd5cacb2b24cf57 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Fri, 19 Feb 2021 15:11:13 +0000 Subject: [PATCH] Rename fields in AllocationProperties Related-To: NEO-5498 Signed-off-by: Zbigniew Zdanowicz --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 2 +- level_zero/core/source/event/event.cpp | 2 +- .../sources/cmdlist/test_cmdlist_1.cpp | 2 +- .../unit_tests/sources/event/test_event.cpp | 2 +- .../unified_memory_manager_tests.cpp | 22 +++++++++++++++---- .../memory_manager/allocation_properties.h | 4 ++-- .../memory_manager/graphics_allocation.h | 2 +- .../source/memory_manager/memory_manager.cpp | 4 ++-- .../memory_manager/unified_memory_manager.cpp | 21 +++++++++--------- .../source/program/program_initialization.cpp | 2 +- 10 files changed, 39 insertions(+), 24 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 52f158dd9f..bc6d3c4c4b 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -1659,7 +1659,7 @@ ze_result_t CommandListCoreFamily::appendQueryKernelTimestamps( } size_t alignedSize = alignUp(sizeof(EventData) * numEvents, MemoryConstants::pageSize64k); - NEO::GraphicsAllocation::AllocationType allocationType = NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER; + NEO::GraphicsAllocation::AllocationType allocationType = NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER; auto devices = device->getNEODevice()->getDeviceBitfield(); NEO::AllocationProperties allocationProperties{device->getRootDeviceIndex(), true, diff --git a/level_zero/core/source/event/event.cpp b/level_zero/core/source/event/event.cpp index 406f04a79e..26eb0a84c0 100644 --- a/level_zero/core/source/event/event.cpp +++ b/level_zero/core/source/event/event.cpp @@ -90,7 +90,7 @@ ze_result_t EventPoolImp::initialize(DriverHandle *driver, uint32_t numDevices, auto deviceBitfield = devices[0]->getNEODevice()->getDeviceBitfield(); auto allocationType = isEventPoolUsedForTimestamp ? NEO::GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER : NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY; if (this->allocOnDevice) { - allocationType = NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER; + allocationType = NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER; } NEO::AllocationProperties eventPoolAllocationProperties{rootDeviceIndex, diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp index c9f56183a0..5a4676451c 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp @@ -632,7 +632,7 @@ HWTEST2_F(AppendQueryKernelTimestamps, givenCommandListWhenAppendQueryKernelTime containsDstPtr = true; } if (residentGfxAlloc->getAllocationType() == - NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER) { + NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER) { gpuTimeStampAlloc = true; } } diff --git a/level_zero/core/test/unit_tests/sources/event/test_event.cpp b/level_zero/core/test/unit_tests/sources/event/test_event.cpp index 511c764f70..f0c3cb3a41 100644 --- a/level_zero/core/test/unit_tests/sources/event/test_event.cpp +++ b/level_zero/core/test/unit_tests/sources/event/test_event.cpp @@ -154,7 +154,7 @@ TEST_F(EventPoolCreate, whenHostVisibleFlagNotSetThenEventAllocationIsOnDevice) ASSERT_NE(nullptr, eventPool); - EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER, eventPool->getAllocation().getAllocationType()); + EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER, eventPool->getAllocation().getAllocationType()); eventPool->destroy(); } diff --git a/opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp index 3de579ec8a..cc8cfefb79 100644 --- a/opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp @@ -550,8 +550,8 @@ TEST(UnifiedMemoryTest, givenDeviceBitfieldWithMultipleBitsSetWhenSharedUnifiedM auto ptr = svmManager->createSharedUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, &cmdQ); - EXPECT_TRUE(memoryManager->multiOsContextCapablePassed); - EXPECT_FALSE(memoryManager->multiStorageResourcePassed); + EXPECT_FALSE(memoryManager->multiOsContextCapablePassed); + EXPECT_TRUE(memoryManager->multiStorageResourcePassed); EXPECT_EQ(unifiedMemoryProperties.subdeviceBitfields.at(mockRootDeviceIndex), memoryManager->subDevicesBitfieldPassed); svmManager->freeSVMAlloc(ptr); @@ -586,7 +586,7 @@ TEST(UnifiedMemoryTest, givenDeviceBitfieldWithMultipleBitsSetWhenDeviceUnifiedM auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties); - EXPECT_TRUE(memoryManager->multiOsContextCapablePassed); + EXPECT_FALSE(memoryManager->multiOsContextCapablePassed); EXPECT_TRUE(memoryManager->multiStorageResourcePassed); EXPECT_EQ(unifiedMemoryProperties.subdeviceBitfields.at(mockRootDeviceIndex), memoryManager->subDevicesBitfieldPassed); @@ -608,6 +608,20 @@ TEST_F(UnifiedMemoryManagerPropertiesTest, givenDeviceBitfieldWithSingleBitSetWh svmManager->freeSVMAlloc(ptr); } +TEST_F(UnifiedMemoryManagerPropertiesTest, givenDeviceBitfieldWithMultiDeviceBitSetWhenDeviceUnifiedMemoryAllocationIsCreatedThenProperPropertiesArePassedToMemoryManager) { + std::set rootDeviceIndices{mockRootDeviceIndex}; + std::map deviceBitfields{{mockRootDeviceIndex, DeviceBitfield(0xF)}}; + SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY, rootDeviceIndices, deviceBitfields); + + auto ptr = svmManager->createUnifiedAllocationWithDeviceStorage(10 * MemoryConstants::pageSize64k, {}, unifiedMemoryProperties); + + EXPECT_FALSE(memoryManager->multiOsContextCapablePassed); + EXPECT_TRUE(memoryManager->multiStorageResourcePassed); + EXPECT_EQ(unifiedMemoryProperties.subdeviceBitfields.at(mockRootDeviceIndex), memoryManager->subDevicesBitfieldPassed); + + svmManager->freeSVMAlloc(ptr); +} + struct ShareableUnifiedMemoryManagerPropertiesTest : public ::testing::Test { void SetUp() override { executionEnvironment = platform()->peekExecutionEnvironment(); @@ -1058,4 +1072,4 @@ HWTEST_F(UnfiedSharedMemoryHWTest, givenSharedUsmAllocationWhenReadBufferThenCpu gpuAllocation->setCpuPtrAndGpuAddress(cpuPtr, gpuAddress); delete buffer; clMemFreeINTEL(&mockContext, sharedMemory); -} \ No newline at end of file +} diff --git a/shared/source/memory_manager/allocation_properties.h b/shared/source/memory_manager/allocation_properties.h index faebd200e4..14365afb63 100644 --- a/shared/source/memory_manager/allocation_properties.h +++ b/shared/source/memory_manager/allocation_properties.h @@ -67,7 +67,7 @@ struct AllocationProperties { bool allocateMemoryParam, size_t sizeParam, GraphicsAllocation::AllocationType allocationTypeParam, - bool multiOsContextCapableParam, + bool multiOsContextCapable, bool isMultiStorageAllocationParam, DeviceBitfield subDevicesBitfieldParam) : rootDeviceIndex(rootDeviceIndexParam), @@ -79,7 +79,7 @@ struct AllocationProperties { flags.flushL3RequiredForRead = 1; flags.flushL3RequiredForWrite = 1; flags.allocateMemory = allocateMemoryParam; - flags.multiOsContextCapable = multiOsContextCapableParam; + flags.multiOsContextCapable = multiOsContextCapable; } }; diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index bee665a6f3..a65c37b570 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -98,7 +98,7 @@ class GraphicsAllocation : public IDNode { DEBUG_MODULE_AREA, UNIFIED_SHARED_MEMORY, WORK_PARTITION_SURFACE, - GPU_TIMESTAMP_TAG_BUFFER + GPU_TIMESTAMP_DEVICE_BUFFER }; ~GraphicsAllocation() override; diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 828856740c..58bd60017a 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -297,7 +297,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo switch (properties.allocationType) { case GraphicsAllocation::AllocationType::SVM_GPU: case GraphicsAllocation::AllocationType::SVM_ZERO_COPY: - case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER: + case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER: allow64KbPages = true; default: break; @@ -381,7 +381,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo case GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP: case GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER: case GraphicsAllocation::AllocationType::DEBUG_MODULE_AREA: - case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_TAG_BUFFER: + case GraphicsAllocation::AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER: allocationData.flags.resource48Bit = true; break; default: diff --git a/shared/source/memory_manager/unified_memory_manager.cpp b/shared/source/memory_manager/unified_memory_manager.cpp index 5b66d9567c..70fe770da3 100644 --- a/shared/source/memory_manager/unified_memory_manager.cpp +++ b/shared/source/memory_manager/unified_memory_manager.cpp @@ -128,13 +128,13 @@ void *SVMAllocsManager::createHostUnifiedMemoryAllocation(size_t size, std::vector rootDeviceIndicesVector(memoryProperties.rootDeviceIndices.begin(), memoryProperties.rootDeviceIndices.end()); uint32_t rootDeviceIndex = rootDeviceIndicesVector.at(0); - auto deviceBitfield = memoryProperties.subdeviceBitfields.at(rootDeviceIndex); + auto &deviceBitfield = memoryProperties.subdeviceBitfields.at(rootDeviceIndex); AllocationProperties unifiedMemoryProperties{rootDeviceIndex, true, alignedSize, allocationType, - deviceBitfield.count() > 1, + false, deviceBitfield.count() > 1, deviceBitfield}; unifiedMemoryProperties.flags.shareable = memoryProperties.allocationFlags.flags.shareable; @@ -167,7 +167,7 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, auto rootDeviceIndex = memoryProperties.device ? memoryProperties.device->getRootDeviceIndex() : *memoryProperties.rootDeviceIndices.begin(); - auto deviceBitfield = memoryProperties.subdeviceBitfields.at(rootDeviceIndex); + auto &deviceBitfield = memoryProperties.subdeviceBitfields.at(rootDeviceIndex); size_t alignedSize = alignUp(size, MemoryConstants::pageSize64k); @@ -177,7 +177,7 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, true, alignedSize, allocationType, - deviceBitfield.count() > 1, + false, deviceBitfield.count() > 1, deviceBitfield}; unifiedMemoryProperties.flags.shareable = memoryProperties.allocationFlags.flags.shareable; @@ -255,13 +255,13 @@ void *SVMAllocsManager::createUnifiedKmdMigratedAllocation(size_t size, const Sv auto rootDeviceIndex = unifiedMemoryProperties.device ? unifiedMemoryProperties.device->getRootDeviceIndex() : *unifiedMemoryProperties.rootDeviceIndices.begin(); - auto deviceBitfield = unifiedMemoryProperties.subdeviceBitfields.at(rootDeviceIndex); + auto &deviceBitfield = unifiedMemoryProperties.subdeviceBitfields.at(rootDeviceIndex); size_t alignedSize = alignUp(size, 2 * MemoryConstants::megaByte); AllocationProperties gpuProperties{rootDeviceIndex, true, alignedSize, GraphicsAllocation::AllocationType::UNIFIED_SHARED_MEMORY, - deviceBitfield.count() > 1, + false, false, deviceBitfield}; @@ -340,7 +340,7 @@ void *SVMAllocsManager::createZeroCopySvmAllocation(size_t size, const SvmAlloca const std::map &subdeviceBitfields) { auto rootDeviceIndex = *rootDeviceIndices.begin(); - auto deviceBitfield = subdeviceBitfields.at(rootDeviceIndex); + auto &deviceBitfield = subdeviceBitfields.at(rootDeviceIndex); AllocationProperties properties{rootDeviceIndex, true, // allocateMemory size, @@ -369,11 +369,12 @@ void *SVMAllocsManager::createUnifiedAllocationWithDeviceStorage(size_t size, co ? unifiedMemoryProperties.device->getRootDeviceIndex() : *unifiedMemoryProperties.rootDeviceIndices.begin(); size_t alignedSize = alignUp(size, 2 * MemoryConstants::megaByte); + const DeviceBitfield &subDevices = unifiedMemoryProperties.subdeviceBitfields.at(rootDeviceIndex); AllocationProperties cpuProperties{rootDeviceIndex, true, // allocateMemory alignedSize, GraphicsAllocation::AllocationType::SVM_CPU, false, // isMultiStorageAllocation - unifiedMemoryProperties.subdeviceBitfields.at(rootDeviceIndex)}; + subDevices}; cpuProperties.alignment = 2 * MemoryConstants::megaByte; auto cacheRegion = MemoryPropertiesHelper::getCacheRegion(unifiedMemoryProperties.allocationFlags); MemoryPropertiesHelper::fillCachePolicyInProperties(cpuProperties, false, svmProperties.readOnly, false, cacheRegion); @@ -388,9 +389,9 @@ void *SVMAllocsManager::createUnifiedAllocationWithDeviceStorage(size_t size, co false, alignedSize, GraphicsAllocation::AllocationType::SVM_GPU, - unifiedMemoryProperties.subdeviceBitfields.at(rootDeviceIndex).count() > 1, false, - unifiedMemoryProperties.subdeviceBitfields.at(rootDeviceIndex)}; + subDevices.count() > 1, + subDevices}; gpuProperties.alignment = 2 * MemoryConstants::megaByte; MemoryPropertiesHelper::fillCachePolicyInProperties(gpuProperties, false, svmProperties.readOnly, false, cacheRegion); diff --git a/shared/source/program/program_initialization.cpp b/shared/source/program/program_initialization.cpp index d85d3b4bee..bab2767f41 100644 --- a/shared/source/program/program_initialization.cpp +++ b/shared/source/program/program_initialization.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT *