Skip to content

Commit 4282fc6

Browse files
authored
[enh] Add clang-format check to github CI (#132)
1 parent 87955f6 commit 4282fc6

25 files changed

+148
-121
lines changed
File renamed without changes.

.github/workflows/linting.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
clang-format:
11+
12+
runs-on: intel-ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Install dependencies
18+
run: |
19+
sudo apt update
20+
sudo apt -y install clang-format
21+
22+
- name: Lint
23+
run: |
24+
find . -type f | grep -P ".*\.(c|cpp|h|hpp)\b" | xargs clang-format -style=file --dry-run -Werror

benchmarks/bench-ipp.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ static void ippargsort(benchmark::State &state, Args &&...args)
6363
// benchmark
6464
for (auto _ : state) {
6565
if constexpr (std::is_same_v<T, float>) {
66-
ippsSortRadixIndexAscend_32f(arr.data(), 4, arg.data(), arrsize, temp);
66+
ippsSortRadixIndexAscend_32f(
67+
arr.data(), 4, arg.data(), arrsize, temp);
6768
}
6869
else if constexpr (std::is_same_v<T, double>) {
69-
ippsSortRadixIndexAscend_64f(arr.data(), 8, arg.data(), arrsize, temp);
70+
ippsSortRadixIndexAscend_64f(
71+
arr.data(), 8, arg.data(), arrsize, temp);
7072
}
7173
else if constexpr (std::is_same_v<T, int32_t>) {
72-
ippsSortRadixIndexAscend_32s(arr.data(), 4, arg.data(), arrsize, temp);
74+
ippsSortRadixIndexAscend_32s(
75+
arr.data(), 4, arg.data(), arrsize, temp);
7376
}
7477
state.PauseTiming();
7578
arr = arr_bkp;

benchmarks/bench-objsort.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ static constexpr char euclidean[] = "euclidean";
55
static constexpr char taxicab[] = "taxicab";
66
static constexpr char chebyshev[] = "chebyshev";
77

8-
template <typename T, const char* val>
8+
template <typename T, const char *val>
99
struct Point3D {
1010
T x;
1111
T y;
@@ -19,9 +19,7 @@ struct Point3D {
1919
}
2020
T distance()
2121
{
22-
if constexpr (name == "x") {
23-
return x;
24-
}
22+
if constexpr (name == "x") { return x; }
2523
else if constexpr (name == "euclidean") {
2624
return std::sqrt(x * x + y * y + z * z);
2725
}
@@ -77,9 +75,8 @@ static void simdobjsort(benchmark::State &state)
7775
std::vector<T> arr_bkp = arr;
7876
// benchmark
7977
for (auto _ : state) {
80-
x86simdsort::object_qsort(arr.data(), arr.size(), [](T p) {
81-
return p.distance();
82-
});
78+
x86simdsort::object_qsort(
79+
arr.data(), arr.size(), [](T p) { return p.distance(); });
8380
state.PauseTiming();
8481
if (!std::is_sorted(arr.begin(), arr.end(), less_than_key<T>())) {
8582
std::cout << "sorting failed \n";
@@ -90,7 +87,7 @@ static void simdobjsort(benchmark::State &state)
9087
}
9188

9289
#define BENCHMARK_OBJSORT(func, T, type, dist) \
93-
BENCHMARK_TEMPLATE(func, T<type,dist>) \
90+
BENCHMARK_TEMPLATE(func, T<type, dist>) \
9491
->Arg(10e1) \
9592
->Arg(10e2) \
9693
->Arg(10e3) \
@@ -101,12 +98,12 @@ static void simdobjsort(benchmark::State &state)
10198
#define BENCH_ALL(dtype) \
10299
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, x) \
103100
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, x) \
104-
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, taxicab ) \
101+
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, taxicab) \
105102
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, taxicab) \
106103
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, euclidean) \
107104
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, euclidean) \
108105
BENCHMARK_OBJSORT(simdobjsort, Point3D, dtype, chebyshev) \
109-
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, chebyshev) \
106+
BENCHMARK_OBJSORT(scalarobjsort, Point3D, dtype, chebyshev)
110107

111108
BENCH_ALL(double)
112109
BENCH_ALL(float)

benchmarks/bench-qsort.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ static void simdsort(benchmark::State &state, Args &&...args)
3636
}
3737
}
3838

39-
4039
#define BENCH_BOTH_QSORT(type) \
4140
BENCH_SORT(simdsort, type) \
42-
BENCH_SORT(scalarsort, type) \
41+
BENCH_SORT(scalarsort, type)
4342

4443
BENCH_BOTH_QSORT(uint64_t)
4544
BENCH_BOTH_QSORT(int64_t)

benchmarks/bench-vqsort.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ static void vqsort(benchmark::State &state, Args &&...args)
1414
std::vector<T> arr_bkp = arr;
1515
// benchmark
1616
for (auto _ : state) {
17-
hwy::HWY_NAMESPACE::VQSortStatic(arr.data(), arrsize, hwy::SortAscending());
17+
hwy::HWY_NAMESPACE::VQSortStatic(
18+
arr.data(), arrsize, hwy::SortAscending());
1819
state.PauseTiming();
1920
arr = arr_bkp;
2021
state.ResumeTiming();

benchmarks/bench.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@
1212
})))
1313

1414
#define BENCH_SORT(func, type) \
15-
MY_BENCHMARK_CAPTURE( \
16-
func, type, random_128, 128, std::string("random")); \
17-
MY_BENCHMARK_CAPTURE( \
18-
func, type, random_256, 256, std::string("random")); \
19-
MY_BENCHMARK_CAPTURE( \
20-
func, type, random_512, 512, std::string("random")); \
21-
MY_BENCHMARK_CAPTURE( \
22-
func, type, random_1k, 1024, std::string("random")); \
15+
MY_BENCHMARK_CAPTURE(func, type, random_128, 128, std::string("random")); \
16+
MY_BENCHMARK_CAPTURE(func, type, random_256, 256, std::string("random")); \
17+
MY_BENCHMARK_CAPTURE(func, type, random_512, 512, std::string("random")); \
18+
MY_BENCHMARK_CAPTURE(func, type, random_1k, 1024, std::string("random")); \
2319
MY_BENCHMARK_CAPTURE(func, type, random_5k, 5000, std::string("random")); \
2420
MY_BENCHMARK_CAPTURE( \
2521
func, type, random_100k, 100000, std::string("random")); \
@@ -37,7 +33,8 @@
3733
func, type, smallrange_512, 512, std::string("smallrange")); \
3834
MY_BENCHMARK_CAPTURE( \
3935
func, type, smallrange_1k, 1024, std::string("smallrange")); \
40-
MY_BENCHMARK_CAPTURE(func, type, smallrange_5k, 5000, std::string("smallrange")); \
36+
MY_BENCHMARK_CAPTURE( \
37+
func, type, smallrange_5k, 5000, std::string("smallrange")); \
4138
MY_BENCHMARK_CAPTURE( \
4239
func, type, smallrange_100k, 100000, std::string("smallrange")); \
4340
MY_BENCHMARK_CAPTURE( \

examples/avx2-32bit-qsort.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "avx2-32bit-qsort.hpp"
22

3-
int main() {
3+
int main()
4+
{
45
const int size = 1000;
56
float arr[size];
67
avx2_qsort(arr, size);

examples/avx512-16bit-qsort.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "avx512-16bit-qsort.hpp"
22

3-
int main() {
3+
int main()
4+
{
45
const int size = 1000;
56
short arr[size];
67
avx512_qsort(arr, size);

examples/avx512-32bit-qsort.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "avx512-32bit-qsort.hpp"
22

3-
int main() {
3+
int main()
4+
{
45
const int size = 1000;
56
float arr[size];
67
avx512_qsort(arr, size);

0 commit comments

Comments
 (0)