blob: fbd732b54047976ec3abae8f54c630c6a6f78e2e [file] [log] [blame]
Hitoshi Mitake827f3b42009-11-18 00:20:09 +09001/*
2 * mem-memcpy.c
3 *
Ingo Molnar13839ec2015-10-19 10:04:17 +02004 * Simple memcpy() and memset() benchmarks
Hitoshi Mitake827f3b42009-11-18 00:20:09 +09005 *
6 * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
7 */
Hitoshi Mitake827f3b42009-11-18 00:20:09 +09008
Arnaldo Carvalho de Meloc2a218c2016-04-26 13:27:23 -03009#include "debug.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090010#include "../perf.h"
11#include "../util/util.h"
Josh Poimboeuf4b6ab942015-12-15 09:39:39 -060012#include <subcmd/parse-options.h>
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090013#include "../util/header.h"
Yann Droneaud57480d22014-06-30 22:28:47 +020014#include "../util/cloexec.h"
Arnaldo Carvalho de Meloa0675582017-04-17 16:51:59 -030015#include "../util/string2.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090016#include "bench.h"
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090017#include "mem-memcpy-arch.h"
Rabin Vincent5bce1a52014-12-02 16:50:40 +010018#include "mem-memset-arch.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090019
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <sys/time.h>
24#include <errno.h>
Arnaldo Carvalho de Melof2b91be2016-08-08 14:59:21 -030025#include <linux/time64.h>
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090026
27#define K 1024
28
Ingo Molnara69b4f72015-10-19 10:04:25 +020029static const char *size_str = "1MB";
Ingo Molnar2f211c82015-10-19 10:04:29 +020030static const char *function_str = "all";
Ingo Molnarb0d22e52015-10-19 10:04:28 +020031static int nr_loops = 1;
Ingo Molnarb14f2d32015-10-19 10:04:23 +020032static bool use_cycles;
33static int cycles_fd;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090034
35static const struct option options[] = {
Ingo Molnarb0d22e52015-10-19 10:04:28 +020036 OPT_STRING('s', "size", &size_str, "1MB",
Ingo Molnara69b4f72015-10-19 10:04:25 +020037 "Specify the size of the memory buffers. "
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020038 "Available units: B, KB, MB, GB and TB (case insensitive)"),
39
Ingo Molnar2f211c82015-10-19 10:04:29 +020040 OPT_STRING('f', "function", &function_str, "all",
41 "Specify the function to run, \"all\" runs all available functions, \"help\" lists them"),
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020042
Ingo Molnarb0d22e52015-10-19 10:04:28 +020043 OPT_INTEGER('l', "nr_loops", &nr_loops,
44 "Specify the number of loops to run. (default: 1)"),
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020045
Ingo Molnarb14f2d32015-10-19 10:04:23 +020046 OPT_BOOLEAN('c', "cycles", &use_cycles,
47 "Use a cycles event instead of gettimeofday() to measure performance"),
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020048
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090049 OPT_END()
50};
51
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090052typedef void *(*memcpy_t)(void *, const void *, size_t);
Rabin Vincent5bce1a52014-12-02 16:50:40 +010053typedef void *(*memset_t)(void *, int, size_t);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090054
Ingo Molnar2f211c82015-10-19 10:04:29 +020055struct function {
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090056 const char *name;
57 const char *desc;
Rabin Vincent308197b2014-12-02 16:50:39 +010058 union {
59 memcpy_t memcpy;
Rabin Vincent5bce1a52014-12-02 16:50:40 +010060 memset_t memset;
Rabin Vincent308197b2014-12-02 16:50:39 +010061 } fn;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090062};
63
Hitoshi Mitake17d7a112012-07-02 22:46:17 +090064static struct perf_event_attr cycle_attr = {
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +090065 .type = PERF_TYPE_HARDWARE,
66 .config = PERF_COUNT_HW_CPU_CYCLES
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090067};
68
Arnaldo Carvalho de Meloc2a218c2016-04-26 13:27:23 -030069static int init_cycles(void)
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090070{
Ingo Molnarb14f2d32015-10-19 10:04:23 +020071 cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag());
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +090072
Arnaldo Carvalho de Meloc2a218c2016-04-26 13:27:23 -030073 if (cycles_fd < 0 && errno == ENOSYS) {
74 pr_debug("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
75 return -1;
76 }
77
78 return cycles_fd;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090079}
80
Ingo Molnarb14f2d32015-10-19 10:04:23 +020081static u64 get_cycles(void)
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090082{
83 int ret;
84 u64 clk;
85
Ingo Molnarb14f2d32015-10-19 10:04:23 +020086 ret = read(cycles_fd, &clk, sizeof(u64));
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090087 BUG_ON(ret != sizeof(u64));
88
89 return clk;
90}
91
92static double timeval2double(struct timeval *ts)
93{
Arnaldo Carvalho de Melof2b91be2016-08-08 14:59:21 -030094 return (double)ts->tv_sec + (double)ts->tv_usec / (double)USEC_PER_SEC;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090095}
96
Ingo Molnar6db175c2015-10-19 10:04:21 +020097#define print_bps(x) do { \
98 if (x < K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020099 printf(" %14lf bytes/sec\n", x); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200100 else if (x < K * K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200101 printf(" %14lfd KB/sec\n", x / K); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200102 else if (x < K * K * K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200103 printf(" %14lf MB/sec\n", x / K / K); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200104 else \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200105 printf(" %14lf GB/sec\n", x / K / K / K); \
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900106 } while (0)
107
Rabin Vincent308197b2014-12-02 16:50:39 +0100108struct bench_mem_info {
Ingo Molnar2f211c82015-10-19 10:04:29 +0200109 const struct function *functions;
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300110 u64 (*do_cycles)(const struct function *r, size_t size, void *src, void *dst);
111 double (*do_gettimeofday)(const struct function *r, size_t size, void *src, void *dst);
Rabin Vincent308197b2014-12-02 16:50:39 +0100112 const char *const *usage;
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300113 bool alloc_src;
Rabin Vincent308197b2014-12-02 16:50:39 +0100114};
115
Ingo Molnar2f211c82015-10-19 10:04:29 +0200116static void __bench_mem_function(struct bench_mem_info *info, int r_idx, size_t size, double size_total)
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900117{
Ingo Molnar2f211c82015-10-19 10:04:29 +0200118 const struct function *r = &info->functions[r_idx];
Ingo Molnar6db175c2015-10-19 10:04:21 +0200119 double result_bps = 0.0;
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200120 u64 result_cycles = 0;
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300121 void *src = NULL, *dst = zalloc(size);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900122
Ingo Molnar2f211c82015-10-19 10:04:29 +0200123 printf("# function '%s' (%s)\n", r->name, r->desc);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900124
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300125 if (dst == NULL)
126 goto out_alloc_failed;
127
128 if (info->alloc_src) {
129 src = zalloc(size);
130 if (src == NULL)
131 goto out_alloc_failed;
132 }
133
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900134 if (bench_format == BENCH_FORMAT_DEFAULT)
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200135 printf("# Copying %s bytes ...\n\n", size_str);
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +0900136
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200137 if (use_cycles) {
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300138 result_cycles = info->do_cycles(r, size, src, dst);
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +0900139 } else {
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300140 result_bps = info->do_gettimeofday(r, size, src, dst);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900141 }
142
143 switch (bench_format) {
144 case BENCH_FORMAT_DEFAULT:
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200145 if (use_cycles) {
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200146 printf(" %14lf cycles/byte\n", (double)result_cycles/size_total);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900147 } else {
Ingo Molnar6db175c2015-10-19 10:04:21 +0200148 print_bps(result_bps);
149 }
150 break;
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900151
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900152 case BENCH_FORMAT_SIMPLE:
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200153 if (use_cycles) {
Ingo Molnara69b4f72015-10-19 10:04:25 +0200154 printf("%lf\n", (double)result_cycles/size_total);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900155 } else {
Ingo Molnar6db175c2015-10-19 10:04:21 +0200156 printf("%lf\n", result_bps);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900157 }
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900158 break;
Ingo Molnar6db175c2015-10-19 10:04:21 +0200159
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900160 default:
Ingo Molnar6db175c2015-10-19 10:04:21 +0200161 BUG_ON(1);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900162 break;
163 }
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300164
165out_free:
166 free(src);
167 free(dst);
168 return;
169out_alloc_failed:
170 printf("# Memory allocation failed - maybe size (%s) is too large?\n", size_str);
171 goto out_free;
Borislav Petkov515e23f2015-02-26 18:51:37 +0100172}
173
Ingo Molnar2946f592015-10-19 10:04:19 +0200174static int bench_mem_common(int argc, const char **argv, struct bench_mem_info *info)
Borislav Petkov515e23f2015-02-26 18:51:37 +0100175{
176 int i;
Ingo Molnara69b4f72015-10-19 10:04:25 +0200177 size_t size;
178 double size_total;
Borislav Petkov515e23f2015-02-26 18:51:37 +0100179
Ingo Molnar13839ec2015-10-19 10:04:17 +0200180 argc = parse_options(argc, argv, options, info->usage, 0);
Borislav Petkov515e23f2015-02-26 18:51:37 +0100181
Arnaldo Carvalho de Meloc2a218c2016-04-26 13:27:23 -0300182 if (use_cycles) {
183 i = init_cycles();
184 if (i < 0) {
185 fprintf(stderr, "Failed to open cycles counter\n");
186 return i;
187 }
188 }
Borislav Petkov515e23f2015-02-26 18:51:37 +0100189
Ingo Molnara69b4f72015-10-19 10:04:25 +0200190 size = (size_t)perf_atoll((char *)size_str);
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200191 size_total = (double)size * nr_loops;
Borislav Petkov515e23f2015-02-26 18:51:37 +0100192
Ingo Molnara69b4f72015-10-19 10:04:25 +0200193 if ((s64)size <= 0) {
194 fprintf(stderr, "Invalid size:%s\n", size_str);
Borislav Petkov515e23f2015-02-26 18:51:37 +0100195 return 1;
196 }
197
Ingo Molnar2f211c82015-10-19 10:04:29 +0200198 if (!strncmp(function_str, "all", 3)) {
199 for (i = 0; info->functions[i].name; i++)
200 __bench_mem_function(info, i, size, size_total);
Borislav Petkovdfecb952015-02-26 19:02:43 +0100201 return 0;
202 }
203
Ingo Molnar2f211c82015-10-19 10:04:29 +0200204 for (i = 0; info->functions[i].name; i++) {
205 if (!strcmp(info->functions[i].name, function_str))
Borislav Petkov515e23f2015-02-26 18:51:37 +0100206 break;
207 }
Ingo Molnar2f211c82015-10-19 10:04:29 +0200208 if (!info->functions[i].name) {
209 if (strcmp(function_str, "help") && strcmp(function_str, "h"))
210 printf("Unknown function: %s\n", function_str);
211 printf("Available functions:\n");
212 for (i = 0; info->functions[i].name; i++) {
Borislav Petkov515e23f2015-02-26 18:51:37 +0100213 printf("\t%s ... %s\n",
Ingo Molnar2f211c82015-10-19 10:04:29 +0200214 info->functions[i].name, info->functions[i].desc);
Borislav Petkov515e23f2015-02-26 18:51:37 +0100215 }
216 return 1;
217 }
218
Ingo Molnar2f211c82015-10-19 10:04:29 +0200219 __bench_mem_function(info, i, size, size_total);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900220
221 return 0;
222}
Rabin Vincent308197b2014-12-02 16:50:39 +0100223
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300224static u64 do_memcpy_cycles(const struct function *r, size_t size, void *src, void *dst)
Rabin Vincent308197b2014-12-02 16:50:39 +0100225{
226 u64 cycle_start = 0ULL, cycle_end = 0ULL;
Rabin Vincent308197b2014-12-02 16:50:39 +0100227 memcpy_t fn = r->fn.memcpy;
228 int i;
229
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300230 /* Make sure to always prefault zero pages even if MMAP_THRESH is crossed: */
231 memset(src, 0, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100232
Ingo Molnar6db175c2015-10-19 10:04:21 +0200233 /*
234 * We prefault the freshly allocated memory range here,
235 * to not measure page fault overhead:
236 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200237 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100238
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200239 cycle_start = get_cycles();
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200240 for (i = 0; i < nr_loops; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200241 fn(dst, src, size);
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200242 cycle_end = get_cycles();
Rabin Vincent308197b2014-12-02 16:50:39 +0100243
Rabin Vincent308197b2014-12-02 16:50:39 +0100244 return cycle_end - cycle_start;
245}
246
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300247static double do_memcpy_gettimeofday(const struct function *r, size_t size, void *src, void *dst)
Rabin Vincent308197b2014-12-02 16:50:39 +0100248{
249 struct timeval tv_start, tv_end, tv_diff;
250 memcpy_t fn = r->fn.memcpy;
Rabin Vincent308197b2014-12-02 16:50:39 +0100251 int i;
252
Ingo Molnar6db175c2015-10-19 10:04:21 +0200253 /*
254 * We prefault the freshly allocated memory range here,
255 * to not measure page fault overhead:
256 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200257 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100258
259 BUG_ON(gettimeofday(&tv_start, NULL));
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200260 for (i = 0; i < nr_loops; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200261 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100262 BUG_ON(gettimeofday(&tv_end, NULL));
263
264 timersub(&tv_end, &tv_start, &tv_diff);
265
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200266 return (double)(((double)size * nr_loops) / timeval2double(&tv_diff));
Rabin Vincent308197b2014-12-02 16:50:39 +0100267}
268
Ingo Molnar2f211c82015-10-19 10:04:29 +0200269struct function memcpy_functions[] = {
Ingo Molnar5dd93302015-10-19 10:04:27 +0200270 { .name = "default",
271 .desc = "Default memcpy() provided by glibc",
272 .fn.memcpy = memcpy },
273
274#ifdef HAVE_ARCH_X86_64_SUPPORT
275# define MEMCPY_FN(_fn, _name, _desc) {.name = _name, .desc = _desc, .fn.memcpy = _fn},
276# include "mem-memcpy-x86-64-asm-def.h"
277# undef MEMCPY_FN
278#endif
279
Arnaldo Carvalho de Meloa4c6a3e2015-10-19 18:17:25 -0300280 { .name = NULL, }
Ingo Molnar5dd93302015-10-19 10:04:27 +0200281};
282
283static const char * const bench_mem_memcpy_usage[] = {
284 "perf bench mem memcpy <options>",
285 NULL
286};
287
Arnaldo Carvalho de Melob0ad8ea2017-03-27 11:47:20 -0300288int bench_mem_memcpy(int argc, const char **argv)
Rabin Vincent308197b2014-12-02 16:50:39 +0100289{
290 struct bench_mem_info info = {
Ingo Molnar2f211c82015-10-19 10:04:29 +0200291 .functions = memcpy_functions,
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200292 .do_cycles = do_memcpy_cycles,
Ingo Molnar13839ec2015-10-19 10:04:17 +0200293 .do_gettimeofday = do_memcpy_gettimeofday,
294 .usage = bench_mem_memcpy_usage,
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300295 .alloc_src = true,
Rabin Vincent308197b2014-12-02 16:50:39 +0100296 };
297
Ingo Molnar2946f592015-10-19 10:04:19 +0200298 return bench_mem_common(argc, argv, &info);
Rabin Vincent308197b2014-12-02 16:50:39 +0100299}
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100300
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300301static u64 do_memset_cycles(const struct function *r, size_t size, void *src __maybe_unused, void *dst)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100302{
303 u64 cycle_start = 0ULL, cycle_end = 0ULL;
304 memset_t fn = r->fn.memset;
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100305 int i;
306
Ingo Molnar6db175c2015-10-19 10:04:21 +0200307 /*
308 * We prefault the freshly allocated memory range here,
309 * to not measure page fault overhead:
310 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200311 fn(dst, -1, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100312
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200313 cycle_start = get_cycles();
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200314 for (i = 0; i < nr_loops; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200315 fn(dst, i, size);
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200316 cycle_end = get_cycles();
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100317
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100318 return cycle_end - cycle_start;
319}
320
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300321static double do_memset_gettimeofday(const struct function *r, size_t size, void *src __maybe_unused, void *dst)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100322{
323 struct timeval tv_start, tv_end, tv_diff;
324 memset_t fn = r->fn.memset;
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100325 int i;
326
Ingo Molnar6db175c2015-10-19 10:04:21 +0200327 /*
328 * We prefault the freshly allocated memory range here,
329 * to not measure page fault overhead:
330 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200331 fn(dst, -1, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100332
333 BUG_ON(gettimeofday(&tv_start, NULL));
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200334 for (i = 0; i < nr_loops; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200335 fn(dst, i, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100336 BUG_ON(gettimeofday(&tv_end, NULL));
337
338 timersub(&tv_end, &tv_start, &tv_diff);
339
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200340 return (double)(((double)size * nr_loops) / timeval2double(&tv_diff));
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100341}
342
343static const char * const bench_mem_memset_usage[] = {
344 "perf bench mem memset <options>",
345 NULL
346};
347
Ingo Molnar2f211c82015-10-19 10:04:29 +0200348static const struct function memset_functions[] = {
Ingo Molnar13839ec2015-10-19 10:04:17 +0200349 { .name = "default",
350 .desc = "Default memset() provided by glibc",
351 .fn.memset = memset },
352
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100353#ifdef HAVE_ARCH_X86_64_SUPPORT
Ingo Molnar13839ec2015-10-19 10:04:17 +0200354# define MEMSET_FN(_fn, _name, _desc) { .name = _name, .desc = _desc, .fn.memset = _fn },
355# include "mem-memset-x86-64-asm-def.h"
356# undef MEMSET_FN
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100357#endif
358
Arnaldo Carvalho de Meloa4c6a3e2015-10-19 18:17:25 -0300359 { .name = NULL, }
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100360};
361
Arnaldo Carvalho de Melob0ad8ea2017-03-27 11:47:20 -0300362int bench_mem_memset(int argc, const char **argv)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100363{
364 struct bench_mem_info info = {
Ingo Molnar2f211c82015-10-19 10:04:29 +0200365 .functions = memset_functions,
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200366 .do_cycles = do_memset_cycles,
Ingo Molnar13839ec2015-10-19 10:04:17 +0200367 .do_gettimeofday = do_memset_gettimeofday,
368 .usage = bench_mem_memset_usage,
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100369 };
370
Ingo Molnar2946f592015-10-19 10:04:19 +0200371 return bench_mem_common(argc, argv, &info);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100372}