Skip to content

refactor: adapt dispatcher for full C++17 compatibility and support pip install on MetaX#5

Open
Ziminli wants to merge 5 commits intofeat/dev-infrafrom
refactor/cpp-17-dispatcher
Open

refactor: adapt dispatcher for full C++17 compatibility and support pip install on MetaX#5
Ziminli wants to merge 5 commits intofeat/dev-infrafrom
refactor/cpp-17-dispatcher

Conversation

@Ziminli
Copy link

@Ziminli Ziminli commented Feb 28, 2026

TL;DR: Refactors the dispatcher to remove C++20-specific features and ensure full C++17 compatibility, and support pip install .[dev] on MetaX.

Key Changes

  • Dispatcher Refactor:

    • Remove the usage of a C++20 feature (explicit template parameter list for lambdas) in the dispatcher.
    • Replace with an equivalent implementation that works under the project’s C++17 standard.
    • Update places where dispatcher is used.
  • Support Pytest on MetaX:

    • Pybind11 and pyproject introduce extra flags that MetaX's compiler (i.e., mxcc) does not support. By adding a wrapper script, it processes the flags and make pip install work.
  • Support Auto-detection on MetaX:

    • Now on MetaX, install InfiniOps can just do pip install .[dev] instead of pip install .[dev] -C cmake.define.WITH_CPU="ON" -C cmake.define.WITH_METAX="ON".
  • Fix Styling Issues:

    • Fix the code styling noncompliance in common/traits.h, common/constexpr_map.h and src/dispatcher.h.

Known Issues & Future Work:

  • None

- dispatcher now does not depend on C++20 features
- udpate the current dispatcher use cases
- add some relevant constexpr traits in common/traits.h
- add `PYBIND_ENABLE_EXTRAS` internal cmake variable for controlling the flags introduced by pybind
@Ziminli Ziminli self-assigned this Feb 28, 2026
template <auto... Items>
struct List {};

// ListGet<I>(List<Items...>{}) extracts the Ith value from a List tag.
Copy link
Collaborator

Choose a reason for hiding this comment

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

先检查所有模板参数中的非类型参数的命名,应该按照变量来,比如应该是 i 而不是 I。之后检查注释和报错信息中代码是否使用了 Markdown,如:`ListGet<i>(List<items...>{})` extracts the `i`th value from a `List` tag.。后面同理,同类问题先不 comment 了,统一处理即可。

Copy link
Author

Choose a reason for hiding this comment

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

已修改

// -----------------------------------------------------------------------------

// Checks if a Functor's template operator()<Value> can be called with Args.
// Checks if a Functor can be called with a ValueTag<Value> and Args...
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个地方着重说一下,怕改错了,正常英文如果结尾是 "..." 就不需要额外的句号,但是改成 Markdown 语法后还需要额外加,因为代码段里的点不算真正的英文句号。

CMakeLists.txt Outdated
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Internal variable to control pybind11's automatic optimization flags (like -flto)
Copy link
Collaborator

Choose a reason for hiding this comment

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

没使用 Markdown,也没加句号。

Copy link
Author

Choose a reason for hiding this comment

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

已修改

CMakeLists.txt Outdated
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Internal variable to control pybind11's automatic optimization flags (like -flto)
set(PYBIND_ENABLE_EXTRAS ON)
Copy link
Collaborator

Choose a reason for hiding this comment

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

改成 PYBIND11_ENABLE_EXTRAS 吧。

Copy link
Author

Choose a reason for hiding this comment

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

已修改

src/dispatcher.h Outdated
: false));

if (!handled) {
std::cerr << "Dispatch error (void): Value " << static_cast<int>(value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

报错信息格式有问题,请参考相关飞书文档。下同,建议严查全篇。

Copy link
Author

Choose a reason for hiding this comment

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

已修改

@Ziminli Ziminli force-pushed the refactor/cpp-17-dispatcher branch from b06f7b6 to 87bd2c0 Compare March 2, 2026 09:05
…, `common/constexpr_map.h` and `dispatcher.h`
@Ziminli Ziminli force-pushed the refactor/cpp-17-dispatcher branch from 87bd2c0 to 1740234 Compare March 2, 2026 12:57
@Ziminli Ziminli changed the title refactor: adapt dispatcher for full C++17 compatibility refactor: adapt dispatcher for full C++17 compatibility and support pip install Mar 2, 2026
@Ziminli Ziminli changed the title refactor: adapt dispatcher for full C++17 compatibility and support pip install refactor: adapt dispatcher for full C++17 compatibility and support pip install on MetaX Mar 2, 2026
@Ziminli Ziminli marked this pull request as ready for review March 2, 2026 13:12
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.

2 participants