Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'learning-process:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimbelan authored Jun 6, 2024
2 parents dd5d142 + 2ee315f commit fe7741e
Show file tree
Hide file tree
Showing 396 changed files with 44,356 additions and 485 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
mpi: msmpi
- name: Download dependencies
run: |
choco install openssl
choco install openssl --execution-timeout 6000
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ venv*
sln/
.DS_Store
.cache
.vs
40 changes: 27 additions & 13 deletions cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ MACRO(SUBDIRLIST result curdir)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()

MACRO(CPPCHECK_TEST ProjectId ALL_SOURCE_FILES)
Expand All @@ -56,18 +56,32 @@ MACRO(CPPCHECK_TEST ProjectId ALL_SOURCE_FILES)
endforeach ()
if (NOT APPLE)
find_program(CPPCHECK_EXEC /usr/bin/cppcheck)
execute_process(COMMAND ${CPPCHECK_EXEC} --version OUTPUT_VARIABLE CPPCHECK_VERSION)
if (CPPCHECK_VERSION)
string(REGEX REPLACE "Cppcheck ([0-9]+\\.[0-9]+).*" "\\1" CPPCHECK_VERSION ${CPPCHECK_VERSION})
if (CPPCHECK_VERSION VERSION_GREATER_EQUAL "2.11")
set(CPPCHECK_FLAGS "--enable=warning,performance,portability,information")
set(CPPCHECK_FLAGS "--disable=missingInclude")
set(CPPCHECK_FLAGS "--language=c++")
set(CPPCHECK_FLAGS "--std=c++11")
set(CPPCHECK_FLAGS "--error-exitcode=1")
set(CPPCHECK_FLAGS "--template=\"[{severity}][{id}] {message} {callstack} \\(On {file}:{line}\\)\"")
set(CPPCHECK_FLAGS "--verbose")
set(CPPCHECK_FLAGS "--quiet")
else ()
set(CPPCHECK_FLAGS "--enable=warning,performance,portability,information")
set(CPPCHECK_FLAGS "--language=c++")
set(CPPCHECK_FLAGS "--std=c++11")
set(CPPCHECK_FLAGS "--error-exitcode=1")
set(CPPCHECK_FLAGS "--template=\"[{severity}][{id}] {message} {callstack} \\(On {file}:{line}\\)\"")
set(CPPCHECK_FLAGS "--verbose")
set(CPPCHECK_FLAGS "--quiet")
endif ()
endif ()
add_custom_target(
"${ProjectId}_cppcheck" ALL
COMMAND ${CPPCHECK_EXEC}
--enable=warning,performance,portability,information
--language=c++
--std=c++11
--error-exitcode=1
--template="[{severity}][{id}] {message} {callstack} \(On {file}:{line}\)"
--verbose
--quiet
${ALL_SOURCE_FILES}
COMMAND ${CPPCHECK_EXEC} ${CPPCHECK_FLAGS} ${ALL_SOURCE_FILES}
)
ENDIF ()
endif( UNIX )
ENDMACRO()
ENDMACRO()
165 changes: 165 additions & 0 deletions tasks/omp/akopyan_z_bin_hull/func_tests/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// Copyright 2024 Akopyan Zal
#include <gtest/gtest.h>

#include <vector>

#include "omp/akopyan_z_bin_hull/include/ops_omp.hpp"

namespace task = akopyan_z_bin_hull_omp;

TEST(akopyan_z_bin_hull_omp_omp, small_test_tri) {
int width = 3;
int height = 4;

// Create data
std::vector<int> out(width * height);
std::vector<int> in = {0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0};

std::vector<int> hullTrue = {0, 1, 1, 0, 2, 1, task::SEPARATOR};

// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskData = std::make_shared<ppc::core::TaskData>();
taskData->inputs.emplace_back(reinterpret_cast<uint8_t*>(in.data()));
taskData->inputs_count.emplace_back(width);
taskData->inputs_count.emplace_back(height);
taskData->outputs.emplace_back(reinterpret_cast<uint8_t*>(out.data()));

// Create Task
task::AkopyanZBinHull testTaskSequential(taskData);
ASSERT_EQ(testTaskSequential.validation(), true);
testTaskSequential.pre_processing();
testTaskSequential.run();
testTaskSequential.post_processing();

for (size_t i = 0; i < hullTrue.size(); i++) EXPECT_EQ(hullTrue[i], out[i]);
}

TEST(akopyan_z_bin_hull_omp_omp, small_test_cross) {
int width = 3;
int height = 4;

// Create data
std::vector<int> out(width * height);
std::vector<int> in = {0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0};

std::vector<int> hullTrue = {0, 1, 1, 0, 2, 1, task::SEPARATOR};

// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskData = std::make_shared<ppc::core::TaskData>();
taskData->inputs.emplace_back(reinterpret_cast<uint8_t*>(in.data()));
taskData->inputs_count.emplace_back(width);
taskData->inputs_count.emplace_back(height);
taskData->outputs.emplace_back(reinterpret_cast<uint8_t*>(out.data()));

// Create Task
task::AkopyanZBinHull testTaskSequential(taskData);
ASSERT_EQ(testTaskSequential.validation(), true);
testTaskSequential.pre_processing();
testTaskSequential.run();
testTaskSequential.post_processing();

for (size_t i = 0; i < hullTrue.size(); i++) EXPECT_EQ(hullTrue[i], out[i]);
}

TEST(akopyan_z_bin_hull_omp_omp, two_labels_test) {
int width = 6;
int height = 6;

// Create data
std::vector<int> out(width * height);
std::vector<int> in = {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0,
0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0};

std::vector<int> hullTrue = {0, 2, 1, 1, 2, 2, 1, 3, task::SEPARATOR, 3, 4, 4, 2, 5, 4, task::SEPARATOR};

// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskData = std::make_shared<ppc::core::TaskData>();
taskData->inputs.emplace_back(reinterpret_cast<uint8_t*>(in.data()));
taskData->inputs_count.emplace_back(width);
taskData->inputs_count.emplace_back(height);
taskData->outputs.emplace_back(reinterpret_cast<uint8_t*>(out.data()));

// Create Task
task::AkopyanZBinHull testTaskSequential(taskData);
ASSERT_EQ(testTaskSequential.validation(), true);
testTaskSequential.pre_processing();
testTaskSequential.run();
testTaskSequential.post_processing();

for (size_t i = 0; i < hullTrue.size(); i++) EXPECT_EQ(hullTrue[i], out[i]);
}

TEST(akopyan_z_bin_hull_omp_omp, two_labels_test2) {
int width = 5;
int height = 8;

// Create data
std::vector<int> out(width * height);
std::vector<int> in = {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0};

std::vector<int> hullTrue = {2, 2, 3, 1, 4, 2, task::SEPARATOR, 0, 6, 1, 6, 1, 7, 0, 7, task::SEPARATOR};

// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskData = std::make_shared<ppc::core::TaskData>();
taskData->inputs.emplace_back(reinterpret_cast<uint8_t*>(in.data()));
taskData->inputs_count.emplace_back(width);
taskData->inputs_count.emplace_back(height);
taskData->outputs.emplace_back(reinterpret_cast<uint8_t*>(out.data()));

// Create Task
task::AkopyanZBinHull testTaskSequential(taskData);
ASSERT_EQ(testTaskSequential.validation(), true);
testTaskSequential.pre_processing();
testTaskSequential.run();
testTaskSequential.post_processing();

for (size_t i = 0; i < hullTrue.size(); i++) ASSERT_EQ(hullTrue[i], out[i]);
}

TEST(akopyan_z_bin_hull_omp_omp, generated_test) {
int width = 10;
int height = 10;

// Create data
std::vector<int> out(width * height);
std::vector<int> in(width * height, 0);
int sqw = width / 2;
int sqh = height / 2;
for (int i = 0; i < sqh - 1; i++) {
for (int j = 0; j < sqw - 1; j++) {
in[i * width + j] = 1;
in[i * width + (sqw + 1 + j)] = 1;
}
}
for (int i = 0; i < width; i++) {
in[sqh * width + i] = 1;
in[(sqh + 2) * width + i] = 1;
}
for (int i = sqh + 3; i < height; i++) {
in[i * width + sqw - 1] = 1;
in[i * width + sqw] = 1;
}

std::vector<int> hullTrue = {
0, 0, sqw - 2, 0, sqw - 2, sqh - 2, 0, sqh - 2, task::SEPARATOR,
sqw + 1, 0, width - 1, 0, width - 1, sqh - 2, sqw + 1, sqh - 2, task::SEPARATOR,
0, sqh, width - 1, sqh, task::SEPARATOR, 0, sqh + 2, width - 1, sqh + 2,
sqw, height - 1, sqw - 1, height - 1, task::SEPARATOR};

// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskData = std::make_shared<ppc::core::TaskData>();
taskData->inputs.emplace_back(reinterpret_cast<uint8_t*>(in.data()));
taskData->inputs_count.emplace_back(width);
taskData->inputs_count.emplace_back(height);
taskData->outputs.emplace_back(reinterpret_cast<uint8_t*>(out.data()));

// Create Task
task::AkopyanZBinHull testTaskSequential(taskData);
ASSERT_EQ(testTaskSequential.validation(), true);
testTaskSequential.pre_processing();
testTaskSequential.run();
testTaskSequential.post_processing();

for (size_t i = 0; i < hullTrue.size(); i++) ASSERT_EQ(hullTrue[i], out[i]);
}
38 changes: 38 additions & 0 deletions tasks/omp/akopyan_z_bin_hull/include/ops_omp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2024 Akopyan Zal
#pragma once

#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "core/task/include/task.hpp"

namespace akopyan_z_bin_hull_omp {
struct pnt {
int x{};
int y{};
pnt() = default;
pnt(int x_, int y_) : x(x_), y(y_) {}
};

const int SEPARATOR = -1;

class AkopyanZBinHull : public ppc::core::Task {
public:
explicit AkopyanZBinHull(std::shared_ptr<ppc::core::TaskData> taskData_) : Task(std::move(taskData_)) {}
bool pre_processing() override;
bool validation() override;
bool run() override;
bool post_processing() override;

private:
std::vector<int> bin_image{};
std::vector<int> out_hull{};
int width{};
int height{};

std::vector<std::vector<pnt>> label_components();
static std::vector<pnt> graham(std::vector<pnt> points);
};
} // namespace akopyan_z_bin_hull_omp
121 changes: 121 additions & 0 deletions tasks/omp/akopyan_z_bin_hull/perf_tests/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Copyright 2024 Akopyan Zal
#include <gtest/gtest.h>
#include <omp.h>

#include <algorithm>
#include <vector>

#include "core/perf/include/perf.hpp"
#include "omp/akopyan_z_bin_hull/include/ops_omp.hpp"

namespace task = akopyan_z_bin_hull_omp;

TEST(akopyan_z_bin_hull_omp_omp, test_pipeline_run) {
int width = 2000;
int height = 2000;

// Create data
std::vector<int> out(width * height);
std::vector<int> in(width * height, 0);
int sqw = width / 2;
int sqh = height / 2;
for (int i = 0; i < sqh - 1; i++) {
for (int j = 0; j < sqw - 1; j++) {
in[i * width + j] = 1;
in[i * width + (sqw + 1 + j)] = 1;
}
}
for (int i = 0; i < width; i++) {
in[sqh * width + i] = 1;
in[(sqh + 2) * width + i] = 1;
}
for (int i = sqh + 3; i < height; i++) {
in[i * width + sqw - 1] = 1;
in[i * width + sqw] = 1;
}

std::vector<int> hullTrue = {
0, 0, sqw - 2, 0, sqw - 2, sqh - 2, 0, sqh - 2, task::SEPARATOR,
sqw + 1, 0, width - 1, 0, width - 1, sqh - 2, sqw + 1, sqh - 2, task::SEPARATOR,
0, sqh, width - 1, sqh, task::SEPARATOR, 0, sqh + 2, width - 1, sqh + 2,
sqw, height - 1, sqw - 1, height - 1, task::SEPARATOR};

// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskData = std::make_shared<ppc::core::TaskData>();
taskData->inputs.emplace_back(reinterpret_cast<uint8_t*>(in.data()));
taskData->inputs_count.emplace_back(width);
taskData->inputs_count.emplace_back(height);
taskData->outputs.emplace_back(reinterpret_cast<uint8_t*>(out.data()));
// Create Task
auto testTaskSequential = std::make_shared<task::AkopyanZBinHull>(taskData);

// Create Perf attributes
auto perfAttr = std::make_shared<ppc::core::PerfAttr>();
perfAttr->num_running = 10;
perfAttr->current_timer = [&] { return omp_get_wtime(); };

// Create and init perf results
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(testTaskSequential);
perfAnalyzer->pipeline_run(perfAttr, perfResults);
ppc::core::Perf::print_perf_statistic(perfResults);

for (size_t i = 0; i < hullTrue.size(); i++) ASSERT_EQ(hullTrue[i], out[i]);
}

TEST(akopyan_z_bin_hull_omp_omp, test_task_run) {
int width = 2000;
int height = 2000;

// Create data
std::vector<int> out(width * height);
std::vector<int> in(width * height, 0);
int sqw = width / 2;
int sqh = height / 2;
for (int i = 0; i < sqh - 1; i++) {
for (int j = 0; j < sqw - 1; j++) {
in[i * width + j] = 1;
in[i * width + (sqw + 1 + j)] = 1;
}
}
for (int i = 0; i < width; i++) {
in[sqh * width + i] = 1;
in[(sqh + 2) * width + i] = 1;
}
for (int i = sqh + 3; i < height; i++) {
in[i * width + sqw - 1] = 1;
in[i * width + sqw] = 1;
}

std::vector<int> hullTrue = {
0, 0, sqw - 2, 0, sqw - 2, sqh - 2, 0, sqh - 2, task::SEPARATOR,
sqw + 1, 0, width - 1, 0, width - 1, sqh - 2, sqw + 1, sqh - 2, task::SEPARATOR,
0, sqh, width - 1, sqh, task::SEPARATOR, 0, sqh + 2, width - 1, sqh + 2,
sqw, height - 1, sqw - 1, height - 1, task::SEPARATOR};

// Create TaskData
std::shared_ptr<ppc::core::TaskData> taskData = std::make_shared<ppc::core::TaskData>();
taskData->inputs.emplace_back(reinterpret_cast<uint8_t*>(in.data()));
taskData->inputs_count.emplace_back(width);
taskData->inputs_count.emplace_back(height);
taskData->outputs.emplace_back(reinterpret_cast<uint8_t*>(out.data()));
// Create Task
auto testTaskSequential = std::make_shared<task::AkopyanZBinHull>(taskData);

// Create Perf attributes
auto perfAttr = std::make_shared<ppc::core::PerfAttr>();
perfAttr->num_running = 10;
perfAttr->current_timer = [&] { return omp_get_wtime(); };

// Create and init perf results
auto perfResults = std::make_shared<ppc::core::PerfResults>();

// Create Perf analyzer
auto perfAnalyzer = std::make_shared<ppc::core::Perf>(testTaskSequential);
perfAnalyzer->task_run(perfAttr, perfResults);
ppc::core::Perf::print_perf_statistic(perfResults);

for (size_t i = 0; i < hullTrue.size(); i++) ASSERT_EQ(hullTrue[i], out[i]);
}
Loading

0 comments on commit fe7741e

Please sign in to comment.