Commit 7bfcf87c authored by hasan  khaddour's avatar hasan khaddour

Add Time Rule

parent a4e4bda8
# Compiler and flags # Compiler and flags
CC = g++ CC = g++
CFLAGS = -fopenmp -O2 CFLAGS = -fopenmp -O2 -lm
PROF_FLAGS = -pg PROF_FLAGS = -pg
# Source file # Source file
SRC = $(Pr) SRC = $(Pr)
# Parameters
N_THREADS = $(n)
N_RECTS = $(r)
PARAM = $(Params)
# Targets # Targets
TARGET_INTEGRAL = integral TARGET_INTEGRAL = integral
TARGET_MANDELBROT = mandelbrot TARGET_MANDELBROT = mandelbrot
# Directories
PROFILE_DIR = profiles
OUT_DIR = out
# Default target (builds both programs) # Default target (builds both programs)
all: $(TARGET_INTEGRAL) $(TARGET_MANDELBROT) all: $(TARGET_INTEGRAL) $(TARGET_MANDELBROT)
# Conditional build target # Conditional build target
build: build:
$(CC) $(CFLAGS) -o $(SRC) $(Pr).c $(CC) $(CFLAGS) -o $(OUT_DIR)/$(Pr) $(Pr).c
# Conditional run target # Conditional run target
run: run:
./$(SRC) ./$(OUT_DIR)/$(SRC) $(n) $(r)
# Profile the specified program # Profile the specified program
profile: profile:
$(CC) $(CFLAGS) $(PROF_FLAGS) -o $(Pr) $(SRC).c # create a folder for the profile file if not exist
./$(SRC) @mkdir -p $(OUT_DIR)
gprof $(SRC).exe gmon.out > $(Pr)_profile.txt
type $(Pr)_profile.txt $(CC) $(CFLAGS) $(PROF_FLAGS) -o $(OUT_DIR)/$(SRC) $(SRC).c
./$(OUT_DIR)/$(SRC) $(n) $(r)
gprof $(OUT_DIR)/$(SRC) gmon.out > $(PROFILE_DIR)/$(Pr)_profile.txt
cat $(PROFILE_DIR)/$(Pr)_profile.txt
# Time measurement rule
time:
@echo "Timing execution of $(Pr) with $(n) threads "
@time $(OUT_DIR)/$(Pr) $(n) $(r) >> /dev/null
# Build each program individually # Build each program individually
$(TARGET_INTEGRAL): integral.c $(TARGET_INTEGRAL): integral.c
$(CC) $(CFLAGS) -o $(TARGET_INTEGRAL) integral.c $(CC) $(CFLAGS) -o $(OUT_DIR)/$(TARGET_INTEGRAL) integral.c
$(TARGET_MANDELBROT): mandelbrot.cpp $(TARGET_MANDELBROT): mandelbrot.c
$(CC) $(CFLAGS) -o $(TARGET_MANDELBROT) mandelbrot.cpp $(CC) $(CFLAGS) -o $(OUT_DIR)/$(TARGET_MANDELBROT) mandelbrot.c
# Clean command # Clean command
clean: clean:
rm -f $(TARGET_INTEGRAL) $(TARGET_MANDELBROT) gmon.out integral_profile.txt mandelbrot_profile.txt rm -rf $(OUT_DIR)/* $(PROFILE_DIR)/* gmon.out
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment