Skip to content

Commit c5a2306

Browse files
committed
update common.mk & parser & test script
1 parent 4da4564 commit c5a2306

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

‎tests/opencl/common.mk‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ VX_CFLAGS += -O3 -mcmodel=medany --sysroot=$(RISCV_SYSROOT) --gcc-toolchain=$(R
3030
VX_CFLAGS += -fno-rtti -fno-exceptions -nostartfiles -nostdlib -fdata-sections -ffunction-sections
3131
VX_CFLAGS += -I$(ROOT_DIR)/hw -I$(VORTEX_HOME)/kernel/include -DXLEN_$(XLEN) -DNDEBUG
3232
VX_CFLAGS += -Xclang -target-feature -Xclang +vortex
33+
#VX_CFLAGS += -Xclang -target-feature -Xclang +zicond
34+
35+
36+
DIVERGENCE_OPT_LEVEL := $(if $(VORTEX_DIVERGENCE_OPT_LEVEL),$(VORTEX_DIVERGENCE_OPT_LEVEL),8)
37+
$(info [INFO] DIVERGENCE_OPT_LEVEL is $(DIVERGENCE_OPT_LEVEL))
38+
39+
ifeq ($(shell test $(DIVERGENCE_OPT_LEVEL) -ge 5 && echo true), true)
3340
VX_CFLAGS += -Xclang -target-feature -Xclang +zicond
41+
endif
42+
3443
VX_CFLAGS += -mllvm -disable-loop-idiom-all # disable memset/memcpy loop replacement
3544
#VX_CFLAGS += -mllvm -vortex-branch-divergence=0
3645
#VX_CFLAGS += -mllvm -print-after-all

‎tests/opencl/parser.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os
2+
import re
3+
import sys
4+
5+
def parse_perf_file(filepath):
6+
instrs_total = 0
7+
cycles_total = 0
8+
with open(filepath, 'r') as f:
9+
for line in f:
10+
match = re.search(r'instrs=(\d+), cycles=(\d+)', line)
11+
if match:
12+
instrs_total += int(match.group(1))
13+
cycles_total += int(match.group(2))
14+
return instrs_total, cycles_total
15+
16+
def extract_O_value(filename):
17+
match = re.search(r'_O(\d+)\.txt', filename)
18+
return int(match.group(1)) if match else None
19+
20+
def run_perf_summary_on_folder(folder_path):
21+
str_option = ""
22+
str_data = ""
23+
for filename in sorted(os.listdir(folder_path)):
24+
if filename.endswith('.txt') and '_O' in filename:
25+
O_value = extract_O_value(filename)
26+
if O_value is not None:
27+
filepath = os.path.join(folder_path, filename)
28+
instrs_total, cycles_total = parse_perf_file(filepath)
29+
#print(f"{O_value} {instrs_total} {cycles_total}")
30+
str_option = str_option + str(O_value) + " "
31+
str_data = str_data + str(instrs_total) + " " + str(cycles_total) + " "
32+
print(str_option)
33+
print(str_data)
34+
35+
36+
if __name__ == "__main__":
37+
if len(sys.argv) < 2:
38+
print("Usage: python script.py <folder_path>")
39+
sys.exit(1)
40+
folder_path = sys.argv[1]
41+
run_perf_summary_on_folder(folder_path)

‎tests/opencl/test.sh‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
if [ -n "$1" ]; then
4+
folders=("$1")
5+
else
6+
folders=("vecadd")
7+
fi
8+
9+
for folder in "${folders[@]}"; do
10+
echo "Processing folder: $folder"
11+
cd $folder
12+
rm *.txt
13+
for level in 1 2 3 5 8 9; do
14+
export VORTEX_DIVERGENCE_OPT_LEVEL=$level
15+
echo "Running with VORTEX_DIVERGENCE_OPT_LEVEL=$VORTEX_DIVERGENCE_OPT_LEVEL $TEST"
16+
make run-simx
17+
done
18+
cd ../
19+
done
20+
21+
for folder in "${folders[@]}"; do
22+
echo "Processing folder: $folder"
23+
python parser.py $folder
24+
done

0 commit comments

Comments
 (0)