From 4a107c7baf363ae3ff95da2a47d21649db3817fe Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Wed, 4 Sep 2024 10:44:30 -0400 Subject: [PATCH] AABB.h passes clang-tidy on Linux. --- .clang-tidy | 2 ++ freud/locality/AABB.h | 16 +++++++--------- freud/util/Histogram.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index c2e216a99..73af17322 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -11,6 +11,7 @@ # readability-identifier-length: We use short identifiers sparingly and in places where they are more readable than long ones. # bugprone-easily-swappable-parameters: Many methods unavoidably take multiple float parameters. # performance-enum-size: There is little to be gained switching from 4-byt ints to 1 byte enums. +# portability-simd-intrinsics: Allow intrinsics to improve performance. Checks: 'bugprone-*, cert-*, @@ -33,4 +34,5 @@ Checks: 'bugprone-*, -readability-identifier-length, -bugprone-easily-swappable-parameters, -performance-enum-size, + -portability-simd-intrinsics, ' diff --git a/freud/locality/AABB.h b/freud/locality/AABB.h index 153e40022..99dda8c9e 100644 --- a/freud/locality/AABB.h +++ b/freud/locality/AABB.h @@ -4,8 +4,6 @@ #ifndef AABB_H #define AABB_H -#include - #include "VectorMath.h" /*! \file AABB.h @@ -29,7 +27,7 @@ inline __m128 sse_load_vec3_float(const vec3& value) in[0] = value.x; in[1] = value.y; in[2] = value.z; - in[3] = 0.0f; + in[3] = 0.0F; return _mm_loadu_ps(in); } @@ -75,7 +73,7 @@ struct CACHE_ALIGN AABB AABB() : tag(0) { #if defined(__SSE__) - float in = 0.0f; + const float in = 0.0F; lower_v = _mm_load_ps1(&in); upper_v = _mm_load_ps1(&in); @@ -147,9 +145,9 @@ struct CACHE_ALIGN AABB vec3 getPosition() const { #if defined(__SSE__) - float half = 0.5f; - __m128 half_v = _mm_load_ps1(&half); - __m128 pos_v = _mm_mul_ps(half_v, _mm_add_ps(lower_v, upper_v)); + const float half = 0.5F; + const __m128 half_v = _mm_load_ps1(&half); + const __m128 pos_v = _mm_mul_ps(half_v, _mm_add_ps(lower_v, upper_v)); return sse_unload_vec3_float(pos_v); #else @@ -215,7 +213,7 @@ struct CACHE_ALIGN AABBSphere AABBSphere() : radius(0), tag(0) { #if defined(__SSE__) - float in = 0.0f; + float in = 0.0F; position_v = _mm_load_ps1(&in); #endif @@ -269,7 +267,7 @@ struct CACHE_ALIGN AABBSphere void translate(const vec3& v) { #if defined(__SSE__) - __m128 v_v = sse_load_vec3_float(v); + const __m128 v_v = sse_load_vec3_float(v); position_v = _mm_add_ps(position_v, v_v); #else diff --git a/freud/util/Histogram.h b/freud/util/Histogram.h index f80638004..ab078e808 100644 --- a/freud/util/Histogram.h +++ b/freud/util/Histogram.h @@ -161,7 +161,7 @@ class RegularAxis : public Axis float const val = (value - m_min) * m_inverse_bin_width; // fast float to int conversion with truncation #ifdef __SSE2__ - size_t bin = _mm_cvtt_ss2si(_mm_load_ss(&val)); + const size_t bin = _mm_cvtt_ss2si(_mm_load_ss(&val)); #else auto const bin = (size_t) (val); #endif