Skip to content

Update clang-format include order rules #38

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

Merged
merged 3 commits into from
Jan 24, 2025
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: 8 additions & 13 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
BasedOnStyle: Google
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<sycl/.*>$'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
- Regex: '^".*"'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
- Regex: '^<sycl/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
SortPriority: 3
- Regex: '<[[:alnum:]_/]+\.(h|hpp)>'
Priority: 3
SortPriority: 2
- Regex: '<^[.]+>'
Priority: 4
SortPriority: 0
CaseSensitive: false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

# folders
*build*/
4 changes: 2 additions & 2 deletions src/fluid/fluid.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

#pragma once

#include <sycl/sycl.hpp>

#include <algorithm> // std::fill
#include <cmath> // std::round
#include <cstdlib> // std::size_t
#include <exception> // std::exception_ptr
#include <iostream> // std::cout, std::endl
#include <vector> // std::vector

#include <sycl/sycl.hpp>

// Kernel declarations.
class fluid_boundary;
class fluid_linear_solve;
Expand Down
4 changes: 2 additions & 2 deletions src/fluid/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*
**************************************************************************/

#include "fluid.h"

#include <Corrade/Containers/StringStlView.h>
#include <Magnum/GL/DefaultFramebuffer.h>
#include <Magnum/GL/Mesh.h>
Expand All @@ -33,8 +35,6 @@

#include <sycl/sycl.hpp>

#include "fluid.h"

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

// Title bar text
Expand Down
8 changes: 4 additions & 4 deletions src/game_of_life/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*
**************************************************************************/

#include "sim.hpp"

#include <Magnum/GL/DefaultFramebuffer.h>
#include <Magnum/GL/Mesh.h>
#include <Magnum/GL/Texture.h>
Expand All @@ -30,12 +32,10 @@
#include <Magnum/Shaders/FlatGL.h>
#include <Magnum/Trade/MeshData.h>

#include <chrono>
#include <thread>

#include <sycl/sycl.hpp>

#include "sim.hpp"
#include <chrono>
#include <thread>

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

Expand Down
4 changes: 2 additions & 2 deletions src/game_of_life/sim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

#pragma once

#include <random>
#include "../include/double_buf.hpp"

#include <sycl/sycl.hpp>

#include "../include/double_buf.hpp"
#include <random>

enum class CellState : unsigned int {
LIVE = 1,
Expand Down
4 changes: 2 additions & 2 deletions src/mandelbrot/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*
**************************************************************************/

#include "mandel.hpp"

#include <Magnum/GL/DefaultFramebuffer.h>
#include <Magnum/GL/Mesh.h>
#include <Magnum/GL/Texture.h>
Expand All @@ -32,8 +34,6 @@

#include <sycl/sycl.hpp>

#include "mandel.hpp"

constexpr size_t WIDTH = 800;
constexpr size_t HEIGHT = 600;
constexpr Magnum::PixelFormat PIXELFORMAT{Magnum::PixelFormat::RGBA8Unorm};
Expand Down
14 changes: 7 additions & 7 deletions src/matrix_multiply_omp_compare/matrix-multiply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
* and differences between them.
* See block_host for the OpenMP implementation. */

#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

#include <chrono>
#include <cmath>
#include <ctime>
#include <iostream>

using namespace cl::sycl;
using namespace sycl;

class mxm_kernel;

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

auto device = q.get_device();
auto maxBlockSize =
device.get_info<cl::sycl::info::device::max_work_group_size>();
device.get_info<sycl::info::device::max_work_group_size>();
auto blockSize = prevPowerOfTwo(std::sqrt(maxBlockSize));
std::cout << " The Device Max Work Group Size is : " << maxBlockSize
<< std::endl;
Expand Down Expand Up @@ -324,14 +325,13 @@ int main(int argc, char* argv[]) {
* to capture potential asynchronous errors. This function will be
* called every time there is an asynchronous error on the queue (i.e.
* some error occurs while the queue is executing kernels) and one of
* cl::sycl::queue::throw() or cl::sycl::queue::wait_and_throw() is
* called. */
* sycl::queue::throw() or sycl::queue::wait_and_throw() is called. */
queue q([&](exception_list eL) {
try {
for (auto& e : eL) {
std::rethrow_exception(e);
}
} catch (cl::sycl::exception e) {
} catch (sycl::exception e) {
std::cout << " An exception has been thrown: " << e.what()
<< std::endl;
}
Expand Down
2 changes: 2 additions & 0 deletions src/nbody/InteropGLBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#define CUDA_GL_INTEROP_API_AVAILABLE 0
#endif

#include <iostream>

/// @brief Magnum GL Buffer wrapper implementing backend-specific interop to
/// work directly on OpenGL device buffers instead of using host memory.
///
Expand Down
12 changes: 6 additions & 6 deletions src/nbody/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*
**************************************************************************/

#include "InteropGLBuffer.hpp"
#include "sim.hpp"

#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Resource.h>
#include <Magnum/GL/AbstractShaderProgram.h>
Expand All @@ -28,6 +31,7 @@
#include <Magnum/GL/Texture.h>
#include <Magnum/GL/TextureFormat.h>
#include <Magnum/GL/Version.h>
#include <Magnum/ImGuiIntegration/Context.hpp>
#include <Magnum/ImageView.h>
#include <Magnum/Magnum.h>
#include <Magnum/Math/Angle.h>
Expand All @@ -40,14 +44,10 @@
#include <Magnum/Trade/ImageData.h>
#include <Magnum/Trade/MeshData.h>

#include <Magnum/ImGuiIntegration/Context.hpp>
#include <chrono>
#include <fstream>

#include <sycl/sycl.hpp>

#include "InteropGLBuffer.hpp"
#include "sim.hpp"
#include <chrono>
#include <fstream>

using num_t = float;
constexpr num_t PI{3.141592653589793238462643383279502884197169399};
Expand Down
12 changes: 6 additions & 6 deletions src/nbody/sim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

#pragma once

#include <iostream>
#include <memory>
#include <random>

#include <sycl/sycl.hpp>

#include "../include/double_buf.hpp"
#include "integrator.hpp"
#include "sycl_bufs.hpp"
#include "tuple_utils.hpp"

#include <sycl/sycl.hpp>

#include <iostream>
#include <memory>
#include <random>

// Convenience types
template <typename num_t>
using vec3 = sycl::vec<num_t, 3>;
Expand Down
4 changes: 2 additions & 2 deletions src/nbody/sycl_bufs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

#pragma once

#include <type_traits>
#include "tuple_utils.hpp"

#include <sycl/sycl.hpp>

#include "tuple_utils.hpp"
#include <type_traits>

// Template function object which transforms buffers to device read accessors
struct BufToReadAccFunc {
Expand Down
7 changes: 2 additions & 5 deletions src/nbody/tuple_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ auto squash_tuple(Tuple&& tpl)
namespace {
template <typename TupleA, typename TupleB, size_t... Ids>
auto add_tuples_help(TupleA&& a, TupleB&& b, index_sequence<Ids...>)
-> decltype(std::make_tuple(std::get<Ids>(std::forward<TupleA>(a)) +
std::get<Ids>(std::forward<TupleB>(b))...)) {
-> decltype(auto) {
return std::make_tuple(std::get<Ids>(std::forward<TupleA>(a)) +
std::get<Ids>(std::forward<TupleB>(b))...);
}
Expand All @@ -143,9 +142,7 @@ template <
size_t SizeA = std::tuple_size<typename std::decay<TupleA>::type>::value,
size_t SizeB = std::tuple_size<typename std::decay<TupleB>::type>::value,
typename Ids = make_index_sequence<SizeA>>
auto add_tuples(TupleA&& a, TupleB&& b)
-> decltype(add_tuples_help(std::forward<TupleA>(a),
std::forward<TupleB>(b), Ids{})) {
auto add_tuples(TupleA&& a, TupleB&& b) -> decltype(auto) {
static_assert(SizeA == SizeB, "Cannot add tuples of differing sizes.");
return add_tuples_help(std::forward<TupleA>(a), std::forward<TupleB>(b),
Ids{});
Expand Down
3 changes: 2 additions & 1 deletion src/scan_parallel_inclusive/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*
**************************************************************************/

#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

#include <algorithm>
#include <iostream>
#include <numeric>
Expand Down
Loading