Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit 9308ea4

Browse files
authored
format: update formatting workflows and files formatting (#72)
* workflows: fix formatting * formatting: format with clang-format * workflow: fix clang-format
1 parent 5170512 commit 9308ea4

File tree

15 files changed

+64
-54
lines changed

15 files changed

+64
-54
lines changed

.github/workflows/python-package.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,31 @@ jobs:
5353
python -m pip install --upgrade pip
5454
pip install black
5555
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
56-
DISTRIB_CODENAME=$(cat /etc/lsb-release | grep DISTRIB_CODENAME | awk -F '=' '{print $NF}')
56+
# Add LLVM key and install clang-16
5757
sudo apt-get update
58-
sudo apt-get install -y software-properties-common wget curl
59-
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
60-
echo "deb http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-8 main" | sudo tee -a /etc/apt/sources.list.d/llvm-toolchain.list
61-
echo "deb-src http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-8 main" | sudo tee -a /etc/apt/sources.list.d/llvm-toolchain.list
62-
sudo apt-get update
63-
sudo apt-get install -y clang-format-8
58+
sudo apt-get install -y software-properties-common wget gnupg
59+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
60+
DISTRIB_CODENAME=$(lsb_release -sc)
61+
echo "deb http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-16 main" | sudo tee /etc/apt/sources.list.d/llvm-16.list
62+
if sudo apt-get update 2>&1 | grep -q "llvm-toolchain-${DISTRIB_CODENAME}-16"; then
63+
echo "LLVM repository added successfully"
64+
fi
65+
if sudo apt-get install -y clang-format-16 2>/dev/null; then
66+
echo "Installed clang-format-16"
67+
echo "CLANG_FORMAT=clang-format-16" >> $GITHUB_ENV
68+
fi
6469
- name: black format
6570
run: |
6671
black --diff --check .
6772
- name: clang-format
6873
run: |
6974
set +e
7075
FILES=$(find include src examples -type f | egrep '\.hpp$|\.cpp$|\.cpp\.in$')
71-
FORMAT_OUT=$(clang-format-8 -output-replacements-xml ${FILES})
76+
FORMAT_OUT=$($CLANG_FORMAT -output-replacements-xml ${FILES})
7277
RET=$(echo ${FORMAT_OUT} | grep -c '<replacement ')
7378
if [ "${RET}" -ne 0 ]; then
7479
echo -e "\nError! Code not formatted. Detected ${RET} lines\n"
75-
clang-format-8 -i ${FILES}
80+
$CLANG_FORMAT -i ${FILES}
7681
git diff
7782
exit ${RET}
7883
fi

examples/user.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
#include "user.hpp"
33

4-
#include "Kokkos_Core.hpp"
5-
64
#include <cstdint>
75
#include <iostream>
86

7+
#include "Kokkos_Core.hpp"
8+
99
struct InitView {
1010
explicit InitView(view_type _v) : m_view(_v) {}
1111

examples/user.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
#include "Kokkos_Core.hpp"
3-
42
#include <cstdint>
53

4+
#include "Kokkos_Core.hpp"
5+
66
using view_type = Kokkos::View<double**, Kokkos::DefaultExecutionSpace>;
77

88
view_type generate_view(size_t);

include/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ inline std::string demangle() {
116116
//----------------------------------------------------------------------------//
117117

118118
template <typename... Args>
119-
std::string join(const std::string &delim, Args &&... args) {
119+
std::string join(const std::string &delim, Args &&...args) {
120120
auto _construct = [&](auto &&_arg) {
121121
std::ostringstream _ss;
122122
_ss << std::forward<decltype(_arg)>(_arg);

include/concepts.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444

4545
#pragma once
4646

47+
#include <KokkosExp_InterOp.hpp>
48+
4749
#include "common.hpp"
4850
#include "fwd.hpp"
4951

50-
#include <KokkosExp_InterOp.hpp>
51-
5252
//----------------------------------------------------------------------------//
5353

5454
// default definition

include/deep_copy.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444

4545
#pragma once
4646

47+
#include <Kokkos_Core.hpp>
48+
#include <Kokkos_DynRankView.hpp>
49+
4750
#include "common.hpp"
4851
#include "concepts.hpp"
4952
#include "fwd.hpp"
5053
#include "traits.hpp"
5154

52-
#include <Kokkos_Core.hpp>
53-
#include <Kokkos_DynRankView.hpp>
54-
5555
//----------------------------------------------------------------------------//
5656

5757
template <size_t DataIdx, size_t SpaceIdx, size_t DimIdx, size_t LayoutIdx,
@@ -128,8 +128,8 @@ struct concrete_view_type_list<std::index_sequence<DataIdx...>> {
128128

129129
template <>
130130
struct concrete_view_type_list<> {
131-
using type = concat_t<type_list<typename concrete_view_type_list<decltype(
132-
std::make_index_sequence<ViewDataTypesEnd>())>::type>>;
131+
using type = concat_t<type_list<typename concrete_view_type_list<
132+
decltype(std::make_index_sequence<ViewDataTypesEnd>())>::type>>;
133133
};
134134

135135
//----------------------------------------------------------------------------//
@@ -194,8 +194,8 @@ struct dynamic_view_type_list<std::index_sequence<DataIdx...>> {
194194

195195
template <>
196196
struct dynamic_view_type_list<> {
197-
using type = concat_t<type_list<typename dynamic_view_type_list<decltype(
198-
std::make_index_sequence<ViewDataTypesEnd>())>::type>>;
197+
using type = concat_t<type_list<typename dynamic_view_type_list<
198+
decltype(std::make_index_sequence<ViewDataTypesEnd>())>::type>>;
199199
};
200200

201201
//----------------------------------------------------------------------------//
@@ -241,7 +241,8 @@ struct deep_copy_compatible {
241241

242242
template <typename Tp, typename Up>
243243
static constexpr bool is_managed() {
244-
return !Tp::traits::memory_traits::is_unmanaged && !Up::traits::memory_traits::is_unmanaged;
244+
return !Tp::traits::memory_traits::is_unmanaged &&
245+
!Up::traits::memory_traits::is_unmanaged;
245246
}
246247

247248
template <typename Tp, bool TpA = Tp::traits::memory_traits::is_atomic>

include/execution_spaces.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444

4545
#pragma once
4646

47+
#include <Kokkos_Core.hpp>
48+
4749
#include "common.hpp"
4850
#include "concepts.hpp"
4951
#include "pools.hpp"
5052
#include "traits.hpp"
5153

52-
#include <Kokkos_Core.hpp>
53-
5454
namespace Common {
5555
template <typename Sp, size_t SpaceIdx>
5656
void generate_execution_space_init(

include/fwd.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@
4444

4545
#pragma once
4646

47-
#include "common.hpp"
48-
#include "defines.hpp"
49-
5047
#include <Kokkos_Core.hpp>
51-
5248
#include <set>
5349
#include <string>
5450

51+
#include "common.hpp"
52+
#include "defines.hpp"
53+
5554
//----------------------------------------------------------------------------//
5655
//
5756
// Execution Spaces

include/libpykokkos.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444

4545
#pragma once
4646

47-
#include "common.hpp"
48-
4947
#include <pybind11/pybind11.h>
5048

49+
#include "common.hpp"
50+
5151
namespace py = pybind11;
5252

5353
void generate_tools(py::module& kokkos);

include/traits.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444

4545
#pragma once
4646

47+
#include <Kokkos_Core.hpp>
48+
4749
#include "common.hpp"
4850
#include "concepts.hpp"
4951
#include "defines.hpp"
5052
#include "fwd.hpp"
5153

52-
#include <Kokkos_Core.hpp>
53-
5454
//----------------------------------------------------------------------------//
5555

5656
DISABLE_TYPE(type_list<>)

0 commit comments

Comments
 (0)