Skip to contentSkip to conversation

perf bench sched cpu-matrix benchmark

PATCH Superseded Kamalesh Babulal 3 participants 4 messages Nov 4, 2011 – Nov 14, 2011 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf bench sched cpu-matrix benchmark

Hi,

During the discussion of the nohz load balancer fix
(https://lkml.org/lkml/2011/9/27/197), Ingo Molnar suggested to replace the simple while1 loop, used for publishing the test results with cpu-matrix test. This patch adds cpu-matrix benchmark under perf bench.

TODO:
- Provide option to run main thread at real-time priority.
- Provide option for changing scheduling priority/policy of worker threads.

perf bench: Add sched cpu-matrix benchmark

perf bench sched cpu-matrix benchmark is a matrix multiplication workload, which can be replaced with the traditional while1 cpu hog.

Example of usage:

% perf bench sched cpu-matrix
# Running sched/cpu-matrix benchmark...

Multiplication of [20] x [20] matrix, using [1] threads
Total time: 0.000170 [sec]

% perf bench sched cpu-matrix -s1k -t3
# Running sched/cpu-matrix benchmark...
elapsed time = 0.100066 sec, progress = 27270868
elapsed time = 0.100079 sec, progress = 27299841
elapsed time = 0.100071 sec, progress = 27253513
elapsed time = 0.100073 sec, progress = 27272693
elapsed time = 0.100090 sec, progress = 10208415

Multiplication of [1024] x [1024] matrix, using [3] threads
Total time: 0.500495 [sec]

% perf bench --format=simple sched cpu-matrix -s1k -t3
Total time: 0.454764 [sec]

--

 tools/perf/Makefile           |    1 +
 tools/perf/bench/bench.h      |    2 +
 tools/perf/bench/cpu-matrix.c |  410 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin-bench.c    |    3 +
 4 files changed, 416 insertions(+), 0 deletions(-)
tools/perf/Makefile +1 -0
index b98e307..02bd562 100644
@@ -363,6 +363,7 @@ ifeq ($(RAW_ARCH),x86_64)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
+BUILTIN_OBJS += $(OUTPUT)bench/cpu-matrix.o
 
 BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
 BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o
tools/perf/bench/bench.h +2 -0
index f7781c6..174465a 100644
@@ -4,6 +4,8 @@
 extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
 extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
 extern int bench_mem_memcpy(int argc, const char **argv, const char *prefix __used);
+extern int bench_cpu_matrix(int argc, const char **argv,
+				const char *prefix __used);
 
 #define BENCH_FORMAT_DEFAULT_STR	"default"
 #define BENCH_FORMAT_DEFAULT		0
tools/perf/bench/cpu-matrix.c new file +410 -0

410 lines not on this page · raw message

tools/perf/builtin-bench.c +3 -0
index fcb9626..df84428 100644
@@ -42,6 +42,9 @@ static struct bench_suite sched_suites[] = {
 	{ "pipe",
 	  "Flood of communication over pipe() between two processes",
 	  bench_sched_pipe      },
+	{ "cpu-matrix",
+	  "Benchmark to run cpu matrix multiplication",
+	  bench_cpu_matrix      },
 	suite_all,
 	{ NULL,
 	  NULL,
#1 lore raw
Quoted 2 lines · Kamalesh Babulal

+/*
+ * Prints the progress of multipilcations done by all threads

Fix typo:
s/multipilcations/multiplications

Quoted 3 lines

+ * every sleep_msec
+ */
+static void print_progress(struct thread_work *work, int thread_count)

We should perhaps add 'sleep_msec' argument to this function.

- vatsa

#2 lore raw
In reply to Kamalesh Babulal
Quoted 36 lines · Kamalesh Babulal

Hi,

During the discussion of the nohz load balancer fix
(https://lkml.org/lkml/2011/9/27/197), Ingo Molnar suggested to replace the simple while1 loop, used for publishing the test results with cpu-matrix test. This patch adds cpu-matrix benchmark under perf bench.

TODO:
- Provide option to run main thread at real-time priority.
- Provide option for changing scheduling priority/policy of worker threads.

perf bench: Add sched cpu-matrix benchmark

perf bench sched cpu-matrix benchmark is a matrix multiplication workload, which can be replaced with the traditional while1 cpu hog.

Example of usage:

% perf bench sched cpu-matrix
# Running sched/cpu-matrix benchmark...

Multiplication of [20] x [20] matrix, using [1] threads
Total time: 0.000170 [sec]

% perf bench sched cpu-matrix -s1k -t3
# Running sched/cpu-matrix benchmark...
elapsed time = 0.100066 sec, progress = 27270868
elapsed time = 0.100079 sec, progress = 27299841
elapsed time = 0.100071 sec, progress = 27253513
elapsed time = 0.100073 sec, progress = 27272693
elapsed time = 0.100090 sec, progress = 10208415

Quoted 2 lines

Multiplication of [1024] x [1024] matrix, using [3] threads
Total time: 0.500495 [sec]

It would be nice to also print the *size* of the matrix, in MBs or so. 1024x1024 of int, long, float ... or double?

Looks pretty useful otherwise. Arnaldo, any objections?

Thanks,

Ingo

#3 lore raw

PATCH v2 1/1 perf bench sched cpu-matrix benchmark

Hi Ingo,
Thanks for the review.

Changes from v1:
- Addressed the review comments from Vatsa and Ingo.
- Added support for creating master/worker thread(s) with individual policy and priority.
- Changed the format of printing the progress multiplications of thread(s).

perf bench: Add sched cpu-matrix benchmark

perf bench sched cpu-matrix benchmark is a matrix multiplication workload, which can be replaced with the traditional while1 cpu hog.

Example of usage:

% perf bench sched cpu-matrix
# Running sched/cpu-matrix benchmark...

Multiplication of [20] x [20] matrix, using [1] threads
Total time: 0.000170 [sec]

% perf bench sched cpu-matrix -s1024 -t10 -p1000
# Running sched/cpu-matrix benchmark...
57701987 multiplications over 1.000069 [sec]
60361191 multiplications over 1.000119 [sec]
...
20753139 multiplications over 1.000151 [sec]

Multiplication of [1K] x [1K] matrix, of unsigned int using [10] threads
Total time: 19.002301 [sec]

% perf bench --format=simple sched cpu-matrix -s1k -t10
Total time: 18.601030 [sec]

% perf bench sched cpu-matrix -s1k -t10 -wr99 -p1000 # Running sched/cpu-matrix benchmark... 56894683 multiplications over 1.000071 [sec] 53085285 multiplications over 1.000115 [sec]
...
37727908 multiplications over 1.000127 [sec]

Multiplication of [1K] x [1K] matrix, of unsigned int using [10] threads
Total time: 19.002302 [sec]

---
 tools/perf/Makefile           |    1 +
 tools/perf/bench/bench.h      |    2 +
 tools/perf/bench/cpu-matrix.c |  573 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin-bench.c    |    3 +
 4 files changed, 579 insertions(+), 0 deletions(-)
tools/perf/Makefile +1 -0
index b98e307..02bd562 100644
@@ -363,6 +363,7 @@ ifeq ($(RAW_ARCH),x86_64)
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
 endif
 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
+BUILTIN_OBJS += $(OUTPUT)bench/cpu-matrix.o
 
 BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
 BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o
tools/perf/bench/bench.h +2 -0
index f7781c6..174465a 100644
@@ -4,6 +4,8 @@
 extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
 extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
 extern int bench_mem_memcpy(int argc, const char **argv, const char *prefix __used);
+extern int bench_cpu_matrix(int argc, const char **argv,
+				const char *prefix __used);
 
 #define BENCH_FORMAT_DEFAULT_STR	"default"
 #define BENCH_FORMAT_DEFAULT		0
tools/perf/bench/cpu-matrix.c new file +573 -0

573 lines not on this page · raw message

tools/perf/builtin-bench.c +3 -0
index fcb9626..df84428 100644
@@ -42,6 +42,9 @@ static struct bench_suite sched_suites[] = {
 	{ "pipe",
 	  "Flood of communication over pipe() between two processes",
 	  bench_sched_pipe      },
+	{ "cpu-matrix",
+	  "Benchmark to run cpu matrix multiplication",
+	  bench_cpu_matrix      },
 	suite_all,
 	{ NULL,
 	  NULL,