Skip to content

Commit 28f993e

Browse files
authored
Update clang-format include order rules (#38)
We should be including the sycl.hpp header from the sycl/ folder. Changing from CL/sycl to sycl/sycl started forcing some header file reordering, which caused pre-commit failures in the CI. So I have changed the clang-format rules to better express what we want, which has then caused other formatting changes for files that were not already compliant to my dread will. * all "headers.hpp" * <third_party/includes.h> * <sycl/sycl.hpp> * <cppstdlibheaders> Other than that, changing the matmul header caused the `cl::` namespace to disappear, so was removed. Other formatting in the tuple_utils header started becoming a bit nasty so knowing that SYCL requires C++ 17, I changed to `decltype(auto)` for some of the function return types. This is a bit more terse and functions exactly the same as the previous version.
1 parent 356abe1 commit 28f993e

File tree

14 files changed

+50
-52
lines changed

14 files changed

+50
-52
lines changed

.clang-format

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
BasedOnStyle: Google
2+
IncludeBlocks: Regroup
23
IncludeCategories:
3-
- Regex: '^<sycl/.*>$'
4-
Priority: 3
5-
SortPriority: 0
6-
CaseSensitive: false
7-
- Regex: '^<.*\.h>'
4+
- Regex: '^".*"'
85
Priority: 1
9-
SortPriority: 0
10-
CaseSensitive: false
11-
- Regex: '^<.*'
6+
- Regex: '^<sycl/'
127
Priority: 2
13-
SortPriority: 0
14-
CaseSensitive: false
15-
- Regex: '.*'
8+
SortPriority: 3
9+
- Regex: '<[[:alnum:]_/]+\.(h|hpp)>'
10+
Priority: 3
11+
SortPriority: 2
12+
- Regex: '<^[.]+>'
1613
Priority: 4
17-
SortPriority: 0
18-
CaseSensitive: false

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@
3030
*.exe
3131
*.out
3232
*.app
33+
34+
# folders
35+
*build*/

src/fluid/fluid.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020

2121
#pragma once
2222

23+
#include <sycl/sycl.hpp>
24+
2325
#include <algorithm> // std::fill
2426
#include <cmath> // std::round
2527
#include <cstdlib> // std::size_t
2628
#include <exception> // std::exception_ptr
2729
#include <iostream> // std::cout, std::endl
2830
#include <vector> // std::vector
2931

30-
#include <sycl/sycl.hpp>
31-
3232
// Kernel declarations.
3333
class fluid_boundary;
3434
class fluid_linear_solve;

src/fluid/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
**************************************************************************/
2020

21+
#include "fluid.h"
22+
2123
#include <Corrade/Containers/StringStlView.h>
2224
#include <Magnum/GL/DefaultFramebuffer.h>
2325
#include <Magnum/GL/Mesh.h>
@@ -33,8 +35,6 @@
3335

3436
#include <sycl/sycl.hpp>
3537

36-
#include "fluid.h"
37-
3838
constexpr Magnum::PixelFormat PIXELFORMAT{Magnum::PixelFormat::RGBA8Unorm};
3939

4040
// Title bar text

src/game_of_life/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
**************************************************************************/
2020

21+
#include "sim.hpp"
22+
2123
#include <Magnum/GL/DefaultFramebuffer.h>
2224
#include <Magnum/GL/Mesh.h>
2325
#include <Magnum/GL/Texture.h>
@@ -30,12 +32,10 @@
3032
#include <Magnum/Shaders/FlatGL.h>
3133
#include <Magnum/Trade/MeshData.h>
3234

33-
#include <chrono>
34-
#include <thread>
35-
3635
#include <sycl/sycl.hpp>
3736

38-
#include "sim.hpp"
37+
#include <chrono>
38+
#include <thread>
3939

4040
constexpr Magnum::PixelFormat PIXELFORMAT{Magnum::PixelFormat::RGBA8Unorm};
4141

src/game_of_life/sim.hpp

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

2121
#pragma once
2222

23-
#include <random>
23+
#include "../include/double_buf.hpp"
2424

2525
#include <sycl/sycl.hpp>
2626

27-
#include "../include/double_buf.hpp"
27+
#include <random>
2828

2929
enum class CellState : unsigned int {
3030
LIVE = 1,

src/mandelbrot/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
**************************************************************************/
2020

21+
#include "mandel.hpp"
22+
2123
#include <Magnum/GL/DefaultFramebuffer.h>
2224
#include <Magnum/GL/Mesh.h>
2325
#include <Magnum/GL/Texture.h>
@@ -32,8 +34,6 @@
3234

3335
#include <sycl/sycl.hpp>
3436

35-
#include "mandel.hpp"
36-
3737
constexpr size_t WIDTH = 800;
3838
constexpr size_t HEIGHT = 600;
3939
constexpr Magnum::PixelFormat PIXELFORMAT{Magnum::PixelFormat::RGBA8Unorm};

src/matrix_multiply_omp_compare/matrix-multiply.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424
* and differences between them.
2525
* See block_host for the OpenMP implementation. */
2626

27-
#include <CL/sycl.hpp>
27+
#include <sycl/sycl.hpp>
28+
2829
#include <chrono>
2930
#include <cmath>
3031
#include <ctime>
3132
#include <iostream>
3233

33-
using namespace cl::sycl;
34+
using namespace sycl;
3435

3536
class mxm_kernel;
3637

@@ -111,7 +112,7 @@ inline bool isPowerOfTwo(int x) { return (x & (x - 1)) == 0; }
111112
* Note that this example only works for powers of two.
112113
* */
113114
template <typename T>
114-
bool local_mxm(cl::sycl::queue& q, T* MA, T* MB, T* MC, int matSize) {
115+
bool local_mxm(sycl::queue& q, T* MA, T* MB, T* MC, int matSize) {
115116
// Make sure it is power of two before running
116117
if (!isPowerOfTwo(matSize)) {
117118
std::cout << " This example only works with power of two sizes "
@@ -121,7 +122,7 @@ bool local_mxm(cl::sycl::queue& q, T* MA, T* MB, T* MC, int matSize) {
121122

122123
auto device = q.get_device();
123124
auto maxBlockSize =
124-
device.get_info<cl::sycl::info::device::max_work_group_size>();
125+
device.get_info<sycl::info::device::max_work_group_size>();
125126
auto blockSize = prevPowerOfTwo(std::sqrt(maxBlockSize));
126127
std::cout << " The Device Max Work Group Size is : " << maxBlockSize
127128
<< std::endl;
@@ -324,14 +325,13 @@ int main(int argc, char* argv[]) {
324325
* to capture potential asynchronous errors. This function will be
325326
* called every time there is an asynchronous error on the queue (i.e.
326327
* some error occurs while the queue is executing kernels) and one of
327-
* cl::sycl::queue::throw() or cl::sycl::queue::wait_and_throw() is
328-
* called. */
328+
* sycl::queue::throw() or sycl::queue::wait_and_throw() is called. */
329329
queue q([&](exception_list eL) {
330330
try {
331331
for (auto& e : eL) {
332332
std::rethrow_exception(e);
333333
}
334-
} catch (cl::sycl::exception e) {
334+
} catch (sycl::exception e) {
335335
std::cout << " An exception has been thrown: " << e.what()
336336
<< std::endl;
337337
}

src/nbody/InteropGLBuffer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#define CUDA_GL_INTEROP_API_AVAILABLE 0
1111
#endif
1212

13+
#include <iostream>
14+
1315
/// @brief Magnum GL Buffer wrapper implementing backend-specific interop to
1416
/// work directly on OpenGL device buffers instead of using host memory.
1517
///

src/nbody/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*
1919
**************************************************************************/
2020

21+
#include "InteropGLBuffer.hpp"
22+
#include "sim.hpp"
23+
2124
#include <Corrade/PluginManager/Manager.h>
2225
#include <Corrade/Utility/Resource.h>
2326
#include <Magnum/GL/AbstractShaderProgram.h>
@@ -28,6 +31,7 @@
2831
#include <Magnum/GL/Texture.h>
2932
#include <Magnum/GL/TextureFormat.h>
3033
#include <Magnum/GL/Version.h>
34+
#include <Magnum/ImGuiIntegration/Context.hpp>
3135
#include <Magnum/ImageView.h>
3236
#include <Magnum/Magnum.h>
3337
#include <Magnum/Math/Angle.h>
@@ -40,14 +44,10 @@
4044
#include <Magnum/Trade/ImageData.h>
4145
#include <Magnum/Trade/MeshData.h>
4246

43-
#include <Magnum/ImGuiIntegration/Context.hpp>
44-
#include <chrono>
45-
#include <fstream>
46-
4747
#include <sycl/sycl.hpp>
4848

49-
#include "InteropGLBuffer.hpp"
50-
#include "sim.hpp"
49+
#include <chrono>
50+
#include <fstream>
5151

5252
using num_t = float;
5353
constexpr num_t PI{3.141592653589793238462643383279502884197169399};

0 commit comments

Comments
 (0)