Skip to content

Commit 1c43ddb

Browse files
author
Colin Davidson
committed
[CI][CLANG-FORMAT] Switch to clang-20-format
This keeps it in line with upstream dpc++
1 parent d729283 commit 1c43ddb

161 files changed

Lines changed: 5086 additions & 7754 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/run_ock_internal_tests.yml

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

173173
- name: setup-ubuntu-clang-format
174174
run:
175-
pip install clang-format==19.1.0
175+
pip install clang-format==20.1.0
176176

177177
- name: run clang-format
178178
run: |
179-
# we've installed clang-format-19 in the docker via pip, which just installs it as clang-format,
179+
# we've installed clang-format-20 in the docker via pip, which just installs it as clang-format,
180180
# so just use clang-format-diff and -b clang-format directly
181181
git fetch origin ${{ github.base_ref }}
182182
git diff --no-color origin/${{ github.base_ref }} | \

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,12 @@ find_package(PythonInterp 3.6 REQUIRED)
197197
# which perform static analysis and style checking on source files.
198198
# When updating the version here, also update that used in the merge request
199199
# config
200-
find_package(ClangTools 19 COMPONENTS clang-format clang-tidy)
200+
find_package(ClangTools 19 COMPONENTS clang-tidy)
201+
if(TARGET ClangTools::clang-tidy)
202+
ca_option(CA_CLANG_TIDY_FLAGS STRING
203+
"Semi-color separated list of clang-tidy flags" "")
204+
endif()
205+
find_package(ClangTools 20 COMPONENTS clang-format)
201206
if(TARGET ClangTools::clang-tidy)
202207
ca_option(CA_CLANG_TIDY_FLAGS STRING
203208
"Semi-color separated list of clang-tidy flags" "")

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ To install the dependencies on Ubuntu, open the terminal and run:
4545

4646
### Recommended packages
4747
* [Ninja](https://ninja-build.org/)
48-
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html) 16
48+
* [clang-format](https://clang.llvm.org/docs/ClangFormat.html) 20
4949
* [lit](https://llvm.org/docs/CommandGuide/lit.html)
5050

5151
To install the recommended packages, run:
5252
```sh
5353
$ sudo apt install -y ninja-build doxygen python3-pip
54-
$ sudo pip3 install lit virtualenv cmakelint clang-format==19.1.0
54+
$ sudo pip3 install lit virtualenv cmakelint clang-format==20.1.0
5555
```
5656

5757
### Compiling oneAPI Construction Kit
Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +0,0 @@
1-
// Copyright (C) Codeplay Software Limited
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4-
// Exceptions; you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// https://github.com/uxlfoundation/oneapi-construction-kit/blob/main/LICENSE.txt
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
14-
//
15-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16-
17-
#include "device_barrier_print.h"
18-
19-
// In this example, the kernel has two computation steps represented by printf
20-
// calls. A barrier is used to ensure step A has been performed by all
21-
// work-items in the work-group before any work-item in the group starts step B.
22-
//
23-
// With a work-group size of four, the output of this example will look like:
24-
//
25-
// Kernel part A (tid = 0)
26-
// Kernel part A (tid = 1)
27-
// Kernel part A (tid = 2)
28-
// Kernel part A (tid = 3)
29-
// Kernel part B (tid = 0)
30-
// Kernel part B (tid = 1)
31-
// Kernel part B (tid = 2)
32-
// Kernel part B (tid = 3)
33-
//
34-
// Without a barrier between the two steps, the output would look like:
35-
//
36-
// Kernel part A (tid = 0)
37-
// Kernel part B (tid = 0)
38-
// Kernel part A (tid = 1)
39-
// Kernel part B (tid = 1)
40-
// Kernel part A (tid = 2)
41-
// Kernel part B (tid = 2)
42-
// Kernel part A (tid = 3)
43-
// Kernel part B (tid = 3)
44-
45-
__kernel void barrier_print(exec_state_t *ctx) {
46-
uint tid = get_global_id(0, ctx);
47-
print(ctx, "Kernel part A (tid = %d)\n", tid);
48-
barrier(ctx);
49-
print(ctx, "Kernel part B (tid = %d)\n", tid);
50-
}
Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +0,0 @@
1-
// Copyright (C) Codeplay Software Limited
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4-
// Exceptions; you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// https://github.com/uxlfoundation/oneapi-construction-kit/blob/main/LICENSE.txt
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
14-
//
15-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16-
17-
#include "device_barrier_sum.h"
18-
19-
// In this example, each work-item in the kernel computes the sum of a few
20-
// values. These values are the same for all items in the work-group. In order
21-
// to reduce the number of memory operations, a small local array is used to
22-
// share these values between the items in the group. Each item only needs to
23-
// load one item from the source buffer, however a barrier is needed to ensure
24-
// all values have been copied before computing the sum.
25-
26-
__kernel void barrier_sum(__global uint *src, __global uint *dst,
27-
__local uint *src_tile, exec_state_t *ctx) {
28-
uint tid = get_global_id(0, ctx);
29-
30-
// Copy values from the source buffer to a local tile.
31-
uint lid = get_local_id(0, ctx);
32-
src_tile[lid] = src[tid];
33-
34-
// Wait for all items in the group to have finished copying values.
35-
barrier(ctx);
36-
37-
// Sum values from the tile and write the result to the output buffer.
38-
uint sum = 0;
39-
for (uint i = 0; i < get_local_size(0, ctx); i++) {
40-
sum += src_tile[i];
41-
}
42-
dst[tid] = sum;
43-
}
Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +0,0 @@
1-
// Copyright (C) Codeplay Software Limited
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4-
// Exceptions; you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// https://github.com/uxlfoundation/oneapi-construction-kit/blob/main/LICENSE.txt
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
14-
//
15-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16-
17-
#include "device_blur.h"
18-
19-
__kernel void copy_and_pad_hor(__global uint *src, __global uint *dst,
20-
exec_state_t *item) {
21-
// Figure out array slice to copy
22-
uint tid = get_global_id(0, item);
23-
uint src_idx = WIDTH * tid;
24-
uint src_idx_end = src_idx + WIDTH;
25-
uint dst_idx = EXTENDED_WIDTH * (tid + 1);
26-
27-
// Duplicate the first element
28-
dst[dst_idx++] = src[src_idx];
29-
30-
// Copy over the middle
31-
while (src_idx < src_idx_end) {
32-
dst[dst_idx++] = src[src_idx++];
33-
}
34-
35-
// Duplicate the last element
36-
dst[dst_idx] = src[src_idx - 1];
37-
}
38-
39-
__kernel void pad_vert(__global uint *dst, exec_state_t *item) {
40-
uint tid = get_global_id(0, item);
41-
uint gap = HEIGHT * EXTENDED_WIDTH;
42-
43-
// Duplicate the topmost and the bottommost pixel.
44-
dst[tid] = dst[tid + EXTENDED_WIDTH];
45-
dst[tid + gap + EXTENDED_WIDTH] = dst[tid + gap];
46-
}
47-
48-
__kernel void blur(__global uint *src, __global uint *dst, exec_state_t *item) {
49-
uint x = get_global_id(0, item);
50-
uint y = get_global_id(1, item);
51-
52-
// Calculate row starting indices.
53-
uint base0 = EXTENDED_WIDTH * y + x;
54-
uint base1 = EXTENDED_WIDTH + base0;
55-
uint base2 = EXTENDED_WIDTH + base1;
56-
57-
// Add together 9 pixels around destination.
58-
uint total = src[base0] + src[base0 + 1] + src[base0 + 2] + src[base1] +
59-
src[base1 + 1] + src[base1 + 2] + src[base2] + src[base2 + 1] +
60-
src[base2 + 2];
61-
62-
// Store the mean of the 9 pixeld into the destination buffer.
63-
dst[WIDTH * y + x] = total / 9;
64-
}
Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +0,0 @@
1-
// Copyright (C) Codeplay Software Limited
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4-
// Exceptions; you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// https://github.com/uxlfoundation/oneapi-construction-kit/blob/main/LICENSE.txt
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
14-
//
15-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16-
17-
#include "device_concatenate_dma.h"
18-
19-
// Carry out the computation for one work-item.
20-
__kernel void concatenate_dma(__global uint *src1, __global uint *src2,
21-
__global uint *dst, uint block_size,
22-
exec_state_t *ctx) {
23-
uint tid = get_global_id(0, ctx);
24-
uint offset = tid * block_size;
25-
uint size = get_global_size(0, ctx) * block_size;
26-
27-
// Enqueue a DMA operation from the first input buffer to the first half of
28-
// the output buffer.
29-
uintptr_t xfer1 =
30-
start_dma(&dst[offset], &src1[offset], block_size * sizeof(uint), ctx);
31-
32-
// Enqueue a DMA operation from the second input buffer to the second half of
33-
// the output buffer, without waiting for the first DMA operation to finish.
34-
uintptr_t xfer2 = start_dma(&dst[size + offset], &src2[offset],
35-
block_size * sizeof(uint), ctx);
36-
37-
// Wait for both DMA operations to finish. Waiting for a DMA operation only
38-
// returns when that operation as well as all other operations enqueued before
39-
// it are completed.
40-
wait_dma(xfer2, ctx);
41-
}
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +0,0 @@
1-
// Copyright (C) Codeplay Software Limited
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4-
// Exceptions; you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// https://github.com/uxlfoundation/oneapi-construction-kit/blob/main/LICENSE.txt
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
14-
//
15-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16-
17-
#include "device_hello.h"
18-
19-
__kernel void hello_async(exec_state_t *ctx) {
20-
print(ctx, "Hello from clik_async! tid=%d, lid=%d, gid=%d\n",
21-
get_global_id(0, ctx), get_local_id(0, ctx), get_group_id(0, ctx));
22-
}
Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +0,0 @@
1-
// Copyright (C) Codeplay Software Limited
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4-
// Exceptions; you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// https://github.com/uxlfoundation/oneapi-construction-kit/blob/main/LICENSE.txt
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
14-
//
15-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16-
17-
#include "device_matrix_multiply.h"
18-
19-
__kernel void matrix_multiply(__global float *a, __global float *b,
20-
__global float *c, uint m, exec_state_t *item) {
21-
uint col = get_global_id(0, item);
22-
uint row = get_global_id(1, item);
23-
float sum = 0.0f;
24-
for (int i = 0; i < m; i++) {
25-
sum += a[(row * m) + i] * b[(i * m) + col];
26-
}
27-
c[(row * m) + col] = sum;
28-
}
Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +0,0 @@
1-
// Copyright (C) Codeplay Software Limited
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM
4-
// Exceptions; you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// https://github.com/uxlfoundation/oneapi-construction-kit/blob/main/LICENSE.txt
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
// License for the specific language governing permissions and limitations
13-
// under the License.
14-
//
15-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
16-
17-
#include "device_matrix_multiply_tiled.h"
18-
19-
__kernel void matrix_multiply(__global float *a, __global float *b,
20-
__global float *c, uint m, exec_state_t *ctx) {
21-
uint col = get_global_id(0, ctx);
22-
uint row = get_global_id(1, ctx);
23-
uint lx = get_local_id(0, ctx);
24-
uint ly = get_local_id(1, ctx);
25-
26-
__local_variable float tile_a[TS * TS];
27-
__local_variable float tile_b[TS * TS];
28-
float sum = 0.0f;
29-
for (int i = 0; i < m; i += TS) {
30-
// Load one tile from A and B into local memory.
31-
tile_a[(ly * TS) + lx] = a[(row * m) + i + lx];
32-
tile_b[(ly * TS) + lx] = b[((i + ly) * m) + col];
33-
barrier(ctx);
34-
35-
// Compute the partial sum for the loaded tile.
36-
for (int j = 0; j < TS; j++) {
37-
sum += tile_a[(ly * TS) + j] * tile_b[(j * TS) + lx];
38-
}
39-
40-
// Wait for all items to be finished before computing the next tile.
41-
barrier(ctx);
42-
}
43-
c[(row * m) + col] = sum;
44-
}

0 commit comments

Comments
 (0)