Limit number of memory allocations to 4000.
authorMika Isojärvi <misojarvi@google.com>
Mon, 25 Jan 2016 19:01:27 +0000 (11:01 -0800)
committerMika Isojärvi <misojarvi@google.com>
Mon, 25 Jan 2016 19:16:21 +0000 (11:16 -0800)
Limit memory allocation count to 4000 in vulkan memory
allocation tests. Fixes issue #255.

Change-Id: I9a1bc129556ce44e1d3e3e8c474c6dc668cea814

external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp
external/vulkancts/mustpass/1.0.0/vk-default.txt

index af0cac0..35b1f46 100644 (file)
@@ -64,6 +64,12 @@ namespace memory
 {
 namespace
 {
+enum
+{
+       // The min max for allocation count is 4096. Use 4000 to take into account
+       // possible memory allocations made by layers etc.
+       MAX_ALLOCATION_COUNT = 4000
+};
 
 struct TestConfig
 {
@@ -115,6 +121,8 @@ tcu::TestStatus AllocateFreeTestInstance::iterate (void)
        const VkDevice                                                  device                          = m_context.getDevice();
        const DeviceInterface&                                  vkd                                     = m_context.getDeviceInterface();
 
+       DE_ASSERT(m_config.memoryAllocationCount <= MAX_ALLOCATION_COUNT);
+
        if (m_memoryTypeIndex == 0)
        {
                log << TestLog::Message << "Memory allocation count: " << m_config.memoryAllocationCount << TestLog::EndMessage;
@@ -271,6 +279,7 @@ public:
 
 private:
        const size_t            m_opCount;
+       deUint32                        m_memoryObjectCount;
        size_t                          m_opNdx;
        de::Random                      m_rng;
        vector<Heap>            m_heaps;
@@ -279,10 +288,11 @@ private:
 };
 
 RandomAllocFreeTestInstance::RandomAllocFreeTestInstance       (Context& context, deUint32 seed)
-       : TestInstance  (context)
-       , m_opCount             (128)
-       , m_opNdx               (0)
-       , m_rng                 (seed)
+       : TestInstance                  (context)
+       , m_opCount                             (128)
+       , m_memoryObjectCount   (0)
+       , m_opNdx                               (0)
+       , m_rng                                 (seed)
 {
        const VkPhysicalDevice                                  physicalDevice          = context.getPhysicalDevice();
        const InstanceInterface&                                vki                                     = context.getInstanceInterface();
@@ -358,7 +368,7 @@ tcu::TestStatus RandomAllocFreeTestInstance::iterate (void)
                else
                        allocateMore = false;
        }
-       else if (!m_nonEmptyHeaps.empty() && !m_nonFullHeaps.empty())
+       else if (!m_nonEmptyHeaps.empty() && !m_nonFullHeaps.empty() && (m_memoryObjectCount < MAX_ALLOCATION_COUNT))
                allocateMore = m_rng.getBool(); // Randomize if both operations are doable.
        else if (m_nonEmptyHeaps.empty())
                allocateMore = true; // Allocate more if there are no objects to free.
@@ -396,6 +406,7 @@ tcu::TestStatus RandomAllocFreeTestInstance::iterate (void)
 
                VK_CHECK(vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &heap.objects.back().memory));
                TCU_CHECK(!!heap.objects.back().memory);
+               m_memoryObjectCount++;
 
                // If heap was empty add to the non empty heaps.
                if (heap.memoryUsage == 0)
@@ -425,6 +436,7 @@ tcu::TestStatus RandomAllocFreeTestInstance::iterate (void)
 
                vkd.freeMemory(device, memoryObject.memory, (const VkAllocationCallbacks*)DE_NULL);
                memoryObject.memory = (VkDeviceMemory)0;
+               m_memoryObjectCount--;
 
                if (heap.memoryUsage >= heap.maxMemoryUsage && heap.memoryUsage - memoryObject.size < heap.maxMemoryUsage)
                        m_nonFullHeaps.push_back(heapNdx);
@@ -529,7 +541,7 @@ tcu::TestCaseGroup* createAllocationTests (tcu::TestContext& testCtx)
                                                if (allocationSize < 4096)
                                                        continue;
 
-                                               config.memoryAllocationCount    = (deUint32)(50 * MiB / allocationSize);
+                                               config.memoryAllocationCount    = de::min((deUint32)(50 * MiB / allocationSize), (deUint32)MAX_ALLOCATION_COUNT);
 
                                                if (config.memoryAllocationCount == 0
                                                        || config.memoryAllocationCount == 1
@@ -576,7 +588,7 @@ tcu::TestCaseGroup* createAllocationTests (tcu::TestContext& testCtx)
 
                                        if (allocationCount == -1)
                                        {
-                                               config.memoryAllocationCount    = (int)((1.00f / 8.00f) / ((float)allocationPercent / 100.0f));
+                                               config.memoryAllocationCount    = de::min((deUint32)((1.00f / 8.00f) / ((float)allocationPercent / 100.0f)), (deUint32)MAX_ALLOCATION_COUNT);
 
                                                if (config.memoryAllocationCount == 0
                                                        || config.memoryAllocationCount == 1
index df6a71d..ff531bb 100644 (file)
@@ -75764,32 +75764,32 @@ dEQP-VK.memory.allocation.basic.size_4KiB.forward.count_1
 dEQP-VK.memory.allocation.basic.size_4KiB.forward.count_10
 dEQP-VK.memory.allocation.basic.size_4KiB.forward.count_100
 dEQP-VK.memory.allocation.basic.size_4KiB.forward.count_1000
-dEQP-VK.memory.allocation.basic.size_4KiB.forward.count_12800
+dEQP-VK.memory.allocation.basic.size_4KiB.forward.count_4000
 dEQP-VK.memory.allocation.basic.size_4KiB.reverse.count_1
 dEQP-VK.memory.allocation.basic.size_4KiB.reverse.count_10
 dEQP-VK.memory.allocation.basic.size_4KiB.reverse.count_100
 dEQP-VK.memory.allocation.basic.size_4KiB.reverse.count_1000
-dEQP-VK.memory.allocation.basic.size_4KiB.reverse.count_12800
+dEQP-VK.memory.allocation.basic.size_4KiB.reverse.count_4000
 dEQP-VK.memory.allocation.basic.size_4KiB.mixed.count_1
 dEQP-VK.memory.allocation.basic.size_4KiB.mixed.count_10
 dEQP-VK.memory.allocation.basic.size_4KiB.mixed.count_100
 dEQP-VK.memory.allocation.basic.size_4KiB.mixed.count_1000
-dEQP-VK.memory.allocation.basic.size_4KiB.mixed.count_12800
+dEQP-VK.memory.allocation.basic.size_4KiB.mixed.count_4000
 dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_1
 dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_10
 dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_100
 dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_1000
-dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_6400
+dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_4000
 dEQP-VK.memory.allocation.basic.size_8KiB.reverse.count_1
 dEQP-VK.memory.allocation.basic.size_8KiB.reverse.count_10
 dEQP-VK.memory.allocation.basic.size_8KiB.reverse.count_100
 dEQP-VK.memory.allocation.basic.size_8KiB.reverse.count_1000
-dEQP-VK.memory.allocation.basic.size_8KiB.reverse.count_6400
+dEQP-VK.memory.allocation.basic.size_8KiB.reverse.count_4000
 dEQP-VK.memory.allocation.basic.size_8KiB.mixed.count_1
 dEQP-VK.memory.allocation.basic.size_8KiB.mixed.count_10
 dEQP-VK.memory.allocation.basic.size_8KiB.mixed.count_100
 dEQP-VK.memory.allocation.basic.size_8KiB.mixed.count_1000
-dEQP-VK.memory.allocation.basic.size_8KiB.mixed.count_6400
+dEQP-VK.memory.allocation.basic.size_8KiB.mixed.count_4000
 dEQP-VK.memory.allocation.basic.size_1MiB.forward.count_1
 dEQP-VK.memory.allocation.basic.size_1MiB.forward.count_10
 dEQP-VK.memory.allocation.basic.size_1MiB.forward.count_50