[FFmpeg-cvslog] cpu-test: test av_cpu_count
Janne Grunau
git at videolan.org
Mon Aug 4 04:12:44 CEST 2014
ffmpeg | branch: master | Janne Grunau <janne-libav at jannau.net> | Sun Aug 3 13:03:13 2014 +0200| [caf5ef852bf71984d3322bbeaf48cfb04ac8255f] | committer: Janne Grunau
cpu-test: test av_cpu_count
Add CPU count and number threads as informative values for fate.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=caf5ef852bf71984d3322bbeaf48cfb04ac8255f
---
libavutil/cpu.c | 14 +++++++++++++-
tests/fate/libavutil.mak | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 20f0fe1..a7e5f7f 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -180,6 +180,7 @@ int av_cpu_count(void)
#ifdef TEST
#include <stdio.h>
+#include "avstring.h"
#if !HAVE_GETOPT
#include "compat/getopt.c"
@@ -245,12 +246,14 @@ int main(int argc, char **argv)
{
int cpu_flags_raw = av_get_cpu_flags();
int cpu_flags_eff;
+ int cpu_count = av_cpu_count();
+ char threads[5] = "auto";
if (cpu_flags_raw < 0)
return 1;
for (;;) {
- int c = getopt(argc, argv, "c:");
+ int c = getopt(argc, argv, "c:t:");
if (c == -1)
break;
switch (c) {
@@ -262,6 +265,14 @@ int main(int argc, char **argv)
av_set_cpu_flags_mask(cpuflags);
break;
}
+ case 't':
+ {
+ int len = av_strlcpy(threads, optarg, sizeof(threads));
+ if (len >= sizeof(threads)) {
+ fprintf(stderr, "Invalid thread count '%s'\n", optarg);
+ return 2;
+ }
+ }
}
}
@@ -272,6 +283,7 @@ int main(int argc, char **argv)
print_cpu_flags(cpu_flags_raw, "raw");
print_cpu_flags(cpu_flags_eff, "effective");
+ fprintf(stderr, "threads = %s (cpu_count = %d)\n", threads, cpu_count);
return 0;
}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 44d88c4..7f3329b 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -27,7 +27,7 @@ fate-blowfish: CMD = run libavutil/blowfish-test
FATE_LIBAVUTIL += fate-cpu
fate-cpu: libavutil/cpu-test$(EXESUF)
-fate-cpu: CMD = run libavutil/cpu-test $(CPUFLAGS:%=-c%)
+fate-cpu: CMD = run libavutil/cpu-test $(CPUFLAGS:%=-c%) $(THREADS:%=-t%)
fate-cpu: REF = /dev/null
FATE_LIBAVUTIL += fate-crc
More information about the ffmpeg-cvslog
mailing list