Skip to content

Commit 10003d1

Browse files
committed
Updating benchmark.py
Also adding some logic to the QPE files to provide the datafile as an argument
1 parent 11a5c28 commit 10003d1

File tree

8 files changed

+88
-40
lines changed

8 files changed

+88
-40
lines changed

QPEMPI

193 KB
Binary file not shown.

QPEMPI.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ int main(int argc, char *argv[]) {
151151

152152
set_rank(rank);
153153

154+
// Determine data file from CLI args or default
155+
const char *dataFile = DATA_FILE;
156+
if (argc > 1) {
157+
dataFile = argv[1];
158+
}
159+
154160
// Start a timer for total runtime statistics
155161
double totalStart = MPI_Wtime();
156162

@@ -159,7 +165,7 @@ int main(int argc, char *argv[]) {
159165
numOptimalIndexes, // Number of indexes
160166
optimalIndexes, // Indexes to build B+ trees for
161167
(const int *)optimalIndexTypes, // Index types
162-
DATA_FILE,
168+
dataFile,
163169
TABLE_NAME
164170
);
165171

QPEOMP.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,22 @@ int main(int argc, char *argv[]) {
145145
printf("Starting main...\n"); fflush(stdout);
146146

147147
// Pull out number of defined threads from CLI args (default to 8)
148+
// Arg 1 can be Data File or Thread Count
148149
int num_threads = 8;
149-
if (argc >= 2) {
150-
num_threads = atoi(argv[1]);
150+
const char *dataFile = DATA_FILE;
151+
152+
if (argc > 1) {
153+
// If first char is digit, assume it's thread count (legacy support)
154+
if (isdigit(argv[1][0])) {
155+
num_threads = atoi(argv[1]);
156+
} else {
157+
// Otherwise it's the data file
158+
dataFile = argv[1];
159+
// And second arg is threads
160+
if (argc > 2) {
161+
num_threads = atoi(argv[2]);
162+
}
163+
}
151164
}
152165
omp_set_num_threads(num_threads);
153166

@@ -160,7 +173,7 @@ int main(int argc, char *argv[]) {
160173
numOptimalIndexes, // Number of indexes
161174
optimalIndexes, // Indexes to build B+ trees for
162175
(const int *)optimalIndexTypes, // Index types
163-
DATA_FILE,
176+
dataFile,
164177
TABLE_NAME
165178
);
166179
printf("Engine Initialized.\n"); fflush(stdout);

QPESeq.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
int main(int argc, char *argv[]) {
1717

18-
// NOTE: defaulting to sample queries file for ease of testing. Can implement CLI arg later.
19-
(void)argc; (void)argv; // Unused for now. Prevent warnings.
18+
// Determine data file from CLI args or default
19+
const char *dataFile = DATA_FILE;
20+
if (argc > 1) {
21+
dataFile = argv[1];
22+
}
2023

2124
// Start a timer for total runtime statistics
2225
clock_t totalStart = clock();
@@ -26,7 +29,7 @@ int main(int argc, char *argv[]) {
2629
numOptimalIndexes, // Number of indexes
2730
optimalIndexes, // Indexes to build B+ trees for
2831
(const int *)optimalIndexTypes, // Index types
29-
DATA_FILE,
32+
dataFile,
3033
TABLE_NAME
3134
);
3235

benchmark.py

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ def run_command(command, silent=False):
1515
if not silent:
1616
print(f"Error running command: {command}")
1717
print(f"Exit code: {e.returncode}")
18-
# We don't raise here to allow the script to continue to cleanup
1918

20-
def draw_menu(stdscr, selected_row_idx, options):
19+
def draw_menu(stdscr, selected_row_idx, options, title):
2120
stdscr.clear()
2221
h, w = stdscr.getmaxyx()
2322

24-
title = "Select Benchmark to Run (Use Arrow Keys + Enter)"
2523
stdscr.addstr(h//2 - len(options)//2 - 2, w//2 - len(title)//2, title)
2624

2725
for idx, row in enumerate(options):
@@ -36,17 +34,10 @@ def draw_menu(stdscr, selected_row_idx, options):
3634

3735
stdscr.refresh()
3836

39-
def main(stdscr):
40-
# Setup colors
41-
curses.start_color()
42-
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
43-
curses.curs_set(0)
44-
45-
options = ["Serial", "OMP", "MPI", "ALL", "Exit"]
37+
def select_option(stdscr, title, options):
4638
selected_row_idx = 0
47-
4839
while True:
49-
draw_menu(stdscr, selected_row_idx, options)
40+
draw_menu(stdscr, selected_row_idx, options, title)
5041
key = stdscr.getch()
5142

5243
if key == curses.KEY_UP and selected_row_idx > 0:
@@ -56,47 +47,82 @@ def main(stdscr):
5647
elif key == curses.KEY_ENTER or key in [10, 13]:
5748
return options[selected_row_idx]
5849

50+
def get_datasets():
51+
data_dir = "data-generation"
52+
if not os.path.exists(data_dir):
53+
return []
54+
files = [f for f in os.listdir(data_dir) if f.endswith(".csv")]
55+
files.sort()
56+
# Return relative paths
57+
return [os.path.join(data_dir, f) for f in files]
58+
59+
def main(stdscr):
60+
# Setup colors
61+
curses.start_color()
62+
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
63+
curses.curs_set(0)
64+
65+
# Select Dataset
66+
datasets = get_datasets()
67+
if not datasets:
68+
return None, "No CSV files found in data-generation/"
69+
70+
datasets.append("Exit")
71+
dataset = select_option(stdscr, "Select Dataset (Use Arrow Keys + Enter)", datasets)
72+
73+
if dataset == "Exit":
74+
return "Exit", None
75+
76+
# Select Benchmark Version
77+
benchmarks = ["Serial", "OMP", "MPI", "ALL", "Exit"]
78+
benchmark = select_option(stdscr, "Select Benchmark to Run", benchmarks)
79+
80+
return benchmark, dataset
81+
5982
def run_benchmark():
6083
# Run make silently
6184
print("Building project... (this may take a moment)")
6285
run_command("make", silent=True)
6386

6487
# Show Menu
6588
try:
66-
# curses.wrapper handles initialization and cleanup of curses
67-
selection = curses.wrapper(main)
89+
selection, dataset = curses.wrapper(main)
6890
except Exception as e:
6991
print(f"Error in UI: {e}")
70-
# Ensure cleanup happens even if UI fails
7192
run_command("make clean", silent=True)
7293
return
7394

74-
if selection == "Exit":
95+
if selection == "Exit" or selection is None:
96+
if dataset and dataset != "Exit":
97+
print(dataset) # Print error message if any
7598
print("Exiting...")
7699
run_command("make clean", silent=True)
77100
return
78101

79-
print(f"\nRunning {selection} Benchmark...\n" + "="*40 + "\n")
102+
print(f"\nRunning {selection} Benchmark with dataset: {dataset}\n" + "="*60 + "\n")
80103

81104
# Run Selected
82-
start_time = time.time()
105+
start_time = time.time()
106+
107+
# Pass dataset as ARGS
108+
args = f'ARGS="{dataset}"'
83109

84110
if selection == "Serial":
85-
run_command("make run")
111+
run_command(f"make run {args}")
86112
elif selection == "OMP":
87-
run_command("make run-omp")
113+
run_command(f"make run-omp {args}")
88114
elif selection == "MPI":
89-
run_command("make run-mpi")
115+
run_command(f"make run-mpi {args}")
90116
elif selection == "ALL":
91117
print("--- Running Serial ---")
92-
run_command("make run")
118+
run_command(f"make run {args}")
93119
print("\n--- Running OMP ---")
94-
run_command("make run-omp")
120+
run_command(f"make run-omp {args}")
95121
print("\n--- Running MPI ---")
96-
run_command("make run-mpi")
122+
run_command(f"make run-mpi {args}")
97123

98124
end_time = time.time()
99-
print("\n" + "="*40)
125+
print("\n" + "="*60)
100126
print(f"Total Benchmark Time: {end_time - start_time:.4f} seconds")
101127

102128
# Run make clean silently

data-generation/commands_1m.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:9881bfe6e9cbaaac36cc1c7b28b624a471d724d532449808fef26430df32b1f4
3-
size 125434931
2+
oid sha256:4cc6c639d9d2bb85214cc75f365516e1b08e01b8f66f45e284372b9902467313
3+
size 119604509

data-generation/commands_50k.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:b303b920c6c6cd992eacb27f5c63110cc0fe4ede54609e453446f34ab1c62047
3-
size 5922674
2+
oid sha256:6e19fc03d3fc84a36555e3609127174c3ce1d598b6970f704f8e617244f2b539
3+
size 3445023

makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,24 @@ test: $(TEST_BINS)
108108

109109
# Run the serial version
110110
run: QPESeq
111-
./QPESeq
111+
./QPESeq $(ARGS)
112112

113113
# Default OpenMP thread count unless overridden
114114
OMP_THREADS ?= 4
115115

116116
# Run OpenMP version correctly — env var applies only to this command
117117
run-omp: QPEOMP
118118
@echo "Running with OMP_NUM_THREADS=$(OMP_THREADS)"
119-
@env OMP_NUM_THREADS=$(OMP_THREADS) ./QPEOMP
119+
@env OMP_NUM_THREADS=$(OMP_THREADS) ./QPEOMP $(ARGS)
120120

121121
# Default MPI process count unless overridden
122122
MPI_PROCS ?= 4
123123

124124
# Run MPI version with proper launcher syntax
125125
run-mpi: QPEMPI
126126
@echo "Running with $(MPI_PROCS) MPI processes..."
127-
@mpirun -np $(MPI_PROCS) ./QPEMPI 2>/dev/null \
128-
|| mpiexec -np $(MPI_PROCS) ./QPEMPI
127+
@mpirun -np $(MPI_PROCS) ./QPEMPI $(ARGS) 2>/dev/null \
128+
|| mpiexec -np $(MPI_PROCS) ./QPEMPI $(ARGS)
129129

130130
# Run QPESeq under Valgrind to check for memory leaks
131131
valgrind: QPESeq

0 commit comments

Comments
 (0)