From dff42545236ba91634a6a9976f4c9912181f3799 Mon Sep 17 00:00:00 2001 From: Samuel Ayala Date: Tue, 20 Feb 2024 17:43:39 -0500 Subject: [PATCH] cleanup --- .clang-tidy | 22 ++++++------ headeronly/simpletimer.hpp | 34 ------------------- vlm/backends/cpu/include/vlm_backend_cpu.hpp | 1 - vlm/backends/cpu/src/vlm_backend_cpu.cpp | 3 +- .../{helper_math.h => helper_math.cuh} | 0 vlm/backends/cuda/src/vlm_backend_cuda.cu | 10 +++--- vlm/include/vlm_mesh.hpp | 2 +- vlm/src/vlm_mesh.cpp | 2 +- 8 files changed, 20 insertions(+), 54 deletions(-) delete mode 100644 headeronly/simpletimer.hpp rename vlm/backends/cuda/include/{helper_math.h => helper_math.cuh} (100%) diff --git a/.clang-tidy b/.clang-tidy index 9fddeb6..8a7810f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,11 +1,13 @@ -Checks: '-*,clang-diagnostic-*,misc-*,performance-*,clang-analyzer-*,bugprone-*' +Checks: '-*,clang-diagnostic-*,misc-*,performance-*,clang-analyzer-*,bugprone-*, +-bugprone-easily-swappable-parameters' CheckOptions: - - { key: readability-identifier-naming.NamespaceCase, value: lower_case } - - { key: readability-identifier-naming.ClassCase, value: CamelCase } - - { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ } - - { key: readability-identifier-naming.StructCase, value: CamelCase } - - { key: readability-identifier-naming.FunctionCase, value: lower_case } - - { key: readability-identifier-naming.VariableCase, value: lower_case } - - { key: readability-identifier-naming.MemberCase, value: lower_case } - - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } - - { key: readability-simplify-boolean-expr, value: true } + - { key: readability-identifier-naming.NamespaceCase, value: lower_case } + - { key: readability-identifier-naming.ClassCase, value: CamelCase } + - { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ } + - { key: readability-identifier-naming.StructCase, value: CamelCase } + - { key: readability-identifier-naming.FunctionCase, value: lower_case } + - { key: readability-identifier-naming.VariableCase, value: lower_case } + - { key: readability-identifier-naming.MemberCase, value: lower_case } + - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } + - { key: readability-simplify-boolean-expr, value: true } + - { key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: true } diff --git a/headeronly/simpletimer.hpp b/headeronly/simpletimer.hpp deleted file mode 100644 index a9a5dd4..0000000 --- a/headeronly/simpletimer.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include - -class SimpleTimer { -public: - SimpleTimer(const char* name) : m_Name(name) { - m_StartTimepoint = std::chrono::high_resolution_clock::now(); - } - - ~SimpleTimer() { Stop();} - - void Stop() { - auto endTimepoint = std::chrono::high_resolution_clock::now(); - - long long start = std::chrono::time_point_cast(m_StartTimepoint).time_since_epoch().count(); - long long end = std::chrono::time_point_cast(endTimepoint).time_since_epoch().count(); - - auto duration = end - start; - std::cout << m_Name << ": "; - - if (duration > 1e6) { - std::cout << duration * 1e-6 << " s" << std::endl; - } else if (duration > 1e3) { - std::cout << duration * 1e-3 << " ms" << std::endl; - } else { - std::cout << duration << " us" << std::endl; - } - } -private: - const char* m_Name; - std::chrono::time_point m_StartTimepoint; -}; diff --git a/vlm/backends/cpu/include/vlm_backend_cpu.hpp b/vlm/backends/cpu/include/vlm_backend_cpu.hpp index 26b5e3e..595bf46 100644 --- a/vlm/backends/cpu/include/vlm_backend_cpu.hpp +++ b/vlm/backends/cpu/include/vlm_backend_cpu.hpp @@ -8,7 +8,6 @@ namespace vlm { class BackendCPU : public Backend { public: std::vector lhs; - std::vector lhs_dummy; std::vector rhs; std::vector ipiv; std::vector gamma; diff --git a/vlm/backends/cpu/src/vlm_backend_cpu.cpp b/vlm/backends/cpu/src/vlm_backend_cpu.cpp index 85ea9fc..29e44a6 100644 --- a/vlm/backends/cpu/src/vlm_backend_cpu.cpp +++ b/vlm/backends/cpu/src/vlm_backend_cpu.cpp @@ -24,7 +24,6 @@ BackendCPU::~BackendCPU() = default; // Destructor definition BackendCPU::BackendCPU(Mesh& mesh) : Backend(mesh) { lhs.resize(mesh.nb_panels_wing() * mesh.nb_panels_wing()); - lhs_dummy.resize(mesh.nb_panels_wing() * mesh.nb_panels_wing()); rhs.resize(mesh.nb_panels_wing()); ipiv.resize(mesh.nb_panels_wing()); gamma.resize(mesh.nb_panels_wing()); @@ -39,7 +38,7 @@ void BackendCPU::reset() { } void BackendCPU::compute_delta_gamma() { - std::copy(gamma.begin(), gamma.begin()+mesh.ns, delta_gamma.begin()); + std::copy(gamma.data(), gamma.data()+mesh.ns, delta_gamma.data()); // note: this is efficient as the memory is contiguous for (u64 i = 1; i < mesh.nc; i++) { diff --git a/vlm/backends/cuda/include/helper_math.h b/vlm/backends/cuda/include/helper_math.cuh similarity index 100% rename from vlm/backends/cuda/include/helper_math.h rename to vlm/backends/cuda/include/helper_math.cuh diff --git a/vlm/backends/cuda/src/vlm_backend_cuda.cu b/vlm/backends/cuda/src/vlm_backend_cuda.cu index 302464e..dd80b8b 100644 --- a/vlm/backends/cuda/src/vlm_backend_cuda.cu +++ b/vlm/backends/cuda/src/vlm_backend_cuda.cu @@ -1,12 +1,12 @@ #include "vlm_backend_cpu.hpp" #include "vlm_backend_cuda.hpp" -#include "simpletimer.hpp" +#include "tinytimer.hpp" #include #include #include -#include "helper_math.h" +#include "helper_math.cuh" #include #include @@ -284,7 +284,7 @@ constexpr u64 get_grid_size(u64 length, u64 block_size) { } void BackendCUDA::compute_lhs(const FlowData& flow) { - SimpleTimer timer("LHS"); + tiny::ScopedTimer timer("LHS"); // Copy the latest mesh that has been corrected for the aoa u64 npt = mesh.nb_panels_total(); u64 nvt = mesh.nb_vertices_total(); @@ -331,7 +331,7 @@ void BackendCUDA::compute_rhs(const FlowData& flow, const std::vector& sect } void BackendCUDA::lu_factor() { - SimpleTimer timer("Factor"); + tiny::ScopedTimer timer("Factor"); int n = (int)mesh.nb_panels_wing(); int h_info = 0; @@ -341,7 +341,7 @@ void BackendCUDA::lu_factor() { }; void BackendCUDA::lu_solve() { - SimpleTimer timer("Solve"); + tiny::ScopedTimer timer("Solve"); //default_backend.solve(); int n = (int)mesh.nb_panels_wing(); int h_info = 0; diff --git a/vlm/include/vlm_mesh.hpp b/vlm/include/vlm_mesh.hpp index 91888c6..737e076 100644 --- a/vlm/include/vlm_mesh.hpp +++ b/vlm/include/vlm_mesh.hpp @@ -82,6 +82,6 @@ class Mesh { }; // todo, update this to mirror the constructor -std::unique_ptr create_mesh(const std::string filename); +std::unique_ptr create_mesh(const std::string& filename); } // namespace vlm \ No newline at end of file diff --git a/vlm/src/vlm_mesh.cpp b/vlm/src/vlm_mesh.cpp index 09b3f92..223dbe4 100644 --- a/vlm/src/vlm_mesh.cpp +++ b/vlm/src/vlm_mesh.cpp @@ -37,7 +37,7 @@ Mesh::Mesh( init(); } -std::unique_ptr vlm::create_mesh(const std::string filename) { +std::unique_ptr vlm::create_mesh(const std::string& filename) { return std::make_unique(filename); }