diff --git a/lab07/aaron/e1/jacobiWaveSplitWork.cpp b/lab07/aaron/e1/jacobiWaveSplitWork.cpp index 4f5db92..00d22b6 100644 --- a/lab07/aaron/e1/jacobiWaveSplitWork.cpp +++ b/lab07/aaron/e1/jacobiWaveSplitWork.cpp @@ -45,6 +45,7 @@ * ------------- */ +#include #include "matrix.h" #include #include @@ -168,24 +169,49 @@ void print_matrix(const Matrix &matrix) } } -int main() -{ - Matrix first = Matrix(8, 8); - Matrix sec = Matrix(8, 8); - - fill_matrix(first, 10); +void benchmarkComputeResult(benchmark::State& state) { + int iterations = state.range(0); + Matrix sec = Matrix(1000, 1000); fill_matrix(sec, 10); - print_matrix(first); - print_matrix(sec); + for (auto _ : state) { + gauss_seidel(sec, iterations); + benchmark::DoNotOptimize(sec); + } +} - gauss_seidel_lin(first, 1000); - gauss_seidel(sec, 1000); +int main(int argc, char** argv) { + ::benchmark::Initialize(&argc, argv); - check(first, sec); + for (int iterations = 0; iterations < 10000; iterations++) { + benchmark::RegisterBenchmark("idk", benchmarkComputeResult) + ->Arg(iterations) + ->Unit(benchmark::kMillisecond); + } - print_matrix(first); - print_matrix(sec); + ::benchmark::RunSpecifiedBenchmarks(); return 0; -} \ No newline at end of file +} + +// int main() +// { +// Matrix first = Matrix(8, 8); +// Matrix sec = Matrix(8, 8); + +// fill_matrix(first, 10); +// fill_matrix(sec, 10); + +// print_matrix(first); +// print_matrix(sec); + +// gauss_seidel_lin(first, 1000); +// gauss_seidel(sec, 1000); + +// check(first, sec); + +// print_matrix(first); +// print_matrix(sec); + +// return 0; +// } \ No newline at end of file diff --git a/lab07/aaron/e2/upload/dbscan_parallel.cpp b/lab07/aaron/e2/upload/dbscan_parallel.cpp index 16a3ae6..2cf7f56 100644 --- a/lab07/aaron/e2/upload/dbscan_parallel.cpp +++ b/lab07/aaron/e2/upload/dbscan_parallel.cpp @@ -13,6 +13,7 @@ void DBSCAN::run(const std::vector& points) { const int n = dataset_.size(); int clusterIndex = 0; + #pragma omp parallel for for (int i = 0; i < n; ++i) { Point& point = dataset_[i]; if (point.clusterID < 0) { @@ -56,7 +57,7 @@ std::set DBSCAN::initializeNeighbors() { Point& pointToCheckNeighborsFor = dataset_[i]; for (int j = 0; j < dataset_.size(); ++j) { if (pointToCheckNeighborsFor.distance(dataset_[j]) <= epsilon_) { - pointToCheckNeighborsFor.neighbors.insert(j); + pointToCheckNeighborsFor.neighbors.insert(j); } } } diff --git a/lab07/aaron/e2/upload/dbscan_serial.cpp b/lab07/aaron/e2/upload/dbscan_serial.cpp index b940748..bbb43ea 100644 --- a/lab07/aaron/e2/upload/dbscan_serial.cpp +++ b/lab07/aaron/e2/upload/dbscan_serial.cpp @@ -1,4 +1,4 @@ -#include "dbscan.h" +#include "dbscan_serial.h" #include #include @@ -11,6 +11,7 @@ void DBSCAN::run(const std::vector& points) { const int n = dataset_.size(); int clusterIndex = 0; + for (int i = 0; i < n; ++i) { Point& point = dataset_[i]; if (point.clusterID < 0) { @@ -23,6 +24,10 @@ void DBSCAN::run(const std::vector& points) { } } } + + for (Point point : dataset_) { + std::cout << point << std::endl; + } } bool DBSCAN::expandCluster(Point& p, std::set& neighbours, int clusterID) { diff --git a/lab07/aaron/e2/upload/makefile b/lab07/aaron/e2/upload/makefile index e1863e0..17c1d54 100644 --- a/lab07/aaron/e2/upload/makefile +++ b/lab07/aaron/e2/upload/makefile @@ -6,11 +6,11 @@ # SOURCE_FILES: The source files of the algorithm, used for each build. # You can add more source files here if needed. -SOURCE_FILES = dbscan.cpp point.cpp +SOURCE_FILES = dbscan_serial.cpp point.cpp # Main rogram, used to cluster the data and save the result. # PROGRAM_NAME: The name of the program that will be generated after compilation. -PROGRAM_NAME = dbscan +PROGRAM_NAME = dbscan_serial RUN_MAIN = run.cpp # Benchmark program: This program is used to benchmark the performance of the algorithm.