This commit is contained in:
Michael Zhang 2023-11-25 01:32:19 -06:00
parent db37ce6a18
commit 755185ca26
2 changed files with 22 additions and 16 deletions

View file

@ -1,18 +1,15 @@
.PHONY: run clean .PHONY: run clean
CFLAGS += -g -O3 CFLAGS += -g
CFLAGS += -DFMT_HEADER_ONLY # CFLAGS += -DFMT_HEADER_ONLY -O3
LDFLAGS += $(shell pkg-config --libs fmt) # LDFLAGS += $(shell pkg-config --libs fmt)
clean:
rm -f lpa
lpac: lpa.cpp
mpicc $(CFLAGS) $(LDFLAGS) -o $@ $<
lpa: lpa.cpp Makefile test.gdb lpa: lpa.cpp Makefile test.gdb
mpic++ $(CFLAGS) $(LDFLAGS) -o $@ lpa.cpp mpic++ $(CFLAGS) $(LDFLAGS) -o $@ lpa.cpp
lpac: lpa.cpp
mpicc $(CFLAGS) $(LDFLAGS) -o $@ $<
run: run:
watchexec -c clear 'make lpa && mpirun -n 4 ./lpa dataset/both_1000.txt' 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 mkdir -p zhan4854
cp $^ zhan4854 cp $^ zhan4854
tar -czvf $@ zhan4854 tar -czvf $@ zhan4854
rm -r zhan4854 rm -r zhan4854
clean:
rm -f lpa

View file

@ -14,8 +14,8 @@
#include <unistd.h> #include <unistd.h>
#include <utility> #include <utility>
#include <fmt/format.h> // #include <fmt/format.h>
#include <fmt/ranges.h> // #include <fmt/ranges.h>
#define TAG_SEND_NUM_EDGES 1001 #define TAG_SEND_NUM_EDGES 1001
#define TAG_SEND_EDGES 1002 #define TAG_SEND_EDGES 1002
@ -161,7 +161,9 @@ int main(int argc, char **argv) {
// STEP 2 TIMER STARTS HERE // STEP 2 TIMER STARTS HERE
MPI_Barrier(MPI_COMM_WORLD); 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 // Each process analyzes the non-local edges that are contained in its portion
// of the graph. // of the graph.
@ -221,7 +223,9 @@ int main(int argc, char **argv) {
// STEP 5 TIMER STARTS HERE // STEP 5 TIMER STARTS HERE
MPI_Barrier(MPI_COMM_WORLD); 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 // The processes perform the transfers of non-local labels and updates of
// local labels until convergence. // local labels until convergence.
@ -311,7 +315,9 @@ int main(int argc, char **argv) {
// END TIMERS // END TIMERS
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
double end_time = MPI_Wtime(); double end_time;
if (rank == 0)
end_time = MPI_Wtime();
if (rank == 0) { if (rank == 0) {
printf("2-5 Time: %0.04fs\n", end_time - step_2_start_time); 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 // Pull the corresponding value from the map
return recvbuf[recv_displs[process_from] + index]; return recvbuf[recv_displs[process_from] + index];
} }