From 30d966230f787670240283af2eede5abb6105c5d Mon Sep 17 00:00:00 2001 From: Piers Daniell Date: Thu, 30 Nov 2017 14:40:00 -0700 Subject: [PATCH] Skip allocation subtests that allocate too much VA For 32-bit builds of CTS we can't allocate more host visible memory than there is virtual address space for the process since the allocation will fail and cause a false negative result. This CL skips over host visible allocations that would add up to more than 1.5GB of virtual address space. This can happen on platforms that expose very large heaps that support memory types that include host visible memory. The implementation can't cap the available memory size since the heap can support allocations of memory other than host visible and it doesn't want to restrict those that don't consume CPU virtual address space. Its up to CTS to limit how much virtual address space it chooses to allocate. Affects: dEQP-VK.memory.allocation.basic.percent_1.*.count_12 Components: Vulkan VK-GL-CTS issue: 859 Change-Id: I321f5cad567245571722f53397df26e23a4cee97 --- .../vulkan/memory/vktMemoryAllocationTests.cpp | 126 ++++++++++++--------- 1 file changed, 70 insertions(+), 56 deletions(-) diff --git a/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp b/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp index 106a587..8943282 100644 --- a/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp +++ b/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp @@ -280,89 +280,103 @@ tcu::TestStatus AllocateFreeTestInstance::iterate (void) if (allocationSize * m_config.memoryAllocationCount * 8 > memoryHeap.size) TCU_THROW(NotSupportedError, "Memory heap doesn't have enough memory."); - try +#if (DE_PTR_SIZE == 4) + // For 32-bit binaries we cap the total host visible allocations to 1.5GB to + // avoid exhausting CPU virtual address space and throwing a false negative result. + if ((memoryType.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && + allocationSize * m_config.memoryAllocationCount >= 1610612736) + + log << TestLog::Message << " Skipping: Not enough CPU virtual address space for all host visible allocations." << TestLog::EndMessage; + else { - const deUint32 totalDeviceMaskCombinations = m_subsetAllocationAllowed ? (1 << m_numPhysDevices) - 1 : 1; - for (deUint32 deviceMask = 1; deviceMask <= totalDeviceMaskCombinations; deviceMask++) - { - // Allocate on all physical devices if subset allocation is not allowed, do only once. - if (!m_subsetAllocationAllowed) - deviceMask = (1 << m_numPhysDevices) - 1; - m_allocFlagsInfo.deviceMask = deviceMask; +#else + { +#endif - if (m_config.order == TestConfig::ALLOC_FREE || m_config.order == TestConfig::ALLOC_REVERSE_FREE) + try + { + const deUint32 totalDeviceMaskCombinations = m_subsetAllocationAllowed ? (1 << m_numPhysDevices) - 1 : 1; + for (deUint32 deviceMask = 1; deviceMask <= totalDeviceMaskCombinations; deviceMask++) { - for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) + // Allocate on all physical devices if subset allocation is not allowed, do only once. + if (!m_subsetAllocationAllowed) + deviceMask = (1 << m_numPhysDevices) - 1; + m_allocFlagsInfo.deviceMask = deviceMask; + + if (m_config.order == TestConfig::ALLOC_FREE || m_config.order == TestConfig::ALLOC_REVERSE_FREE) { - VkMemoryAllocateInfo alloc = + for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) { - VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // sType - m_useDeviceGroups ? &m_allocFlagsInfo : DE_NULL, // pNext - allocationSize, // allocationSize - m_memoryTypeIndex // memoryTypeIndex; - }; + VkMemoryAllocateInfo alloc = + { + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // sType + m_useDeviceGroups ? &m_allocFlagsInfo : DE_NULL, // pNext + allocationSize, // allocationSize + m_memoryTypeIndex // memoryTypeIndex; + }; - VK_CHECK(vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &memoryObjects[ndx])); + VK_CHECK(vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &memoryObjects[ndx])); - TCU_CHECK(!!memoryObjects[ndx]); - } + TCU_CHECK(!!memoryObjects[ndx]); + } - if (m_config.order == TestConfig::ALLOC_FREE) - { - for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) + if (m_config.order == TestConfig::ALLOC_FREE) { - const VkDeviceMemory mem = memoryObjects[memoryObjects.size() - 1 - ndx]; + for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) + { + const VkDeviceMemory mem = memoryObjects[memoryObjects.size() - 1 - ndx]; - vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL); - memoryObjects[memoryObjects.size() - 1 - ndx] = (VkDeviceMemory)0; + vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL); + memoryObjects[memoryObjects.size() - 1 - ndx] = (VkDeviceMemory)0; + } + } + else + { + for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) + { + const VkDeviceMemory mem = memoryObjects[ndx]; + + vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL); + memoryObjects[ndx] = (VkDeviceMemory)0; + } } } else { for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) { - const VkDeviceMemory mem = memoryObjects[ndx]; - - vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL); + const VkMemoryAllocateInfo alloc = + { + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // sType + m_useDeviceGroups ? &m_allocFlagsInfo : DE_NULL, // pNext + allocationSize, // allocationSize + m_memoryTypeIndex // memoryTypeIndex; + }; + + VK_CHECK(vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &memoryObjects[ndx])); + TCU_CHECK(!!memoryObjects[ndx]); + + vkd.freeMemory(device, memoryObjects[ndx], (const VkAllocationCallbacks*)DE_NULL); memoryObjects[ndx] = (VkDeviceMemory)0; } } } - else + } + catch (...) + { + for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) { - for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) - { - const VkMemoryAllocateInfo alloc = - { - VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // sType - m_useDeviceGroups ? &m_allocFlagsInfo : DE_NULL, // pNext - allocationSize, // allocationSize - m_memoryTypeIndex // memoryTypeIndex; - }; - - VK_CHECK(vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &memoryObjects[ndx])); - TCU_CHECK(!!memoryObjects[ndx]); + const VkDeviceMemory mem = memoryObjects[ndx]; - vkd.freeMemory(device, memoryObjects[ndx], (const VkAllocationCallbacks*)DE_NULL); + if (!!mem) + { + vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL); memoryObjects[ndx] = (VkDeviceMemory)0; } } - } - } - catch (...) - { - for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) - { - const VkDeviceMemory mem = memoryObjects[ndx]; - if (!!mem) - { - vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL); - memoryObjects[ndx] = (VkDeviceMemory)0; - } + throw; } - - throw; } } } -- 2.7.4