AUTH's THMMY "Parallel and distributed systems" course assignments.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 4 semaines
il y a 3 semaines
il y a 2 semaines
il y a 3 semaines
il y a 3 semaines
il y a 4 semaines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #
  2. # PDS HW2 Makefile
  3. #
  4. # Copyright (C) 2024 Christos Choutouridis <christos@choutouridis.net>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Lesser General Public License as
  8. # published by the Free Software Foundation, either version 3
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Lesser General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Lesser General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # ============== Project settings ==============
  20. # Project's name
  21. PROJECT := PDS_homework_2
  22. # Excecutable's name
  23. TARGET := bitonic
  24. # Source directories list(space seperated). Makefile-relative path, UNDER current directory.
  25. SRC_DIR_LIST := src test test/gtest
  26. # Include directories list(space seperated). Makefile-relative path.
  27. INC_DIR_LIST := include \
  28. test \
  29. test/gtest/ \
  30. /usr/lib/x86_64-linux-gnu/openmpi/include/ \
  31. src
  32. # Exclude files list(space seperated). Filenames only.
  33. # EXC_FILE_LIST := bad.cpp old.cpp
  34. # Build directories
  35. BUILD_DIR := bin
  36. OBJ_DIR := $(BUILD_DIR)/obj
  37. DEP_DIR := $(BUILD_DIR)/.dep
  38. OUTPUT_DIR := out-rc3b
  39. # ========== Compiler settings ==========
  40. # Compiler flags for debug and release
  41. DEB_CFLAGS := -DDEBUG -g3 -Wall -Wextra -std=c11 -fopenmp
  42. REL_CFLAGS := -Wall -Wextra -O3 -std=c11 -fopenmp
  43. DEB_CXXFLAGS := -DDEBUG -g3 -Wall -Wextra -std=c++17 -fopenmp
  44. REL_CXXFLAGS := -Wall -Wextra -O3 -std=c++17 -fopenmp
  45. # Pre-defines
  46. # PRE_DEFS := MYCAB=1729 SUPER_MODE
  47. PRE_DEFS := _GLIBCXX_PARALLEL
  48. # ============== Linker settings ==============
  49. # Linker flags (example: -pthread -lm)
  50. LDFLAGS := -pthread -fopenmp
  51. # Map output file
  52. MAP_FILE := output.map
  53. MAP_FLAG := -Xlinker -Map=$(BUILD_DIR)/$(MAP_FILE)
  54. # ============== Docker settings ==============
  55. # We need:
  56. # - Bind the entire project directory(the dir that icludes all the code) as volume.
  57. # - In docker instance, change to working directory(where the makefile is).
  58. DOCKER_VOL_DIR := $(shell pwd)
  59. DOCKER_WRK_DIR :=
  60. DOCKER_RUN := docker run --rm
  61. DOCKER_FLAGS := -v $(DOCKER_VOL_DIR):/usr/src/$(PROJECT) -w /usr/src/$(PROJECT)/$(DOCKER_WRK_DIR)
  62. # docker invoke mechanism (edit with care)
  63. # note:
  64. # Here, `DOCKER` variable is empty. Rules can assign `DOCKER := DOCKER_CMD` when docker
  65. # functionality is needed.
  66. DOCKER_CMD = $(DOCKER_RUN) $(DOCKER_FLAGS) $(IMAGE)
  67. DOCKER :=
  68. # ============== Tool selection ==============
  69. # compiler and compiler flags.
  70. CSIZE := size
  71. CFLAGS := $(DEB_CFLAGS)
  72. CXXFLAGS := $(DEB_CXXFLAGS)
  73. CXX := g++ #mpic++
  74. CC := gcc #mpicc
  75. #
  76. # =========== Main body and Patterns ===========
  77. #
  78. #ifeq ($(OS), Windows_NT)
  79. # TARGET := $(TARGET).exe
  80. #endif
  81. INC := $(foreach dir,$(INC_DIR_LIST),-I$(dir))
  82. DEF := $(foreach def,$(PRE_DEFS),-D$(def))
  83. EXC := $(foreach fil,$(EXC_FILE_LIST), \
  84. $(foreach dir,$(SRC_DIR_LIST),$(wildcard $(dir)/$(fil))) \
  85. )
  86. # source files. object and dependencies list
  87. # recursive search into current and source directories
  88. SRC := $(wildcard *.cpp)
  89. SRC += $(foreach dir,$(SRC_DIR_LIST),$(wildcard $(dir)/*.cpp))
  90. SRC += $(foreach dir,$(SRC_DIR_LIST),$(wildcard $(dir)/**/*.cpp))
  91. SRC := $(filter-out $(EXC),$(SRC))
  92. #SRC := $(abspath $(SRC))
  93. OBJ := $(foreach file,$(SRC:%.cpp=%.o),$(OBJ_DIR)/$(file))
  94. DEP := $(foreach file,$(SRC:%.cpp=%.d),$(DEP_DIR)/$(file))
  95. # Make Dependencies pattern.
  96. # This little trick enables recompilation only when dependencies change
  97. # and it does so for changes both in source AND header files ;)
  98. #
  99. # It is based on Tom Tromey's method.
  100. #
  101. # Invoke cpp to create makefile rules with dependencies for each source file
  102. $(DEP_DIR)/%.d: %.c
  103. @mkdir -p $(@D)
  104. @$(DOCKER) $(CC) -E $(CFLAGS) $(INC) $(DEF) -MM -MT $(OBJ_DIR)/$(<:.c=.o) -MF $@ $<
  105. # c file objects depent on .c AND dependency files, which have an empty recipe
  106. $(OBJ_DIR)/%.o: %.c $(DEP_DIR)/%.d
  107. @mkdir -p $(@D)
  108. @$(DOCKER) $(CC) -c $(CFLAGS) $(INC) $(DEF) -o $@ $<
  109. $(DEP_DIR)/%.d: %.cpp
  110. @mkdir -p $(@D)
  111. @$(DOCKER) $(CXX) -E $(CXXFLAGS) $(INC) $(DEF) -MM -MT $(OBJ_DIR)/$(<:.cpp=.o) -MF $@ $<
  112. # cpp file objects depent on .cpp AND dependency files, which have an empty recipe
  113. $(OBJ_DIR)/%.o: %.cpp $(DEP_DIR)/%.d
  114. @mkdir -p $(@D)
  115. @$(DOCKER) $(CXX) -c $(CXXFLAGS) $(INC) $(DEF) -o $@ $<
  116. # empty recipe for dependency files. This prevents make errors
  117. $(DEP):
  118. # now include all dependencies
  119. # After all they are makefile dependency rules ;)
  120. include $(wildcard $(DEP))
  121. # main target rule
  122. $(BUILD_DIR)/$(TARGET): $(OBJ)
  123. @mkdir -p $(@D)
  124. @echo Linking to target: $(TARGET)
  125. @echo $(DOCKER) $(CXX) '$$(OBJ)' $(LDFLAGS) $(MAP_FLAG) -o $(@D)/$(TARGET)
  126. @$(DOCKER) $(CXX) $(OBJ) $(LDFLAGS) $(MAP_FLAG) -o $(@D)/$(TARGET)
  127. @echo
  128. @echo Print size information
  129. @$(CSIZE) $(@D)/$(TARGET)
  130. @echo Done
  131. #
  132. # ================ Default local build rules =================
  133. # example:
  134. # make debug
  135. .DEFAULT_GOAL := all
  136. .PHONY: clean
  137. clean:
  138. @echo Cleaning build directories
  139. @rm -rf $(OBJ_DIR)
  140. @rm -rf $(DEP_DIR)
  141. @rm -rf $(BUILD_DIR)
  142. debug: CFLAGS := $(DEB_CFLAGS)
  143. debug: $(BUILD_DIR)/$(TARGET)
  144. release: CFLAGS := $(REL_CFLAGS)
  145. release: $(BUILD_DIR)/$(TARGET)
  146. #
  147. # ================ Build rules =================
  148. #
  149. # Local or inside HPC rules
  150. distbubbletonic: CC := mpicc
  151. distbubbletonic: CXX := mpic++
  152. distbubbletonic: CFLAGS := $(REL_CFLAGS) -DCODE_VERSION=BUBBLETONIC
  153. distbubbletonic: CXXFLAGS := $(REL_CXXFLAGS) -DCODE_VERSION=BUBBLETONIC
  154. distbubbletonic: TARGET := distbubbletonic
  155. distbubbletonic: $(BUILD_DIR)/$(TARGET)
  156. @mkdir -p $(OUTPUT_DIR)
  157. cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_DIR)/$(TARGET)
  158. distbitonic: CC := mpicc
  159. distbitonic: CXX := mpic++
  160. distbitonic: CFLAGS := $(REL_CFLAGS) -DCODE_VERSION=BITONIC
  161. distbitonic: CXXFLAGS := $(REL_CXXFLAGS) -DCODE_VERSION=BITONIC
  162. distbitonic: TARGET := distbitonic
  163. distbitonic: $(BUILD_DIR)/$(TARGET)
  164. @mkdir -p $(OUTPUT_DIR)
  165. cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_DIR)/$(TARGET)
  166. deb_distbubbletonic: CC := mpicc
  167. deb_distbubbletonic: CXX := mpic++
  168. deb_distbubbletonic: CFLAGS := $(DEB_CFLAGS) -DCODE_VERSION=BUBBLETONIC -DDEBUG
  169. deb_distbubbletonic: CXXFLAGS := $(DEB_CXXFLAGS) -DCODE_VERSION=BUBBLETONIC -DDEBUG
  170. deb_distbubbletonic: TARGET := deb_distbubbletonic
  171. deb_distbubbletonic: $(BUILD_DIR)/$(TARGET)
  172. @mkdir -p $(OUTPUT_DIR)
  173. cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_DIR)/$(TARGET)
  174. deb_distbitonic: CC := mpicc
  175. deb_distbitonic: CXX := mpic++
  176. deb_distbitonic: CFLAGS := $(DEB_CFLAGS) -DCODE_VERSION=BITONIC -DDEBUG
  177. deb_distbitonic: CXXFLAGS := $(DEB_CXXFLAGS) -DCODE_VERSION=BITONIC -DDEBUG
  178. deb_distbitonic: TARGET := deb_distbitonic
  179. deb_distbitonic: $(BUILD_DIR)/$(TARGET)
  180. @mkdir -p $(OUTPUT_DIR)
  181. cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_DIR)/$(TARGET)
  182. tests: CC := mpicc
  183. tests: CXX := mpic++
  184. tests: CFLAGS := $(DEB_CFLAGS) -DCODE_VERSION=BITONIC -DDEBUG -DTESTING
  185. tests: CXXFLAGS := $(DEB_CXXFLAGS) -DCODE_VERSION=BITONIC -DDEBUG -DTESTING
  186. tests: TARGET := tests
  187. tests: $(BUILD_DIR)/$(TARGET)
  188. @mkdir -p $(OUTPUT_DIR)
  189. cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_DIR)/$(TARGET)
  190. perfbitonic: CC := mpicc
  191. perfbitonic: CXX := mpic++
  192. perfbitonic: CFLAGS := $(REL_CFLAGS) -g -DCODE_VERSION=BITONIC
  193. perfbitonic: CXXFLAGS := $(REL_CXXFLAGS) -g -DCODE_VERSION=BITONIC
  194. perfbitonic: TARGET := perfbitonic
  195. perfbitonic: $(BUILD_DIR)/$(TARGET)
  196. @mkdir -p $(OUTPUT_DIR)
  197. cp $(BUILD_DIR)/$(TARGET) $(OUTPUT_DIR)/$(TARGET)
  198. hpc-build:
  199. make clean
  200. make distbubbletonic
  201. make clean
  202. make distbitonic
  203. make clean
  204. make tests
  205. all: debug distbubbletonic distbitonic
  206. # Note:
  207. # Add a gcc based make rule here in order for clangd to successfully scan the project files.
  208. # Otherwise we do not need the gcc build.