Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions runtime/test/src/tpcds_1_cpp/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
PYTHON_CONFIG := python3-config
# CFLAGS := $(CFLAGS) -O3
CFLAGS := $(CFLAGS) $(shell python3-config --cflags)
CFLAGS := $(CFLAGS) -I$(shell python3 -c "import numpy as np; print(np.get_include());")
LDFLAGS := -lpython3.8 $(shell python3-config --ldflags)
CFLAGS := $(CFLAGS) -g -pg -O0 -std=c++17
LDFLAGS := -lpython3.8 $(shell python3-config --ldflags)

.PHONY: all clean

all: tpcds_1
all: tpcds_1 tpcds_1_mem tpcds_1_cpu

clean:
rm reference.o tpcds_1
rm *.o tpcds_1 tpcds_1_mem tpcds_1_cpu

reference.o: reference.c
gcc -c $(CFLAGS) -g -o $@ -fPIC $^
g++ -c $(CFLAGS) -g -o $@ -fPIC $^

reference_cpu.o: reference_cpu.cpp
g++ -c $(CFLAGS) -g -o $@ -fPIC $^

reference_mem.o: reference_mem.cpp
g++ -c $(CFLAGS) -g -o $@ -fPIC $^

tpcds_1: reference.o
gcc $^ -o $@ $(LDFLAGS)
g++ $^ -o $@ $(LDFLAGS)

tpcds_1_mem: reference_mem.o
g++ $^ -o $@ $(LDFLAGS) -ltcmalloc -lprofiler

tpcds_1_cpu: reference_cpu.o
g++ $^ -o $@ $(LDFLAGS)

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python lifetime.py ../reference_mem.cpp --target_function main_ > tpcds.lifetime.csv
python memusage.py ./tpcds_1.mem.log --source_path ../reference_mem.cpp --exec_path ../tpcds_1_mem > tpcds.line_activity.csv
python final.py --lifetime_csv_path tpcds.lifetime.csv --line_activity_csv_path tpcds.line_activity.csv
45 changes: 45 additions & 0 deletions runtime/test/src/tpcds_1_cpp/analysis_memory/final.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Calculate the per-symbol lifetime and memory usage.

import argparse

import pandas as pd

def parse_args():
args = argparse.ArgumentParser(
usage='python final.py --lifetime_csv_path tpcds.lifetime.csv --line_activity_csv_path tpcds.line_activity.csv'
)
args.add_argument('--lifetime_csv_path', type=str, help='Path to the lifetime CSV file.', required=True)
args.add_argument('--line_activity_csv_path', type=str, help='Path to the line activity CSV file.', required=True)
args.add_argument('--display_markdown', action='store_true', help='Print markdown format to stdout.', default=False)
return args.parse_args()

def human_readable_size(x):
if x < 1024:
return f'{x}B'
elif x < 1024 * 1024:
return f'{x / 1024:.2f}KB'
elif x < 1024 * 1024 * 1024:
return f'{x / 1024 / 1024:.2f}MB'
else:
return f'{x / 1024 / 1024 / 1024:.2f}GB'

def main():
args = parse_args()
lifetime_df = pd.read_csv(args.lifetime_csv_path)
line_activity_df = pd.read_csv(args.line_activity_csv_path, index_col=0)
line_activity_df = line_activity_df.drop(columns=['timestamp'])
line_activity_df = line_activity_df[line_activity_df.event == 'NewHook']
line_activity_df = line_activity_df.drop(columns=['event'])
line_activity_df = line_activity_df.groupby(['line_num']).sum().reset_index()

line_activity_df = line_activity_df.rename(columns={'size': 'alloc_footprint'})
line_activity_df['alloc_footprint_h'] = line_activity_df['alloc_footprint'].apply(human_readable_size)

df = lifetime_df.merge(line_activity_df, left_on='start_line', right_on='line_num', how='inner')
if args.display_markdown:
print(df.to_markdown())
else:
print(df.to_csv())

if __name__ == '__main__':
main()
Loading