Add command line parameter deqp-subprocess-cfg-file
authorPawel Ksiezopolski <pawel.ksiezopolski@mobica.com>
Mon, 6 Dec 2021 21:35:38 +0000 (22:35 +0100)
committerPawel Ksiezopolski <pawel.ksiezopolski@mobica.com>
Thu, 9 Dec 2021 16:44:27 +0000 (17:44 +0100)
Default subprocess test count is defined by command line parameter
deqp-subprocess-test-count. New parameter ( deqp-subprocess-cfg-file )
may be used to modify default value for test subtrees.

Affects tests:
dEQP-VKSC.*

Components:
Framework VulkanSC

VK-GL-CTS Issue: 3320

Change-Id: Ic36e569f73f93e360f55cbfbe048160cce87f6cf

external/vulkancts/README.md
external/vulkancts/framework/vulkan/vkResourceInterface.cpp
external/vulkancts/framework/vulkan/vkResourceInterface.hpp
external/vulkancts/modules/vulkan/vktTestPackage.cpp
framework/common/tcuCommandLine.cpp
framework/common/tcuCommandLine.hpp

index a1f7c67..e9d7593 100644 (file)
@@ -144,7 +144,7 @@ Running CTS
 
 Following command line options MUST be used when running CTS:
 
-       --deqp-caselist-file=<vulkancts>/external/vulkancts/mustpass/master/vk-default.txt
+       --deqp-caselist-file=<vulkancts>/external/vulkancts/mustpass/master/vk-default.txt (or vksc-default.txt for Vulkan SC implementations)
        --deqp-log-images=disable
        --deqp-log-shader-sources=disable
 
@@ -245,6 +245,17 @@ are performed on separate process in a single batch:
 
        --deqp-subprocess-test-count=<value>
 
+Above mentioned parameter works as default value for all tests.
+You may also define how many tests are performed on a separate process
+for specific test tree branch using parameter:
+
+       --deqp-subprocess-cfg-file=<path>
+
+File should contain test pattern followed by numeric value, for example:
+dEQP-VKSC.api.copy_and_blit.core.image_to_image.dimensions.src32768x4_dst32768x4.*, 5
+dEQP-VKSC.texture.explicit_lod.2d.sizes.*, 20
+dEQP-VKSC.texture.explicit_lod.2d.sizes.128x128_*, 4
+
 There is also one option used by CTS internally and should not be used manually.
 It informs deqp-vksc application that it works as subprocess:
 
@@ -254,7 +265,7 @@ No other command line options are allowed.
 
 ### Win32
 
-    Vulkan:
+       Vulkan:
 
        cd <builddir>/external/vulkancts/modules/vulkan
        Debug\deqp-vk.exe --deqp-caselist-file=...
@@ -268,7 +279,7 @@ Test log will be written into TestResults.qpa
 
 ### Linux
 
-    Vulkan:
+       Vulkan:
 
        cd <builddir>/external/vulkancts/modules/vulkan
        ./deqp-vk --deqp-caselist-file=...
@@ -797,8 +808,12 @@ OpenGL and OpenCL parameters not affecting Vulkan API were suppressed.
     default: 'disable'
 
   --deqp-subprocess-test-count=<value>
-    Define number of tests performed in subprocess (Vulkan SC only)
-    default: '64'
+    Define default number of tests performed in subprocess (Vulkan SC only)
+    default: '65536'
+
+  --deqp-subprocess-cfg-file=<path>
+       Config file defining number of tests performed in subprocess for specific test branches (Vulkan SC only)
+    default: ''
 
   --deqp-server-address=<value>
     Server address (host:port) responsible for shader compilation (Vulkan SC only)
index fdeebac..71be33f 100644 (file)
@@ -65,6 +65,11 @@ void ResourceInterface::initTestCase (const std::string& casePath)
        m_currentTestPath = casePath;
 }
 
+const std::string& ResourceInterface::getCasePath() const
+{
+       return m_currentTestPath;
+}
+
 #ifdef CTS_USES_VULKANSC
 void ResourceInterface::initApiVersion (const deUint32 version)
 {
index 01725f4..614be14 100644 (file)
@@ -52,6 +52,7 @@ public:
        virtual void                                                                                            deinitDevice                            (VkDevice                                                               device) = 0;
 
        virtual void                                                                                            initTestCase                            (const std::string&                                             casePath);
+       const std::string&                                                                                      getCasePath                                     () const;
 
        // buildProgram
        template <typename InfoType, typename IteratorType>
index 8a077e3..8aeba9d 100644 (file)
@@ -134,28 +134,37 @@ using tcu::TestLog;
 
 // TestCaseExecutor
 
+#ifdef CTS_USES_VULKANSC
+struct DetailedSubprocessTestCount
+{
+       std::string                                                                     testPattern;
+       int                                                                                     testCount;
+};
+#endif // CTS_USES_VULKANSC
+
 class TestCaseExecutor : public tcu::TestCaseExecutor
 {
 public:
-                                                                                               TestCaseExecutor        (tcu::TestContext& testCtx);
-                                                                                               ~TestCaseExecutor       (void);
+                                                                                               TestCaseExecutor                        (tcu::TestContext& testCtx);
+                                                                                               ~TestCaseExecutor                       (void);
 
-       void                                                                            init                            (tcu::TestCase* testCase, const std::string& path) override;
-       void                                                                            deinit                          (tcu::TestCase* testCase) override;
+       void                                                                            init                                            (tcu::TestCase* testCase, const std::string& path) override;
+       void                                                                            deinit                                          (tcu::TestCase* testCase) override;
 
-       tcu::TestNode::IterateResult                            iterate                         (tcu::TestCase* testCase) override;
+       tcu::TestNode::IterateResult                            iterate                                         (tcu::TestCase* testCase) override;
 
-       void                                                                            deinitTestPackage       (tcu::TestContext& testCtx) override;
-       bool                                                                            usesLocalStatus         () override;
-       void                                                                            updateGlobalStatus      (tcu::TestRunStatus& status) override;
-       void                                                                            reportDurations         (tcu::TestContext& testCtx, const std::string& packageName, const deInt64& duration, const std::map<std::string, deUint64>& groupsDurationTime) override;
+       void                                                                            deinitTestPackage                       (tcu::TestContext& testCtx) override;
+       bool                                                                            usesLocalStatus                         () override;
+       void                                                                            updateGlobalStatus                      (tcu::TestRunStatus& status) override;
+       void                                                                            reportDurations                         (tcu::TestContext& testCtx, const std::string& packageName, const deInt64& duration, const std::map<std::string, deUint64>& groupsDurationTime) override;
+       int                                                                                     getCurrentSubprocessCount       (const std::string& casePath, int defaultSubprocessCount);
 
 private:
-       void                                                                            logUnusedShaders        (tcu::TestCase* testCase);
+       void                                                                            logUnusedShaders                (tcu::TestCase* testCase);
 
-       void                                                                            runTestsInSubprocess(tcu::TestContext& testCtx);
+       void                                                                            runTestsInSubprocess    (tcu::TestContext& testCtx);
 
-       bool                                                                            spirvVersionSupported(vk::SpirvVersion);
+       bool                                                                            spirvVersionSupported   (vk::SpirvVersion);
 
        vk::BinaryCollection                                            m_progCollection;
        vk::BinaryRegistryReader                                        m_prebuiltBinRegistry;
@@ -174,7 +183,8 @@ private:
 
 #ifdef CTS_USES_VULKANSC
        std::unique_ptr<vksc_server::ipc::Parent>       m_parentIPC;
-#endif
+       std::vector<DetailedSubprocessTestCount>        m_detailedSubprocessTestCount;
+#endif // CTS_USES_VULKANSC
 };
 
 #ifdef CTS_USES_VULKANSC
@@ -184,7 +194,7 @@ static deBool       openWrite                               (int type, const char* message)                                 { DE_UNREF(type);
 static deBool  openWriteFtm                    (int type, const char* format, va_list args)    { DE_UNREF(type); DE_UNREF(format); DE_UNREF(args); return true; }
 static void            suppressStandardOutput  ()                                                                                              { qpRedirectOut(supressedWrite, supressedWriteFtm); }
 static void            restoreStandardOutput   ()                                                                                              { qpRedirectOut(openWrite, openWriteFtm); }
-#endif
+#endif // CTS_USES_VULKANSC
 
 static MovePtr<vk::Library> createLibrary (tcu::TestContext& testCtx)
 {
@@ -201,6 +211,16 @@ static vk::VkPhysicalDeviceProperties getPhysicalDeviceProperties(vkt::Context&
        return properties;
 }
 
+std::string trim (const std::string& original)
+{
+       static const std::string whiteSigns = " \t";
+       const auto beg = original.find_first_not_of(whiteSigns);
+       if (beg == std::string::npos)
+               return std::string();
+       const auto end = original.find_last_not_of(whiteSigns);
+       return original.substr(beg, end - beg + 1);
+}
+
 TestCaseExecutor::TestCaseExecutor (tcu::TestContext& testCtx)
        : m_prebuiltBinRegistry (testCtx.getArchive(), "vulkan/prebuilt")
        , m_library                             (createLibrary(testCtx))
@@ -239,6 +259,41 @@ TestCaseExecutor::TestCaseExecutor (tcu::TestContext& testCtx)
                m_parentIPC.reset( new vksc_server::ipc::Parent{portOffset} );
        }
 
+       // Load information about test tree branches that use subprocess test count other than default
+       // Expected file format:
+       if (!testCtx.getCommandLine().isSubProcess() && !std::string(testCtx.getCommandLine().getSubprocessConfigFile()).empty())
+       {
+               std::ifstream                   iFile(testCtx.getCommandLine().getSubprocessConfigFile(), std::ios::in);
+               if (!iFile)
+                       TCU_THROW(InternalError, (std::string("Missing config file defining number of tests: ") + testCtx.getCommandLine().getSubprocessConfigFile()).c_str());
+               std::string line;
+               while (std::getline(iFile, line))
+               {
+                       if (line.empty())
+                               continue;
+                       std::size_t pos = line.find_first_of(',');
+                       if (pos == std::string::npos)
+                               continue;
+                       std::string testPattern, testNumber;
+                       std::copy(line.begin(), line.begin() + pos, std::back_inserter(testPattern));
+                       testPattern = trim(testPattern);
+                       std::copy(line.begin() + pos + 1, line.end(), std::back_inserter(testNumber));
+                       testNumber = trim(testNumber);
+                       if (testPattern.empty() || testNumber.empty())
+                               continue;
+                       std::istringstream is(testNumber);
+                       int testCount;
+                       if ((is >> testCount).fail())
+                               continue;
+                       m_detailedSubprocessTestCount.push_back(DetailedSubprocessTestCount{ testPattern, testCount });
+               }
+               // sort test patterns
+               std::sort(m_detailedSubprocessTestCount.begin(), m_detailedSubprocessTestCount.end(), [](const DetailedSubprocessTestCount& lhs, const DetailedSubprocessTestCount& rhs)
+                       {
+                               return lhs.testCount < rhs.testCount;
+                       } );
+       }
+
        // If we are provided with remote location
        if (!std::string(testCtx.getCommandLine().getServerAddress()).empty())
        {
@@ -417,7 +472,8 @@ void TestCaseExecutor::deinit (tcu::TestCase* testCase)
 #ifdef CTS_USES_VULKANSC
        if (!m_context->getTestContext().getCommandLine().isSubProcess())
        {
-               if (m_testsForSubprocess.size() >= std::size_t(m_context->getTestContext().getCommandLine().getSubprocessTestCount()) )
+               int currentSubprocessCount = getCurrentSubprocessCount(m_context->getResourceInterface()->getCasePath(), m_context->getTestContext().getCommandLine().getSubprocessTestCount());
+               if (m_testsForSubprocess.size() >= std::size_t(currentSubprocessCount) )
                {
                        runTestsInSubprocess(m_context->getTestContext());
 
@@ -580,6 +636,18 @@ void TestCaseExecutor::reportDurations(tcu::TestContext& testCtx, const std::str
 
 }
 
+int TestCaseExecutor::getCurrentSubprocessCount(const std::string& casePath, int defaultSubprocessCount)
+{
+#ifdef CTS_USES_VULKANSC
+       for (const auto& detailed : m_detailedSubprocessTestCount)
+               if (tcu::matchWildcards(detailed.testPattern.begin(), detailed.testPattern.end(), casePath.begin(), casePath.end(), false))
+                       return detailed.testCount;
+#else
+       DE_UNREF(casePath);
+#endif // CTS_USES_VULKANSC
+       return defaultSubprocessCount;
+}
+
 void TestCaseExecutor::runTestsInSubprocess (tcu::TestContext& testCtx)
 {
 #ifdef CTS_USES_VULKANSC
index 55b08a2..5e953b9 100644 (file)
@@ -107,6 +107,7 @@ DE_DECLARE_COMMAND_LINE_OPT(RunnerType,                                     tcu::TestRunnerType);
 DE_DECLARE_COMMAND_LINE_OPT(TerminateOnFail,                   bool);
 DE_DECLARE_COMMAND_LINE_OPT(SubProcess,                                        bool);
 DE_DECLARE_COMMAND_LINE_OPT(SubprocessTestCount,               int);
+DE_DECLARE_COMMAND_LINE_OPT(SubprocessConfigFile,              std::string);
 DE_DECLARE_COMMAND_LINE_OPT(ServerAddress,                             std::string);
 DE_DECLARE_COMMAND_LINE_OPT(CommandPoolMinSize,                        int);
 DE_DECLARE_COMMAND_LINE_OPT(CommandDefaultSize,                        int);
@@ -230,7 +231,8 @@ void registerOptions (de::cmdline::Parser& parser)
                << Option<RunnerType>                                   (DE_NULL,       "deqp-runner-type",                                                     "Filter test cases based on runner",                            s_runnerTypes,          "any")
                << Option<TerminateOnFail>                              (DE_NULL,       "deqp-terminate-on-fail",                                       "Terminate the run on first failure",                           s_enableNames,          "disable")
                << Option<SubProcess>                                   (DE_NULL,       "deqp-subprocess",                                                      "Inform app that it works as subprocess (Vulkan SC only, do not use manually)", s_enableNames, "disable")
-               << Option<SubprocessTestCount>                  (DE_NULL,       "deqp-subprocess-test-count",                           "Define number of tests performed in subprocess (Vulkan SC only)",              "64")
+               << Option<SubprocessTestCount>                  (DE_NULL,       "deqp-subprocess-test-count",                           "Define default number of tests performed in subprocess for specific test cases(Vulkan SC only)",       "65536")
+               << Option<SubprocessConfigFile>                 (DE_NULL,       "deqp-subprocess-cfg-file",                                     "Config file defining number of tests performed in subprocess for specific test branches (Vulkan SC only)", "")
                << Option<ServerAddress>                                (DE_NULL,       "deqp-server-address",                                          "Server address (host:port) responsible for shader compilation (Vulkan SC only)", "")
                << Option<CommandPoolMinSize>                   (DE_NULL,       "deqp-command-pool-min-size",                           "Define minimum size of the command pool (in bytes) to use (Vulkan SC only)","0")
                << Option<CommandDefaultSize>                   (DE_NULL,       "deqp-command-default-size",                            "Define default single command size (in bytes) to use (Vulkan SC only)",        "256")
@@ -1028,6 +1030,15 @@ const char* CommandLine::getEGLPixmapType (void) const
                return DE_NULL;
 }
 
+const char* CommandLine::getSubprocessConfigFile (void) const
+{
+       if (m_cmdLine.hasOption<opt::SubprocessConfigFile>())
+               return m_cmdLine.getOption<opt::SubprocessConfigFile>().c_str();
+       else
+               return DE_NULL;
+}
+
+
 const char* CommandLine::getServerAddress (void) const
 {
        if (m_cmdLine.hasOption<opt::ServerAddress>())
index ece37a9..2dd4e8f 100644 (file)
@@ -277,9 +277,12 @@ public:
        //! Start as subprocess ( Vulkan SC )
        bool                                                    isSubProcess                            (void) const;
 
-       //! Define number of tests performed in main process ( Vulkan SC )
+       //! Define default number of tests performed in main process ( Vulkan SC )
        int                                                             getSubprocessTestCount          (void) const;
 
+       //! Config file defining number of tests performed in subprocess for specific test branches
+       const char*                                             getSubprocessConfigFile         (void) const;
+
        //! Optional server address that will be responsible for (among other things) compiling shaders ( Vulkan SC )
        const char*                                             getServerAddress                        (void) const;