Skip to content

Commit b44f01d

Browse files
committed
Picked up latest boom and added rvv performance kernels that used for perf eval
1 parent 090bec9 commit b44f01d

File tree

89 files changed

+5191
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5191
-1
lines changed

measure_perf.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import os
2+
import subprocess
3+
import csv
4+
import argparse
5+
6+
def get_pc_from_elf(file_name, label):
7+
cmd = f"nm {file_name} | grep {label}"
8+
try:
9+
result = subprocess.check_output(cmd, shell=True).decode('utf-8')
10+
pc_value = result.split()[0]
11+
return pc_value[-8:]
12+
except subprocess.CalledProcessError:
13+
return "NA"
14+
15+
def get_cycle_from_log(log_file, pc_value):
16+
cmd = f"cat {log_file} | grep 'PC=0x{pc_value}'"
17+
try:
18+
result = subprocess.check_output(cmd, shell=True).decode('utf-8')
19+
cycle = result.split("<")[1].split(">")[0]
20+
return cycle
21+
except subprocess.CalledProcessError: # grep found nothing
22+
return "NA"
23+
24+
def main(perf_tests_path, logs_path, output_file):
25+
log_files = [f for f in os.listdir(logs_path) if f.endswith('.log')]
26+
27+
with open(output_file, "w", newline="") as csvfile:
28+
writer = csv.writer(csvfile)
29+
writer.writerow(["Test Name", "Start Cycle", "End Cycle"])
30+
31+
for log in log_files:
32+
test_base_name = os.path.splitext(log)[0]
33+
elf_path = os.path.join(perf_tests_path, f"{test_base_name}.elf")
34+
exe_path = os.path.join(perf_tests_path, f"{test_base_name}.exe")
35+
36+
if os.path.exists(elf_path):
37+
test_path = elf_path
38+
elif os.path.exists(exe_path):
39+
test_path = exe_path
40+
else:
41+
writer.writerow([test_base_name, "NA", "NA"])
42+
continue
43+
44+
start_pc = get_pc_from_elf(test_path, "perf_start")
45+
end_pc = get_pc_from_elf(test_path, "perf_end")
46+
47+
log_file_path = os.path.join(logs_path, log)
48+
start_cycle = get_cycle_from_log(log_file_path, start_pc)
49+
end_cycle = get_cycle_from_log(log_file_path, end_pc)
50+
51+
writer.writerow([test_base_name, start_cycle, end_cycle])
52+
53+
if __name__ == "__main__":
54+
parser = argparse.ArgumentParser(description="Measure the performance of a simulation.")
55+
parser.add_argument("--perf_tests_path", required=True, help="Path to the performance tests.")
56+
parser.add_argument("--logs_path", required=True, help="Path to the logs.")
57+
parser.add_argument("--output", default="output.csv", help="Path and name of the output CSV file. Default is output.csv.")
58+
59+
args = parser.parse_args()
60+
61+
main(args.perf_tests_path, args.logs_path, args.output)
62+
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/rvv/kernels/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright (c) 2020, Barcelona Supercomputing Center
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met: redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer;
8+
redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution;
11+
neither the name of the copyright holders nor the names of its
12+
contributors may be used to endorse or promote products derived from
13+
this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
If you use this software or a modified version of it for your research, please cite the paper:
28+
Cristóbal Ramírez, César Hernandez, Oscar Palomar, Osman Unsal, Marco Ramírez, and Adrián Cristal. 2020. A RISC-V Simulator and Benchmark Suite for Designing and Evaluating Vector Architectures. ACM Trans. Archit. Code Optim. 17, 4, Article 38 (October 2020), 29 pages. https://doi.org/10.1145/3422667

tests/rvv/kernels/_axpy/Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#makefile
2+
export CC=/tools_risc/opensrc/riscv-toolchain-06-13-23/llvm/linux/bin
3+
export TESTGEN=/home/jzhang/ws/ws1/testgen/generators/cc/rv_cc/resources
4+
OPTS := -mcmodel=medany -static -std=gnu99 -O3 -fno-builtin-printf -fno-common -nostdlib -nostartfiles
5+
VECTOR_TARGET := bin/vector
6+
SERIAL_TARGET := bin/serial
7+
SIZE := TINY
8+
9+
start:
10+
mkdir -p bin; \
11+
rm bin/*.*
12+
13+
vector:
14+
$(CC)/clang $(OPTS) \
15+
-march=rv64imafdv -mabi=lp64d \
16+
-I$(TESTGEN) \
17+
-I../common/ \
18+
../common/mem.c $(TESTGEN)/syscalls.c $(TESTGEN)/crt.S src/* \
19+
-lm -lgcc -T../common/test.ld \
20+
-D$(SIZE) -DUSE_RISCV_VECTOR \
21+
-o $(VECTOR_TARGET).exe
22+
$(CC)/llvm-objdump $(VECTOR_TARGET).exe -D > $(VECTOR_TARGET).dump
23+
24+
clean:
25+
rm bin/*.dump; \
26+
rm bin/*.exe;
501 KB
Binary file not shown.
14.4 KB
Binary file not shown.

tests/rvv/kernels/_axpy/naive/axpy.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
#include <math.h>
4+
#include <assert.h>
5+
6+
7+
#include "../../common/vector_defines.h"
8+
9+
void axpy_intrinsics(double a, double *dx, double *dy, int n) {
10+
int i;
11+
12+
// long gvl = __builtin_epi_vsetvl(n, __epi_e64, __epi_m1);
13+
long gvl = vsetvl_e64m1(n); //PLCT
14+
15+
_MMR_f64 v_a = _MM_SET_f64(a, gvl);
16+
17+
for (i = 0; i < n;) {
18+
// gvl = __builtin_epi_vsetvl(n - i, __epi_e64, __epi_m1);
19+
gvl = vsetvl_e64m1(n - i); //PLCT
20+
21+
_MMR_f64 v_dx = _MM_LOAD_f64(&dx[i], gvl);
22+
_MMR_f64 v_dy = _MM_LOAD_f64(&dy[i], gvl);
23+
_MMR_f64 v_res = _MM_MACC_f64(v_dy, v_a, v_dx, gvl);
24+
_MM_STORE_f64(&dy[i], v_res, gvl);
25+
26+
i += gvl;
27+
};
28+
29+
FENCE();
30+
}

0 commit comments

Comments
 (0)