timer
This commit is contained in:
parent
ca96bf8b2d
commit
fac66e8e70
5 changed files with 33 additions and 8 deletions
1
assignments/03/.gitignore
vendored
1
assignments/03/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
lpa
|
lpa
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
.cache
|
.cache
|
||||||
|
report.pdf
|
|
@ -4,10 +4,19 @@ CFLAGS += -DFMT_HEADER_ONLY
|
||||||
LDFLAGS += $(shell pkg-config --libs fmt)
|
LDFLAGS += $(shell pkg-config --libs fmt)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm lpa
|
rm -f lpa
|
||||||
|
|
||||||
lpa: lpa.cpp
|
lpa: lpa.cpp
|
||||||
mpic++ $(CFLAGS) $(LDFLAGS) -o $@ -g $<
|
mpic++ $(CFLAGS) $(LDFLAGS) -o $@ -g $<
|
||||||
|
|
||||||
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'
|
||||||
|
|
||||||
|
report.pdf: report.typ
|
||||||
|
typst compile $< $@
|
||||||
|
|
||||||
|
zhan4854.tar.gz: Makefile ASSIGNMENT.md lpa.cpp report.pdf
|
||||||
|
mkdir -p zhan4854
|
||||||
|
cp $^ zhan4854
|
||||||
|
tar -czvf $@ zhan4854
|
||||||
|
rm -r zhan4854
|
|
@ -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
|
||||||
|
@ -154,6 +154,10 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
// STEP 2 TIMER STARTS HERE
|
||||||
|
MPI::COMM_WORLD.Barrier();
|
||||||
|
double 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.
|
||||||
#pragma region
|
#pragma region
|
||||||
|
@ -209,6 +213,10 @@ int main(int argc, char **argv) {
|
||||||
#pragma region
|
#pragma region
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
// STEP 5 TIMER STARTS HERE
|
||||||
|
MPI::COMM_WORLD.Barrier();
|
||||||
|
double 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.
|
||||||
#pragma region
|
#pragma region
|
||||||
|
@ -289,9 +297,9 @@ int main(int argc, char **argv) {
|
||||||
int total_changes;
|
int total_changes;
|
||||||
MPI::COMM_WORLD.Allreduce(&num_changes, &total_changes, 1, MPI_INT,
|
MPI::COMM_WORLD.Allreduce(&num_changes, &total_changes, 1, MPI_INT,
|
||||||
MPI::SUM);
|
MPI::SUM);
|
||||||
std::cout << fmt::format("[{}] # updates: {} ({})", rank, num_changes,
|
// std::cout << fmt::format("[{}] # updates: {} ({})", rank, num_changes,
|
||||||
total_changes)
|
// total_changes)
|
||||||
<< std::endl;
|
// << std::endl;
|
||||||
|
|
||||||
if (total_changes == 0) {
|
if (total_changes == 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -304,6 +312,13 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
// END TIMERS
|
||||||
|
MPI::COMM_WORLD.Barrier();
|
||||||
|
double end_time = MPI::Wtime();
|
||||||
|
|
||||||
|
printf("2-5 Time: %0.04fs\n", end_time - step_2_start_time);
|
||||||
|
printf("5 Time: %0.04fs\n", end_time - step_5_start_time);
|
||||||
|
|
||||||
// The results are gathered to a single process, which writes them to the
|
// The results are gathered to a single process, which writes them to the
|
||||||
// disk.
|
// disk.
|
||||||
#pragma region
|
#pragma region
|
||||||
|
|
0
assignments/03/report.typ
Normal file
0
assignments/03/report.typ
Normal file
BIN
assignments/03/zhan4854.tar.gz
Normal file
BIN
assignments/03/zhan4854.tar.gz
Normal file
Binary file not shown.
Loading…
Reference in a new issue