Hi,
> Hi, I just saw this patch flying by and looked into it (I'm not a
> maintainer for this package).
>
> The following lines are very likely not correct:
>
> ++ # For native compilation tune for the host processor
> ++ if (CMAKE_SYSTEM_PROCESSOR STREQUAL
> CMAKE_HOST_SYSTEM_PROCESSOR)
> ++ append(DEF_ARCH_OPT_FLAGS "-march=native")
> ++ endif()
>
> We must not compile with -march=native, as this makes the build
> dependent on the build machine. By that it is neither portable nor
> reproducible anymore.
I have update the patch in order to add basic support for loongarch64 in
onednn source package.
Please consider the
patch(onednn-add-basic-support-for-loongarch64.patch) I attached.
Also, please remember to add loong64 support in d/control, as follows,
```
diff -Nru onednn-3.5.3/debian/control onednn-3.5.3/debian/control
--- onednn-3.5.3/debian/control 2024-11-01 08:21:29.000000000 +0000
+++ onednn-3.5.3/debian/control 2025-02-12 06:43:30.000000000 +0000
@@ -16,7 +16,7 @@
Package: libdnnl-dev
Section: libdevel
-Architecture: amd64 arm64 ppc64el s390x riscv64
+Architecture: amd64 arm64 ppc64el s390x riscv64 loong64
Depends: libdnnl3 (= ${binary:Version}), ${misc:Depends}
Breaks: libmkldnn-dev
Replaces: libmkldnn-dev
@@ -33,7 +33,7 @@
Package: libdnnl3
Section: libs
-Architecture: amd64 arm64 ppc64el s390x riscv64
+Architecture: amd64 arm64 ppc64el s390x riscv64 loong64
Multi-Arch: same
Depends: ${misc:Depends}, ${shlibs:Depends}
Breaks: libmkldnn1
```
Based attached patch and append loong64 support in d/control, I copy my
local test results, as follows,
```
165/167 Test #165: test_graph_unit_dnnl_typecast_usm_cpu
................... Passed 0.01 sec
Start 166: test_graph_unit_utils
166/167 Test #166: test_graph_unit_utils
................................... Passed 0.01 sec
Start 167: noexcept-cpp
167/167 Test #167: noexcept-cpp
............................................ Passed 0.00 sec
100% tests passed, 0 tests failed out of 167
Total Test time (real) = 391.31 sec
```
Your opinions are welcome.
Best regards,
Dandan Zhang
Description: Add basic build support for loongarch64.
.
onednn (3.5.3-5+loong64) unstable; urgency=medium
.
* Add basic build support for loongarch64
Author: Dandan Zhang <zhangdan...@loongson.cn>
---
Last-Update: 2025-02-12
--- onednn-3.5.3.orig/CMakeLists.txt
+++ onednn-3.5.3/CMakeLists.txt
@@ -95,6 +95,8 @@ if(NOT DNNL_TARGET_ARCH)
set(DNNL_TARGET_ARCH "S390X")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(rv.*|RV.*|riscv.*|RISCV.*)")
set(DNNL_TARGET_ARCH "RV64")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(loongarch64.*|LOONGARCH64.*|loong64.*|LOONG64.*)")
+ set(DNNL_TARGET_ARCH "LOONGARCH64")
else()
set(DNNL_TARGET_ARCH "X64")
endif()
--- onednn-3.5.3.orig/README.md
+++ onednn-3.5.3/README.md
@@ -74,6 +74,7 @@ oneDNN supports platforms based on the f
- [OpenPOWER](https://openpowerfoundation.org/) / [IBM Power ISA](https://en.wikipedia.org/wiki/Power_ISA).
- [IBMz z/Architecture (s390x)](https://en.wikipedia.org/wiki/Z/Architecture).
- [RISC-V 64-bit (RV64)](https://en.wikipedia.org/wiki/RISC-V).
+- [LOONGARCH 64 bit](https://docs.kernel.org/arch/loongarch/introduction.html).
> **WARNING**
>
--- onednn-3.5.3.orig/cmake/platform.cmake
+++ onednn-3.5.3/cmake/platform.cmake
@@ -363,6 +363,8 @@ elseif(UNIX OR MINGW)
elseif(DNNL_TARGET_ARCH STREQUAL "RV64")
# G = General-purpose extensions, C = Compression extension (very common).
append(DEF_ARCH_OPT_FLAGS "-march=rv64gc")
+ elseif(DNNL_TARGET_ARCH STREQUAL "LOONGARCH64")
+ append(DEF_ARCH_OPT_FLAGS "-march=loongarch64")
elseif(DNNL_TARGET_ARCH STREQUAL "X64")
platform_gnu_x64_arch_ccxx_flags(DEF_ARCH_OPT_FLAGS)
endif()
--- onednn-3.5.3.orig/src/cpu/README.md
+++ onednn-3.5.3/src/cpu/README.md
@@ -46,6 +46,7 @@ enable or disable parts of code. There t
- `DNNL_PPC64` is 1 on OpenPOWER / IBM Power architecture;
- `DNNL_S390X` is 1 on IBMz / s390x architecture;
- `DNNL_RV64` is 1 on RISC-V architecture;
+- `DNNL_LOONGARCH64` is 1 on LoongArch architecture;
- `DNNL_ARCH_GENERIC` is 1 on other platforms.
Only one of the macros above is defined to 1. All others are defined to 0.
--- onednn-3.5.3.orig/src/cpu/platform.hpp
+++ onednn-3.5.3/src/cpu/platform.hpp
@@ -30,11 +30,12 @@
// - DNNL_PPC64
// - DNNL_S390X
// - DNNL_RV64
+// - DNNL_LOONGARCH64
// - DNNL_ARCH_GENERIC
// Target architecture macro is set to 1, others to 0. All macros are defined.
#if defined(DNNL_X64) + defined(DNNL_AARCH64) + defined(DNNL_PPC64) \
- + defined(DNNL_S390X) + defined(DNNL_RV64) \
+ + defined(DNNL_S390X) + defined(DNNL_RV64) + defined(DNNL_LOONGARCH64)\
+ defined(DNNL_ARCH_GENERIC) \
== 0
#if defined(__x86_64__) || defined(_M_X64)
@@ -47,13 +48,15 @@
#define DNNL_S390X 1
#elif defined(__riscv)
#define DNNL_RV64 1
+#elif defined(__loongarch_lp64)
+#define DNNL_LOONGARCH64 1
#else
#define DNNL_ARCH_GENERIC 1
#endif
#endif // defined(DNNL_X64) + ... == 0
#if defined(DNNL_X64) + defined(DNNL_AARCH64) + defined(DNNL_PPC64) \
- + defined(DNNL_S390X) + defined(DNNL_RV64) \
+ + defined(DNNL_S390X) + defined(DNNL_RV64) + defined(DNNL_LOONGARCH64) \
+ defined(DNNL_ARCH_GENERIC) \
!= 1
#error One and only one architecture should be defined at a time
@@ -74,6 +77,9 @@
#if !defined(DNNL_RV64)
#define DNNL_RV64 0
#endif
+#if !defined(DNNL_LOONGARCH64)
+#define DNNL_LOONGARCH64 0
+#endif
#if !defined(DNNL_ARCH_GENERIC)
#define DNNL_ARCH_GENERIC 0
#endif