Aggregation function MAX

This commit is contained in:
Oleksii Oleksenko
2020-06-25 16:05:27 +02:00
parent 57aba2efd1
commit 976902dee1
6 changed files with 18 additions and 2 deletions

View File

@@ -144,6 +144,7 @@ Both `nanoBench.sh` and `kernel-nanoBench.sh` support the following command-line
| `-avg` | Selects the arithmetic mean (excluding the top and bottom 20% of the values) as the aggregate function. `[This is the default]` |
| `-median` | Selects the median as the aggregate function. |
| `-min` | Selects the minimum as the aggregate function. |
| `-max` | Selects the maximum as the aggregate function. |
| `-basic_mode` | The effect of this option is described in the [Generated Code](#generated-code) section. |
| `-no_mem` | If this option is enabled, the code for `read_perf_ctrs` does not make any memory accesses and stores all performance counter values in registers. This can, for example, be useful for benchmarks that require that the state of the data caches does not change after the execution of `code_init`. *If this option is used, the code to be benchmarked must not modify registers* ***R8-R11 (Intel)*** *and* ***R8-R13 (AMD).*** *Furthermore, `read_perf_ctrs` will modify* ***RAX, RCX, and RDX***. |
| `-cpu <n>` | Pins the measurement thread to CPU n. `[Default: Pin the thread to the CPU it is currently running on.]` |

View File

@@ -659,6 +659,14 @@ int64_t get_aggregate_value_100(int64_t* values, size_t length) {
}
}
return min * 100;
} else if (aggregate_function == MAX) {
int64_t max = values[0];
for (int i=0; i<length; i++) {
if (values[i] > max) {
max = values[i];
}
}
return max * 100;
} else {
qsort(values, length, sizeof(int64_t), cmpInt64);

View File

@@ -107,7 +107,7 @@ extern int no_mem;
extern int basic_mode;
#define BASIC_MODE_DEFAULT 0;
enum agg_enum {AVG_20_80, MIN, MED};
enum agg_enum {AVG_20_80, MIN, MAX, MED};
extern int aggregate_function;
#define AGGREGATE_FUNCTION_DEFAULT AVG_20_80;

View File

@@ -2,7 +2,7 @@
if [ "$EUID" -ne 0 ]; then
echo "Error: nanoBench requires root privileges"
echo "Try \"sudo ./nb_km-asm.sh ...\""
echo "Try \"sudo ./kernel-nanoBench.sh ...\""
exit 1
fi
@@ -89,6 +89,9 @@ while [ "$1" ]; do
elif [[ "$1" == -min* ]]; then
echo "min" > /sys/nb/agg
shift
elif [[ "$1" == -max* ]]; then
echo "max" > /sys/nb/agg
shift
elif [[ "$1" == -med* ]]; then
echo "med" > /sys/nb/agg
shift
@@ -112,6 +115,7 @@ while [ "$1" ]; do
echo " -avg: Selects the arithmetic mean as the aggregate function."
echo " -median: Selects the median as the aggregate function."
echo " -min: Selects the minimum as the aggregate function."
echo " -max: Selects the maximum as the aggregate function."
echo " -basic_mode: Enables basic mode."
echo " -no_mem: The code for reading the perf. ctrs. does not make memory accesses."
echo " -cpu <n>: Pins the measurement thread to CPU n."

View File

@@ -270,6 +270,8 @@ static ssize_t agg_show(struct kobject *kobj, struct kobj_attribute *attr, char
static ssize_t agg_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {
if (!strncmp(buf, "min", 3)) {
aggregate_function = MIN;
} else if (!strncmp(buf, "max", 3)) {
aggregate_function = MAX;
} else if (!strncmp(buf, "med", 3)) {
aggregate_function = MED;
} else {

View File

@@ -80,6 +80,7 @@ int main(int argc, char **argv) {
{"avg", no_argument, &aggregate_function, AVG_20_80},
{"median", no_argument, &aggregate_function, MED},
{"min", no_argument, &aggregate_function, MIN},
{"max", no_argument, &aggregate_function, MAX},
{"basic_mode", no_argument, &basic_mode, 1},
{"no_mem", no_argument, &no_mem, 1},
{"verbose", no_argument, &verbose, 1},