blob: 318da3421e69c0b77d87cd897c35ecaf57db323e [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
9#include "../perf.h"
10#include "../util/util.h"
11#include "../util/parse-options.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090012#include "../util/header.h"
Yann Droneaud57480d22014-06-30 22:28:47 +020013#include "../util/cloexec.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090014#include "bench.h"
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090015#include "mem-memcpy-arch.h"
Rabin Vincent5bce1a52014-12-02 16:50:40 +010016#include "mem-memset-arch.h"
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090017
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include <sys/time.h>
22#include <errno.h>
23
24#define K 1024
25
Ingo Molnara69b4f72015-10-19 10:04:25 +020026static const char *size_str = "1MB";
Ingo Molnare815e322015-10-19 10:04:24 +020027static const char *routine_str = "all";
Jan Beuliche3e877e2012-01-18 13:29:59 +000028static int iterations = 1;
Ingo Molnarb14f2d32015-10-19 10:04:23 +020029static bool use_cycles;
30static int cycles_fd;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090031
32static const struct option options[] = {
Ingo Molnara69b4f72015-10-19 10:04:25 +020033 OPT_STRING('l', "size", &size_str, "1MB",
34 "Specify the size of the memory buffers. "
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020035 "Available units: B, KB, MB, GB and TB (case insensitive)"),
36
Ingo Molnare815e322015-10-19 10:04:24 +020037 OPT_STRING('r', "routine", &routine_str, "all",
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020038 "Specify the routine to run, \"all\" runs all available routines, \"help\" lists them"),
39
Jan Beuliche3e877e2012-01-18 13:29:59 +000040 OPT_INTEGER('i', "iterations", &iterations,
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020041 "Repeat the function this number of times"),
42
Ingo Molnarb14f2d32015-10-19 10:04:23 +020043 OPT_BOOLEAN('c', "cycles", &use_cycles,
44 "Use a cycles event instead of gettimeofday() to measure performance"),
Ingo Molnar13b1fdc2015-10-19 10:04:26 +020045
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090046 OPT_END()
47};
48
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090049typedef void *(*memcpy_t)(void *, const void *, size_t);
Rabin Vincent5bce1a52014-12-02 16:50:40 +010050typedef void *(*memset_t)(void *, int, size_t);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090051
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090052struct routine {
53 const char *name;
54 const char *desc;
Rabin Vincent308197b2014-12-02 16:50:39 +010055 union {
56 memcpy_t memcpy;
Rabin Vincent5bce1a52014-12-02 16:50:40 +010057 memset_t memset;
Rabin Vincent308197b2014-12-02 16:50:39 +010058 } fn;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090059};
60
Rabin Vincent308197b2014-12-02 16:50:39 +010061struct routine memcpy_routines[] = {
Ingo Molnar13839ec2015-10-19 10:04:17 +020062 { .name = "default",
63 .desc = "Default memcpy() provided by glibc",
64 .fn.memcpy = memcpy },
65
Ingo Molnar89fe8082013-09-30 12:07:11 +020066#ifdef HAVE_ARCH_X86_64_SUPPORT
Ingo Molnar13839ec2015-10-19 10:04:17 +020067# define MEMCPY_FN(_fn, _name, _desc) {.name = _name, .desc = _desc, .fn.memcpy = _fn},
68# include "mem-memcpy-x86-64-asm-def.h"
69# undef MEMCPY_FN
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +090070#endif
71
Ingo Molnar13839ec2015-10-19 10:04:17 +020072 { NULL, }
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090073};
74
75static const char * const bench_mem_memcpy_usage[] = {
76 "perf bench mem memcpy <options>",
77 NULL
78};
79
Hitoshi Mitake17d7a112012-07-02 22:46:17 +090080static struct perf_event_attr cycle_attr = {
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +090081 .type = PERF_TYPE_HARDWARE,
82 .config = PERF_COUNT_HW_CPU_CYCLES
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090083};
84
Ingo Molnarb14f2d32015-10-19 10:04:23 +020085static void init_cycles(void)
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090086{
Ingo Molnarb14f2d32015-10-19 10:04:23 +020087 cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag());
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +090088
Ingo Molnarb14f2d32015-10-19 10:04:23 +020089 if (cycles_fd < 0 && errno == ENOSYS)
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +090090 die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
91 else
Ingo Molnarb14f2d32015-10-19 10:04:23 +020092 BUG_ON(cycles_fd < 0);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090093}
94
Ingo Molnarb14f2d32015-10-19 10:04:23 +020095static u64 get_cycles(void)
Hitoshi Mitake827f3b42009-11-18 00:20:09 +090096{
97 int ret;
98 u64 clk;
99
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200100 ret = read(cycles_fd, &clk, sizeof(u64));
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900101 BUG_ON(ret != sizeof(u64));
102
103 return clk;
104}
105
106static double timeval2double(struct timeval *ts)
107{
Ingo Molnar13839ec2015-10-19 10:04:17 +0200108 return (double)ts->tv_sec + (double)ts->tv_usec / (double)1000000;
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900109}
110
Ingo Molnar6db175c2015-10-19 10:04:21 +0200111#define print_bps(x) do { \
112 if (x < K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200113 printf(" %14lf bytes/sec\n", x); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200114 else if (x < K * K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200115 printf(" %14lfd KB/sec\n", x / K); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200116 else if (x < K * K * K) \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200117 printf(" %14lf MB/sec\n", x / K / K); \
Ingo Molnar6db175c2015-10-19 10:04:21 +0200118 else \
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200119 printf(" %14lf GB/sec\n", x / K / K / K); \
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900120 } while (0)
121
Rabin Vincent308197b2014-12-02 16:50:39 +0100122struct bench_mem_info {
123 const struct routine *routines;
Ingo Molnara69b4f72015-10-19 10:04:25 +0200124 u64 (*do_cycles)(const struct routine *r, size_t size);
125 double (*do_gettimeofday)(const struct routine *r, size_t size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100126 const char *const *usage;
127};
128
Ingo Molnara69b4f72015-10-19 10:04:25 +0200129static void __bench_mem_routine(struct bench_mem_info *info, int r_idx, size_t size, double size_total)
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900130{
Borislav Petkov515e23f2015-02-26 18:51:37 +0100131 const struct routine *r = &info->routines[r_idx];
Ingo Molnar6db175c2015-10-19 10:04:21 +0200132 double result_bps = 0.0;
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200133 u64 result_cycles = 0;
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900134
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200135 printf("# Routine '%s' (%s)\n", r->name, r->desc);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900136
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900137 if (bench_format == BENCH_FORMAT_DEFAULT)
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200138 printf("# Copying %s bytes ...\n\n", size_str);
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +0900139
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200140 if (use_cycles) {
Ingo Molnara69b4f72015-10-19 10:04:25 +0200141 result_cycles = info->do_cycles(r, size);
Hitoshi Mitake12eac0b2009-11-20 12:37:17 +0900142 } else {
Ingo Molnara69b4f72015-10-19 10:04:25 +0200143 result_bps = info->do_gettimeofday(r, size);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900144 }
145
146 switch (bench_format) {
147 case BENCH_FORMAT_DEFAULT:
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200148 if (use_cycles) {
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200149 printf(" %14lf cycles/byte\n", (double)result_cycles/size_total);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900150 } else {
Ingo Molnar6db175c2015-10-19 10:04:21 +0200151 print_bps(result_bps);
152 }
153 break;
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900154
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900155 case BENCH_FORMAT_SIMPLE:
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200156 if (use_cycles) {
Ingo Molnara69b4f72015-10-19 10:04:25 +0200157 printf("%lf\n", (double)result_cycles/size_total);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900158 } else {
Ingo Molnar6db175c2015-10-19 10:04:21 +0200159 printf("%lf\n", result_bps);
Hitoshi Mitake49ce8fc2010-11-25 16:04:52 +0900160 }
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900161 break;
Ingo Molnar6db175c2015-10-19 10:04:21 +0200162
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900163 default:
Ingo Molnar6db175c2015-10-19 10:04:21 +0200164 BUG_ON(1);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900165 break;
166 }
Borislav Petkov515e23f2015-02-26 18:51:37 +0100167}
168
Ingo Molnar2946f592015-10-19 10:04:19 +0200169static int bench_mem_common(int argc, const char **argv, struct bench_mem_info *info)
Borislav Petkov515e23f2015-02-26 18:51:37 +0100170{
171 int i;
Ingo Molnara69b4f72015-10-19 10:04:25 +0200172 size_t size;
173 double size_total;
Borislav Petkov515e23f2015-02-26 18:51:37 +0100174
Ingo Molnar13839ec2015-10-19 10:04:17 +0200175 argc = parse_options(argc, argv, options, info->usage, 0);
Borislav Petkov515e23f2015-02-26 18:51:37 +0100176
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200177 if (use_cycles)
178 init_cycles();
Borislav Petkov515e23f2015-02-26 18:51:37 +0100179
Ingo Molnara69b4f72015-10-19 10:04:25 +0200180 size = (size_t)perf_atoll((char *)size_str);
181 size_total = (double)size * iterations;
Borislav Petkov515e23f2015-02-26 18:51:37 +0100182
Ingo Molnara69b4f72015-10-19 10:04:25 +0200183 if ((s64)size <= 0) {
184 fprintf(stderr, "Invalid size:%s\n", size_str);
Borislav Petkov515e23f2015-02-26 18:51:37 +0100185 return 1;
186 }
187
Ingo Molnare815e322015-10-19 10:04:24 +0200188 if (!strncmp(routine_str, "all", 3)) {
Borislav Petkovdfecb952015-02-26 19:02:43 +0100189 for (i = 0; info->routines[i].name; i++)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200190 __bench_mem_routine(info, i, size, size_total);
Borislav Petkovdfecb952015-02-26 19:02:43 +0100191 return 0;
192 }
193
Borislav Petkov515e23f2015-02-26 18:51:37 +0100194 for (i = 0; info->routines[i].name; i++) {
Ingo Molnare815e322015-10-19 10:04:24 +0200195 if (!strcmp(info->routines[i].name, routine_str))
Borislav Petkov515e23f2015-02-26 18:51:37 +0100196 break;
197 }
198 if (!info->routines[i].name) {
Ingo Molnar13b1fdc2015-10-19 10:04:26 +0200199 if (strcmp(routine_str, "help") && strcmp(routine_str, "h"))
200 printf("Unknown routine: %s\n", routine_str);
201 printf("Available routines:\n");
Borislav Petkov515e23f2015-02-26 18:51:37 +0100202 for (i = 0; info->routines[i].name; i++) {
203 printf("\t%s ... %s\n",
204 info->routines[i].name, info->routines[i].desc);
205 }
206 return 1;
207 }
208
Ingo Molnara69b4f72015-10-19 10:04:25 +0200209 __bench_mem_routine(info, i, size, size_total);
Hitoshi Mitake827f3b42009-11-18 00:20:09 +0900210
211 return 0;
212}
Rabin Vincent308197b2014-12-02 16:50:39 +0100213
Ingo Molnara69b4f72015-10-19 10:04:25 +0200214static void memcpy_alloc_mem(void **dst, void **src, size_t size)
Rabin Vincent308197b2014-12-02 16:50:39 +0100215{
Ingo Molnara69b4f72015-10-19 10:04:25 +0200216 *dst = zalloc(size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100217 if (!*dst)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200218 die("memory allocation failed - maybe size is too large?\n");
Rabin Vincent308197b2014-12-02 16:50:39 +0100219
Ingo Molnara69b4f72015-10-19 10:04:25 +0200220 *src = zalloc(size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100221 if (!*src)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200222 die("memory allocation failed - maybe size is too large?\n");
Ingo Molnar13839ec2015-10-19 10:04:17 +0200223
224 /* Make sure to always prefault zero pages even if MMAP_THRESH is crossed: */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200225 memset(*src, 0, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100226}
227
Ingo Molnara69b4f72015-10-19 10:04:25 +0200228static u64 do_memcpy_cycles(const struct routine *r, size_t size)
Rabin Vincent308197b2014-12-02 16:50:39 +0100229{
230 u64 cycle_start = 0ULL, cycle_end = 0ULL;
231 void *src = NULL, *dst = NULL;
232 memcpy_t fn = r->fn.memcpy;
233 int i;
234
Ingo Molnara69b4f72015-10-19 10:04:25 +0200235 memcpy_alloc_mem(&dst, &src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100236
Ingo Molnar6db175c2015-10-19 10:04:21 +0200237 /*
238 * We prefault the freshly allocated memory range here,
239 * to not measure page fault overhead:
240 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200241 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100242
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200243 cycle_start = get_cycles();
Rabin Vincent308197b2014-12-02 16:50:39 +0100244 for (i = 0; i < iterations; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200245 fn(dst, src, size);
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200246 cycle_end = get_cycles();
Rabin Vincent308197b2014-12-02 16:50:39 +0100247
248 free(src);
249 free(dst);
250 return cycle_end - cycle_start;
251}
252
Ingo Molnara69b4f72015-10-19 10:04:25 +0200253static double do_memcpy_gettimeofday(const struct routine *r, size_t size)
Rabin Vincent308197b2014-12-02 16:50:39 +0100254{
255 struct timeval tv_start, tv_end, tv_diff;
256 memcpy_t fn = r->fn.memcpy;
257 void *src = NULL, *dst = NULL;
258 int i;
259
Ingo Molnara69b4f72015-10-19 10:04:25 +0200260 memcpy_alloc_mem(&dst, &src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100261
Ingo Molnar6db175c2015-10-19 10:04:21 +0200262 /*
263 * We prefault the freshly allocated memory range here,
264 * to not measure page fault overhead:
265 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200266 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100267
268 BUG_ON(gettimeofday(&tv_start, NULL));
269 for (i = 0; i < iterations; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200270 fn(dst, src, size);
Rabin Vincent308197b2014-12-02 16:50:39 +0100271 BUG_ON(gettimeofday(&tv_end, NULL));
272
273 timersub(&tv_end, &tv_start, &tv_diff);
274
275 free(src);
276 free(dst);
Ingo Molnar6db175c2015-10-19 10:04:21 +0200277
Ingo Molnara69b4f72015-10-19 10:04:25 +0200278 return (double)(((double)size * iterations) / timeval2double(&tv_diff));
Rabin Vincent308197b2014-12-02 16:50:39 +0100279}
280
Ingo Molnar2946f592015-10-19 10:04:19 +0200281int bench_mem_memcpy(int argc, const char **argv, const char *prefix __maybe_unused)
Rabin Vincent308197b2014-12-02 16:50:39 +0100282{
283 struct bench_mem_info info = {
Ingo Molnar13839ec2015-10-19 10:04:17 +0200284 .routines = memcpy_routines,
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200285 .do_cycles = do_memcpy_cycles,
Ingo Molnar13839ec2015-10-19 10:04:17 +0200286 .do_gettimeofday = do_memcpy_gettimeofday,
287 .usage = bench_mem_memcpy_usage,
Rabin Vincent308197b2014-12-02 16:50:39 +0100288 };
289
Ingo Molnar2946f592015-10-19 10:04:19 +0200290 return bench_mem_common(argc, argv, &info);
Rabin Vincent308197b2014-12-02 16:50:39 +0100291}
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100292
Ingo Molnara69b4f72015-10-19 10:04:25 +0200293static void memset_alloc_mem(void **dst, size_t size)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100294{
Ingo Molnara69b4f72015-10-19 10:04:25 +0200295 *dst = zalloc(size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100296 if (!*dst)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200297 die("memory allocation failed - maybe size is too large?\n");
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100298}
299
Ingo Molnara69b4f72015-10-19 10:04:25 +0200300static u64 do_memset_cycles(const struct routine *r, size_t size)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100301{
302 u64 cycle_start = 0ULL, cycle_end = 0ULL;
303 memset_t fn = r->fn.memset;
304 void *dst = NULL;
305 int i;
306
Ingo Molnara69b4f72015-10-19 10:04:25 +0200307 memset_alloc_mem(&dst, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100308
Ingo Molnar6db175c2015-10-19 10:04:21 +0200309 /*
310 * We prefault the freshly allocated memory range here,
311 * to not measure page fault overhead:
312 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200313 fn(dst, -1, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100314
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200315 cycle_start = get_cycles();
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100316 for (i = 0; i < iterations; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200317 fn(dst, i, size);
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200318 cycle_end = get_cycles();
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100319
320 free(dst);
321 return cycle_end - cycle_start;
322}
323
Ingo Molnara69b4f72015-10-19 10:04:25 +0200324static double do_memset_gettimeofday(const struct routine *r, size_t size)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100325{
326 struct timeval tv_start, tv_end, tv_diff;
327 memset_t fn = r->fn.memset;
328 void *dst = NULL;
329 int i;
330
Ingo Molnara69b4f72015-10-19 10:04:25 +0200331 memset_alloc_mem(&dst, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100332
Ingo Molnar6db175c2015-10-19 10:04:21 +0200333 /*
334 * We prefault the freshly allocated memory range here,
335 * to not measure page fault overhead:
336 */
Ingo Molnara69b4f72015-10-19 10:04:25 +0200337 fn(dst, -1, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100338
339 BUG_ON(gettimeofday(&tv_start, NULL));
340 for (i = 0; i < iterations; ++i)
Ingo Molnara69b4f72015-10-19 10:04:25 +0200341 fn(dst, i, size);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100342 BUG_ON(gettimeofday(&tv_end, NULL));
343
344 timersub(&tv_end, &tv_start, &tv_diff);
345
346 free(dst);
Ingo Molnara69b4f72015-10-19 10:04:25 +0200347 return (double)(((double)size * iterations) / timeval2double(&tv_diff));
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100348}
349
350static const char * const bench_mem_memset_usage[] = {
351 "perf bench mem memset <options>",
352 NULL
353};
354
355static const struct routine memset_routines[] = {
Ingo Molnar13839ec2015-10-19 10:04:17 +0200356 { .name = "default",
357 .desc = "Default memset() provided by glibc",
358 .fn.memset = memset },
359
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100360#ifdef HAVE_ARCH_X86_64_SUPPORT
Ingo Molnar13839ec2015-10-19 10:04:17 +0200361# define MEMSET_FN(_fn, _name, _desc) { .name = _name, .desc = _desc, .fn.memset = _fn },
362# include "mem-memset-x86-64-asm-def.h"
363# undef MEMSET_FN
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100364#endif
365
Ingo Molnar13839ec2015-10-19 10:04:17 +0200366 { NULL, }
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100367};
368
Ingo Molnar13839ec2015-10-19 10:04:17 +0200369int bench_mem_memset(int argc, const char **argv, const char *prefix __maybe_unused)
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100370{
371 struct bench_mem_info info = {
Ingo Molnar13839ec2015-10-19 10:04:17 +0200372 .routines = memset_routines,
Ingo Molnarb14f2d32015-10-19 10:04:23 +0200373 .do_cycles = do_memset_cycles,
Ingo Molnar13839ec2015-10-19 10:04:17 +0200374 .do_gettimeofday = do_memset_gettimeofday,
375 .usage = bench_mem_memset_usage,
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100376 };
377
Ingo Molnar2946f592015-10-19 10:04:19 +0200378 return bench_mem_common(argc, argv, &info);
Rabin Vincent5bce1a52014-12-02 16:50:40 +0100379}