diff --git a/.clang-format b/.clang-format index aa68020..e7d2354 100644 --- a/.clang-format +++ b/.clang-format @@ -1,18 +1,13 @@ BasedOnStyle: Google +IncludeBlocks: Regroup IncludeCategories: - - Regex: '^$' - Priority: 3 - SortPriority: 0 - CaseSensitive: false - - Regex: '^<.*\.h>' + - Regex: '^".*"' Priority: 1 - SortPriority: 0 - CaseSensitive: false - - Regex: '^<.*' + - Regex: '^' + Priority: 3 + SortPriority: 2 + - Regex: '<^[.]+>' Priority: 4 - SortPriority: 0 - CaseSensitive: false diff --git a/.gitignore b/.gitignore index 259148f..d634910 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,6 @@ *.exe *.out *.app + +# folders +*build*/ diff --git a/src/fluid/fluid.h b/src/fluid/fluid.h index d6458d4..8195ea5 100644 --- a/src/fluid/fluid.h +++ b/src/fluid/fluid.h @@ -20,6 +20,8 @@ #pragma once +#include + #include // std::fill #include // std::round #include // std::size_t @@ -27,8 +29,6 @@ #include // std::cout, std::endl #include // std::vector -#include - // Kernel declarations. class fluid_boundary; class fluid_linear_solve; diff --git a/src/fluid/main.cpp b/src/fluid/main.cpp index 43fdc90..fdccf30 100644 --- a/src/fluid/main.cpp +++ b/src/fluid/main.cpp @@ -18,6 +18,8 @@ * **************************************************************************/ +#include "fluid.h" + #include #include #include @@ -33,8 +35,6 @@ #include -#include "fluid.h" - constexpr Magnum::PixelFormat PIXELFORMAT{Magnum::PixelFormat::RGBA8Unorm}; // Title bar text diff --git a/src/game_of_life/main.cpp b/src/game_of_life/main.cpp index 1764bb8..d2393f7 100644 --- a/src/game_of_life/main.cpp +++ b/src/game_of_life/main.cpp @@ -18,6 +18,8 @@ * **************************************************************************/ +#include "sim.hpp" + #include #include #include @@ -30,12 +32,10 @@ #include #include -#include -#include - #include -#include "sim.hpp" +#include +#include constexpr Magnum::PixelFormat PIXELFORMAT{Magnum::PixelFormat::RGBA8Unorm}; diff --git a/src/game_of_life/sim.hpp b/src/game_of_life/sim.hpp index 7f27c2e..862d309 100644 --- a/src/game_of_life/sim.hpp +++ b/src/game_of_life/sim.hpp @@ -20,11 +20,11 @@ #pragma once -#include +#include "../include/double_buf.hpp" #include -#include "../include/double_buf.hpp" +#include enum class CellState : unsigned int { LIVE = 1, diff --git a/src/mandelbrot/main.cpp b/src/mandelbrot/main.cpp index 0f3ecb8..9531df6 100644 --- a/src/mandelbrot/main.cpp +++ b/src/mandelbrot/main.cpp @@ -18,6 +18,8 @@ * **************************************************************************/ +#include "mandel.hpp" + #include #include #include @@ -32,8 +34,6 @@ #include -#include "mandel.hpp" - constexpr size_t WIDTH = 800; constexpr size_t HEIGHT = 600; constexpr Magnum::PixelFormat PIXELFORMAT{Magnum::PixelFormat::RGBA8Unorm}; diff --git a/src/matrix_multiply_omp_compare/matrix-multiply.cpp b/src/matrix_multiply_omp_compare/matrix-multiply.cpp index e7e73a8..2c04e11 100644 --- a/src/matrix_multiply_omp_compare/matrix-multiply.cpp +++ b/src/matrix_multiply_omp_compare/matrix-multiply.cpp @@ -24,13 +24,14 @@ * and differences between them. * See block_host for the OpenMP implementation. */ -#include +#include + #include #include #include #include -using namespace cl::sycl; +using namespace sycl; class mxm_kernel; @@ -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 -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 " @@ -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(); + device.get_info(); auto blockSize = prevPowerOfTwo(std::sqrt(maxBlockSize)); std::cout << " The Device Max Work Group Size is : " << maxBlockSize << std::endl; @@ -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; } diff --git a/src/nbody/InteropGLBuffer.hpp b/src/nbody/InteropGLBuffer.hpp index 28db459..33bc60f 100644 --- a/src/nbody/InteropGLBuffer.hpp +++ b/src/nbody/InteropGLBuffer.hpp @@ -10,6 +10,8 @@ #define CUDA_GL_INTEROP_API_AVAILABLE 0 #endif +#include + /// @brief Magnum GL Buffer wrapper implementing backend-specific interop to /// work directly on OpenGL device buffers instead of using host memory. /// diff --git a/src/nbody/main.cpp b/src/nbody/main.cpp index e0622f7..f87a4b9 100644 --- a/src/nbody/main.cpp +++ b/src/nbody/main.cpp @@ -18,6 +18,9 @@ * **************************************************************************/ +#include "InteropGLBuffer.hpp" +#include "sim.hpp" + #include #include #include @@ -28,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -40,14 +44,10 @@ #include #include -#include -#include -#include - #include -#include "InteropGLBuffer.hpp" -#include "sim.hpp" +#include +#include using num_t = float; constexpr num_t PI{3.141592653589793238462643383279502884197169399}; diff --git a/src/nbody/sim.hpp b/src/nbody/sim.hpp index 5df3b79..61758f7 100644 --- a/src/nbody/sim.hpp +++ b/src/nbody/sim.hpp @@ -20,17 +20,17 @@ #pragma once -#include -#include -#include - -#include - #include "../include/double_buf.hpp" #include "integrator.hpp" #include "sycl_bufs.hpp" #include "tuple_utils.hpp" +#include + +#include +#include +#include + // Convenience types template using vec3 = sycl::vec; diff --git a/src/nbody/sycl_bufs.hpp b/src/nbody/sycl_bufs.hpp index 0b2207d..9dab42c 100644 --- a/src/nbody/sycl_bufs.hpp +++ b/src/nbody/sycl_bufs.hpp @@ -20,11 +20,11 @@ #pragma once -#include +#include "tuple_utils.hpp" #include -#include "tuple_utils.hpp" +#include // Template function object which transforms buffers to device read accessors struct BufToReadAccFunc { diff --git a/src/nbody/tuple_utils.hpp b/src/nbody/tuple_utils.hpp index 2128b54..2603fcc 100644 --- a/src/nbody/tuple_utils.hpp +++ b/src/nbody/tuple_utils.hpp @@ -131,8 +131,7 @@ auto squash_tuple(Tuple&& tpl) namespace { template auto add_tuples_help(TupleA&& a, TupleB&& b, index_sequence) - -> decltype(std::make_tuple(std::get(std::forward(a)) + - std::get(std::forward(b))...)) { + -> decltype(auto) { return std::make_tuple(std::get(std::forward(a)) + std::get(std::forward(b))...); } @@ -143,9 +142,7 @@ template < size_t SizeA = std::tuple_size::type>::value, size_t SizeB = std::tuple_size::type>::value, typename Ids = make_index_sequence> -auto add_tuples(TupleA&& a, TupleB&& b) - -> decltype(add_tuples_help(std::forward(a), - std::forward(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(a), std::forward(b), Ids{}); diff --git a/src/scan_parallel_inclusive/scan.cpp b/src/scan_parallel_inclusive/scan.cpp index b099b3d..6a9f7b9 100644 --- a/src/scan_parallel_inclusive/scan.cpp +++ b/src/scan_parallel_inclusive/scan.cpp @@ -18,7 +18,8 @@ * **************************************************************************/ -#include +#include + #include #include #include