Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions cpp/modmesh/buffer/pymod/buffer_pymod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,40 @@

#include <modmesh/buffer/pymod/buffer_pymod.hpp> // Must be the first include.

#include <modmesh/simd/simd_support.hpp>

namespace modmesh
{

namespace python
{

namespace
{

char const * simd_feature_name()
{
using namespace modmesh::simd::detail;
switch (detect_simd())
{
case SIMD_NONE: return "NONE";
case SIMD_NEON: return "NEON";
case SIMD_SSE: return "SSE";
case SIMD_SSE2: return "SSE2";
case SIMD_SSE3: return "SSE3";
case SIMD_SSSE3: return "SSSE3";
case SIMD_SSE41: return "SSE41";
case SIMD_SSE42: return "SSE42";
case SIMD_AVX: return "AVX";
case SIMD_AVX2: return "AVX2";
case SIMD_AVX512: return "AVX512";
case SIMD_UNKNOWN: return "UNKNOWN";
}
return "UNKNOWN";
}

} // namespace

struct buffer_pymod_tag;

template <>
Expand All @@ -52,6 +80,14 @@ void initialize_buffer(pybind11::module & mod)
wrap_ConcreteBuffer(mod);
wrap_SimpleArray(mod);
wrap_SimpleArrayPlex(mod);

// Reports the runtime-detected SIMD feature so pytest can verify that
// NEON dispatch is active on aarch64. Without this guard, a regression
// that silently routes everything to the scalar path would still pass
// every correctness check. Kept under an underscore-prefixed name
// because detect_simd() only meaningfully reflects the dispatched
// backend on aarch64 today; on other targets it would mislead users.
mod.def("_simd_feature", &simd_feature_name);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For checking if simd is working.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpp/modmesh/toggle/ may be a more on-topic module for the SIMD check, but it's fine to have it here in buffer.

};

OneTimeInitializer<buffer_pymod_tag>::me()(mod, initialize_impl);
Expand Down
Loading
Loading