Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 2, 2023
1 parent 4990f5e commit 76136a1
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 112 deletions.
4 changes: 2 additions & 2 deletions misc/baselines/bandwidth.cu
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ __global__ void fd(float *a, float *b, int *c, int n) {
// i = (i * 1e-10f);
// i = i * i * i * i * i % m;
// b_s[i % m] = 1;
//#define C(x) i += (i >> x);
//#define C(x) i += (i >> x);
// #define C(x) i += (i >> x);
// #define C(x) i += (i >> x);
// for (int t = 0; t < 240; t++)
// C(30);
i += int(sin(i * 1e-20f));
Expand Down
4 changes: 1 addition & 3 deletions taichi/analysis/gen_offline_cache_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,7 @@ class ASTSerializer : public IRVisitor, public ExpressionVisitor {
}

#define DEFINE_EMIT_ENUM(EnumType) \
void emit(EnumType type) { \
emit_pod(type); \
}
void emit(EnumType type) { emit_pod(type); }

DEFINE_EMIT_ENUM(ExprOpCode);
DEFINE_EMIT_ENUM(StmtOpCode);
Expand Down
10 changes: 3 additions & 7 deletions taichi/common/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,8 @@ class InterfaceHolder {
} \
} ImplementationInjector_##base_class_name##class_name##instance;

#define TI_NAME(alias) \
virtual std::string get_name() const override { \
return get_name_static(); \
} \
static std::string get_name_static() { \
return alias; \
}
#define TI_NAME(alias) \
virtual std::string get_name() const override { return get_name_static(); } \
static std::string get_name_static() { return alias; }

} // namespace taichi
2 changes: 1 addition & 1 deletion taichi/common/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// JSON serialization/deserialization.
// @PENGUINLIONG
#include <sstream>
//#include "gft/log.hpp"
// #include "gft/log.hpp"
#include "taichi/common/json.h"

namespace liong {
Expand Down
6 changes: 2 additions & 4 deletions taichi/ir/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ class ExpressionVisitor {
bool invoke_default_visitor_{false};
};

#define TI_DEFINE_ACCEPT_FOR_EXPRESSION \
void accept(ExpressionVisitor *visitor) override { \
visitor->visit(this); \
}
#define TI_DEFINE_ACCEPT_FOR_EXPRESSION \
void accept(ExpressionVisitor *visitor) override { visitor->visit(this); }

} // namespace taichi::lang
12 changes: 3 additions & 9 deletions taichi/ir/expression_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,19 @@
Expr expr_##opname(const Expr &expr) { \
return Expr::make<UnaryOpExpression>(UnaryOpType::opname, expr); \
} \
Expr operator op(const Expr &expr) { \
return expr_##opname(expr); \
}
Expr operator op(const Expr &expr) { return expr_##opname(expr); }

#define DEFINE_EXPRESSION_FUNC_UNARY(opname) \
Expr opname(const Expr &expr) { \
return Expr::make<UnaryOpExpression>(UnaryOpType::opname, expr); \
} \
Expr expr_##opname(const Expr &expr) { \
return opname(expr); \
}
Expr expr_##opname(const Expr &expr) { return opname(expr); }

#define DEFINE_EXPRESSION_OP_BINARY(op, opname) \
Expr operator op(const Expr &lhs, const Expr &rhs) { \
return Expr::make<BinaryOpExpression>(BinaryOpType::opname, lhs, rhs); \
} \
Expr expr_##opname(const Expr &lhs, const Expr &rhs) { \
return lhs op rhs; \
}
Expr expr_##opname(const Expr &lhs, const Expr &rhs) { return lhs op rhs; }

#define DEFINE_EXPRESSION_FUNC_BINARY(opname) \
Expr opname(const Expr &lhs, const Expr &rhs) { \
Expand Down
6 changes: 2 additions & 4 deletions taichi/ir/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ class StatementTypeNameVisitor : public IRVisitor {
StatementTypeNameVisitor() {
}

#define PER_STATEMENT(x) \
void visit(x *stmt) override { \
type_name = #x; \
}
#define PER_STATEMENT(x) \
void visit(x *stmt) override { type_name = #x; }
#include "taichi/inc/statements.inc.h"

#undef PER_STATEMENT
Expand Down
6 changes: 2 additions & 4 deletions taichi/ir/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,8 @@ class IRNode {
std::unique_ptr<IRNode> clone();
};

#define TI_DEFINE_ACCEPT \
void accept(IRVisitor *visitor) override { \
visitor->visit(this); \
}
#define TI_DEFINE_ACCEPT \
void accept(IRVisitor *visitor) override { visitor->visit(this); }

#define TI_DEFINE_CLONE \
std::unique_ptr<Stmt> clone() const override { \
Expand Down
44 changes: 22 additions & 22 deletions taichi/math/sifakis_svd.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ branching and elementary floating point operations
A. McAdams, A. Selle, R. Tamstorf, J. Teran and E. Sifakis
*/

//#####################################################################
// Copyright (c) 2010-2011, Eftychios Sifakis.
// #####################################################################
// Copyright (c) 2010-2011, Eftychios Sifakis.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or
// other materials provided with the distribution.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or
// other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//#####################################################################
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// #####################################################################

TI_FORCE_INLINE float rsqrt(const float f) {
return 1.0f / std::sqrt(f);
Expand Down
12 changes: 4 additions & 8 deletions taichi/program/field_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
#include "taichi/rhi/device.h"
#include "taichi/program/program.h"

#define DEFINE_PROPERTY(Type, name) \
Type name; \
void set_##name(const Type &new_name) { \
name = new_name; \
} \
Type get_##name() { \
return name; \
}
#define DEFINE_PROPERTY(Type, name) \
Type name; \
void set_##name(const Type &new_name) { name = new_name; } \
Type get_##name() { return name; }

namespace taichi {

Expand Down
4 changes: 1 addition & 3 deletions taichi/rhi/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ constexpr size_t kBufferSizeEntireSize = size_t(-1);
inline name operator&(name a, name b) { \
return static_cast<name>(int(a) & int(b)); \
} \
inline bool operator&&(name a, name b) { \
return (int(a) & int(b)) != 0; \
}
inline bool operator&&(name a, name b) { return (int(a) & int(b)) != 0; }

enum class BlendOp : uint32_t { add, subtract, reverse_subtract, min, max };

Expand Down
2 changes: 1 addition & 1 deletion taichi/rhi/dx/dx_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ constexpr bool kD3d11DebugEnabled = false;
// force software rendering.
constexpr bool kD3d11ForceRef = false;
// Enable to spawn a debug window and swapchain
//#define TAICHI_DX11_DEBUG_WINDOW
// #define TAICHI_DX11_DEBUG_WINDOW

void check_dx_error(HRESULT hr, const char *msg);

Expand Down
18 changes: 6 additions & 12 deletions taichi/runtime/llvm/runtime_module/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,14 @@ DEFINE_ATOMIC_OP_INTRINSIC(xor, i64)
DEFINE_ATOMIC_OP_INTRINSIC(xor, u32)
DEFINE_ATOMIC_OP_INTRINSIC(xor, u64)

#define DEFINE_ADD(T) \
T add_##T(T a, T b) { \
return a + b; \
}
#define DEFINE_ADD(T) \
T add_##T(T a, T b) { return a + b; }

#define DEFINE_MIN(T) \
T min_##T(T a, T b) { \
return b > a ? a : b; \
}
#define DEFINE_MIN(T) \
T min_##T(T a, T b) { return b > a ? a : b; }

#define DEFINE_MAX(T) \
T max_##T(T a, T b) { \
return b < a ? a : b; \
}
#define DEFINE_MAX(T) \
T max_##T(T a, T b) { return b < a ? a : b; }

#define DEFINE_ATOMIC_OP_COMP_EXCH(OP, T) \
T atomic_##OP##_##T(volatile T *dest, T inc) { \
Expand Down
24 changes: 7 additions & 17 deletions taichi/runtime/llvm/runtime_module/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,10 @@ __asm__(".symver expf,expf@GLIBC_2.2.5");
#endif

// For accessing struct fields
#define STRUCT_FIELD(S, F) \
extern "C" decltype(S::F) S##_get_##F(S *s) { \
return s->F; \
} \
extern "C" decltype(S::F) *S##_get_ptr_##F(S *s) { \
return &(s->F); \
} \
extern "C" void S##_set_##F(S *s, decltype(S::F) f) { \
s->F = f; \
}
#define STRUCT_FIELD(S, F) \
extern "C" decltype(S::F) S##_get_##F(S *s) { return s->F; } \
extern "C" decltype(S::F) *S##_get_ptr_##F(S *s) { return &(s->F); } \
extern "C" void S##_set_##F(S *s, decltype(S::F) f) { s->F = f; }

#define STRUCT_FIELD_ARRAY(S, F) \
extern "C" std::remove_all_extents_t<decltype(S::F)> S##_get_##F(S *s, \
Expand Down Expand Up @@ -163,13 +157,9 @@ std::size_t taichi_strlen(const char *str) {
return len;
}

#define DEFINE_UNARY_REAL_FUNC(F) \
f32 F##_f32(f32 x) { \
return std::F(x); \
} \
f64 F##_f64(f64 x) { \
return std::F(x); \
}
#define DEFINE_UNARY_REAL_FUNC(F) \
f32 F##_f32(f32 x) { return std::F(x); } \
f64 F##_f64(f64 x) { return std::F(x); }

DEFINE_UNARY_REAL_FUNC(exp)
DEFINE_UNARY_REAL_FUNC(log)
Expand Down
12 changes: 4 additions & 8 deletions taichi/ui/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,10 @@ inline int next_power_of_2(int n) {
return 1 << count;
}

#define DEFINE_PROPERTY(Type, name) \
Type name; \
void set_##name(const Type &new_name) { \
name = new_name; \
} \
Type get_##name() { \
return name; \
}
#define DEFINE_PROPERTY(Type, name) \
Type name; \
void set_##name(const Type &new_name) { name = new_name; } \
Type get_##name() { return name; }

inline std::vector<char> read_file(const std::string &filename) {
std::ifstream file(filename, std::ios::ate | std::ios::binary);
Expand Down
10 changes: 3 additions & 7 deletions taichi/util/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,9 @@ constexpr int bit_length() {
return std::is_same<T, bool>() ? 1 : sizeof(T) * 8;
}

#define TI_BIT_FIELD(T, name, start) \
T get_##name() const { \
return (T)Base::get<start, bit::bit_length<T>()>(); \
} \
void set_##name(const T &val) { \
Base::set<start, bit::bit_length<T>()>(val); \
}
#define TI_BIT_FIELD(T, name, start) \
T get_##name() const { return (T)Base::get<start, bit::bit_length<T>()>(); } \
void set_##name(const T &val) { Base::set<start, bit::bit_length<T>()>(val); }

template <typename T, int N>
TI_FORCE_INLINE constexpr T product(const std::array<T, N> arr) {
Expand Down

0 comments on commit 76136a1

Please sign in to comment.