From 755185ca2641190eec80ab739accd76dc0988b1d Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sat, 25 Nov 2023 01:32:19 -0600 Subject: [PATCH] modif --- assignments/03/Makefile | 20 ++++++++++---------- assignments/03/lpa.cpp | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/assignments/03/Makefile b/assignments/03/Makefile index bd871c1..912753f 100644 --- a/assignments/03/Makefile +++ b/assignments/03/Makefile @@ -1,18 +1,15 @@ .PHONY: run clean -CFLAGS += -g -O3 -CFLAGS += -DFMT_HEADER_ONLY -LDFLAGS += $(shell pkg-config --libs fmt) - -clean: - rm -f lpa - -lpac: lpa.cpp - mpicc $(CFLAGS) $(LDFLAGS) -o $@ $< +CFLAGS += -g +# CFLAGS += -DFMT_HEADER_ONLY -O3 +# LDFLAGS += $(shell pkg-config --libs fmt) lpa: lpa.cpp Makefile test.gdb mpic++ $(CFLAGS) $(LDFLAGS) -o $@ lpa.cpp +lpac: lpa.cpp + mpicc $(CFLAGS) $(LDFLAGS) -o $@ $< + run: watchexec -c clear 'make lpa && mpirun -n 4 ./lpa dataset/both_1000.txt' @@ -23,4 +20,7 @@ zhan4854.tar.gz: Makefile ASSIGNMENT.md lpa.cpp report.pdf mkdir -p zhan4854 cp $^ zhan4854 tar -czvf $@ zhan4854 - rm -r zhan4854 \ No newline at end of file + rm -r zhan4854 + +clean: + rm -f lpa diff --git a/assignments/03/lpa.cpp b/assignments/03/lpa.cpp index 695a6ab..1042a31 100644 --- a/assignments/03/lpa.cpp +++ b/assignments/03/lpa.cpp @@ -14,8 +14,8 @@ #include #include -#include -#include +// #include +// #include #define TAG_SEND_NUM_EDGES 1001 #define TAG_SEND_EDGES 1002 @@ -161,7 +161,9 @@ int main(int argc, char **argv) { // STEP 2 TIMER STARTS HERE MPI_Barrier(MPI_COMM_WORLD); - double step_2_start_time = MPI_Wtime(); + double step_2_start_time; + if (rank == 0) + step_2_start_time = MPI_Wtime(); // Each process analyzes the non-local edges that are contained in its portion // of the graph. @@ -221,7 +223,9 @@ int main(int argc, char **argv) { // STEP 5 TIMER STARTS HERE MPI_Barrier(MPI_COMM_WORLD); - double step_5_start_time = MPI_Wtime(); + double step_5_start_time; + if (rank == 0) + step_5_start_time = MPI_Wtime(); // The processes perform the transfers of non-local labels and updates of // local labels until convergence. @@ -311,7 +315,9 @@ int main(int argc, char **argv) { // END TIMERS MPI_Barrier(MPI_COMM_WORLD); - double end_time = MPI_Wtime(); + double end_time; + if (rank == 0) + end_time = MPI_Wtime(); if (rank == 0) { printf("2-5 Time: %0.04fs\n", end_time - step_2_start_time); @@ -431,4 +437,4 @@ int lookup_assignment(int *base_node_assignment, pair my_node_range, // Pull the corresponding value from the map return recvbuf[recv_displs[process_from] + index]; -} \ No newline at end of file +}