<div dir="ltr"><div dir="ltr">This patch has been pushed to the public repo.<br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><b>__________________________</b></div><div><b>Karam Singh</b></div><div><b>Ph.D. IIT Guwahati</b></div><div><font size="1">Senior Software (Video Coding) Engineer </font></div><div><font size="1">Mobile: +91 8011279030</font></div><div><font size="1">Block 9A, 6th floor, DLF Cyber City</font></div><div><font size="1">Manapakkam, Chennai 600 089</font></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 11, 2024 at 10:10 PM George Steed <<a href="mailto:george.steed@arm.com">george.steed@arm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Allow disabling benchmarking if we are just running tests to check for<br>
correctness. This requires us to refactor parameter parsing to enable<br>
options without an argument.<br>
---<br>
source/test/testbench.cpp | 72 +++++++++++++++++++++++----------------<br>
1 file changed, 42 insertions(+), 30 deletions(-)<br>
<br>
diff --git a/source/test/testbench.cpp b/source/test/testbench.cpp<br>
index de5fef2c2..ac93e37b3 100644<br>
--- a/source/test/testbench.cpp<br>
+++ b/source/test/testbench.cpp<br>
@@ -83,9 +83,10 @@ const char* const* chromaPartStr[X265_CSP_COUNT] =<br>
void do_help()<br>
{<br>
printf("x265 optimized primitive testbench\n\n");<br>
- printf("usage: TestBench [--cpuid CPU] [--testbench BENCH] [--help]\n\n");<br>
+ printf("usage: TestBench [--cpuid CPU] [--testbench BENCH] [--nobench] [--help]\n\n");<br>
printf(" CPU is comma separated SIMD arch list, example: SSE4,AVX\n");<br>
printf(" BENCH is one of (pixel,transforms,interp,intrapred)\n\n");<br>
+ printf(" --nobench disables running benchmarks, only run correctness tests\n\n");<br>
printf("By default, the test bench will test all benches on detected CPU architectures\n");<br>
printf("Options and testbench name may be truncated.\n");<br>
}<br>
@@ -100,13 +101,9 @@ int main(int argc, char *argv[])<br>
bool enableavx512 = true;<br>
int cpuid = X265_NS::cpu_detect(enableavx512);<br>
const char *testname = 0;<br>
+ bool run_benchmarks = true;<br>
<br>
- if (!(argc & 1))<br>
- {<br>
- do_help();<br>
- return 0;<br>
- }<br>
- for (int i = 1; i < argc - 1; i += 2)<br>
+ for (int i = 1; i < argc; )<br>
{<br>
if (strncmp(argv[i], "--", 2))<br>
{<br>
@@ -115,8 +112,13 @@ int main(int argc, char *argv[])<br>
return 1;<br>
}<br>
const char *name = argv[i] + 2;<br>
- const char *value = argv[i + 1];<br>
- if (!strncmp(name, "cpuid", strlen(name)))<br>
+ const char *value = i + 1 < argc ? argv[i + 1] : "";<br>
+ if (!strncmp(name, "help", strlen(name)))<br>
+ {<br>
+ do_help();<br>
+ return 0;<br>
+ }<br>
+ else if (!strncmp(name, "cpuid", strlen(name)))<br>
{<br>
bool bError = false;<br>
cpuid = parseCpuName(value, bError, enableavx512);<br>
@@ -125,11 +127,19 @@ int main(int argc, char *argv[])<br>
printf("Invalid CPU name: %s\n", value);<br>
return 1;<br>
}<br>
+ i += 2;<br>
}<br>
else if (!strncmp(name, "testbench", strlen(name)))<br>
{<br>
testname = value;<br>
printf("Testing only harnesses that match name <%s>\n", testname);<br>
+ i += 2;<br>
+ }<br>
+ else if (!strncmp(name, "nobench", strlen(name)))<br>
+ {<br>
+ printf("Disabling performance benchmarking\n");<br>
+ run_benchmarks = false;<br>
+ i += 1;<br>
}<br>
else<br>
{<br>
@@ -233,34 +243,36 @@ int main(int argc, char *argv[])<br>
}<br>
<br>
/******************* Cycle count for all primitives **********************/<br>
-<br>
- EncoderPrimitives optprim;<br>
- memset(&optprim, 0, sizeof(optprim));<br>
+ if (run_benchmarks)<br>
+ {<br>
+ EncoderPrimitives optprim;<br>
+ memset(&optprim, 0, sizeof(optprim));<br>
#if defined(X265_ARCH_X86) || defined(X265_ARCH_ARM64)<br>
- setupIntrinsicPrimitives(optprim, cpuid);<br>
+ setupIntrinsicPrimitives(optprim, cpuid);<br>
#endif<br>
<br>
- setupAssemblyPrimitives(optprim, cpuid);<br>
+ setupAssemblyPrimitives(optprim, cpuid);<br>
<br>
- /* Note that we do not setup aliases for performance tests, that would be<br>
- * redundant. The testbench only verifies they are correctly aliased */<br>
+ /* Note that we do not setup aliases for performance tests, that would be<br>
+ * redundant. The testbench only verifies they are correctly aliased */<br>
<br>
- /* some hybrid primitives may rely on other primitives in the<br>
- * global primitive table, so set up those pointers. This is a<br>
- * bit ugly, but I don't see a better solution */<br>
- memcpy(&primitives, &optprim, sizeof(EncoderPrimitives));<br>
+ /* some hybrid primitives may rely on other primitives in the<br>
+ * global primitive table, so set up those pointers. This is a<br>
+ * bit ugly, but I don't see a better solution */<br>
+ memcpy(&primitives, &optprim, sizeof(EncoderPrimitives));<br>
<br>
- printf("\nTest performance improvement with full optimizations\n");<br>
- fflush(stdout);<br>
+ printf("\nTest performance improvement with full optimizations\n");<br>
+ fflush(stdout);<br>
<br>
- for (size_t h = 0; h < sizeof(harness) / sizeof(TestHarness*); h++)<br>
- {<br>
- if (testname && strncmp(testname, harness[h]->getName(), strlen(testname)))<br>
- continue;<br>
- printf("== %s primitives ==\n", harness[h]->getName());<br>
- harness[h]->measureSpeed(cprim, optprim);<br>
- }<br>
+ for (size_t h = 0; h < sizeof(harness) / sizeof(TestHarness*); h++)<br>
+ {<br>
+ if (testname && strncmp(testname, harness[h]->getName(), strlen(testname)))<br>
+ continue;<br>
+ printf("== %s primitives ==\n", harness[h]->getName());<br>
+ harness[h]->measureSpeed(cprim, optprim);<br>
+ }<br>
<br>
- printf("\n");<br>
+ printf("\n");<br>
+ }<br>
return 0;<br>
}<br>
-- <br>
2.34.1<br>
<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div>