2009-11-17 15:20:09 +00:00
|
|
|
/*
|
|
|
|
* mem-memcpy.c
|
|
|
|
*
|
2015-10-19 08:04:17 +00:00
|
|
|
* Simple memcpy() and memset() benchmarks
|
2009-11-17 15:20:09 +00:00
|
|
|
*
|
|
|
|
* Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../perf.h"
|
|
|
|
#include "../util/util.h"
|
|
|
|
#include "../util/parse-options.h"
|
|
|
|
#include "../util/header.h"
|
2014-06-30 20:28:47 +00:00
|
|
|
#include "../util/cloexec.h"
|
2009-11-17 15:20:09 +00:00
|
|
|
#include "bench.h"
|
2010-11-25 07:04:52 +00:00
|
|
|
#include "mem-memcpy-arch.h"
|
2014-12-02 15:50:40 +00:00
|
|
|
#include "mem-memset-arch.h"
|
2009-11-17 15:20:09 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#define K 1024
|
|
|
|
|
2009-11-20 03:37:17 +00:00
|
|
|
static const char *length_str = "1MB";
|
2015-10-19 08:04:18 +00:00
|
|
|
static const char *routine = "all";
|
2012-01-18 13:29:59 +00:00
|
|
|
static int iterations = 1;
|
2012-07-02 13:46:17 +00:00
|
|
|
static bool use_cycle;
|
|
|
|
static int cycle_fd;
|
2010-11-25 07:04:52 +00:00
|
|
|
static bool only_prefault;
|
|
|
|
static bool no_prefault;
|
2009-11-17 15:20:09 +00:00
|
|
|
|
|
|
|
static const struct option options[] = {
|
|
|
|
OPT_STRING('l', "length", &length_str, "1MB",
|
|
|
|
"Specify length of memory to copy. "
|
2012-06-20 06:08:06 +00:00
|
|
|
"Available units: B, KB, MB, GB and TB (upper and lower)"),
|
2015-10-19 08:04:18 +00:00
|
|
|
OPT_STRING('r', "routine", &routine, "all",
|
2015-02-26 18:02:43 +00:00
|
|
|
"Specify routine to copy, \"all\" runs all available routines"),
|
2012-01-18 13:29:59 +00:00
|
|
|
OPT_INTEGER('i', "iterations", &iterations,
|
|
|
|
"repeat memcpy() invocation this number of times"),
|
2012-07-02 13:46:17 +00:00
|
|
|
OPT_BOOLEAN('c', "cycle", &use_cycle,
|
2012-06-20 06:08:06 +00:00
|
|
|
"Use cycles event instead of gettimeofday() for measuring"),
|
2010-11-25 07:04:52 +00:00
|
|
|
OPT_BOOLEAN('o', "only-prefault", &only_prefault,
|
|
|
|
"Show only the result with page faults before memcpy()"),
|
|
|
|
OPT_BOOLEAN('n', "no-prefault", &no_prefault,
|
|
|
|
"Show only the result without page faults before memcpy()"),
|
2009-11-17 15:20:09 +00:00
|
|
|
OPT_END()
|
|
|
|
};
|
|
|
|
|
2010-11-25 07:04:52 +00:00
|
|
|
typedef void *(*memcpy_t)(void *, const void *, size_t);
|
2014-12-02 15:50:40 +00:00
|
|
|
typedef void *(*memset_t)(void *, int, size_t);
|
2010-11-25 07:04:52 +00:00
|
|
|
|
2009-11-17 15:20:09 +00:00
|
|
|
struct routine {
|
|
|
|
const char *name;
|
|
|
|
const char *desc;
|
2014-12-02 15:50:39 +00:00
|
|
|
union {
|
|
|
|
memcpy_t memcpy;
|
2014-12-02 15:50:40 +00:00
|
|
|
memset_t memset;
|
2014-12-02 15:50:39 +00:00
|
|
|
} fn;
|
2009-11-17 15:20:09 +00:00
|
|
|
};
|
|
|
|
|
2014-12-02 15:50:39 +00:00
|
|
|
struct routine memcpy_routines[] = {
|
2015-10-19 08:04:17 +00:00
|
|
|
{ .name = "default",
|
|
|
|
.desc = "Default memcpy() provided by glibc",
|
|
|
|
.fn.memcpy = memcpy },
|
2010-11-25 07:04:52 +00:00
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
#ifdef HAVE_ARCH_X86_64_SUPPORT
|
|
|
|
# define MEMCPY_FN(_fn, _name, _desc) {.name = _name, .desc = _desc, .fn.memcpy = _fn},
|
|
|
|
# include "mem-memcpy-x86-64-asm-def.h"
|
|
|
|
# undef MEMCPY_FN
|
2010-11-25 07:04:52 +00:00
|
|
|
#endif
|
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
{ NULL, }
|
2009-11-17 15:20:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const bench_mem_memcpy_usage[] = {
|
|
|
|
"perf bench mem memcpy <options>",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-07-02 13:46:17 +00:00
|
|
|
static struct perf_event_attr cycle_attr = {
|
2009-11-20 03:37:17 +00:00
|
|
|
.type = PERF_TYPE_HARDWARE,
|
|
|
|
.config = PERF_COUNT_HW_CPU_CYCLES
|
2009-11-17 15:20:09 +00:00
|
|
|
};
|
|
|
|
|
2012-07-02 13:46:17 +00:00
|
|
|
static void init_cycle(void)
|
2009-11-17 15:20:09 +00:00
|
|
|
{
|
2015-10-19 08:04:17 +00:00
|
|
|
cycle_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag());
|
2009-11-20 03:37:17 +00:00
|
|
|
|
2012-07-02 13:46:17 +00:00
|
|
|
if (cycle_fd < 0 && errno == ENOSYS)
|
2009-11-20 03:37:17 +00:00
|
|
|
die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
|
|
|
|
else
|
2012-07-02 13:46:17 +00:00
|
|
|
BUG_ON(cycle_fd < 0);
|
2009-11-17 15:20:09 +00:00
|
|
|
}
|
|
|
|
|
2012-07-02 13:46:17 +00:00
|
|
|
static u64 get_cycle(void)
|
2009-11-17 15:20:09 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
u64 clk;
|
|
|
|
|
2012-07-02 13:46:17 +00:00
|
|
|
ret = read(cycle_fd, &clk, sizeof(u64));
|
2009-11-17 15:20:09 +00:00
|
|
|
BUG_ON(ret != sizeof(u64));
|
|
|
|
|
|
|
|
return clk;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double timeval2double(struct timeval *ts)
|
|
|
|
{
|
2015-10-19 08:04:17 +00:00
|
|
|
return (double)ts->tv_sec + (double)ts->tv_usec / (double)1000000;
|
2009-11-17 15:20:09 +00:00
|
|
|
}
|
|
|
|
|
2010-11-25 07:04:52 +00:00
|
|
|
#define print_bps(x) do { \
|
|
|
|
if (x < K) \
|
|
|
|
printf(" %14lf B/Sec", x); \
|
|
|
|
else if (x < K * K) \
|
|
|
|
printf(" %14lfd KB/Sec", x / K); \
|
|
|
|
else if (x < K * K * K) \
|
|
|
|
printf(" %14lf MB/Sec", x / K / K); \
|
|
|
|
else \
|
|
|
|
printf(" %14lf GB/Sec", x / K / K / K); \
|
|
|
|
} while (0)
|
|
|
|
|
2014-12-02 15:50:39 +00:00
|
|
|
struct bench_mem_info {
|
|
|
|
const struct routine *routines;
|
|
|
|
u64 (*do_cycle)(const struct routine *r, size_t len, bool prefault);
|
|
|
|
double (*do_gettimeofday)(const struct routine *r, size_t len, bool prefault);
|
|
|
|
const char *const *usage;
|
|
|
|
};
|
|
|
|
|
2015-02-26 17:51:37 +00:00
|
|
|
static void __bench_mem_routine(struct bench_mem_info *info, int r_idx, size_t len, double totallen)
|
2009-11-17 15:20:09 +00:00
|
|
|
{
|
2015-02-26 17:51:37 +00:00
|
|
|
const struct routine *r = &info->routines[r_idx];
|
2010-11-25 07:04:52 +00:00
|
|
|
double result_bps[2];
|
2012-07-02 13:46:17 +00:00
|
|
|
u64 result_cycle[2];
|
2015-10-19 08:04:17 +00:00
|
|
|
int prefault = no_prefault ? 0 : 1;
|
2009-11-17 15:20:09 +00:00
|
|
|
|
2012-07-02 13:46:17 +00:00
|
|
|
result_cycle[0] = result_cycle[1] = 0ULL;
|
2010-11-25 07:04:52 +00:00
|
|
|
result_bps[0] = result_bps[1] = 0.0;
|
|
|
|
|
2015-02-26 18:02:43 +00:00
|
|
|
printf("Routine %s (%s)\n", r->name, r->desc);
|
2009-11-17 15:20:09 +00:00
|
|
|
|
2010-11-25 07:04:52 +00:00
|
|
|
if (bench_format == BENCH_FORMAT_DEFAULT)
|
|
|
|
printf("# Copying %s Bytes ...\n\n", length_str);
|
2009-11-17 15:20:09 +00:00
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
if (!only_prefault && prefault) {
|
|
|
|
/* Show both results: */
|
2012-07-02 13:46:17 +00:00
|
|
|
if (use_cycle) {
|
2015-02-26 17:51:37 +00:00
|
|
|
result_cycle[0] = info->do_cycle(r, len, false);
|
|
|
|
result_cycle[1] = info->do_cycle(r, len, true);
|
2010-11-25 07:04:52 +00:00
|
|
|
} else {
|
2015-02-26 17:51:37 +00:00
|
|
|
result_bps[0] = info->do_gettimeofday(r, len, false);
|
|
|
|
result_bps[1] = info->do_gettimeofday(r, len, true);
|
2010-11-25 07:04:52 +00:00
|
|
|
}
|
2009-11-17 15:20:09 +00:00
|
|
|
} else {
|
2015-02-26 17:51:37 +00:00
|
|
|
if (use_cycle)
|
2015-10-19 08:04:17 +00:00
|
|
|
result_cycle[prefault] = info->do_cycle(r, len, only_prefault);
|
2015-02-26 17:51:37 +00:00
|
|
|
else
|
2015-10-19 08:04:17 +00:00
|
|
|
result_bps[prefault] = info->do_gettimeofday(r, len, only_prefault);
|
2009-11-17 15:20:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (bench_format) {
|
|
|
|
case BENCH_FORMAT_DEFAULT:
|
2015-10-19 08:04:17 +00:00
|
|
|
if (!only_prefault && prefault) {
|
2012-07-02 13:46:17 +00:00
|
|
|
if (use_cycle) {
|
|
|
|
printf(" %14lf Cycle/Byte\n",
|
|
|
|
(double)result_cycle[0]
|
2014-12-02 15:50:41 +00:00
|
|
|
/ totallen);
|
2012-07-02 13:46:17 +00:00
|
|
|
printf(" %14lf Cycle/Byte (with prefault)\n",
|
|
|
|
(double)result_cycle[1]
|
2014-12-02 15:50:41 +00:00
|
|
|
/ totallen);
|
2010-11-25 07:04:52 +00:00
|
|
|
} else {
|
|
|
|
print_bps(result_bps[0]);
|
|
|
|
printf("\n");
|
|
|
|
print_bps(result_bps[1]);
|
|
|
|
printf(" (with prefault)\n");
|
2009-11-17 15:20:09 +00:00
|
|
|
}
|
2010-11-25 07:04:52 +00:00
|
|
|
} else {
|
2012-07-02 13:46:17 +00:00
|
|
|
if (use_cycle) {
|
|
|
|
printf(" %14lf Cycle/Byte",
|
2015-10-19 08:04:17 +00:00
|
|
|
(double)result_cycle[prefault]
|
2014-12-02 15:50:41 +00:00
|
|
|
/ totallen);
|
2010-11-25 07:04:52 +00:00
|
|
|
} else
|
2015-10-19 08:04:17 +00:00
|
|
|
print_bps(result_bps[prefault]);
|
2010-11-25 07:04:52 +00:00
|
|
|
|
|
|
|
printf("%s\n", only_prefault ? " (with prefault)" : "");
|
2009-11-17 15:20:09 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BENCH_FORMAT_SIMPLE:
|
2015-10-19 08:04:17 +00:00
|
|
|
if (!only_prefault && prefault) {
|
2012-07-02 13:46:17 +00:00
|
|
|
if (use_cycle) {
|
2010-11-25 07:04:52 +00:00
|
|
|
printf("%lf %lf\n",
|
2014-12-02 15:50:41 +00:00
|
|
|
(double)result_cycle[0] / totallen,
|
|
|
|
(double)result_cycle[1] / totallen);
|
2010-11-25 07:04:52 +00:00
|
|
|
} else {
|
|
|
|
printf("%lf %lf\n",
|
|
|
|
result_bps[0], result_bps[1]);
|
|
|
|
}
|
|
|
|
} else {
|
2012-07-02 13:46:17 +00:00
|
|
|
if (use_cycle) {
|
2015-10-19 08:04:17 +00:00
|
|
|
printf("%lf\n", (double)result_cycle[prefault]
|
2014-12-02 15:50:41 +00:00
|
|
|
/ totallen);
|
2010-11-25 07:04:52 +00:00
|
|
|
} else
|
2015-10-19 08:04:17 +00:00
|
|
|
printf("%lf\n", result_bps[prefault]);
|
2010-11-25 07:04:52 +00:00
|
|
|
}
|
2009-11-17 15:20:09 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-10-19 08:04:17 +00:00
|
|
|
/* Reaching this means there's some disaster: */
|
2009-11-20 03:37:17 +00:00
|
|
|
die("unknown format: %d\n", bench_format);
|
2009-11-17 15:20:09 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-02-26 17:51:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int bench_mem_common(int argc, const char **argv,
|
|
|
|
const char *prefix __maybe_unused,
|
|
|
|
struct bench_mem_info *info)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
size_t len;
|
|
|
|
double totallen;
|
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
argc = parse_options(argc, argv, options, info->usage, 0);
|
2015-02-26 17:51:37 +00:00
|
|
|
|
|
|
|
if (no_prefault && only_prefault) {
|
|
|
|
fprintf(stderr, "Invalid options: -o and -n are mutually exclusive\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_cycle)
|
|
|
|
init_cycle();
|
|
|
|
|
|
|
|
len = (size_t)perf_atoll((char *)length_str);
|
|
|
|
totallen = (double)len * iterations;
|
|
|
|
|
|
|
|
if ((s64)len <= 0) {
|
|
|
|
fprintf(stderr, "Invalid length:%s\n", length_str);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
/* Same as without specifying either of prefault and no-prefault: */
|
2015-02-26 17:51:37 +00:00
|
|
|
if (only_prefault && no_prefault)
|
|
|
|
only_prefault = no_prefault = false;
|
|
|
|
|
2015-02-26 18:02:43 +00:00
|
|
|
if (!strncmp(routine, "all", 3)) {
|
|
|
|
for (i = 0; info->routines[i].name; i++)
|
|
|
|
__bench_mem_routine(info, i, len, totallen);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-26 17:51:37 +00:00
|
|
|
for (i = 0; info->routines[i].name; i++) {
|
|
|
|
if (!strcmp(info->routines[i].name, routine))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!info->routines[i].name) {
|
|
|
|
printf("Unknown routine:%s\n", routine);
|
|
|
|
printf("Available routines...\n");
|
|
|
|
for (i = 0; info->routines[i].name; i++) {
|
|
|
|
printf("\t%s ... %s\n",
|
|
|
|
info->routines[i].name, info->routines[i].desc);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__bench_mem_routine(info, i, len, totallen);
|
2009-11-17 15:20:09 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-12-02 15:50:39 +00:00
|
|
|
|
|
|
|
static void memcpy_alloc_mem(void **dst, void **src, size_t length)
|
|
|
|
{
|
|
|
|
*dst = zalloc(length);
|
|
|
|
if (!*dst)
|
|
|
|
die("memory allocation failed - maybe length is too large?\n");
|
|
|
|
|
|
|
|
*src = zalloc(length);
|
|
|
|
if (!*src)
|
|
|
|
die("memory allocation failed - maybe length is too large?\n");
|
2015-10-19 08:04:17 +00:00
|
|
|
|
|
|
|
/* Make sure to always prefault zero pages even if MMAP_THRESH is crossed: */
|
2014-12-02 15:50:39 +00:00
|
|
|
memset(*src, 0, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 do_memcpy_cycle(const struct routine *r, size_t len, bool prefault)
|
|
|
|
{
|
|
|
|
u64 cycle_start = 0ULL, cycle_end = 0ULL;
|
|
|
|
void *src = NULL, *dst = NULL;
|
|
|
|
memcpy_t fn = r->fn.memcpy;
|
|
|
|
int i;
|
|
|
|
|
2015-01-15 09:20:22 +00:00
|
|
|
memcpy_alloc_mem(&dst, &src, len);
|
2014-12-02 15:50:39 +00:00
|
|
|
|
|
|
|
if (prefault)
|
|
|
|
fn(dst, src, len);
|
|
|
|
|
|
|
|
cycle_start = get_cycle();
|
|
|
|
for (i = 0; i < iterations; ++i)
|
|
|
|
fn(dst, src, len);
|
|
|
|
cycle_end = get_cycle();
|
|
|
|
|
|
|
|
free(src);
|
|
|
|
free(dst);
|
|
|
|
return cycle_end - cycle_start;
|
|
|
|
}
|
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
static double do_memcpy_gettimeofday(const struct routine *r, size_t len, bool prefault)
|
2014-12-02 15:50:39 +00:00
|
|
|
{
|
|
|
|
struct timeval tv_start, tv_end, tv_diff;
|
|
|
|
memcpy_t fn = r->fn.memcpy;
|
|
|
|
void *src = NULL, *dst = NULL;
|
|
|
|
int i;
|
|
|
|
|
2015-01-15 09:20:22 +00:00
|
|
|
memcpy_alloc_mem(&dst, &src, len);
|
2014-12-02 15:50:39 +00:00
|
|
|
|
|
|
|
if (prefault)
|
|
|
|
fn(dst, src, len);
|
|
|
|
|
|
|
|
BUG_ON(gettimeofday(&tv_start, NULL));
|
|
|
|
for (i = 0; i < iterations; ++i)
|
|
|
|
fn(dst, src, len);
|
|
|
|
BUG_ON(gettimeofday(&tv_end, NULL));
|
|
|
|
|
|
|
|
timersub(&tv_end, &tv_start, &tv_diff);
|
|
|
|
|
|
|
|
free(src);
|
|
|
|
free(dst);
|
2014-12-02 15:50:41 +00:00
|
|
|
return (double)(((double)len * iterations) / timeval2double(&tv_diff));
|
2014-12-02 15:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int bench_mem_memcpy(int argc, const char **argv,
|
|
|
|
const char *prefix __maybe_unused)
|
|
|
|
{
|
|
|
|
struct bench_mem_info info = {
|
2015-10-19 08:04:17 +00:00
|
|
|
.routines = memcpy_routines,
|
|
|
|
.do_cycle = do_memcpy_cycle,
|
|
|
|
.do_gettimeofday = do_memcpy_gettimeofday,
|
|
|
|
.usage = bench_mem_memcpy_usage,
|
2014-12-02 15:50:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return bench_mem_common(argc, argv, prefix, &info);
|
|
|
|
}
|
2014-12-02 15:50:40 +00:00
|
|
|
|
|
|
|
static void memset_alloc_mem(void **dst, size_t length)
|
|
|
|
{
|
|
|
|
*dst = zalloc(length);
|
|
|
|
if (!*dst)
|
|
|
|
die("memory allocation failed - maybe length is too large?\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 do_memset_cycle(const struct routine *r, size_t len, bool prefault)
|
|
|
|
{
|
|
|
|
u64 cycle_start = 0ULL, cycle_end = 0ULL;
|
|
|
|
memset_t fn = r->fn.memset;
|
|
|
|
void *dst = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memset_alloc_mem(&dst, len);
|
|
|
|
|
|
|
|
if (prefault)
|
|
|
|
fn(dst, -1, len);
|
|
|
|
|
|
|
|
cycle_start = get_cycle();
|
|
|
|
for (i = 0; i < iterations; ++i)
|
|
|
|
fn(dst, i, len);
|
|
|
|
cycle_end = get_cycle();
|
|
|
|
|
|
|
|
free(dst);
|
|
|
|
return cycle_end - cycle_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double do_memset_gettimeofday(const struct routine *r, size_t len,
|
|
|
|
bool prefault)
|
|
|
|
{
|
|
|
|
struct timeval tv_start, tv_end, tv_diff;
|
|
|
|
memset_t fn = r->fn.memset;
|
|
|
|
void *dst = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memset_alloc_mem(&dst, len);
|
|
|
|
|
|
|
|
if (prefault)
|
|
|
|
fn(dst, -1, len);
|
|
|
|
|
|
|
|
BUG_ON(gettimeofday(&tv_start, NULL));
|
|
|
|
for (i = 0; i < iterations; ++i)
|
|
|
|
fn(dst, i, len);
|
|
|
|
BUG_ON(gettimeofday(&tv_end, NULL));
|
|
|
|
|
|
|
|
timersub(&tv_end, &tv_start, &tv_diff);
|
|
|
|
|
|
|
|
free(dst);
|
2014-12-02 15:50:41 +00:00
|
|
|
return (double)(((double)len * iterations) / timeval2double(&tv_diff));
|
2014-12-02 15:50:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char * const bench_mem_memset_usage[] = {
|
|
|
|
"perf bench mem memset <options>",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct routine memset_routines[] = {
|
2015-10-19 08:04:17 +00:00
|
|
|
{ .name = "default",
|
|
|
|
.desc = "Default memset() provided by glibc",
|
|
|
|
.fn.memset = memset },
|
2014-12-02 15:50:40 +00:00
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
#ifdef HAVE_ARCH_X86_64_SUPPORT
|
|
|
|
# define MEMSET_FN(_fn, _name, _desc) { .name = _name, .desc = _desc, .fn.memset = _fn },
|
|
|
|
# include "mem-memset-x86-64-asm-def.h"
|
|
|
|
# undef MEMSET_FN
|
2014-12-02 15:50:40 +00:00
|
|
|
#endif
|
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
{ NULL, }
|
2014-12-02 15:50:40 +00:00
|
|
|
};
|
|
|
|
|
2015-10-19 08:04:17 +00:00
|
|
|
int bench_mem_memset(int argc, const char **argv, const char *prefix __maybe_unused)
|
2014-12-02 15:50:40 +00:00
|
|
|
{
|
|
|
|
struct bench_mem_info info = {
|
2015-10-19 08:04:17 +00:00
|
|
|
.routines = memset_routines,
|
|
|
|
.do_cycle = do_memset_cycle,
|
|
|
|
.do_gettimeofday = do_memset_gettimeofday,
|
|
|
|
.usage = bench_mem_memset_usage,
|
2014-12-02 15:50:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return bench_mem_common(argc, argv, prefix, &info);
|
|
|
|
}
|