Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add workflow for cython/cpp linting #147

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/lint_cpp.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions .github/workflows/lint_cython.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Format Python Code
name: Python Linter & Format

on: [pull_request]

Expand Down
4 changes: 2 additions & 2 deletions src/c/backend/include/parray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstdint>
#include <unordered_map>
Expand All @@ -24,8 +24,8 @@
// scheduling task
class InnerPArray {
public:
uint64_t id; // unique ID of the PArray

Check warning on line 27 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:27:12 [cppcoreguidelines-non-private-member-variables-in-classes]

member variable 'id' has public visibility
uint64_t parent_id; // unique ID of the parent PArray

Check warning on line 28 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:28:12 [cppcoreguidelines-non-private-member-variables-in-classes]

member variable 'parent_id' has public visibility

/// Track the number of tasks that are using or are planning to use this
/// PArray.
Expand All @@ -35,7 +35,7 @@
/// compared to restructuring overheads), but this counter is decreased.
/// This is used to provide more accurate PArray placement information
/// to the task mapping step.
std::vector<CopyableAtomic<size_t>> num_active_tasks;

Check warning on line 38 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:38:39 [cppcoreguidelines-non-private-member-variables-in-classes]

member variable 'num_active_tasks' has public visibility

InnerPArray() = delete;
InnerPArray(void *, uint64_t, uint64_t, InnerPArray *, PArrayState *,
Expand All @@ -43,17 +43,17 @@

/// Get current size (in bytes) of each copy of the PArray
/// if it is a subarray, return the subarray's size
const uint64_t get_size() const;

Check warning on line 46 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:46:18 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Set the size of the PArray
void set_size(uint64_t new_size);

/// Return True if there is an PArray copy (possibly invalid) on this device
bool exists_on_device(uint64_t device_id);

Check warning on line 52 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:52:8 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Return True if there is an PArray copy and its coherence state is valid on
/// this device
bool valid_on_device(uint64_t device_id);

Check warning on line 56 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:56:8 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Add a pointer of the task that will use this PArray to the task list
void add_task(InnerTask *task);
Expand All @@ -65,17 +65,17 @@
void decr_num_active_tasks(DevID_t global_dev_id);

/// Get the number of counter for the active tasks that use this PArray.
size_t get_num_active_tasks(DevID_t global_dev_id);

Check warning on line 68 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:68:10 [modernize-use-trailing-return-type]

use a trailing return type for this function

// TODO(hc): I will replace this list with a concurrent map.
/// Get a reference to a list of tasks who are using this PArray
TaskList &get_task_list_ref();

Check warning on line 72 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:72:13 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Return the instance of Python PArray.
void *get_py_parray();

Check warning on line 75 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:75:9 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Return the parent id of the current instance.
uint64_t get_parray_parentid();

Check warning on line 78 in src/c/backend/include/parray.hpp

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/c/backend/include/parray.hpp:78:12 [modernize-use-trailing-return-type]

use a trailing return type for this function

/// Return a pointer of the parent PArray.
InnerPArray *get_parent_parray();
Expand Down
1 change: 0 additions & 1 deletion src/c/backend/include/phases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/c/backend/phases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ void Mapper::run(SchedulerPhase *next_phase) {
std::vector<std::shared_ptr<DeviceRequirement>> 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.
Expand Down
13 changes: 7 additions & 6 deletions src/c/backend/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ void LocalityLoadBalancingMappingPolicy::run_task_mapping(
std::vector<std::shared_ptr<DeviceRequirement>> *chosen_devices,
const std::vector<std::vector<std::pair<parray::InnerPArray *, AccessMode>>>
&parray_list,
std::vector<std::shared_ptr<PlacementRequirementBase>> *placement_req_options_vec) {
std::vector<std::shared_ptr<PlacementRequirementBase>>
*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,
Expand Down Expand Up @@ -242,8 +243,8 @@ void LocalityLoadBalancingMappingPolicy::run_task_mapping(
std::shared_ptr<DeviceRequirement> dev_req =
std::dynamic_pointer_cast<DeviceRequirement>(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;
}
Expand All @@ -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;
}
Expand Down
Loading