Skip to content

Comments

Refactor: Component-based architecture#192

Draft
davidbeckingsale wants to merge 4 commits intomainfrom
feature/refactor
Draft

Refactor: Component-based architecture#192
davidbeckingsale wants to merge 4 commits intomainfrom
feature/refactor

Conversation

@davidbeckingsale
Copy link
Collaborator

Summary

This PR refactors the Proteus JIT compilation system into a component-based architecture with clear separation of concerns:

  • Engine: Encapsulates backend details and creates compilation tasks
  • CompilationTask: Represents a function with specific specialization
  • Builder: Transforms CompilationTask into CompilationResult
  • CompilationResult: Contains function pointer and execution info
  • Cache: Manages storage and retrieval of compilation results
  • Code: Represents the extracted function code (LLVM IR)
  • CodeContext: Maintains registry of functions and lambdas

This change is intended to make the system more modular, maintainable, and easier to extend with new features.

Added DESIGN.md to document the new architecture.

Test plan

This is a refactoring PR that introduces the new architecture but doesn't change any existing behavior.
After merging this PR, additional PRs will gradually migrate the existing implementation to the new components.

  • Run existing CPU tests
  • Run existing GPU tests (CUDA/HIP)
  • Review DESIGN.md for architectural clarity

🤖 Generated with Claude Code

davidbeckingsale and others added 4 commits March 28, 2025 15:08
This refactoring restructures the Proteus JIT compilation system into distinct components:

- Engine: Encapsulates backend details and creates compilation tasks
- CompilationTask: Represents a function with specific specialization
- Builder: Transforms CompilationTask into CompilationResult
- CompilationResult: Contains function pointer and execution info
- Cache: Manages storage and retrieval of compilation results
- Code: Represents the extracted function code (LLVM IR)
- CodeContext: Maintains registry of functions and lambdas

This redesign creates a cleaner separation of concerns, with each component
having a focused responsibility, making the system more modular and maintainable.

Added DESIGN.md to document the new architecture.
This change adds a proper Builder interface and refactors the CompilerSync and
CompilerAsync classes to use it:

1. Created a generic Builder interface
2. Implemented SyncBuilder for synchronous compilation
3. Implemented AsyncBuilder for asynchronous compilation
4. Updated CompilerSync and CompilerAsync to use these builders
5. Added a helper method in JitEngineHost to demonstrate using the new Builder

This implementation provides better separation of concerns between the compilation
strategy (sync vs async) and the actual compilation work. It aligns with the
component-based architecture described in DESIGN.md.
This commit adds:
- Engine base class with common functionality
- CPU, CUDA, and HIP backend implementations
- Integration with SyncBuilder and AsyncBuilder
- Migration path from JitEngineHost to Engine
- Test program for the Engine component
- Enhanced architecture documentation and component diagram

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format (v18.1.3) reports: 16 file(s) not formatted
  • include/proteus/AsyncBuilder.hpp
  • include/proteus/Builder.hpp
  • include/proteus/Cache.hpp
  • include/proteus/CacheAdapter.hpp
  • include/proteus/Code.hpp
  • include/proteus/CodeContext.hpp
  • include/proteus/CompilationResult.hpp
  • include/proteus/CompilationTask.hpp
  • include/proteus/CompilerAsync.hpp
  • include/proteus/CompilerSync.hpp
  • include/proteus/Engine.hpp
  • include/proteus/JitEngineHost.hpp
  • include/proteus/SyncBuilder.hpp
  • src/lib/Engine.cpp
  • src/lib/JitEngineHost.cpp
  • tests/cpu/test_engine.cpp
clang-tidy (v18.1.3) reports: 31 concern(s)
  • include/proteus/AsyncBuilder.hpp:24:1: warning: [llvm-include-order]

    #includes are not sorted properly

       24 | #include "proteus/CompilationTask.hpp"
          | ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/CompilationResult.hpp"
       25 | #include "proteus/CompilationResult.hpp"
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/CompilationTask.hpp"
  • include/proteus/Builder.hpp:18:1: warning: [llvm-include-order]

    #includes are not sorted properly

       18 | #include "proteus/CompilationTask.hpp"
          | ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/CompilationResult.hpp"
       19 | #include "proteus/CompilationResult.hpp"
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/CompilationTask.hpp"
  • include/proteus/Code.hpp:16:1: warning: [llvm-include-order]

    #includes are not sorted properly

       16 | #include <llvm/IR/Module.h>
          | ^        ~~~~~~~~~~~~~~~~~~
          |          <llvm/Bitcode/BitcodeReader.h>
       17 | #include <llvm/Bitcode/BitcodeReader.h>
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          <llvm/Bitcode/BitcodeWriter.h>
       18 | #include <llvm/Bitcode/BitcodeWriter.h>
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          <llvm/IR/Module.h>
  • include/proteus/Code.hpp:111:7: error: [clang-diagnostic-error]

    use of undeclared identifier 'PROTEUS_FATAL_ERROR'

      111 |       PROTEUS_FATAL_ERROR("Failed to parse bitcode" + toString(std::move(E)));
          |       ^
  • include/proteus/CodeContext.hpp:20:1: warning: [llvm-include-order]

    #includes are not sorted properly

       20 | #include <unordered_map>
          | ^        ~~~~~~~~~~~~~~~
          |          <optional>
       21 | #include <optional>
          |          ~~~~~~~~~~
          |          <unordered_map>
  • include/proteus/CodeContext.hpp:62:24: error: [clang-diagnostic-error]

    call to implicitly-deleted default constructor of 'CodeContext'

       62 |     static CodeContext Singleton;
          |                        ^
    /home/runner/work/proteus/proteus/include/proteus/CodeContext.hpp:187:3: note: explicitly defaulted function was implicitly deleted here
      187 |   CodeContext() = default;
          |   ^
    /home/runner/work/proteus/proteus/include/proteus/CodeContext.hpp:194:45: note: default constructor of 'CodeContext' is implicitly deleted because field 'LambdaMap' has a deleted default constructor
      194 |   std::unordered_map<StringRef, LambdaInfo> LambdaMap;
          |                                             ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unordered_map.h:148:7: note: explicitly defaulted function was implicitly deleted here
      148 |       unordered_map() = default;
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unordered_map.h:112:18: note: default constructor of 'unordered_map<llvm::StringRef, proteus::LambdaInfo>' is implicitly deleted because field '_M_h' has a deleted default constructor
      112 |       _Hashtable _M_h;
          |                  ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable.h:539:7: note: explicitly defaulted function was implicitly deleted here
      539 |       _Hashtable() = default;
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable.h:186:7: note: default constructor of '_Hashtable<llvm::StringRef, std::pair<const llvm::StringRef, proteus::LambdaInfo>, std::allocator<std::pair<const llvm::StringRef, proteus::LambdaInfo>>, std::__detail::_Select1st, std::equal_to<llvm::StringRef>, std::hash<llvm::StringRef>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true>>' is implicitly deleted because base class '__detail::_Hashtable_base<StringRef, pair<const StringRef, LambdaInfo>, _Select1st, equal_to<StringRef>, hash<StringRef>, _Mod_range_hashing, _Default_ranged_hash, _Hashtable_traits<true, false, true>>' has a deleted default constructor
      186 |     : public __detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal,
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1726:7: note: explicitly defaulted function was implicitly deleted here
     1726 |       _Hashtable_base() = default;
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1684:7: note: default constructor of '_Hashtable_base<llvm::StringRef, std::pair<const llvm::StringRef, proteus::LambdaInfo>, std::__detail::_Select1st, std::equal_to<llvm::StringRef>, std::hash<llvm::StringRef>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true>>' is implicitly deleted because base class '_Hash_code_base<StringRef, pair<const StringRef, LambdaInfo>, _Select1st, hash<StringRef>, _Mod_range_hashing, _Default_ranged_hash, _Hashtable_traits<true, false, true>::__hash_cached::value>' has a deleted default constructor
     1684 |     : public _Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash,
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1326:7: note: explicitly defaulted function was implicitly deleted here
     1326 |       _Hash_code_base() = default;
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1305:7: note: default constructor of '_Hash_code_base<llvm::StringRef, std::pair<const llvm::StringRef, proteus::LambdaInfo>, std::__detail::_Select1st, std::hash<llvm::StringRef>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>' is implicitly deleted because base class '_Hashtable_ebo_helper<1, hash<StringRef>>' has a deleted destructor
     1305 |     : private _Hashtable_ebo_helper<1, _Hash>
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1241:7: note: destructor of '_Hashtable_ebo_helper<1, std::hash<llvm::StringRef>>' is implicitly deleted because base class 'std::hash<llvm::StringRef>' has a deleted destructor
     1241 |     : private _Tp
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/functional_hash.h:102:19: note: destructor of 'hash<llvm::StringRef>' is implicitly deleted because base class '__hash_enum<StringRef>' has an inaccessible destructor
      102 |     struct hash : __hash_enum<_Tp>
          |                   ^
  • include/proteus/CodeContext.hpp:187:3: warning: [clang-diagnostic-defaulted-function-deleted]

    explicitly defaulted default constructor is implicitly deleted

      187 |   CodeContext() = default;
          |   ^
    /home/runner/work/proteus/proteus/include/proteus/CodeContext.hpp:194:45: note: default constructor of 'CodeContext' is implicitly deleted because field 'LambdaMap' has a deleted default constructor
      194 |   std::unordered_map<StringRef, LambdaInfo> LambdaMap;
          |                                             ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unordered_map.h:148:7: note: explicitly defaulted function was implicitly deleted here
      148 |       unordered_map() = default;
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unordered_map.h:112:18: note: default constructor of 'unordered_map<llvm::StringRef, proteus::LambdaInfo>' is implicitly deleted because field '_M_h' has a deleted default constructor
      112 |       _Hashtable _M_h;
          |                  ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable.h:539:7: note: explicitly defaulted function was implicitly deleted here
      539 |       _Hashtable() = default;
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable.h:186:7: note: default constructor of '_Hashtable<llvm::StringRef, std::pair<const llvm::StringRef, proteus::LambdaInfo>, std::allocator<std::pair<const llvm::StringRef, proteus::LambdaInfo>>, std::__detail::_Select1st, std::equal_to<llvm::StringRef>, std::hash<llvm::StringRef>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true>>' is implicitly deleted because base class '__detail::_Hashtable_base<StringRef, pair<const StringRef, LambdaInfo>, _Select1st, equal_to<StringRef>, hash<StringRef>, _Mod_range_hashing, _Default_ranged_hash, _Hashtable_traits<true, false, true>>' has a deleted default constructor
      186 |     : public __detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal,
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1726:7: note: explicitly defaulted function was implicitly deleted here
     1726 |       _Hashtable_base() = default;
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1684:7: note: default constructor of '_Hashtable_base<llvm::StringRef, std::pair<const llvm::StringRef, proteus::LambdaInfo>, std::__detail::_Select1st, std::equal_to<llvm::StringRef>, std::hash<llvm::StringRef>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true>>' is implicitly deleted because base class '_Hash_code_base<StringRef, pair<const StringRef, LambdaInfo>, _Select1st, hash<StringRef>, _Mod_range_hashing, _Default_ranged_hash, _Hashtable_traits<true, false, true>::__hash_cached::value>' has a deleted default constructor
     1684 |     : public _Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash,
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1326:7: note: explicitly defaulted function was implicitly deleted here
     1326 |       _Hash_code_base() = default;
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1305:7: note: default constructor of '_Hash_code_base<llvm::StringRef, std::pair<const llvm::StringRef, proteus::LambdaInfo>, std::__detail::_Select1st, std::hash<llvm::StringRef>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>' is implicitly deleted because base class '_Hashtable_ebo_helper<1, hash<StringRef>>' has a deleted destructor
     1305 |     : private _Hashtable_ebo_helper<1, _Hash>
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/hashtable_policy.h:1241:7: note: destructor of '_Hashtable_ebo_helper<1, std::hash<llvm::StringRef>>' is implicitly deleted because base class 'std::hash<llvm::StringRef>' has a deleted destructor
     1241 |     : private _Tp
          |       ^
    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/functional_hash.h:102:19: note: destructor of 'hash<llvm::StringRef>' is implicitly deleted because base class '__hash_enum<StringRef>' has an inaccessible destructor
      102 |     struct hash : __hash_enum<_Tp>
          |                   ^
    /home/runner/work/proteus/proteus/include/proteus/CodeContext.hpp:187:19: note: replace 'default' with 'delete'
      187 |   CodeContext() = default;
          |                   ^~~~~~~
          |                   delete
  • include/proteus/CompilerSync.hpp:20:1: warning: [llvm-include-order]

    #includes are not sorted properly

       20 | #include "proteus/SyncBuilder.hpp"
          | ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/Debug.h"
       21 | #include "proteus/Debug.h"
          |          ~~~~~~~~~~~~~~~~~
          |          "proteus/Hashing.hpp"
       22 | #include "proteus/Hashing.hpp"
          |          ~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/SyncBuilder.hpp"
  • include/proteus/SyncBuilder.hpp:19:1: warning: [llvm-include-order]

    #includes are not sorted properly

       19 | #include "proteus/CompilationTask.hpp"
          | ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/CompilationResult.hpp"
       20 | #include "proteus/CompilationResult.hpp"
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/CompilationTask.hpp"
  • src/lib/Engine.cpp:18:1: warning: [llvm-include-order]

    #includes are not sorted properly

       18 | #include <llvm/Transforms/IPO.h>
          | ^        ~~~~~~~~~~~~~~~~~~~~~~~
          |          <llvm/Analysis/TargetLibraryInfo.h>
       19 | #include <llvm/Transforms/IPO/PassManagerBuilder.h>
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          <llvm/IR/LegacyPassManager.h>
       20 | #include <llvm/IR/LegacyPassManager.h>
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          <llvm/Target/TargetMachine.h>
       21 | #include <llvm/Analysis/TargetLibraryInfo.h>
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          <llvm/Transforms/IPO.h>
       22 | #include <llvm/Target/TargetMachine.h>
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |          <llvm/Transforms/IPO/PassManagerBuilder.h>
  • src/lib/Engine.cpp:33:15: warning: [readability-identifier-naming]

    invalid case style for variable 'i'

       33 |   for (size_t i = 0; i < RCIndices.size(); i++) {
          |               ^      ~                     ~
          |               I      I                     I
       34 |     int32_t Idx = RCIndices[i];
          |                             ~
          |                             I
       35 |     int32_t Type = RCTypes[i];
          |                            ~
          |                            I
  • src/lib/Engine.cpp:161:15: warning: [readability-identifier-naming]

    invalid case style for variable 'i'

      161 |   for (size_t i = 0; i < RuntimeConstants.size(); i++) {
          |               ^      ~                            ~
          |               I      I                            I
      162 |     RCIndices.push_back(RuntimeConstants[i].ArgIdx);
          |                                          ~
          |                                          I
  • src/lib/Engine.cpp:287:15: warning: [readability-identifier-naming]

    invalid case style for variable 'i'

      287 |   for (size_t i = 0; i < RuntimeConstants.size(); i++) {
          |               ^      ~                            ~
          |               I      I                            I
      288 |     RCIndices.push_back(RuntimeConstants[i].ArgIdx);
          |                                          ~
          |                                          I
  • src/lib/Engine.cpp:412:15: warning: [readability-identifier-naming]

    invalid case style for variable 'i'

      412 |   for (size_t i = 0; i < RuntimeConstants.size(); i++) {
          |               ^      ~                            ~
          |               I      I                            I
      413 |     RCIndices.push_back(RuntimeConstants[i].ArgIdx);
          |                                          ~
          |                                          I
  • src/lib/JitEngineHost.cpp:433:1: warning: [llvm-include-order]

    #includes are not sorted properly

      433 | #include "proteus/SyncBuilder.hpp"
          | ^        ~~~~~~~~~~~~~~~~~~~~~~~~~
          |          "proteus/Code.hpp"
      434 | #include "proteus/Engine.hpp"
      435 | #include "proteus/Code.hpp"
          |          ~~~~~~~~~~~~~~~~~~
          |          "proteus/SyncBuilder.hpp"
  • tests/cpu/test_engine.cpp:31:18: warning: [readability-identifier-naming]

    invalid case style for parameter 'alpha'

       31 | void daxpy(float alpha, float* x, float* y, int n) {
          |                  ^~~~~
          |                  Alpha
       32 |   for (int i = 0; i < n; i++) {
       33 |     y[i] = alpha * x[i] + y[i];
          |            ~~~~~
          |            Alpha
  • tests/cpu/test_engine.cpp:31:32: warning: [readability-identifier-naming]

    invalid case style for parameter 'x'

       31 | void daxpy(float alpha, float* x, float* y, int n) {
          |                                ^
          |                                X
       32 |   for (int i = 0; i < n; i++) {
       33 |     y[i] = alpha * x[i] + y[i];
          |                    ~
          |                    X
  • tests/cpu/test_engine.cpp:31:42: warning: [readability-identifier-naming]

    invalid case style for parameter 'y'

       31 | void daxpy(float alpha, float* x, float* y, int n) {
          |                                          ^
          |                                          Y
       32 |   for (int i = 0; i < n; i++) {
       33 |     y[i] = alpha * x[i] + y[i];
          |     ~                     ~
          |     Y                     Y
  • tests/cpu/test_engine.cpp:31:49: warning: [readability-identifier-naming]

    invalid case style for parameter 'n'

       31 | void daxpy(float alpha, float* x, float* y, int n) {
          |                                                 ^
          |                                                 N
       32 |   for (int i = 0; i < n; i++) {
          |                       ~
          |                       N
  • tests/cpu/test_engine.cpp:32:12: warning: [readability-identifier-naming]

    invalid case style for variable 'i'

       32 |   for (int i = 0; i < n; i++) {
          |            ^      ~      ~
          |            I      I      I
       33 |     y[i] = alpha * x[i] + y[i];
          |       ~              ~      ~
          |       I              I      I
  • tests/cpu/test_engine.cpp:82:22: warning: [readability-identifier-naming]

    invalid case style for variable 'x'

       82 |   std::vector<float> x(N, 1.0f);
          |                      ^
          |                      X
  • tests/cpu/test_engine.cpp:83:22: warning: [readability-identifier-naming]

    invalid case style for variable 'y'

       83 |   std::vector<float> y(N, 2.0f);
          |                      ^
          |                      Y
  • tests/cpu/test_engine.cpp:84:22: warning: [readability-identifier-naming]

    invalid case style for variable 'expected'

       84 |   std::vector<float> expected(N);
          |                      ^~~~~~~~
          |                      Expected
       85 |   float alpha = 3.0f;
       86 |   
       87 |   // Compute expected results using host function
       88 |   daxpy(alpha, x.data(), y.data(), N);
       89 |   expected = y;
          |   ~~~~~~~~
          |   Expected
  • tests/cpu/test_engine.cpp:85:9: warning: [readability-identifier-naming]

    invalid case style for variable 'alpha'

       85 |   float alpha = 3.0f;
          |         ^~~~~
          |         Alpha
       86 |   
       87 |   // Compute expected results using host function
       88 |   daxpy(alpha, x.data(), y.data(), N);
          |         ~~~~~
          |         Alpha
  • tests/cpu/test_engine.cpp:146:10: warning: [readability-identifier-naming]

    invalid case style for variable 'start'

      146 |     auto start = std::chrono::high_resolution_clock::now();
          |          ^~~~~
          |          Start
  • tests/cpu/test_engine.cpp:151:10: warning: [readability-identifier-naming]

    invalid case style for variable 'end'

      151 |     auto end = std::chrono::high_resolution_clock::now();
          |          ^~~
          |          End
  • tests/cpu/test_engine.cpp:152:47: warning: [readability-identifier-naming]

    invalid case style for variable 'elapsed'

      152 |     std::chrono::duration<double, std::milli> elapsed = end - start;
          |                                               ^~~~~~~
          |                                               Elapsed
  • tests/cpu/test_engine.cpp:155:10: warning: [readability-identifier-naming]

    invalid case style for variable 'correct'

      155 |     bool correct = true;
          |          ^~~~~~~
          |          Correct
      156 |     for (int i = 0; i < N; i++) {
      157 |       if (std::abs(y[i] - expected[i]) > 1e-6) {
      158 |         std::cerr << "Mismatch at " << i << ": " << y[i] << " vs " << expected[i] << "\n";
      159 |         correct = false;
          |         ~~~~~~~
          |         Correct
      160 |         break;
      161 |       }
      162 |     }
      163 |     
      164 |     if (correct) {
          |         ~~~~~~~
          |         Correct
  • tests/cpu/test_engine.cpp:156:14: warning: [readability-identifier-naming]

    invalid case style for variable 'i'

      156 |     for (int i = 0; i < N; i++) {
          |              ^      ~      ~
          |              I      I      I
      157 |       if (std::abs(y[i] - expected[i]) > 1e-6) {
          |                      ~             ~
          |                      I             I
      158 |         std::cerr << "Mismatch at " << i << ": " << y[i] << " vs " << expected[i] << "\n";
          |                                        ~              ~                        ~
          |                                        I              I                        I
  • tests/cpu/test_engine.cpp:167:7: warning: [llvm-else-after-return]

    do not use 'else' after 'return'

      167 |     } else {
          |       ^~~~~~
      168 |       std::cerr << "Test FAILED.\n";
          |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      169 |       return 1;
          |       ~~~~~~~~~
      170 |     }
          |     ~
  • tests/cpu/test_engine.cpp:172:34: warning: [readability-identifier-naming]

    invalid case style for variable 'e'

      172 |   } catch (const std::exception& e) {
          |                                  ^
          |                                  E
      173 |     std::cerr << "Exception: " << e.what() << "\n";
          |                                   ~
          |                                   E

Have any feedback or feature suggestions? Share it here.

@ggeorgakoudis ggeorgakoudis marked this pull request as draft June 13, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant