From bf11b25111cd18f0839fa38af4a5e99a4b368c96 Mon Sep 17 00:00:00 2001 From: dialecticDolt Date: Wed, 1 Nov 2023 03:38:22 -0500 Subject: [PATCH] ci: add workflow for cython/cpp linting --- .github/workflows/lint_cpp.yml | 21 ++++++++++++++++++ .github/workflows/lint_cython.yml | 22 +++++++++++++++++++ .../{format_with_ruff.yml => lint_python.yml} | 2 +- src/c/backend/include/parray.hpp | 4 ++-- src/c/backend/include/phases.hpp | 1 - src/c/backend/phases.cpp | 3 +-- src/c/backend/policy.cpp | 13 ++++++----- 7 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/lint_cpp.yml create mode 100644 .github/workflows/lint_cython.yml rename .github/workflows/{format_with_ruff.yml => lint_python.yml} (96%) diff --git a/.github/workflows/lint_cpp.yml b/.github/workflows/lint_cpp.yml new file mode 100644 index 00000000..f83f76cf --- /dev/null +++ b/.github/workflows/lint_cpp.yml @@ -0,0 +1,21 @@ +name: CPP Linter + +on: pull_request + +jobs: + cpp-linter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cpp-linter/cpp-linter-action@v2 + id: linter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + style: llvm + + - name: Fail fast?! + if: steps.linter.outputs.checks-failed > 0 + run: echo "Some files failed the linting checks!" + # for actual deployment + # run: exit 1 diff --git a/.github/workflows/lint_cython.yml b/.github/workflows/lint_cython.yml new file mode 100644 index 00000000..38639368 --- /dev/null +++ b/.github/workflows/lint_cython.yml @@ -0,0 +1,22 @@ +name: Cython Linter + +on: [pull_request] + +jobs: + format: + runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository. + contents: write + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: '3.11' + - name: Install cython-lint + run: pip install cython-lint + - name: Check code formatting + run: cython-lint src/python/parla/cython diff --git a/.github/workflows/format_with_ruff.yml b/.github/workflows/lint_python.yml similarity index 96% rename from .github/workflows/format_with_ruff.yml rename to .github/workflows/lint_python.yml index 53391a71..057799c5 100644 --- a/.github/workflows/format_with_ruff.yml +++ b/.github/workflows/lint_python.yml @@ -1,4 +1,4 @@ -name: Format Python Code +name: Python Linter & Format on: [pull_request] diff --git a/src/c/backend/include/parray.hpp b/src/c/backend/include/parray.hpp index e0d28dd1..c939e88c 100644 --- a/src/c/backend/include/parray.hpp +++ b/src/c/backend/include/parray.hpp @@ -7,9 +7,9 @@ #pragma once +#include "atomic_wrapper.hpp" #include "containers.hpp" -#include "include/atomic_wrapper.hpp" -#include "include/device.hpp" +#include "device.hpp" #include "parray_state.hpp" #include #include diff --git a/src/c/backend/include/phases.hpp b/src/c/backend/include/phases.hpp index fb28b6e5..8b3e4a6a 100644 --- a/src/c/backend/include/phases.hpp +++ b/src/c/backend/include/phases.hpp @@ -167,7 +167,6 @@ class Mapper : virtual public SchedulerPhase { void run(SchedulerPhase *next_phase); size_t get_count(); - /// @brief Increase the count of tasks mapped to a device /// @param dev_id Device global ID where a task is mapped /// @return The number of the tasks mapped to a device diff --git a/src/c/backend/phases.cpp b/src/c/backend/phases.cpp index 6d563e20..0bcb091a 100644 --- a/src/c/backend/phases.cpp +++ b/src/c/backend/phases.cpp @@ -63,8 +63,7 @@ void Mapper::run(SchedulerPhase *next_phase) { std::vector> chosen_devices; policy_->run_task_mapping(task, *this, &chosen_devices, parray_list, - &placement_req_options_vec); - + &placement_req_options_vec); if (chosen_devices.empty()) { // It means that none of the devices is available for this task. diff --git a/src/c/backend/policy.cpp b/src/c/backend/policy.cpp index 1cf1c762..0a3b6f03 100644 --- a/src/c/backend/policy.cpp +++ b/src/c/backend/policy.cpp @@ -208,7 +208,8 @@ void LocalityLoadBalancingMappingPolicy::run_task_mapping( std::vector> *chosen_devices, const std::vector>> &parray_list, - std::vector> *placement_req_options_vec) { + std::vector> + *placement_req_options_vec) { // A set of chosen devices to a task. Score_t best_score{-1}; // If any device was chosen as a candidate device, @@ -242,8 +243,8 @@ void LocalityLoadBalancingMappingPolicy::run_task_mapping( std::shared_ptr dev_req = std::dynamic_pointer_cast(base_req); Score_t score{0}; - bool is_req_available = calc_score_devplacement( - task, dev_req, mapper, &score, parray_list[0]); + bool is_req_available = calc_score_devplacement(task, dev_req, mapper, + &score, parray_list[0]); if (!is_req_available) { continue; } @@ -263,9 +264,9 @@ void LocalityLoadBalancingMappingPolicy::run_task_mapping( // std::cout << "[Mapper] Task name:" << task->get_name() << ", " << // "Checking arch requirement." // << "\n"; - bool is_req_available = calc_score_archplacement( - task, arch_req, mapper, chosen_dev_req, &chosen_dev_score, - parray_list[0]); + bool is_req_available = + calc_score_archplacement(task, arch_req, mapper, chosen_dev_req, + &chosen_dev_score, parray_list[0]); if (!is_req_available) { continue; }