blob: 0251dd348124afc4c7a119503c5704d16ba1c3ff [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Hitoshi Mitake827f3b42009-11-18 00:20:09 +09002/*
3 * mem-memcpy.c
4 *
Ingo Molnar13839ec2015-10-19 10:04:17 +02005 * Simple memcpy() and memset() benchmarks
Hitoshi Mitake827f3b42009-11-18 00:20:09 +09006 *
7 * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
8 */
Hitoshi Mitake827f3b42009-11-18 00:20:09 +09009
Arnaldo Carvalho de Meloc2a218c2016-04-26 13:27:23 -030010#include "debug.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090011#include "../perf.h"
12#include "../util/util.h"
Josh Poimboeuf4b6ab942015-12-15 09:39:39 -060013#include <subcmd/parse-options.h>
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090014#include "../util/header.h"
Yann Droneaud57480d22014-06-30 22:28:47 +020015#include "../util/cloexec.h"
Arnaldo Carvalho de Meloa0675582017-04-17 16:51:59 -030016#include "../util/string2.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090017#include "bench.h"
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090018#include "mem-memcpy-arch.h"
Rabin Vincent5bce1a52014-12-02 16:50:40 +010019#include "mem-memset-arch.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090020
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24#include <sys/time.h>
25#include <errno.h>
Arnaldo Carvalho de Melof2b91be2016-08-08 14:59:21 -030026#include <linux/time64.h>
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090027
28#define K 1024
29
Ingo Molnara69b4f72015-10-19 10:04:25 +020030static const char *size_str = "1MB";
Ingo Molnar2f211c82015-10-19 10:04:29 +020031static const char *function_str = "all";
Ingo Molnarb0d22e52015-10-19 10:04:28 +020032static int nr_loops = 1;
Ingo Molnarb14f2d32015-10-19 10:04:23 +020033static bool use_cycles;
34static int cycles_fd;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090035
36static const struct option options[] = {
Ingo Molnarb0d22e52015-10-19 10:04:28 +020037 OPT_STRING('s', "size", &size_str, "1MB",
Ingo Molnara69b4f72015-10-19 10:04:25 +020038 "Specify the size of the memory buffers. "
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020039 "Available units: B, KB, MB, GB and TB (case insensitive)"),
40
Ingo Molnar2f211c82015-10-19 10:04:29 +020041 OPT_STRING('f', "function", &function_str, "all",
42 "Specify the function to run, \"all\" runs all available functions, \"help\" lists them"),
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020043
Ingo Molnarb0d22e52015-10-19 10:04:28 +020044 OPT_INTEGER('l', "nr_loops", &nr_loops,
45 "Specify the number of loops to run. (default: 1)"),
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020046
Ingo Molnarb14f2d32015-10-19 10:04:23 +020047 OPT_BOOLEAN('c', "cycles", &use_cycles,
48 "Use a cycles event instead of gettimeofday() to measure performance"),
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020049
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090050 OPT_END()
51};
52
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090053typedef void *(*memcpy_t)(void *, const void *, size_t);
Rabin Vincent5bce1a52014-12-02 16:50:40 +010054typedef void *(*memset_t)(void *, int, size_t);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090055
Ingo Molnar2f211c82015-10-19 10:04:29 +020056struct function {
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090057 const char *name;
58 const char *desc;
Rabin Vincent308197b2014-12-02 16:50:39 +010059 union {
60 memcpy_t memcpy;
Rabin Vincent5bce1a52014-12-02 16:50:40 +010061 memset_t memset;
Rabin Vincent308197b2014-12-02 16:50:39 +010062 } fn;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090063};
64
Hitoshi Mitake17d7a112012-07-02 22:46:17 +090065static struct perf_event_attr cycle_attr = {
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +090066 .type = PERF_TYPE_HARDWARE,
67 .config = PERF_COUNT_HW_CPU_CYCLES
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090068};
69
Arnaldo Carvalho de Meloc2a218c2016-04-26 13:27:23 -030070static int init_cycles(void)
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090071{
Ingo Molnarb14f2d32015-10-19 10:04:23 +020072 cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag());
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +090073
Arnaldo Carvalho de Meloc2a218c2016-04-26 13:27:23 -030074 if (cycles_fd < 0 && errno == ENOSYS) {
75 pr_debug("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
76 return -1;
77 }
78
79 return cycles_fd;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090080}
81
Ingo Molnarb14f2d32015-10-19 10:04:23 +020082static u64 get_cycles(void)
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090083{
84 int ret;
85 u64 clk;
86
Ingo Molnarb14f2d32015-10-19 10:04:23 +020087 ret = read(cycles_fd, &clk, sizeof(u64));
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090088 BUG_ON(ret != sizeof(u64));
89
90 return clk;
91}
92
93static double timeval2double(struct timeval *ts)
94{
Arnaldo Carvalho de Melof2b91be2016-08-08 14:59:21 -030095 return (double)ts->tv_sec + (double)ts->tv_usec / (double)USEC_PER_SEC;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090096}
97
Ingo Molnar6db175c2015-10-19 10:04:21 +020098#define print_bps(x) do { \
99 if (x < K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200100 printf(" %14lf bytes/sec\n", x); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200101 else if (x < K * K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200102 printf(" %14lfd KB/sec\n", x / K); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200103 else if (x < K * K * K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200104 printf(" %14lf MB/sec\n", x / K / K); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200105 else \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200106 printf(" %14lf GB/sec\n", x / K / K / K); \
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900107 } while (0)
108
Rabin Vincent308197b2014-12-02 16:50:39 +0100109struct bench_mem_info {
Ingo Molnar2f211c82015-10-19 10:04:29 +0200110 const struct function *functions;
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300111 u64 (*do_cycles)(const struct function *r, size_t size, void *src, void *dst);
112 double (*do_gettimeofday)(const struct function *r, size_t size, void *src, void *dst);
Rabin Vincent308197b2014-12-02 16:50:39 +0100113 const char *const *usage;
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300114 bool alloc_src;
Rabin Vincent308197b2014-12-02 16:50:39 +0100115};
116
Ingo Molnar2f211c82015-10-19 10:04:29 +0200117static 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 +0900118{
Ingo Molnar2f211c82015-10-19 10:04:29 +0200119 const struct function *r = &info->functions[r_idx];
Ingo Molnar6db175c2015-10-19 10:04:21 +0200120 double result_bps = 0.0;
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200121 u64 result_cycles = 0;
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300122 void *src = NULL, *dst = zalloc(size);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900123
Ingo Molnar2f211c82015-10-19 10:04:29 +0200124 printf("# function '%s' (%s)\n", r->name, r->desc);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900125
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300126 if (dst == NULL)
127 goto out_alloc_failed;
128
129 if (info->alloc_src) {
130 src = zalloc(size);
131 if (src == NULL)
132 goto out_alloc_failed;
133 }
134
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900135 if (bench_format == BENCH_FORMAT_DEFAULT)
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200136 printf("# Copying %s bytes ...\n\n", size_str);
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +0900137
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200138 if (use_cycles) {
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300139 result_cycles = info->do_cycles(r, size, src, dst);
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +0900140 } else {
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300141 result_bps = info->do_gettimeofday(r, size, src, dst);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900142 }
143
144 switch (bench_format) {
145 case BENCH_FORMAT_DEFAULT:
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200146 if (use_cycles) {
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200147 printf(" %14lf cycles/byte\n", (double)result_cycles/size_total);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900148 } else {
Ingo Molnar6db175c2015-10-19 10:04:21 +0200149 print_bps(result_bps);
150 }
151 break;
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900152
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900153 case BENCH_FORMAT_SIMPLE:
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200154 if (use_cycles) {
Ingo Molnara69b4f72015-10-19 10:04:25 +0200155 printf("%lf\n", (double)result_cycles/size_total);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900156 } else {
Ingo Molnar6db175c2015-10-19 10:04:21 +0200157 printf("%lf\n", result_bps);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900158 }
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900159 break;
Ingo Molnar6db175c2015-10-19 10:04:21 +0200160
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900161 default:
Ingo Molnar6db175c2015-10-19 10:04:21 +0200162 BUG_ON(1);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900163 break;
164 }
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300165
166out_free:
167 free(src);
168 free(dst);
169 return;
170out_alloc_failed:
171 printf("# Memory allocation failed - maybe size (%s) is too large?\n", size_str);
172 goto out_free;
Borislav Petkov515e23f2015-02-26 18:51:37 +0100173}
174
Ingo Molnar2946f592015-10-19 10:04:19 +0200175static int bench_mem_common(int argc, const char **argv, struct bench_mem_info *info)
Borislav Petkov515e23f2015-02-26 18:51:37 +0100176{
177 int i;
Ingo Molnara69b4f72015-10-19 10:04:25 +0200178 size_t size;
179 double size_total;
Borislav Petkov515e23f2015-02-26 18:51:37 +0100180
Ingo Molnar13839ec2015-10-19 10:04:17 +0200181 argc = parse_options(argc, argv, options, info->usage, 0);
Borislav Petkov515e23f2015-02-26 18:51:37 +0100182
Arnaldo Carvalho de Meloc2a218c2016-04-26 13:27:23 -0300183 if (use_cycles) {
184 i = init_cycles();
185 if (i < 0) {
186 fprintf(stderr, "Failed to open cycles counter\n");
187 return i;
188 }
189 }
Borislav Petkov515e23f2015-02-26 18:51:37 +0100190
Ingo Molnara69b4f72015-10-19 10:04:25 +0200191 size = (size_t)perf_atoll((char *)size_str);
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200192 size_total = (double)size * nr_loops;
Borislav Petkov515e23f2015-02-26 18:51:37 +0100193
Ingo Molnara69b4f72015-10-19 10:04:25 +0200194 if ((s64)size <= 0) {
195 fprintf(stderr, "Invalid size:%s\n", size_str);
Borislav Petkov515e23f2015-02-26 18:51:37 +0100196 return 1;
197 }
198
Ingo Molnar2f211c82015-10-19 10:04:29 +0200199 if (!strncmp(function_str, "all", 3)) {
200 for (i = 0; info->functions[i].name; i++)
201 __bench_mem_function(info, i, size, size_total);
Borislav Petkovdfecb952015-02-26 19:02:43 +0100202 return 0;
203 }
204
Ingo Molnar2f211c82015-10-19 10:04:29 +0200205 for (i = 0; info->functions[i].name; i++) {
206 if (!strcmp(info->functions[i].name, function_str))
Borislav Petkov515e23f2015-02-26 18:51:37 +0100207 break;
208 }
Ingo Molnar2f211c82015-10-19 10:04:29 +0200209 if (!info->functions[i].name) {
210 if (strcmp(function_str, "help") && strcmp(function_str, "h"))
211 printf("Unknown function: %s\n", function_str);
212 printf("Available functions:\n");
213 for (i = 0; info->functions[i].name; i++) {
Borislav Petkov515e23f2015-02-26 18:51:37 +0100214 printf("\t%s ... %s\n",
Ingo Molnar2f211c82015-10-19 10:04:29 +0200215 info->functions[i].name, info->functions[i].desc);
Borislav Petkov515e23f2015-02-26 18:51:37 +0100216 }
217 return 1;
218 }
219
Ingo Molnar2f211c82015-10-19 10:04:29 +0200220 __bench_mem_function(info, i, size, size_total);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900221
222 return 0;
223}
Rabin Vincent308197b2014-12-02 16:50:39 +0100224
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300225static u64 do_memcpy_cycles(const struct function *r, size_t size, void *src, void *dst)
Rabin Vincent308197b2014-12-02 16:50:39 +0100226{
227 u64 cycle_start = 0ULL, cycle_end = 0ULL;
Rabin Vincent308197b2014-12-02 16:50:39 +0100228 memcpy_t fn = r->fn.memcpy;
229 int i;
230
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300231 /* Make sure to always prefault zero pages even if MMAP_THRESH is crossed: */
232 memset(src, 0, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100233
Ingo Molnar6db175c2015-10-19 10:04:21 +0200234 /*
235 * We prefault the freshly allocated memory range here,
236 * to not measure page fault overhead:
237 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200238 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100239
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200240 cycle_start = get_cycles();
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200241 for (i = 0; i < nr_loops; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200242 fn(dst, src, size);
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200243 cycle_end = get_cycles();
Rabin Vincent308197b2014-12-02 16:50:39 +0100244
Rabin Vincent308197b2014-12-02 16:50:39 +0100245 return cycle_end - cycle_start;
246}
247
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300248static double do_memcpy_gettimeofday(const struct function *r, size_t size, void *src, void *dst)
Rabin Vincent308197b2014-12-02 16:50:39 +0100249{
250 struct timeval tv_start, tv_end, tv_diff;
251 memcpy_t fn = r->fn.memcpy;
Rabin Vincent308197b2014-12-02 16:50:39 +0100252 int i;
253
Ingo Molnar6db175c2015-10-19 10:04:21 +0200254 /*
255 * We prefault the freshly allocated memory range here,
256 * to not measure page fault overhead:
257 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200258 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100259
260 BUG_ON(gettimeofday(&tv_start, NULL));
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200261 for (i = 0; i < nr_loops; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200262 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100263 BUG_ON(gettimeofday(&tv_end, NULL));
264
265 timersub(&tv_end, &tv_start, &tv_diff);
266
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200267 return (double)(((double)size * nr_loops) / timeval2double(&tv_diff));
Rabin Vincent308197b2014-12-02 16:50:39 +0100268}
269
Ingo Molnar2f211c82015-10-19 10:04:29 +0200270struct function memcpy_functions[] = {
Ingo Molnar5dd93302015-10-19 10:04:27 +0200271 { .name = "default",
272 .desc = "Default memcpy() provided by glibc",
273 .fn.memcpy = memcpy },
274
275#ifdef HAVE_ARCH_X86_64_SUPPORT
276# define MEMCPY_FN(_fn, _name, _desc) {.name = _name, .desc = _desc, .fn.memcpy = _fn},
277# include "mem-memcpy-x86-64-asm-def.h"
278# undef MEMCPY_FN
279#endif
280
Arnaldo Carvalho de Meloa4c6a3e2015-10-19 18:17:25 -0300281 { .name = NULL, }
Ingo Molnar5dd93302015-10-19 10:04:27 +0200282};
283
284static const char * const bench_mem_memcpy_usage[] = {
285 "perf bench mem memcpy <options>",
286 NULL
287};
288
Arnaldo Carvalho de Melob0ad8ea2017-03-27 11:47:20 -0300289int bench_mem_memcpy(int argc, const char **argv)
Rabin Vincent308197b2014-12-02 16:50:39 +0100290{
291 struct bench_mem_info info = {
Ingo Molnar2f211c82015-10-19 10:04:29 +0200292 .functions = memcpy_functions,
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200293 .do_cycles = do_memcpy_cycles,
Ingo Molnar13839ec2015-10-19 10:04:17 +0200294 .do_gettimeofday = do_memcpy_gettimeofday,
295 .usage = bench_mem_memcpy_usage,
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300296 .alloc_src = true,
Rabin Vincent308197b2014-12-02 16:50:39 +0100297 };
298
Ingo Molnar2946f592015-10-19 10:04:19 +0200299 return bench_mem_common(argc, argv, &info);
Rabin Vincent308197b2014-12-02 16:50:39 +0100300}
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100301
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300302static u64 do_memset_cycles(const struct function *r, size_t size, void *src __maybe_unused, void *dst)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100303{
304 u64 cycle_start = 0ULL, cycle_end = 0ULL;
305 memset_t fn = r->fn.memset;
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100306 int i;
307
Ingo Molnar6db175c2015-10-19 10:04:21 +0200308 /*
309 * We prefault the freshly allocated memory range here,
310 * to not measure page fault overhead:
311 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200312 fn(dst, -1, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100313
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200314 cycle_start = get_cycles();
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200315 for (i = 0; i < nr_loops; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200316 fn(dst, i, size);
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200317 cycle_end = get_cycles();
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100318
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100319 return cycle_end - cycle_start;
320}
321
Arnaldo Carvalho de Melo47b57572016-10-14 17:52:18 -0300322static double do_memset_gettimeofday(const struct function *r, size_t size, void *src __maybe_unused, void *dst)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100323{
324 struct timeval tv_start, tv_end, tv_diff;
325 memset_t fn = r->fn.memset;
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100326 int i;
327
Ingo Molnar6db175c2015-10-19 10:04:21 +0200328 /*
329 * We prefault the freshly allocated memory range here,
330 * to not measure page fault overhead:
331 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200332 fn(dst, -1, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100333
334 BUG_ON(gettimeofday(&tv_start, NULL));
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200335 for (i = 0; i < nr_loops; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200336 fn(dst, i, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100337 BUG_ON(gettimeofday(&tv_end, NULL));
338
339 timersub(&tv_end, &tv_start, &tv_diff);
340
Ingo Molnarb0d22e52015-10-19 10:04:28 +0200341 return (double)(((double)size * nr_loops) / timeval2double(&tv_diff));
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100342}
343
344static const char * const bench_mem_memset_usage[] = {
345 "perf bench mem memset <options>",
346 NULL
347};
348
Ingo Molnar2f211c82015-10-19 10:04:29 +0200349static const struct function memset_functions[] = {
Ingo Molnar13839ec2015-10-19 10:04:17 +0200350 { .name = "default",
351 .desc = "Default memset() provided by glibc",
352 .fn.memset = memset },
353
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100354#ifdef HAVE_ARCH_X86_64_SUPPORT
Ingo Molnar13839ec2015-10-19 10:04:17 +0200355# define MEMSET_FN(_fn, _name, _desc) { .name = _name, .desc = _desc, .fn.memset = _fn },
356# include "mem-memset-x86-64-asm-def.h"
357# undef MEMSET_FN
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100358#endif
359
Arnaldo Carvalho de Meloa4c6a3e2015-10-19 18:17:25 -0300360 { .name = NULL, }
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100361};
362
Arnaldo Carvalho de Melob0ad8ea2017-03-27 11:47:20 -0300363int bench_mem_memset(int argc, const char **argv)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100364{
365 struct bench_mem_info info = {
Ingo Molnar2f211c82015-10-19 10:04:29 +0200366 .functions = memset_functions,
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200367 .do_cycles = do_memset_cycles,
Ingo Molnar13839ec2015-10-19 10:04:17 +0200368 .do_gettimeofday = do_memset_gettimeofday,
369 .usage = bench_mem_memset_usage,
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100370 };
371
Ingo Molnar2946f592015-10-19 10:04:19 +0200372 return bench_mem_common(argc, argv, &info);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100373}