Makefile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. NAME = libbag
  2. CC ?= gcc
  3. RM ?= @rm
  4. MKDIR ?= @mkdir
  5. CFLAGS := -O3 -Wall -Wextra -fopenmp
  6. SRC_DIR = src
  7. BUILD_DIR = build
  8. DATA_DIR = data
  9. INCLUDES = src
  10. OBJECTS = $(NAME).o simple.o cbag.o
  11. PLOTS = simple_prod_cons_avg_plot.tex simple_1_prod_avg_plot.tex simple_1_cons_avg_plot.tex simple_add_tra_avg_plot.tex simple_add_avg_plot.tex simple_tra_avg_plot.tex cbag_prod_cons_avg_plot.tex cbag_1_prod_avg_plot.tex cbag_1_cons_avg_plot.tex cbag_add_tra_avg_plot.tex cbag_add_avg_plot.tex cbag_tra_avg_plot.tex
  12. SMALLPLOTS = simple_small_prod_cons_avg_plot.tex simple_small_1_prod_avg_plot.tex simple_small_1_cons_avg_plot.tex simple_small_add_tra_avg_plot.tex simple_small_add_avg_plot.tex simple_small_tra_avg_plot.tex cbag_small_prod_cons_avg_plot.tex cbag_small_1_prod_avg_plot.tex cbag_small_1_cons_avg_plot.tex cbag_small_add_tra_avg_plot.tex cbag_small_add_avg_plot.tex cbag_small_tra_avg_plot.tex
  13. all: $(BUILD_DIR) $(NAME) $(NAME).so
  14. @echo "Built $(NAME)"
  15. $(DATA_DIR):
  16. @echo "Creating data directory: $(DATA_DIR)"
  17. $(MKDIR) $(DATA_DIR)
  18. $(BUILD_DIR):
  19. @echo "Creating build directory: $(BUILD_DIR)"
  20. $(MKDIR) $(BUILD_DIR)
  21. $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
  22. @echo "Compiling $<"
  23. $(CC) $(CFLAGS) -fPIC -I$(INCLUDES) -c -o $@ $<
  24. $(NAME): $(foreach object,$(OBJECTS),$(BUILD_DIR)/$(object))
  25. @echo "Linking $(NAME)"
  26. $(CC) $(CFLAGS) -o $@ $^
  27. $(NAME).so: $(foreach object,$(OBJECTS),$(BUILD_DIR)/$(object))
  28. @echo "Linking $(NAME)"
  29. $(CC) $(CFLAGS) -fPIC -shared -o $@ $^
  30. small-bench: $(BUILD_DIR) $(NAME).so $(DATA_DIR)
  31. @echo "Running small-bench ..."
  32. @echo "Note: to run on slurm, use target `slurm-small-bench`"
  33. @python benchmark.py
  34. @echo "Finished small-bench"
  35. bench:
  36. @echo "Running bench (detailed benchmark) ..."
  37. @echo "Note: to run on slurm, use target `slurm-bench`"
  38. @python benchmark.py --threads 2,4,8,16,32,64 --workload 10000,100000,1000000 --repetitions 4 --prefix ""
  39. @echo "Finished bench"
  40. slurm-small-bench: $(BUILD_DIR) $(NAME).so $(DATA_DIR)
  41. @echo "Running slurm-small-bench ..."
  42. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py
  43. @echo "Finished slurm-small-bench"
  44. slurm-bench:
  45. @echo "Running bench (detailed benchmark) ..."
  46. @echo " (only simple)"
  47. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 10000 --repetitions 16 --prefix "" --cbag false --simple true
  48. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 100000 --repetitions 16 --prefix "" --cbag false --simple true --prod_cons true --1_cons false --1_prod false --add_try_remove_any false
  49. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 100000 --repetitions 16 --prefix "" --cbag false --simple true --prod_cons false --1_cons true --1_prod false --add_try_remove_any false
  50. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 100000 --repetitions 4 --prefix "" --cbag false --simple true --prod_cons false --1_cons false --1_prod true --add_try_remove_any false
  51. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 100000 --repetitions 16 --prefix "" --cbag false --simple true --prod_cons false --1_cons false --1_prod false --add_try_remove_any true
  52. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 1000000 --repetitions 8 --prefix "" --cbag false --simple true --prod_cons true --1_cons false --1_prod false --add_try_remove_any false
  53. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 1000000 --repetitions 8 --prefix "" --cbag false --simple true --prod_cons false --1_cons true --1_prod false --add_try_remove_any false
  54. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 1000000 --repetitions 2 --prefix "" --cbag false --simple true --prod_cons false --1_cons false --1_prod true --add_try_remove_any false
  55. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 1000000 --repetitions 8 --prefix "" --cbag false --simple true --prod_cons false --1_cons false --1_prod false --add_try_remove_any true
  56. @echo " (only cbag)"
  57. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 10000 --repetitions 16 --prefix "" --cbag true --simple false
  58. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 100000 --repetitions 16 --prefix "" --cbag true --simple false --prod_cons true --1_cons false --1_prod false --add_try_remove_any false
  59. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 100000 --repetitions 16 --prefix "" --cbag true --simple false --prod_cons false --1_cons true --1_prod false --add_try_remove_any false
  60. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 100000 --repetitions 4 --prefix "" --cbag true --simple false --prod_cons false --1_cons false --1_prod true --add_try_remove_any false
  61. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 100000 --repetitions 16 --prefix "" --cbag true --simple false --prod_cons false --1_cons false --1_prod false --add_try_remove_any true
  62. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 1000000 --repetitions 8 --prefix "" --cbag true --simple false --prod_cons true --1_cons false --1_prod false --add_try_remove_any false
  63. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 1000000 --repetitions 8 --prefix "" --cbag true --simple false --prod_cons false --1_cons true --1_prod false --add_try_remove_any false
  64. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 1000000 --repetitions 2 --prefix "" --cbag true --simple false --prod_cons false --1_cons false --1_prod true --add_try_remove_any false
  65. @srun -p q_student -t 10 -N 1 -c 64 python benchmark.py --threads 2,4,8,16,32,64 --workload 1000000 --repetitions 8 --prefix "" --cbag true --simple false --prod_cons false --1_cons false --1_prod false --add_try_remove_any true
  66. @echo "Finished slurm-bench"
  67. small-plot:
  68. @echo "Plotting small-bench results ..."
  69. bash -c 'cd plots && for tex in $(SMALLPLOTS); do \
  70. pdflatex "\newcommand{\DATAPATH}{../data/$$(ls ../data/ | sort -r | head -n 1)}\input{$$tex}"; \
  71. echo "created plot for $$tex"; \
  72. done'
  73. @echo "============================================"
  74. @echo "Done"
  75. plot:
  76. @echo "Plotting bench results ..."
  77. bash -c 'cd plots && for tex in $(PLOTS); do \
  78. pdflatex "\newcommand{\DATAPATH}{../data/$$(ls ../data/ | sort -r | head -n 1)}\input{$$tex}"; \
  79. echo "created plot for $$tex"; \
  80. done'
  81. @echo "============================================"
  82. @echo "Done"
  83. report: plot
  84. @echo "Compiling report ..."
  85. bash -c 'cd report && pdflatex report.tex && pdflatex report.tex'
  86. @echo "============================================"
  87. @echo "Done"
  88. zip:
  89. @zip framework.zip benchmark.py Makefile README src/* plots/avg_plot.tex report/report.tex
  90. clean:
  91. @echo "Cleaning build directory: $(BUILD_DIR) and binaries: $(NAME) $(NAME).so"
  92. $(RM) -Rf $(BUILD_DIR)
  93. $(RM) -f $(NAME) $(NAME).so
  94. $(RM) -f plots/*.aux plots/*.log plots/*.fls plots/*.synctex.gz plots/*.fdb_latexmk plots/*.pdf report/*.aux report/*.fdb_latexmk report/*.fls report/*.log report/*.out report/*.pdf
  95. .PHONY: clean report