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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_BUILD_TYPE Release)

set(CMAKE_CXX_COMPILER g++)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Ofast -ffast-math -funroll-loops -march=native -std=c++11")
if(DEVICE_TYPE STREQUAL "xpu" AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Ofast -ffast-math -funroll-loops -march=x86-64-v3 -std=c++11")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❓ 疑问 条件仅覆盖 DEVICE_TYPE=xpu,其他设备类型(如 dcu)若在 Intel 机器上编译、在海光机器上运行,同样会触发 illegal instruction 错误。

是否有意只修复 XPU 场景?如果是,建议在注释中说明原因;如果其他设备类型也有跨平台部署需求,可考虑将条件扩展为:

if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Ofast -ffast-math -funroll-loops -march=x86-64-v3 -std=c++11")
else()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Ofast -ffast-math -funroll-loops -march=native -std=c++11")
endif()

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.

目前仅 XPU 的硬件环境比较复杂,其它硬件如果需要可自行增加

else()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❓ 疑问 -march=x86-64-v3 需要 GCC 11+(2021 年发布)才支持该 march level 名称。请确认构建环境的最低 GCC 版本满足此要求,否则会出现 error: bad value (x86-64-v3) for -march= switch 编译错误。

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.

P800 基于 ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddleqa:xpu-ubuntu2204-x86_64-gcc123-py310 镜像,默认 gcc 版本 12.3。

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Ofast -ffast-math -funroll-loops -march=native -std=c++11")
endif()
add_compile_options("-std=c++11")

find_library(IBVERBS_LIBRARY ibverbs)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
"-DPYTHON_VERSION=",
f"-DPYTHON_INCLUDE_DIR={sys.prefix}/include/python{sys.version_info.major}.{sys.version_info.minor}",
f"-DPYTHON_LIBRARY={sys.prefix}/lib/libpython{sys.version_info.major}.{sys.version_info.minor}.so",
f"-DDEVICE_TYPE={get_device_type()}",
]
build_args = []

Expand Down
Loading