Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Update formatting to clang-format-6 (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
DuncanMcBain committed Jan 23, 2019
1 parent 163fdf3 commit af9c5ec
Show file tree
Hide file tree
Showing 29 changed files with 881 additions and 849 deletions.
44 changes: 41 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
Expand All @@ -20,26 +20,62 @@ AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakBeforeInheritanceComma: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
Expand All @@ -49,7 +85,9 @@ PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
Expand Down
1 change: 0 additions & 1 deletion demos/game_of_life/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ namespace sycl = cl::sycl;

#include "sim.hpp"


class GameOfLifeApp
#ifdef CODEPLAY_DRAW_LOGO
: public CodeplayDemoApp
Expand Down
5 changes: 3 additions & 2 deletions demos/game_of_life/sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "sim.hpp"


// This is needed to have a translation unit containing the SYCL kernel
void GameOfLifeSim::step() { this->internal_step(); }
void GameOfLifeSim::step() {
this->internal_step();
}
15 changes: 6 additions & 9 deletions demos/game_of_life/sim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace sycl = cl::sycl;

#include <double_buf.hpp>


enum class CellState : cl::sycl::cl_uint {
LIVE = 1,
DEAD = 0,
Expand Down Expand Up @@ -85,10 +84,10 @@ class GameOfLifeSim {
}
}) {
// Initialize game grid to empty
auto acells = m_game.read()
.cells.get_access<sycl::access::mode::discard_write>();
auto aimg = m_game.read()
.img.get_access<sycl::access::mode::discard_write>();
auto acells =
m_game.read().cells.get_access<sycl::access::mode::discard_write>();
auto aimg =
m_game.read().img.get_access<sycl::access::mode::discard_write>();
for (size_t y = 0; y < m_height; y++) {
for (size_t x = 0; x < m_width; x++) {
acells[sycl::id<2>(x, y)] = CellState::DEAD;
Expand All @@ -108,8 +107,7 @@ class GameOfLifeSim {
/// Calls the provided function with image data
template <typename Func>
void with_img(Func&& func) {
auto acc = m_game.read()
.img.get_access<sycl::access::mode::read>();
auto acc = m_game.read().img.get_access<sycl::access::mode::read>();
func(acc.get_pointer());
}

Expand All @@ -124,8 +122,7 @@ class GameOfLifeSim {
// Have to write into read-buffer rather than write-buffer, since it is
// the read-buffer
// that will be read by the kernel.
auto acc = this->m_game.read()
.cells.get_access<mode::write>();
auto acc = this->m_game.read().cells.get_access<mode::write>();

while (!m_clicks.empty()) {
auto press = m_clicks.back();
Expand Down
1 change: 0 additions & 1 deletion demos/include/codeplay_demo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <cinder/app/RendererGl.h>
#include <cinder/gl/gl.h>


// Adds logo drawing functionality.
class CodeplayDemoApp : public ci::app::App {
protected:
Expand Down
1 change: 0 additions & 1 deletion demos/include/double_buf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include <utility>


// Double-buffers any kind of value.
template <typename T>
class DoubleBuf {
Expand Down
3 changes: 1 addition & 2 deletions demos/include/integrator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "tuple_utils.hpp"


/* Given a function `func` expressing a derivative of order N, a time step size
* `step`,
* and N+1 values `vals` with the initial conditions of y(N-1), .., y1, y, t, in
Expand Down Expand Up @@ -99,7 +98,7 @@ std::tuple<Args...> integrate_step_rk4(func_t func, time_t step, Args... vals) {
template <typename time_t, typename func_t, typename... Args>
std::tuple<Args...> integrate_step_euler(func_t func, time_t step, Args... vals
// TODO kmem ptr for temporary storage
) {
) {
static_assert(sizeof...(Args) >= 2,
"Do you want infinite loops in your compiler? Because this is "
"how you get infinite loops in your compiler.");
Expand Down
10 changes: 5 additions & 5 deletions demos/include/sycl_bufs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include "tuple_utils.hpp"


// Template function object which transforms buffers to device read accessors
struct BufToReadAccFunc {
template <typename In>
Expand All @@ -51,16 +50,17 @@ struct BufToDcdWriteAccFunc {
template <typename In>
AUTO_FUNC(operator()(In&& in),
std::forward<In>(in)
.first.template get_access<cl::sycl::access::mode::discard_write>(
.first
.template get_access<cl::sycl::access::mode::discard_write>(
*std::forward<In>(in).second))
};

// Template function object which transforms buffers to host read accessors
struct BufToHostReadAccFunc {
template <typename In>
auto operator()(In&& in) -> decltype(
std::forward<In>(in)
.template get_access<cl::sycl::access::mode::read>()) {
auto operator()(In&& in)
-> decltype(std::forward<In>(in)
.template get_access<cl::sycl::access::mode::read>()) {
return std::forward<In>(in)
.template get_access<cl::sycl::access::mode::read>();
}
Expand Down
9 changes: 4 additions & 5 deletions demos/include/tuple_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include <tuple>


/* Given a function name and a one-line body, defines an auto-return-type
* function with these parameters. */
#define AUTO_FUNC(signature, body) \
Expand All @@ -54,7 +53,7 @@ using Concat = typename concat<S1, S2>::type;

template <size_t N>
struct gen_seq;
}
} // namespace

template <size_t N>
using make_index_sequence = typename gen_seq<N>::type;
Expand All @@ -68,7 +67,7 @@ template <>
struct gen_seq<0> : index_sequence<> {};
template <>
struct gen_seq<1> : index_sequence<0> {};
}
} // namespace

template <typename... Ts>
using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
Expand All @@ -86,7 +85,7 @@ void setvar_helper(tuple_t const& tpl, Arg& arg, Args&... args) {
arg = std::get<K>(tpl);
setvar_helper<K + 1>(tpl, args...);
}
}
} // namespace

template <typename tuple_t, typename... Args>
void setvar(tuple_t const& tpl, Args&... args) {
Expand Down Expand Up @@ -143,7 +142,7 @@ auto add_tuples_help(TupleA&& a, TupleB&& b, index_sequence<Ids...>)
return std::make_tuple(std::get<Ids>(std::forward<TupleA>(a)) +
std::get<Ids>(std::forward<TupleB>(b))...);
}
}
} // namespace

template <
typename TupleA, typename TupleB,
Expand Down
1 change: 0 additions & 1 deletion demos/mandelbrot/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ namespace sycl = cl::sycl;

#include "mandel.hpp"


constexpr size_t WIDTH = 800;
constexpr size_t HEIGHT = 600;

Expand Down
1 change: 0 additions & 1 deletion demos/mandelbrot/mandel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#include "mandel.hpp"


template <>
void MandelbrotCalculator<float>::calc() {
this->internal_calc();
Expand Down
7 changes: 2 additions & 5 deletions demos/mandelbrot/mandel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <CL/sycl.hpp>
namespace sycl = cl::sycl;


/* Computes an image representing the Mandelbrot set on the complex
* plane at a given zoom level. */
template <typename num_t>
Expand Down Expand Up @@ -177,12 +176,10 @@ class MandelbrotCalculator {

// Linearly interpolate between the colors using the fractional part
// of 'mandelness' to get smooth transitions
auto col =
col_a * (num_t(1) - fract) +
col_b * fract;
auto col = col_a * (num_t(1) - fract) + col_b * fract;

// Store color in image
img_acc[item] = { col.x(), col.y(), col.z(), col.w() };
img_acc[item] = {col.x(), col.y(), col.z(), col.w()};
});
});
}
Expand Down
Loading

0 comments on commit af9c5ec

Please sign in to comment.