From 9455e833aba376e3a0a74935c113b8fad000722d Mon Sep 17 00:00:00 2001 From: Renbo Date: Mon, 15 Jul 2024 14:58:56 +0800 Subject: [PATCH 1/2] update to ucx-1.15.0-2.src.rpm Signed-off-by: Renbo --- 0001-add-loongarch64-support-for-ucx.patch | 749 --------------------- download | 2 +- ucx.spec | 40 +- 3 files changed, 22 insertions(+), 769 deletions(-) delete mode 100644 0001-add-loongarch64-support-for-ucx.patch diff --git a/0001-add-loongarch64-support-for-ucx.patch b/0001-add-loongarch64-support-for-ucx.patch deleted file mode 100644 index d4a4df5..0000000 --- a/0001-add-loongarch64-support-for-ucx.patch +++ /dev/null @@ -1,749 +0,0 @@ -From 17c06e6237067219e88ac7d43e962a1a0e46bbb4 Mon Sep 17 00:00:00 2001 -From: Wenlong Zhang - liuzhilin -Date: Thu, 11 Jan 2024 08:32:58 +0000 -Subject: [PATCH] add loongarch64 support for ucx - ---- - config.guess | 3 + - src/ucm/Makefile.am | 2 + - src/ucm/Makefile.in | 19 ++++- - src/ucm/bistro/bistro.c | 2 +- - src/ucm/bistro/bistro.h | 2 + - src/ucm/bistro/bistro_loongarch64.c | 85 +++++++++++++++++++++ - src/ucm/bistro/bistro_loongarch64.h | 46 +++++++++++ - src/ucs/Makefile.am | 4 + - src/ucs/Makefile.in | 33 +++++++- - src/ucs/arch/atomic.h | 2 + - src/ucs/arch/bitops.h | 2 + - src/ucs/arch/cpu.h | 2 + - src/ucs/arch/global_opts.h | 2 + - src/ucs/arch/loongarch64/bitops.h | 42 ++++++++++ - src/ucs/arch/loongarch64/cpu.h | 101 +++++++++++++++++++++++++ - src/ucs/arch/loongarch64/global_opts.c | 24 ++++++ - src/ucs/arch/loongarch64/global_opts.h | 24 ++++++ - 17 files changed, 388 insertions(+), 7 deletions(-) - create mode 100644 src/ucm/bistro/bistro_loongarch64.c - create mode 100644 src/ucm/bistro/bistro_loongarch64.h - create mode 100644 src/ucs/arch/loongarch64/bitops.h - create mode 100644 src/ucs/arch/loongarch64/cpu.h - create mode 100644 src/ucs/arch/loongarch64/global_opts.c - create mode 100644 src/ucs/arch/loongarch64/global_opts.h - -diff --git a/config.guess b/config.guess -index b79252d..74933dc 100755 ---- a/config.guess -+++ b/config.guess -@@ -883,6 +883,9 @@ EOF - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; -+ loongarch64:Linux:*:*) -+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} -+ exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; -diff --git a/src/ucm/Makefile.am b/src/ucm/Makefile.am -index 48b82bf..75b9821 100644 ---- a/src/ucm/Makefile.am -+++ b/src/ucm/Makefile.am -@@ -31,6 +31,7 @@ noinst_HEADERS = \ - bistro/bistro.h \ - bistro/bistro_x86_64.h \ - bistro/bistro_aarch64.h \ -+ bistro/bistro_loongarch64.h \ - bistro/bistro_ppc64.h - - libucm_la_SOURCES = \ -@@ -44,6 +45,7 @@ libucm_la_SOURCES = \ - bistro/bistro.c \ - bistro/bistro_x86_64.c \ - bistro/bistro_aarch64.c \ -+ bistro/bistro_loongarch64.c \ - bistro/bistro_ppc64.c - - if HAVE_UCM_PTMALLOC286 -diff --git a/src/ucm/Makefile.in b/src/ucm/Makefile.in -index 1dd6749..7cc43f5 100644 ---- a/src/ucm/Makefile.in -+++ b/src/ucm/Makefile.in -@@ -191,7 +191,7 @@ am__libucm_la_SOURCES_DIST = event/event.c malloc/malloc_hook.c \ - mmap/install.c util/replace.c util/log.c util/reloc.c \ - util/sys.c bistro/bistro.c bistro/bistro_x86_64.c \ - bistro/bistro_aarch64.c bistro/bistro_ppc64.c \ -- ptmalloc286/malloc.c -+ bistro/bistro_loongarch64.c ptmalloc286/malloc.c - am__dirstamp = $(am__leading_dot)dirstamp - @HAVE_UCM_PTMALLOC286_TRUE@am__objects_1 = \ - @HAVE_UCM_PTMALLOC286_TRUE@ ptmalloc286/libucm_la-malloc.lo -@@ -201,6 +201,7 @@ am_libucm_la_OBJECTS = event/libucm_la-event.lo \ - util/libucm_la-reloc.lo util/libucm_la-sys.lo \ - bistro/libucm_la-bistro.lo bistro/libucm_la-bistro_x86_64.lo \ - bistro/libucm_la-bistro_aarch64.lo \ -+ bistro/libucm_la-bistro_loongarch64.lo \ - bistro/libucm_la-bistro_ppc64.lo $(am__objects_1) - libucm_la_OBJECTS = $(am_libucm_la_OBJECTS) - AM_V_lt = $(am__v_lt_@AM_V@) -@@ -264,7 +265,7 @@ am__noinst_HEADERS_DIST = event/event.h malloc/malloc_hook.h \ - util/replace.h util/log.h util/reloc.h util/sys.h \ - bistro/bistro_int.h bistro/bistro.h bistro/bistro_x86_64.h \ - bistro/bistro_aarch64.h bistro/bistro_ppc64.h \ -- ptmalloc286/malloc-2.8.6.h -+ bistro/bistro_loongarch64.h ptmalloc286/malloc-2.8.6.h - HEADERS = $(nobase_dist_libucm_la_HEADERS) $(noinst_HEADERS) - RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -@@ -568,11 +569,11 @@ noinst_HEADERS = event/event.h malloc/malloc_hook.h malloc/allocator.h \ - mmap/mmap.h util/khash_safe.h util/replace.h util/log.h \ - util/reloc.h util/sys.h bistro/bistro_int.h bistro/bistro.h \ - bistro/bistro_x86_64.h bistro/bistro_aarch64.h \ -- bistro/bistro_ppc64.h $(am__append_3) -+ bistro/bistro_ppc64.h bistro/bistro_loongarch64.h $(am__append_3) - libucm_la_SOURCES = event/event.c malloc/malloc_hook.c mmap/install.c \ - util/replace.c util/log.c util/reloc.c util/sys.c \ - bistro/bistro.c bistro/bistro_x86_64.c bistro/bistro_aarch64.c \ -- bistro/bistro_ppc64.c $(am__append_2) -+ bistro/bistro_ppc64.c bistro/bistro_loongarch64.c $(am__append_2) - all: all-recursive - - .SUFFIXES: -@@ -692,6 +693,8 @@ bistro/libucm_la-bistro_x86_64.lo: bistro/$(am__dirstamp) \ - bistro/$(DEPDIR)/$(am__dirstamp) - bistro/libucm_la-bistro_aarch64.lo: bistro/$(am__dirstamp) \ - bistro/$(DEPDIR)/$(am__dirstamp) -+bistro/libucm_la-bistro_loongarch64.lo: bistro/$(am__dirstamp) \ -+ bistro/$(DEPDIR)/$(am__dirstamp) - bistro/libucm_la-bistro_ppc64.lo: bistro/$(am__dirstamp) \ - bistro/$(DEPDIR)/$(am__dirstamp) - ptmalloc286/$(am__dirstamp): -@@ -726,6 +729,7 @@ distclean-compile: - - @AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro_aarch64.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro_loongarch64.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro_ppc64.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro_x86_64.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libucm_la-event.Plo@am__quote@ -@@ -831,6 +835,13 @@ bistro/libucm_la-bistro_aarch64.lo: bistro/bistro_aarch64.c - @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucm_la_CPPFLAGS) $(CPPFLAGS) $(libucm_la_CFLAGS) $(CFLAGS) -c -o bistro/libucm_la-bistro_aarch64.lo `test -f 'bistro/bistro_aarch64.c' || echo '$(srcdir)/'`bistro/bistro_aarch64.c - -+bistro/libucm_la-bistro_loongarch64.lo: bistro/bistro_loongarch64.c -+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucm_la_CPPFLAGS) $(CPPFLAGS) $(libucm_la_CFLAGS) $(CFLAGS) -MT bistro/libucm_la-bistro_loongarch64.lo -MD -MP -MF bistro/$(DEPDIR)/libucm_la-bistro_loongarch64.Tpo -c -o bistro/libucm_la-bistro_loongarch64.lo `test -f 'bistro/bistro_loongarch64.c' || echo '$(srcdir)/'`bistro/bistro_loongarch64.c -+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bistro/$(DEPDIR)/libucm_la-bistro_loongarch64.Tpo bistro/$(DEPDIR)/libucm_la-bistro_loongarch64.Plo -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bistro/bistro_loongarch64.c' object='bistro/libucm_la-bistro_loongarch64.lo' libtool=yes @AMDEPBACKSLASH@ -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucm_la_CPPFLAGS) $(CPPFLAGS) $(libucm_la_CFLAGS) $(CFLAGS) -c -o bistro/libucm_la-bistro_loongarch64.lo `test -f 'bistro/bistro_loongarch64.c' || echo '$(srcdir)/'`bistro/bistro_loongarch64.c -+ - bistro/libucm_la-bistro_ppc64.lo: bistro/bistro_ppc64.c - @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucm_la_CPPFLAGS) $(CPPFLAGS) $(libucm_la_CFLAGS) $(CFLAGS) -MT bistro/libucm_la-bistro_ppc64.lo -MD -MP -MF bistro/$(DEPDIR)/libucm_la-bistro_ppc64.Tpo -c -o bistro/libucm_la-bistro_ppc64.lo `test -f 'bistro/bistro_ppc64.c' || echo '$(srcdir)/'`bistro/bistro_ppc64.c - @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bistro/$(DEPDIR)/libucm_la-bistro_ppc64.Tpo bistro/$(DEPDIR)/libucm_la-bistro_ppc64.Plo -diff --git a/src/ucm/bistro/bistro.c b/src/ucm/bistro/bistro.c -index acc62fd..e7ae23f 100644 ---- a/src/ucm/bistro/bistro.c -+++ b/src/ucm/bistro/bistro.c -@@ -63,7 +63,7 @@ ucs_status_t ucm_bistro_apply_patch(void *dst, void *patch, size_t len) - return status; - } - --#if defined(__x86_64__) || defined (__aarch64__) -+#if defined(__x86_64__) || defined (__aarch64__) || defined (__loongarch__) - struct ucm_bistro_restore_point { - void *addr; /* address of function to restore */ - size_t patch_len; /* patch length */ -diff --git a/src/ucm/bistro/bistro.h b/src/ucm/bistro/bistro.h -index b622e3c..4b0bfbb 100644 ---- a/src/ucm/bistro/bistro.h -+++ b/src/ucm/bistro/bistro.h -@@ -20,6 +20,8 @@ typedef struct ucm_bistro_restore_point ucm_bistro_restore_point_t; - # include "bistro_aarch64.h" - #elif defined(__x86_64__) - # include "bistro_x86_64.h" -+#elif defined(__loongarch__) -+# include "bistro_loongarch64.h" - #else - # error "Unsupported architecture" - #endif -diff --git a/src/ucm/bistro/bistro_loongarch64.c b/src/ucm/bistro/bistro_loongarch64.c -new file mode 100644 -index 0000000..5c62717 ---- /dev/null -+++ b/src/ucm/bistro/bistro_loongarch64.c -@@ -0,0 +1,85 @@ -+/** -+ * Copyright (C) Mellanox Technologies Ltd. 2018. ALL RIGHTS RESERVED. -+ * -+ * See file LICENSE for terms. -+ */ -+ -+#ifdef HAVE_CONFIG_H -+# include "config.h" -+#endif -+ -+/* ******************************************************* -+ * LOONGARCH64 processors family * -+ * ***************************************************** */ -+#if defined(__loongarch__) -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+ -+/* Register number used to store indirect jump address. -+ * r20 is the highest numbered temporary register, assuming this one is safe -+ * to use. */ -+#define R20 20 -+ -+/** -+ * @brief Generate a mov immediate instruction -+ * -+ * @param[in] _rd, _rj register number (0-31) -+ * @param[in] _si20, _si20 signed mmediate value 20, 12 bits -+ * @param[in] _ui12 immediate value -+ */ -+#define LU12I_W(_rd, _si20) \ -+ ((10 << 25) + (((_si20) & 0xfffff) << 5) + (_rd)) -+ -+#define LU32I_D(_rd, _si20) \ -+ (((22 >> 1) << 25) + (((_si20) & 0xfffff) << 5) + (_rd)) -+ -+#define LU52I_D(_rd, _rj, _si12) \ -+ (((48 >> 2) << 22) + (((_si12) & 0xfff) << 10) + ((_rj) << 5) + (_rd)) -+ -+#define ORI(_rd, _rj, _ui12) \ -+ (((56 >> 2) << 22) + (((_ui12) & 0xfff) << 10) + ((_rj) << 5) + (_rd)) -+ -+#define JIRL(_rd, _rj, _offs) \ -+ ((19 << 26) + ((_offs) << 10) + ((_rj) << 5) + (_rd)) -+ -+ucs_status_t ucm_bistro_patch(void *func_ptr, void *hook, const char *symbol, -+ void **orig_func_p, -+ ucm_bistro_restore_point_t **rp) -+{ -+ ucm_bistro_patch_t patch = { -+ .lu12i = LU12I_W(R20, (uintptr_t)hook >> 12), -+ .ori = ORI(R20, R20, (uintptr_t)hook), -+ .lu32i = LU32I_D(R20, (uintptr_t)hook >> 32), -+ .lu52i = LU52I_D(R20, R20, (uintptr_t)hook >> 52), -+ .jirl = JIRL(0, R20, 0) -+ }; -+ ucs_status_t status; -+ -+ if (orig_func_p != NULL) { -+ return UCS_ERR_UNSUPPORTED; -+ } -+ -+ status = ucm_bistro_create_restore_point(func_ptr, sizeof(patch), rp); -+ if (UCS_STATUS_IS_ERR(status)) { -+ return status; -+ } -+ -+ return ucm_bistro_apply_patch(func_ptr, &patch, sizeof(patch)); -+} -+ -+ucs_status_t ucm_bistro_relocate_one(ucm_bistro_relocate_context_t *ctx) -+{ -+ return UCS_ERR_UNSUPPORTED; -+} -+#endif -diff --git a/src/ucm/bistro/bistro_loongarch64.h b/src/ucm/bistro/bistro_loongarch64.h -new file mode 100644 -index 0000000..bbc6c0f ---- /dev/null -+++ b/src/ucm/bistro/bistro_loongarch64.h -@@ -0,0 +1,46 @@ -+/** -+ * Copyright (C) Mellanox Technologies Ltd. 2018. ALL RIGHTS RESERVED. -+ * -+ * See file LICENSE for terms. -+ */ -+ -+ -+#ifndef UCM_BISTRO_BISTRO_LOONGARCH64_H_ -+#define UCM_BISTRO_BISTRO_LOONGARCH64_H_ -+ -+#include -+ -+#include -+#include -+ -+#define UCM_BISTRO_PROLOGUE -+#define UCM_BISTRO_EPILOGUE -+ -+typedef struct ucm_bistro_patch { -+ uint32_t lu12i; /* lu12i.w r20, addr >> 12 */ -+ uint32_t ori; /* ori r20, r20, addr */ -+ uint32_t lu32i; /* lu32i.d r20, r20, addr >> 32 */ -+ uint32_t lu52i; /* lu52i.d r20, r20, addr >> 52*/ -+ uint32_t jirl; /* jirl 0, r20, 0 */ -+} UCS_S_PACKED ucm_bistro_patch_t; -+ -+/** -+ * Set library function call hook using Binary Instrumentation -+ * method (BISTRO): replace function body by user defined call -+ * -+ * @param func_ptr Pointer to function to patch. -+ * @param hook User-defined function-replacer. -+ * @param symbol Function name to replace. -+ * @param orig_func_p Unsupported on this architecture and must be NULL. -+ * If set to a non-NULL value, this function returns -+ * @ref UCS_ERR_UNSUPPORTED. -+ * @param rp Restore point used to restore original function. -+ * Optional, may be NULL. -+ * -+ * @return Error code as defined by @ref ucs_status_t -+ */ -+ucs_status_t ucm_bistro_patch(void *func_ptr, void *hook, const char *symbol, -+ void **orig_func_p, -+ ucm_bistro_restore_point_t **rp); -+ -+#endif -diff --git a/src/ucs/Makefile.am b/src/ucs/Makefile.am -index 9e0bd2f..cf39678 100644 ---- a/src/ucs/Makefile.am -+++ b/src/ucs/Makefile.am -@@ -22,6 +22,7 @@ libucs_la_LIBADD = $(LIBM) $(top_builddir)/src/ucm/libucm.la $(BFD_LIBS) - nobase_dist_libucs_la_HEADERS = \ - arch/aarch64/bitops.h \ - arch/ppc64/bitops.h \ -+ arch/loongarch64/bitops.h \ - arch/x86_64/bitops.h \ - arch/bitops.h \ - algorithm/crc.h \ -@@ -80,12 +81,14 @@ nobase_dist_libucs_la_HEADERS = \ - arch/x86_64/global_opts.h \ - arch/x86_64/atomic.h \ - arch/aarch64/global_opts.h \ -+ arch/loongarch64/global_opts.h \ - arch/generic/atomic.h \ - arch/ppc64/global_opts.h \ - arch/global_opts.h - - noinst_HEADERS = \ - arch/aarch64/cpu.h \ -+ arch/loongarch64/cpu.h \ - arch/generic/cpu.h \ - arch/ppc64/cpu.h \ - arch/x86_64/cpu.h \ -@@ -138,6 +141,7 @@ libucs_la_SOURCES = \ - algorithm/string_distance.c \ - arch/aarch64/cpu.c \ - arch/aarch64/global_opts.c \ -+ arch/loongarch64/global_opts.c \ - arch/ppc64/timebase.c \ - arch/ppc64/global_opts.c \ - arch/x86_64/cpu.c \ -diff --git a/src/ucs/Makefile.in b/src/ucs/Makefile.in -index 053d70a..5cb387e 100644 ---- a/src/ucs/Makefile.in -+++ b/src/ucs/Makefile.in -@@ -202,6 +202,7 @@ am__libucs_la_SOURCES_DIST = algorithm/crc.c algorithm/qsort_r.c \ - arch/aarch64/global_opts.c arch/ppc64/timebase.c \ - arch/ppc64/global_opts.c arch/x86_64/cpu.c \ - arch/x86_64/global_opts.c arch/cpu.c async/async.c \ -+ arch/loongarch64/global_opts.c \ - async/signal.c async/pipe.c async/eventfd.c async/thread.c \ - config/global_opts.c config/ucm_opts.c config/ini.c \ - config/parser.c datastruct/arbiter.c datastruct/array.c \ -@@ -231,6 +232,7 @@ am_libucs_la_OBJECTS = algorithm/libucs_la-crc.lo \ - algorithm/libucs_la-string_distance.lo \ - arch/aarch64/libucs_la-cpu.lo \ - arch/aarch64/libucs_la-global_opts.lo \ -+ arch/loongarch64/libucs_la-global_opts.lo \ - arch/ppc64/libucs_la-timebase.lo \ - arch/ppc64/libucs_la-global_opts.lo \ - arch/x86_64/libucs_la-cpu.lo \ -@@ -643,6 +645,7 @@ libucs_ladir = $(includedir)/ucs - libucs_la_LIBADD = $(LIBM) $(top_builddir)/src/ucm/libucm.la $(BFD_LIBS) - nobase_dist_libucs_la_HEADERS = \ - arch/aarch64/bitops.h \ -+ arch/loongarch64/bitops.h \ - arch/ppc64/bitops.h \ - arch/x86_64/bitops.h \ - arch/bitops.h \ -@@ -702,12 +705,14 @@ nobase_dist_libucs_la_HEADERS = \ - arch/x86_64/global_opts.h \ - arch/x86_64/atomic.h \ - arch/aarch64/global_opts.h \ -+ arch/loongarch64/global_opts.h \ - arch/generic/atomic.h \ - arch/ppc64/global_opts.h \ - arch/global_opts.h - - noinst_HEADERS = \ - arch/aarch64/cpu.h \ -+ arch/loongarch64/cpu.h \ - arch/generic/cpu.h \ - arch/ppc64/cpu.h \ - arch/x86_64/cpu.h \ -@@ -759,6 +764,7 @@ libucs_la_SOURCES = algorithm/crc.c algorithm/qsort_r.c \ - arch/aarch64/global_opts.c arch/ppc64/timebase.c \ - arch/ppc64/global_opts.c arch/x86_64/cpu.c \ - arch/x86_64/global_opts.c arch/cpu.c async/async.c \ -+ arch/loongarch64/global_opts.c \ - async/signal.c async/pipe.c async/eventfd.c async/thread.c \ - config/global_opts.c config/ucm_opts.c config/ini.c \ - config/parser.c datastruct/arbiter.c datastruct/array.c \ -@@ -878,6 +884,16 @@ arch/aarch64/libucs_la-cpu.lo: arch/aarch64/$(am__dirstamp) \ - arch/aarch64/$(DEPDIR)/$(am__dirstamp) - arch/aarch64/libucs_la-global_opts.lo: arch/aarch64/$(am__dirstamp) \ - arch/aarch64/$(DEPDIR)/$(am__dirstamp) -+arch/loongarch64/$(am__dirstamp): -+ @$(MKDIR_P) arch/loongarch64 -+ @: > arch/loongarch64/$(am__dirstamp) -+arch/loongarch64/$(DEPDIR)/$(am__dirstamp): -+ @$(MKDIR_P) arch/loongarch64/$(DEPDIR) -+ @: > arch/loongarch64/$(DEPDIR)/$(am__dirstamp) -+arch/loongarch64/libucs_la-cpu.lo: arch/loongarch64/$(am__dirstamp) \ -+ arch/loongarch64/$(DEPDIR)/$(am__dirstamp) -+arch/loongarch64/libucs_la-global_opts.lo: arch/loongarch64/$(am__dirstamp) \ -+ arch/loongarch64/$(DEPDIR)/$(am__dirstamp) - arch/ppc64/$(am__dirstamp): - @$(MKDIR_P) arch/ppc64 - @: > arch/ppc64/$(am__dirstamp) -@@ -1164,6 +1180,8 @@ mostlyclean-compile: - -rm -f arch/*.lo - -rm -f arch/aarch64/*.$(OBJEXT) - -rm -f arch/aarch64/*.lo -+ -rm -f arch/loongarch64/*.$(OBJEXT) -+ -rm -f arch/loongarch64/*.lo - -rm -f arch/ppc64/*.$(OBJEXT) - -rm -f arch/ppc64/*.lo - -rm -f arch/x86_64/*.$(OBJEXT) -@@ -1203,6 +1221,7 @@ distclean-compile: - @AMDEP_TRUE@@am__include@ @am__quote@arch/aarch64/$(DEPDIR)/libucs_la-cpu.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@arch/aarch64/$(DEPDIR)/libucs_la-global_opts.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@arch/aarch64/$(DEPDIR)/libucs_la-memcpy_thunderx2.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@arch/loongarch64/$(DEPDIR)/libucs_la-global_opts.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@arch/ppc64/$(DEPDIR)/libucs_la-global_opts.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@arch/ppc64/$(DEPDIR)/libucs_la-timebase.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@arch/x86_64/$(DEPDIR)/libucs_la-cpu.Plo@am__quote@ -@@ -1357,6 +1376,13 @@ arch/aarch64/libucs_la-global_opts.lo: arch/aarch64/global_opts.c - @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucs_la_CPPFLAGS) $(CPPFLAGS) $(libucs_la_CFLAGS) $(CFLAGS) -c -o arch/aarch64/libucs_la-global_opts.lo `test -f 'arch/aarch64/global_opts.c' || echo '$(srcdir)/'`arch/aarch64/global_opts.c - -+arch/loongarch64/libucs_la-global_opts.lo: arch/loongarch64/global_opts.c -+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucs_la_CPPFLAGS) $(CPPFLAGS) $(libucs_la_CFLAGS) $(CFLAGS) -MT arch/loongarch64/libucs_la-global_opts.lo -MD -MP -MF arch/loongarch64/$(DEPDIR)/libucs_la-global_opts.Tpo -c -o arch/loongarch64/libucs_la-global_opts.lo `test -f 'arch/loongarch64/global_opts.c' || echo '$(srcdir)/'`arch/loongarch64/global_opts.c -+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) arch/loongarch64/$(DEPDIR)/libucs_la-global_opts.Tpo arch/loongarch64/$(DEPDIR)/libucs_la-global_opts.Plo -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='arch/loongarch64/global_opts.c' object='arch/loongarch64/libucs_la-global_opts.lo' libtool=yes @AMDEPBACKSLASH@ -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucs_la_CPPFLAGS) $(CPPFLAGS) $(libucs_la_CFLAGS) $(CFLAGS) -c -o arch/loongarch64/libucs_la-global_opts.lo `test -f 'arch/loongarch64/global_opts.c' || echo '$(srcdir)/'`arch/loongarch64/global_opts.c -+ - arch/ppc64/libucs_la-timebase.lo: arch/ppc64/timebase.c - @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucs_la_CPPFLAGS) $(CPPFLAGS) $(libucs_la_CFLAGS) $(CFLAGS) -MT arch/ppc64/libucs_la-timebase.lo -MD -MP -MF arch/ppc64/$(DEPDIR)/libucs_la-timebase.Tpo -c -o arch/ppc64/libucs_la-timebase.lo `test -f 'arch/ppc64/timebase.c' || echo '$(srcdir)/'`arch/ppc64/timebase.c - @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) arch/ppc64/$(DEPDIR)/libucs_la-timebase.Tpo arch/ppc64/$(DEPDIR)/libucs_la-timebase.Plo -@@ -1820,6 +1846,7 @@ clean-libtool: - -rm -rf algorithm/.libs algorithm/_libs - -rm -rf arch/.libs arch/_libs - -rm -rf arch/aarch64/.libs arch/aarch64/_libs -+ -rm -rf arch/loongarch64/.libs arch/loongarch64/_libs - -rm -rf arch/ppc64/.libs arch/ppc64/_libs - -rm -rf arch/x86_64/.libs arch/x86_64/_libs - -rm -rf async/.libs async/_libs -@@ -2077,6 +2104,8 @@ distclean-generic: - -rm -f arch/$(am__dirstamp) - -rm -f arch/aarch64/$(DEPDIR)/$(am__dirstamp) - -rm -f arch/aarch64/$(am__dirstamp) -+ -rm -f arch/loongarch64/$(DEPDIR)/$(am__dirstamp) -+ -rm -f arch/loongarch64/$(am__dirstamp) - -rm -f arch/ppc64/$(DEPDIR)/$(am__dirstamp) - -rm -f arch/ppc64/$(am__dirstamp) - -rm -f arch/x86_64/$(DEPDIR)/$(am__dirstamp) -@@ -2115,7 +2144,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ - clean-libtool mostlyclean-am - - distclean: distclean-recursive -- -rm -rf algorithm/$(DEPDIR) arch/$(DEPDIR) arch/aarch64/$(DEPDIR) arch/ppc64/$(DEPDIR) arch/x86_64/$(DEPDIR) async/$(DEPDIR) config/$(DEPDIR) datastruct/$(DEPDIR) debug/$(DEPDIR) memory/$(DEPDIR) profile/$(DEPDIR) stats/$(DEPDIR) sys/$(DEPDIR) sys/topo/base/$(DEPDIR) time/$(DEPDIR) type/$(DEPDIR) vfs/base/$(DEPDIR) -+ -rm -rf algorithm/$(DEPDIR) arch/$(DEPDIR) arch/aarch64/$(DEPDIR) arch/loongarch64/$(DEPDIR) arch/ppc64/$(DEPDIR) arch/x86_64/$(DEPDIR) async/$(DEPDIR) config/$(DEPDIR) datastruct/$(DEPDIR) debug/$(DEPDIR) memory/$(DEPDIR) profile/$(DEPDIR) stats/$(DEPDIR) sys/$(DEPDIR) sys/topo/base/$(DEPDIR) time/$(DEPDIR) type/$(DEPDIR) vfs/base/$(DEPDIR) - -rm -f Makefile - distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags -@@ -2162,7 +2191,7 @@ install-ps-am: - installcheck-am: - - maintainer-clean: maintainer-clean-recursive -- -rm -rf algorithm/$(DEPDIR) arch/$(DEPDIR) arch/aarch64/$(DEPDIR) arch/ppc64/$(DEPDIR) arch/x86_64/$(DEPDIR) async/$(DEPDIR) config/$(DEPDIR) datastruct/$(DEPDIR) debug/$(DEPDIR) memory/$(DEPDIR) profile/$(DEPDIR) stats/$(DEPDIR) sys/$(DEPDIR) sys/topo/base/$(DEPDIR) time/$(DEPDIR) type/$(DEPDIR) vfs/base/$(DEPDIR) -+ -rm -rf algorithm/$(DEPDIR) arch/$(DEPDIR) arch/aarch64/$(DEPDIR) arch/loongarch64/$(DEPDIR) arch/ppc64/$(DEPDIR) arch/x86_64/$(DEPDIR) async/$(DEPDIR) config/$(DEPDIR) datastruct/$(DEPDIR) debug/$(DEPDIR) memory/$(DEPDIR) profile/$(DEPDIR) stats/$(DEPDIR) sys/$(DEPDIR) sys/topo/base/$(DEPDIR) time/$(DEPDIR) type/$(DEPDIR) vfs/base/$(DEPDIR) - -rm -f Makefile - maintainer-clean-am: distclean-am maintainer-clean-generic - -diff --git a/src/ucs/arch/atomic.h b/src/ucs/arch/atomic.h -index 52be711..6b53cb3 100644 ---- a/src/ucs/arch/atomic.h -+++ b/src/ucs/arch/atomic.h -@@ -15,6 +15,8 @@ - # include "generic/atomic.h" - #elif defined(__aarch64__) - # include "generic/atomic.h" -+#elif defined(__loongarch__) -+# include "generic/atomic.h" - #else - # error "Unsupported architecture" - #endif -diff --git a/src/ucs/arch/bitops.h b/src/ucs/arch/bitops.h -index e89a37d..7047a46 100644 ---- a/src/ucs/arch/bitops.h -+++ b/src/ucs/arch/bitops.h -@@ -20,6 +20,8 @@ BEGIN_C_DECLS - # include "ppc64/bitops.h" - #elif defined(__aarch64__) - # include "aarch64/bitops.h" -+#elif defined(__loongarch__) -+# include "loongarch64/bitops.h" - #else - # error "Unsupported architecture" - #endif -diff --git a/src/ucs/arch/cpu.h b/src/ucs/arch/cpu.h -index a59561c..727ffc8 100644 ---- a/src/ucs/arch/cpu.h -+++ b/src/ucs/arch/cpu.h -@@ -98,6 +98,8 @@ typedef struct ucs_cpu_builtin_memcpy { - # include "ppc64/cpu.h" - #elif defined(__aarch64__) - # include "aarch64/cpu.h" -+#elif defined(__loongarch__) -+# include "loongarch64/cpu.h" - #else - # error "Unsupported architecture" - #endif -diff --git a/src/ucs/arch/global_opts.h b/src/ucs/arch/global_opts.h -index 75d0861..c8ad5b8 100644 ---- a/src/ucs/arch/global_opts.h -+++ b/src/ucs/arch/global_opts.h -@@ -15,6 +15,8 @@ - # include "ppc64/global_opts.h" - #elif defined(__aarch64__) - # include "aarch64/global_opts.h" -+#elif defined(__loongarch__) -+# include "loongarch64/global_opts.h" - #else - # error "Unsupported architecture" - #endif -diff --git a/src/ucs/arch/loongarch64/bitops.h b/src/ucs/arch/loongarch64/bitops.h -new file mode 100644 -index 0000000..86ad7f1 ---- /dev/null -+++ b/src/ucs/arch/loongarch64/bitops.h -@@ -0,0 +1,42 @@ -+/** -+* Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED. -+* -+* See file LICENSE for terms. -+*/ -+ -+#ifndef UCS_LOONGARCH64_BITOPS_H_ -+#define UCS_LOONGARCH64_BITOPS_H_ -+ -+#include -+#include -+ -+ -+static UCS_F_ALWAYS_INLINE unsigned __ucs_ilog2_u32(uint32_t n) -+{ -+ int bit; -+ asm ("clz.w %0,%1" : "=r" (bit) : "r" (n)); -+ return 31 - bit; -+} -+ -+static UCS_F_ALWAYS_INLINE unsigned __ucs_ilog2_u64(uint64_t n) -+{ -+ int bit; -+ asm ("clz.d %0,%1" : "=r" (bit) : "r" (n)); -+ return 63 - bit; -+} -+ -+static UCS_F_ALWAYS_INLINE unsigned ucs_ffs32(uint32_t n) -+{ -+ int bit; -+ asm ("ctz.w %0,%1" : "=r" (bit) : "r" (n)); -+ return 31 - bit; -+} -+ -+static UCS_F_ALWAYS_INLINE unsigned ucs_ffs64(uint64_t n) -+{ -+ int bit; -+ asm ("ctz.d %0,%1" : "=r" (bit) : "r" (n)); -+ return 63 - bit; -+} -+ -+#endif -diff --git a/src/ucs/arch/loongarch64/cpu.h b/src/ucs/arch/loongarch64/cpu.h -new file mode 100644 -index 0000000..51b153b ---- /dev/null -+++ b/src/ucs/arch/loongarch64/cpu.h -@@ -0,0 +1,101 @@ -+/** -+* Copyright (C) Mellanox Technologies Ltd. 2001-2013. ALL RIGHTS RESERVED. -+* Copyright (C) ARM Ltd. 2016-2017. ALL RIGHTS RESERVED. -+* -+* See file LICENSE for terms. -+*/ -+ -+ -+#ifndef UCS_LOONGARCH64_CPU_H_ -+#define UCS_LOONGARCH64_CPU_H_ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+BEGIN_C_DECLS -+ -+/** @file cpu.h */ -+ -+#define UCS_ARCH_CACHE_LINE_SIZE 64 -+ -+/* Assume the worst - weak memory ordering */ -+#define ucs_memory_bus_fence() asm volatile ("dbar 0"::: "memory") -+#define ucs_memory_bus_store_fence() ucs_memory_bus_fence() -+#define ucs_memory_bus_load_fence() ucs_memory_bus_fence() -+#define ucs_memory_bus_cacheline_wc_flush() -+#define ucs_memory_cpu_fence() ucs_memory_bus_fence() -+#define ucs_memory_cpu_store_fence() asm volatile ("dbar 0 \n" \ -+ ::: "memory") -+#define ucs_memory_cpu_load_fence() asm volatile ("dbar 0 \n" \ -+ "dbar 0 \n" \ -+ ::: "memory") -+#define ucs_memory_cpu_wc_fence() ucs_memory_bus_fence() -+ -+ -+static inline uint64_t ucs_arch_read_hres_clock() -+{ -+ uint64_t tb; -+ __drdtime_t tsc; -+ tsc = __rdtime_d(); -+ tb = tsc.dvalue; -+ return tb; -+} -+ -+static inline double ucs_arch_get_clocks_per_sec() { -+ uint64_t freq; -+ freq = 100 * 1000 * 1000; -+ return (double) freq; -+} -+ -+static inline ucs_cpu_model_t ucs_arch_get_cpu_model() -+{ -+ return UCS_CPU_MODEL_UNKNOWN; -+} -+ -+static inline ucs_cpu_vendor_t ucs_arch_get_cpu_vendor() -+{ -+ return UCS_CPU_VENDOR_UNKNOWN; -+} -+ -+static inline int ucs_arch_get_cpu_flag() -+{ -+ return UCS_CPU_FLAG_UNKNOWN; -+} -+ -+static inline void ucs_cpu_init() -+{ -+} -+ -+#define ucs_arch_wait_mem ucs_arch_generic_wait_mem -+ -+#if !HAVE___CLEAR_CACHE -+static inline void ucs_arch_clear_cache(void *start, void *end) -+{ -+ ucs_memory_cpu_fence(); -+} -+#endif -+ -+static inline void *ucs_memcpy_relaxed(void *dst, const void *src, size_t len) -+{ -+ return memcpy(dst, src, len); -+} -+ -+static UCS_F_ALWAYS_INLINE void -+ucs_memcpy_nontemporal(void *dst, const void *src, size_t len) -+{ -+ memcpy(dst, src, len); -+} -+ -+static inline ucs_status_t ucs_arch_get_cache_size(size_t *cache_sizes) -+{ -+ return UCS_ERR_UNSUPPORTED; -+} -+ -+END_C_DECLS -+ -+#endif -diff --git a/src/ucs/arch/loongarch64/global_opts.c b/src/ucs/arch/loongarch64/global_opts.c -new file mode 100644 -index 0000000..17f7a2a ---- /dev/null -+++ b/src/ucs/arch/loongarch64/global_opts.c -@@ -0,0 +1,24 @@ -+/** -+* Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED. -+* -+* See file LICENSE for terms. -+*/ -+ -+#if defined(__loongarch__) -+ -+#ifdef HAVE_CONFIG_H -+# include "config.h" -+#endif -+ -+#include -+#include -+ -+ucs_config_field_t ucs_arch_global_opts_table[] = { -+ {NULL} -+}; -+ -+void ucs_arch_print_memcpy_limits(ucs_arch_global_opts_t *config) -+{ -+} -+ -+#endif -diff --git a/src/ucs/arch/loongarch64/global_opts.h b/src/ucs/arch/loongarch64/global_opts.h -new file mode 100644 -index 0000000..b43786c ---- /dev/null -+++ b/src/ucs/arch/loongarch64/global_opts.h -@@ -0,0 +1,24 @@ -+/** -+* Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED. -+* -+* See file LICENSE for terms. -+*/ -+ -+ -+#ifndef UCS_LOONGARCH64_GLOBAL_OPTS_H_ -+#define UCS_LOONGARCH64_GLOBAL_OPTS_H_ -+ -+#include -+ -+BEGIN_C_DECLS -+ -+#define UCS_ARCH_GLOBAL_OPTS_INITALIZER {} -+ -+/* built-in memcpy config */ -+typedef struct ucs_arch_global_opts { -+ char dummy; -+} ucs_arch_global_opts_t; -+ -+END_C_DECLS -+ -+#endif --- -2.39.3 - diff --git a/download b/download index 552e7a6..37c70f0 100644 --- a/download +++ b/download @@ -1 +1 @@ -3dbdd26e95af9713e3101fffaf67a647 ucx-1.14.1.tar.gz +bb141973027ba522b397f89272681cee ucx-1.15.0.tar.gz diff --git a/ucx.spec b/ucx.spec index a2e27c3..c3dca96 100644 --- a/ucx.spec +++ b/ucx.spec @@ -1,4 +1,3 @@ -%define anolis_release .0.1 %{!?configure_options: %global configure_options %{nil}} %bcond_without cma %bcond_with cuda @@ -17,21 +16,19 @@ %bcond_with vfs Name: ucx -Version: 1.14.1 -Release: 1%{anolis_release}%{?dist}.1 +Version: 1.15.0 +Release: 2%{?dist} Summary: UCX is a communication library implementing high-performance messaging License: BSD URL: http://www.openucx.org Source: https://github.com/openucx/%{name}/releases/download/v%{version}/ucx-%{version}.tar.gz -Patch0001: 0001-add-loongarch64-support-for-ucx.patch - BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) Prefix: %{_prefix} # UCX currently supports only the following architectures -ExclusiveArch: aarch64 ppc64le x86_64 loongarch64 +ExclusiveArch: aarch64 ppc64le x86_64 %if %{defined extra_deps} Requires: %{?extra_deps} @@ -94,7 +91,7 @@ Provides header files and examples for developing with UCX. %prep %setup -q -%patch0001 -p1 + %build %define _with_arg() %{expand:%%{?with_%{1}:--with-%{2}}%%{!?with_%{1}:--without-%{2}}} %define _enable_arg() %{expand:%%{?with_%{1}:--enable-%{2}}%%{!?with_%{1}:--disable-%{2}}} @@ -104,9 +101,6 @@ Provides header files and examples for developing with UCX. --disable-assertions \ --disable-params-check \ --without-java \ -%ifarch loongarch64 - --without-go \ -%endif %_enable_arg cma cma \ %_with_arg cuda cuda \ %_with_arg gdrcopy gdrcopy \ @@ -238,6 +232,7 @@ for large messages. %if %{with rdmacm} %package rdmacm Requires: %{name}-ib%{?_isa} = %{version}-%{release} +Requires: %{name}%{?_isa} = %{version}-%{release} Summary: UCX RDMA connection manager support %description rdmacm @@ -314,15 +309,22 @@ library internals, protocol objects, transports status, and more. %endif %changelog -* Thu Jan 11 2024 Wenlong Zhang - 1.14.1-1.0.1 -- Update to 1.14.1 - Add loongarch64 support for ucx - -* Thu Jul 27 2023 Jingyun Hua - 1.13.1-2.0.2 -- Fix build error on loongarch64 - -* Tue Jul 04 2023 Jacob Wang - 1.13.1-2.0.1 -- Add support for loongarch64 (gongwen@nfschina.com) +* Thu Nov 09 2023 Kamal Heib - 1.15.0-2 +- Fix requirement error +- Resolves: RHEL-932 + +* Tue Nov 07 2023 Kamal Heib - 1.15.0-1 +- Update to upstream release 1.15.0 +- Resolves: RHEL-932 + +* Wed Jun 07 2023 Kamal Heib - 1.14.1-1.1 +- Fix rpmdeps issue. +- Resolves: rhbz#2170072 + +* Fri Jun 02 2023 Kamal Heib - 1.14.1-1 +- Update to upstream release 1.14.1 +- Add gating tests +- Resolves: rhbz#2170072 * Wed Feb 08 2023 Michal Schmidt - 1.13.1-2 - Update to upstream release 1.13.1 -- Gitee From b080af549f79bd0dab68484e053bf7b0752a745a Mon Sep 17 00:00:00 2001 From: Wenlong Zhang Date: Thu, 11 Jan 2024 09:09:49 +0000 Subject: [PATCH 2/2] add loongarch64 support for ucx --- 0001-add-loongarch64-support-for-ucx.patch | 749 +++++++++++++++++++++ ucx.spec | 15 +- 2 files changed, 761 insertions(+), 3 deletions(-) create mode 100644 0001-add-loongarch64-support-for-ucx.patch diff --git a/0001-add-loongarch64-support-for-ucx.patch b/0001-add-loongarch64-support-for-ucx.patch new file mode 100644 index 0000000..d4a4df5 --- /dev/null +++ b/0001-add-loongarch64-support-for-ucx.patch @@ -0,0 +1,749 @@ +From 17c06e6237067219e88ac7d43e962a1a0e46bbb4 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang + liuzhilin +Date: Thu, 11 Jan 2024 08:32:58 +0000 +Subject: [PATCH] add loongarch64 support for ucx + +--- + config.guess | 3 + + src/ucm/Makefile.am | 2 + + src/ucm/Makefile.in | 19 ++++- + src/ucm/bistro/bistro.c | 2 +- + src/ucm/bistro/bistro.h | 2 + + src/ucm/bistro/bistro_loongarch64.c | 85 +++++++++++++++++++++ + src/ucm/bistro/bistro_loongarch64.h | 46 +++++++++++ + src/ucs/Makefile.am | 4 + + src/ucs/Makefile.in | 33 +++++++- + src/ucs/arch/atomic.h | 2 + + src/ucs/arch/bitops.h | 2 + + src/ucs/arch/cpu.h | 2 + + src/ucs/arch/global_opts.h | 2 + + src/ucs/arch/loongarch64/bitops.h | 42 ++++++++++ + src/ucs/arch/loongarch64/cpu.h | 101 +++++++++++++++++++++++++ + src/ucs/arch/loongarch64/global_opts.c | 24 ++++++ + src/ucs/arch/loongarch64/global_opts.h | 24 ++++++ + 17 files changed, 388 insertions(+), 7 deletions(-) + create mode 100644 src/ucm/bistro/bistro_loongarch64.c + create mode 100644 src/ucm/bistro/bistro_loongarch64.h + create mode 100644 src/ucs/arch/loongarch64/bitops.h + create mode 100644 src/ucs/arch/loongarch64/cpu.h + create mode 100644 src/ucs/arch/loongarch64/global_opts.c + create mode 100644 src/ucs/arch/loongarch64/global_opts.h + +diff --git a/config.guess b/config.guess +index b79252d..74933dc 100755 +--- a/config.guess ++++ b/config.guess +@@ -883,6 +883,9 @@ EOF + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; ++ loongarch64:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; +diff --git a/src/ucm/Makefile.am b/src/ucm/Makefile.am +index 48b82bf..75b9821 100644 +--- a/src/ucm/Makefile.am ++++ b/src/ucm/Makefile.am +@@ -31,6 +31,7 @@ noinst_HEADERS = \ + bistro/bistro.h \ + bistro/bistro_x86_64.h \ + bistro/bistro_aarch64.h \ ++ bistro/bistro_loongarch64.h \ + bistro/bistro_ppc64.h + + libucm_la_SOURCES = \ +@@ -44,6 +45,7 @@ libucm_la_SOURCES = \ + bistro/bistro.c \ + bistro/bistro_x86_64.c \ + bistro/bistro_aarch64.c \ ++ bistro/bistro_loongarch64.c \ + bistro/bistro_ppc64.c + + if HAVE_UCM_PTMALLOC286 +diff --git a/src/ucm/Makefile.in b/src/ucm/Makefile.in +index 1dd6749..7cc43f5 100644 +--- a/src/ucm/Makefile.in ++++ b/src/ucm/Makefile.in +@@ -191,7 +191,7 @@ am__libucm_la_SOURCES_DIST = event/event.c malloc/malloc_hook.c \ + mmap/install.c util/replace.c util/log.c util/reloc.c \ + util/sys.c bistro/bistro.c bistro/bistro_x86_64.c \ + bistro/bistro_aarch64.c bistro/bistro_ppc64.c \ +- ptmalloc286/malloc.c ++ bistro/bistro_loongarch64.c ptmalloc286/malloc.c + am__dirstamp = $(am__leading_dot)dirstamp + @HAVE_UCM_PTMALLOC286_TRUE@am__objects_1 = \ + @HAVE_UCM_PTMALLOC286_TRUE@ ptmalloc286/libucm_la-malloc.lo +@@ -201,6 +201,7 @@ am_libucm_la_OBJECTS = event/libucm_la-event.lo \ + util/libucm_la-reloc.lo util/libucm_la-sys.lo \ + bistro/libucm_la-bistro.lo bistro/libucm_la-bistro_x86_64.lo \ + bistro/libucm_la-bistro_aarch64.lo \ ++ bistro/libucm_la-bistro_loongarch64.lo \ + bistro/libucm_la-bistro_ppc64.lo $(am__objects_1) + libucm_la_OBJECTS = $(am_libucm_la_OBJECTS) + AM_V_lt = $(am__v_lt_@AM_V@) +@@ -264,7 +265,7 @@ am__noinst_HEADERS_DIST = event/event.h malloc/malloc_hook.h \ + util/replace.h util/log.h util/reloc.h util/sys.h \ + bistro/bistro_int.h bistro/bistro.h bistro/bistro_x86_64.h \ + bistro/bistro_aarch64.h bistro/bistro_ppc64.h \ +- ptmalloc286/malloc-2.8.6.h ++ bistro/bistro_loongarch64.h ptmalloc286/malloc-2.8.6.h + HEADERS = $(nobase_dist_libucm_la_HEADERS) $(noinst_HEADERS) + RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +@@ -568,11 +569,11 @@ noinst_HEADERS = event/event.h malloc/malloc_hook.h malloc/allocator.h \ + mmap/mmap.h util/khash_safe.h util/replace.h util/log.h \ + util/reloc.h util/sys.h bistro/bistro_int.h bistro/bistro.h \ + bistro/bistro_x86_64.h bistro/bistro_aarch64.h \ +- bistro/bistro_ppc64.h $(am__append_3) ++ bistro/bistro_ppc64.h bistro/bistro_loongarch64.h $(am__append_3) + libucm_la_SOURCES = event/event.c malloc/malloc_hook.c mmap/install.c \ + util/replace.c util/log.c util/reloc.c util/sys.c \ + bistro/bistro.c bistro/bistro_x86_64.c bistro/bistro_aarch64.c \ +- bistro/bistro_ppc64.c $(am__append_2) ++ bistro/bistro_ppc64.c bistro/bistro_loongarch64.c $(am__append_2) + all: all-recursive + + .SUFFIXES: +@@ -692,6 +693,8 @@ bistro/libucm_la-bistro_x86_64.lo: bistro/$(am__dirstamp) \ + bistro/$(DEPDIR)/$(am__dirstamp) + bistro/libucm_la-bistro_aarch64.lo: bistro/$(am__dirstamp) \ + bistro/$(DEPDIR)/$(am__dirstamp) ++bistro/libucm_la-bistro_loongarch64.lo: bistro/$(am__dirstamp) \ ++ bistro/$(DEPDIR)/$(am__dirstamp) + bistro/libucm_la-bistro_ppc64.lo: bistro/$(am__dirstamp) \ + bistro/$(DEPDIR)/$(am__dirstamp) + ptmalloc286/$(am__dirstamp): +@@ -726,6 +729,7 @@ distclean-compile: + + @AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro_aarch64.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro_loongarch64.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro_ppc64.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@bistro/$(DEPDIR)/libucm_la-bistro_x86_64.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/libucm_la-event.Plo@am__quote@ +@@ -831,6 +835,13 @@ bistro/libucm_la-bistro_aarch64.lo: bistro/bistro_aarch64.c + @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucm_la_CPPFLAGS) $(CPPFLAGS) $(libucm_la_CFLAGS) $(CFLAGS) -c -o bistro/libucm_la-bistro_aarch64.lo `test -f 'bistro/bistro_aarch64.c' || echo '$(srcdir)/'`bistro/bistro_aarch64.c + ++bistro/libucm_la-bistro_loongarch64.lo: bistro/bistro_loongarch64.c ++@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucm_la_CPPFLAGS) $(CPPFLAGS) $(libucm_la_CFLAGS) $(CFLAGS) -MT bistro/libucm_la-bistro_loongarch64.lo -MD -MP -MF bistro/$(DEPDIR)/libucm_la-bistro_loongarch64.Tpo -c -o bistro/libucm_la-bistro_loongarch64.lo `test -f 'bistro/bistro_loongarch64.c' || echo '$(srcdir)/'`bistro/bistro_loongarch64.c ++@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bistro/$(DEPDIR)/libucm_la-bistro_loongarch64.Tpo bistro/$(DEPDIR)/libucm_la-bistro_loongarch64.Plo ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bistro/bistro_loongarch64.c' object='bistro/libucm_la-bistro_loongarch64.lo' libtool=yes @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucm_la_CPPFLAGS) $(CPPFLAGS) $(libucm_la_CFLAGS) $(CFLAGS) -c -o bistro/libucm_la-bistro_loongarch64.lo `test -f 'bistro/bistro_loongarch64.c' || echo '$(srcdir)/'`bistro/bistro_loongarch64.c ++ + bistro/libucm_la-bistro_ppc64.lo: bistro/bistro_ppc64.c + @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucm_la_CPPFLAGS) $(CPPFLAGS) $(libucm_la_CFLAGS) $(CFLAGS) -MT bistro/libucm_la-bistro_ppc64.lo -MD -MP -MF bistro/$(DEPDIR)/libucm_la-bistro_ppc64.Tpo -c -o bistro/libucm_la-bistro_ppc64.lo `test -f 'bistro/bistro_ppc64.c' || echo '$(srcdir)/'`bistro/bistro_ppc64.c + @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bistro/$(DEPDIR)/libucm_la-bistro_ppc64.Tpo bistro/$(DEPDIR)/libucm_la-bistro_ppc64.Plo +diff --git a/src/ucm/bistro/bistro.c b/src/ucm/bistro/bistro.c +index acc62fd..e7ae23f 100644 +--- a/src/ucm/bistro/bistro.c ++++ b/src/ucm/bistro/bistro.c +@@ -63,7 +63,7 @@ ucs_status_t ucm_bistro_apply_patch(void *dst, void *patch, size_t len) + return status; + } + +-#if defined(__x86_64__) || defined (__aarch64__) ++#if defined(__x86_64__) || defined (__aarch64__) || defined (__loongarch__) + struct ucm_bistro_restore_point { + void *addr; /* address of function to restore */ + size_t patch_len; /* patch length */ +diff --git a/src/ucm/bistro/bistro.h b/src/ucm/bistro/bistro.h +index b622e3c..4b0bfbb 100644 +--- a/src/ucm/bistro/bistro.h ++++ b/src/ucm/bistro/bistro.h +@@ -20,6 +20,8 @@ typedef struct ucm_bistro_restore_point ucm_bistro_restore_point_t; + # include "bistro_aarch64.h" + #elif defined(__x86_64__) + # include "bistro_x86_64.h" ++#elif defined(__loongarch__) ++# include "bistro_loongarch64.h" + #else + # error "Unsupported architecture" + #endif +diff --git a/src/ucm/bistro/bistro_loongarch64.c b/src/ucm/bistro/bistro_loongarch64.c +new file mode 100644 +index 0000000..5c62717 +--- /dev/null ++++ b/src/ucm/bistro/bistro_loongarch64.c +@@ -0,0 +1,85 @@ ++/** ++ * Copyright (C) Mellanox Technologies Ltd. 2018. ALL RIGHTS RESERVED. ++ * ++ * See file LICENSE for terms. ++ */ ++ ++#ifdef HAVE_CONFIG_H ++# include "config.h" ++#endif ++ ++/* ******************************************************* ++ * LOONGARCH64 processors family * ++ * ***************************************************** */ ++#if defined(__loongarch__) ++ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++ ++/* Register number used to store indirect jump address. ++ * r20 is the highest numbered temporary register, assuming this one is safe ++ * to use. */ ++#define R20 20 ++ ++/** ++ * @brief Generate a mov immediate instruction ++ * ++ * @param[in] _rd, _rj register number (0-31) ++ * @param[in] _si20, _si20 signed mmediate value 20, 12 bits ++ * @param[in] _ui12 immediate value ++ */ ++#define LU12I_W(_rd, _si20) \ ++ ((10 << 25) + (((_si20) & 0xfffff) << 5) + (_rd)) ++ ++#define LU32I_D(_rd, _si20) \ ++ (((22 >> 1) << 25) + (((_si20) & 0xfffff) << 5) + (_rd)) ++ ++#define LU52I_D(_rd, _rj, _si12) \ ++ (((48 >> 2) << 22) + (((_si12) & 0xfff) << 10) + ((_rj) << 5) + (_rd)) ++ ++#define ORI(_rd, _rj, _ui12) \ ++ (((56 >> 2) << 22) + (((_ui12) & 0xfff) << 10) + ((_rj) << 5) + (_rd)) ++ ++#define JIRL(_rd, _rj, _offs) \ ++ ((19 << 26) + ((_offs) << 10) + ((_rj) << 5) + (_rd)) ++ ++ucs_status_t ucm_bistro_patch(void *func_ptr, void *hook, const char *symbol, ++ void **orig_func_p, ++ ucm_bistro_restore_point_t **rp) ++{ ++ ucm_bistro_patch_t patch = { ++ .lu12i = LU12I_W(R20, (uintptr_t)hook >> 12), ++ .ori = ORI(R20, R20, (uintptr_t)hook), ++ .lu32i = LU32I_D(R20, (uintptr_t)hook >> 32), ++ .lu52i = LU52I_D(R20, R20, (uintptr_t)hook >> 52), ++ .jirl = JIRL(0, R20, 0) ++ }; ++ ucs_status_t status; ++ ++ if (orig_func_p != NULL) { ++ return UCS_ERR_UNSUPPORTED; ++ } ++ ++ status = ucm_bistro_create_restore_point(func_ptr, sizeof(patch), rp); ++ if (UCS_STATUS_IS_ERR(status)) { ++ return status; ++ } ++ ++ return ucm_bistro_apply_patch(func_ptr, &patch, sizeof(patch)); ++} ++ ++ucs_status_t ucm_bistro_relocate_one(ucm_bistro_relocate_context_t *ctx) ++{ ++ return UCS_ERR_UNSUPPORTED; ++} ++#endif +diff --git a/src/ucm/bistro/bistro_loongarch64.h b/src/ucm/bistro/bistro_loongarch64.h +new file mode 100644 +index 0000000..bbc6c0f +--- /dev/null ++++ b/src/ucm/bistro/bistro_loongarch64.h +@@ -0,0 +1,46 @@ ++/** ++ * Copyright (C) Mellanox Technologies Ltd. 2018. ALL RIGHTS RESERVED. ++ * ++ * See file LICENSE for terms. ++ */ ++ ++ ++#ifndef UCM_BISTRO_BISTRO_LOONGARCH64_H_ ++#define UCM_BISTRO_BISTRO_LOONGARCH64_H_ ++ ++#include ++ ++#include ++#include ++ ++#define UCM_BISTRO_PROLOGUE ++#define UCM_BISTRO_EPILOGUE ++ ++typedef struct ucm_bistro_patch { ++ uint32_t lu12i; /* lu12i.w r20, addr >> 12 */ ++ uint32_t ori; /* ori r20, r20, addr */ ++ uint32_t lu32i; /* lu32i.d r20, r20, addr >> 32 */ ++ uint32_t lu52i; /* lu52i.d r20, r20, addr >> 52*/ ++ uint32_t jirl; /* jirl 0, r20, 0 */ ++} UCS_S_PACKED ucm_bistro_patch_t; ++ ++/** ++ * Set library function call hook using Binary Instrumentation ++ * method (BISTRO): replace function body by user defined call ++ * ++ * @param func_ptr Pointer to function to patch. ++ * @param hook User-defined function-replacer. ++ * @param symbol Function name to replace. ++ * @param orig_func_p Unsupported on this architecture and must be NULL. ++ * If set to a non-NULL value, this function returns ++ * @ref UCS_ERR_UNSUPPORTED. ++ * @param rp Restore point used to restore original function. ++ * Optional, may be NULL. ++ * ++ * @return Error code as defined by @ref ucs_status_t ++ */ ++ucs_status_t ucm_bistro_patch(void *func_ptr, void *hook, const char *symbol, ++ void **orig_func_p, ++ ucm_bistro_restore_point_t **rp); ++ ++#endif +diff --git a/src/ucs/Makefile.am b/src/ucs/Makefile.am +index 9e0bd2f..cf39678 100644 +--- a/src/ucs/Makefile.am ++++ b/src/ucs/Makefile.am +@@ -22,6 +22,7 @@ libucs_la_LIBADD = $(LIBM) $(top_builddir)/src/ucm/libucm.la $(BFD_LIBS) + nobase_dist_libucs_la_HEADERS = \ + arch/aarch64/bitops.h \ + arch/ppc64/bitops.h \ ++ arch/loongarch64/bitops.h \ + arch/x86_64/bitops.h \ + arch/bitops.h \ + algorithm/crc.h \ +@@ -80,12 +81,14 @@ nobase_dist_libucs_la_HEADERS = \ + arch/x86_64/global_opts.h \ + arch/x86_64/atomic.h \ + arch/aarch64/global_opts.h \ ++ arch/loongarch64/global_opts.h \ + arch/generic/atomic.h \ + arch/ppc64/global_opts.h \ + arch/global_opts.h + + noinst_HEADERS = \ + arch/aarch64/cpu.h \ ++ arch/loongarch64/cpu.h \ + arch/generic/cpu.h \ + arch/ppc64/cpu.h \ + arch/x86_64/cpu.h \ +@@ -138,6 +141,7 @@ libucs_la_SOURCES = \ + algorithm/string_distance.c \ + arch/aarch64/cpu.c \ + arch/aarch64/global_opts.c \ ++ arch/loongarch64/global_opts.c \ + arch/ppc64/timebase.c \ + arch/ppc64/global_opts.c \ + arch/x86_64/cpu.c \ +diff --git a/src/ucs/Makefile.in b/src/ucs/Makefile.in +index 053d70a..5cb387e 100644 +--- a/src/ucs/Makefile.in ++++ b/src/ucs/Makefile.in +@@ -202,6 +202,7 @@ am__libucs_la_SOURCES_DIST = algorithm/crc.c algorithm/qsort_r.c \ + arch/aarch64/global_opts.c arch/ppc64/timebase.c \ + arch/ppc64/global_opts.c arch/x86_64/cpu.c \ + arch/x86_64/global_opts.c arch/cpu.c async/async.c \ ++ arch/loongarch64/global_opts.c \ + async/signal.c async/pipe.c async/eventfd.c async/thread.c \ + config/global_opts.c config/ucm_opts.c config/ini.c \ + config/parser.c datastruct/arbiter.c datastruct/array.c \ +@@ -231,6 +232,7 @@ am_libucs_la_OBJECTS = algorithm/libucs_la-crc.lo \ + algorithm/libucs_la-string_distance.lo \ + arch/aarch64/libucs_la-cpu.lo \ + arch/aarch64/libucs_la-global_opts.lo \ ++ arch/loongarch64/libucs_la-global_opts.lo \ + arch/ppc64/libucs_la-timebase.lo \ + arch/ppc64/libucs_la-global_opts.lo \ + arch/x86_64/libucs_la-cpu.lo \ +@@ -643,6 +645,7 @@ libucs_ladir = $(includedir)/ucs + libucs_la_LIBADD = $(LIBM) $(top_builddir)/src/ucm/libucm.la $(BFD_LIBS) + nobase_dist_libucs_la_HEADERS = \ + arch/aarch64/bitops.h \ ++ arch/loongarch64/bitops.h \ + arch/ppc64/bitops.h \ + arch/x86_64/bitops.h \ + arch/bitops.h \ +@@ -702,12 +705,14 @@ nobase_dist_libucs_la_HEADERS = \ + arch/x86_64/global_opts.h \ + arch/x86_64/atomic.h \ + arch/aarch64/global_opts.h \ ++ arch/loongarch64/global_opts.h \ + arch/generic/atomic.h \ + arch/ppc64/global_opts.h \ + arch/global_opts.h + + noinst_HEADERS = \ + arch/aarch64/cpu.h \ ++ arch/loongarch64/cpu.h \ + arch/generic/cpu.h \ + arch/ppc64/cpu.h \ + arch/x86_64/cpu.h \ +@@ -759,6 +764,7 @@ libucs_la_SOURCES = algorithm/crc.c algorithm/qsort_r.c \ + arch/aarch64/global_opts.c arch/ppc64/timebase.c \ + arch/ppc64/global_opts.c arch/x86_64/cpu.c \ + arch/x86_64/global_opts.c arch/cpu.c async/async.c \ ++ arch/loongarch64/global_opts.c \ + async/signal.c async/pipe.c async/eventfd.c async/thread.c \ + config/global_opts.c config/ucm_opts.c config/ini.c \ + config/parser.c datastruct/arbiter.c datastruct/array.c \ +@@ -878,6 +884,16 @@ arch/aarch64/libucs_la-cpu.lo: arch/aarch64/$(am__dirstamp) \ + arch/aarch64/$(DEPDIR)/$(am__dirstamp) + arch/aarch64/libucs_la-global_opts.lo: arch/aarch64/$(am__dirstamp) \ + arch/aarch64/$(DEPDIR)/$(am__dirstamp) ++arch/loongarch64/$(am__dirstamp): ++ @$(MKDIR_P) arch/loongarch64 ++ @: > arch/loongarch64/$(am__dirstamp) ++arch/loongarch64/$(DEPDIR)/$(am__dirstamp): ++ @$(MKDIR_P) arch/loongarch64/$(DEPDIR) ++ @: > arch/loongarch64/$(DEPDIR)/$(am__dirstamp) ++arch/loongarch64/libucs_la-cpu.lo: arch/loongarch64/$(am__dirstamp) \ ++ arch/loongarch64/$(DEPDIR)/$(am__dirstamp) ++arch/loongarch64/libucs_la-global_opts.lo: arch/loongarch64/$(am__dirstamp) \ ++ arch/loongarch64/$(DEPDIR)/$(am__dirstamp) + arch/ppc64/$(am__dirstamp): + @$(MKDIR_P) arch/ppc64 + @: > arch/ppc64/$(am__dirstamp) +@@ -1164,6 +1180,8 @@ mostlyclean-compile: + -rm -f arch/*.lo + -rm -f arch/aarch64/*.$(OBJEXT) + -rm -f arch/aarch64/*.lo ++ -rm -f arch/loongarch64/*.$(OBJEXT) ++ -rm -f arch/loongarch64/*.lo + -rm -f arch/ppc64/*.$(OBJEXT) + -rm -f arch/ppc64/*.lo + -rm -f arch/x86_64/*.$(OBJEXT) +@@ -1203,6 +1221,7 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@arch/aarch64/$(DEPDIR)/libucs_la-cpu.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@arch/aarch64/$(DEPDIR)/libucs_la-global_opts.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@arch/aarch64/$(DEPDIR)/libucs_la-memcpy_thunderx2.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@arch/loongarch64/$(DEPDIR)/libucs_la-global_opts.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@arch/ppc64/$(DEPDIR)/libucs_la-global_opts.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@arch/ppc64/$(DEPDIR)/libucs_la-timebase.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@arch/x86_64/$(DEPDIR)/libucs_la-cpu.Plo@am__quote@ +@@ -1357,6 +1376,13 @@ arch/aarch64/libucs_la-global_opts.lo: arch/aarch64/global_opts.c + @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucs_la_CPPFLAGS) $(CPPFLAGS) $(libucs_la_CFLAGS) $(CFLAGS) -c -o arch/aarch64/libucs_la-global_opts.lo `test -f 'arch/aarch64/global_opts.c' || echo '$(srcdir)/'`arch/aarch64/global_opts.c + ++arch/loongarch64/libucs_la-global_opts.lo: arch/loongarch64/global_opts.c ++@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucs_la_CPPFLAGS) $(CPPFLAGS) $(libucs_la_CFLAGS) $(CFLAGS) -MT arch/loongarch64/libucs_la-global_opts.lo -MD -MP -MF arch/loongarch64/$(DEPDIR)/libucs_la-global_opts.Tpo -c -o arch/loongarch64/libucs_la-global_opts.lo `test -f 'arch/loongarch64/global_opts.c' || echo '$(srcdir)/'`arch/loongarch64/global_opts.c ++@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) arch/loongarch64/$(DEPDIR)/libucs_la-global_opts.Tpo arch/loongarch64/$(DEPDIR)/libucs_la-global_opts.Plo ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='arch/loongarch64/global_opts.c' object='arch/loongarch64/libucs_la-global_opts.lo' libtool=yes @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucs_la_CPPFLAGS) $(CPPFLAGS) $(libucs_la_CFLAGS) $(CFLAGS) -c -o arch/loongarch64/libucs_la-global_opts.lo `test -f 'arch/loongarch64/global_opts.c' || echo '$(srcdir)/'`arch/loongarch64/global_opts.c ++ + arch/ppc64/libucs_la-timebase.lo: arch/ppc64/timebase.c + @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libucs_la_CPPFLAGS) $(CPPFLAGS) $(libucs_la_CFLAGS) $(CFLAGS) -MT arch/ppc64/libucs_la-timebase.lo -MD -MP -MF arch/ppc64/$(DEPDIR)/libucs_la-timebase.Tpo -c -o arch/ppc64/libucs_la-timebase.lo `test -f 'arch/ppc64/timebase.c' || echo '$(srcdir)/'`arch/ppc64/timebase.c + @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) arch/ppc64/$(DEPDIR)/libucs_la-timebase.Tpo arch/ppc64/$(DEPDIR)/libucs_la-timebase.Plo +@@ -1820,6 +1846,7 @@ clean-libtool: + -rm -rf algorithm/.libs algorithm/_libs + -rm -rf arch/.libs arch/_libs + -rm -rf arch/aarch64/.libs arch/aarch64/_libs ++ -rm -rf arch/loongarch64/.libs arch/loongarch64/_libs + -rm -rf arch/ppc64/.libs arch/ppc64/_libs + -rm -rf arch/x86_64/.libs arch/x86_64/_libs + -rm -rf async/.libs async/_libs +@@ -2077,6 +2104,8 @@ distclean-generic: + -rm -f arch/$(am__dirstamp) + -rm -f arch/aarch64/$(DEPDIR)/$(am__dirstamp) + -rm -f arch/aarch64/$(am__dirstamp) ++ -rm -f arch/loongarch64/$(DEPDIR)/$(am__dirstamp) ++ -rm -f arch/loongarch64/$(am__dirstamp) + -rm -f arch/ppc64/$(DEPDIR)/$(am__dirstamp) + -rm -f arch/ppc64/$(am__dirstamp) + -rm -f arch/x86_64/$(DEPDIR)/$(am__dirstamp) +@@ -2115,7 +2144,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool mostlyclean-am + + distclean: distclean-recursive +- -rm -rf algorithm/$(DEPDIR) arch/$(DEPDIR) arch/aarch64/$(DEPDIR) arch/ppc64/$(DEPDIR) arch/x86_64/$(DEPDIR) async/$(DEPDIR) config/$(DEPDIR) datastruct/$(DEPDIR) debug/$(DEPDIR) memory/$(DEPDIR) profile/$(DEPDIR) stats/$(DEPDIR) sys/$(DEPDIR) sys/topo/base/$(DEPDIR) time/$(DEPDIR) type/$(DEPDIR) vfs/base/$(DEPDIR) ++ -rm -rf algorithm/$(DEPDIR) arch/$(DEPDIR) arch/aarch64/$(DEPDIR) arch/loongarch64/$(DEPDIR) arch/ppc64/$(DEPDIR) arch/x86_64/$(DEPDIR) async/$(DEPDIR) config/$(DEPDIR) datastruct/$(DEPDIR) debug/$(DEPDIR) memory/$(DEPDIR) profile/$(DEPDIR) stats/$(DEPDIR) sys/$(DEPDIR) sys/topo/base/$(DEPDIR) time/$(DEPDIR) type/$(DEPDIR) vfs/base/$(DEPDIR) + -rm -f Makefile + distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags +@@ -2162,7 +2191,7 @@ install-ps-am: + installcheck-am: + + maintainer-clean: maintainer-clean-recursive +- -rm -rf algorithm/$(DEPDIR) arch/$(DEPDIR) arch/aarch64/$(DEPDIR) arch/ppc64/$(DEPDIR) arch/x86_64/$(DEPDIR) async/$(DEPDIR) config/$(DEPDIR) datastruct/$(DEPDIR) debug/$(DEPDIR) memory/$(DEPDIR) profile/$(DEPDIR) stats/$(DEPDIR) sys/$(DEPDIR) sys/topo/base/$(DEPDIR) time/$(DEPDIR) type/$(DEPDIR) vfs/base/$(DEPDIR) ++ -rm -rf algorithm/$(DEPDIR) arch/$(DEPDIR) arch/aarch64/$(DEPDIR) arch/loongarch64/$(DEPDIR) arch/ppc64/$(DEPDIR) arch/x86_64/$(DEPDIR) async/$(DEPDIR) config/$(DEPDIR) datastruct/$(DEPDIR) debug/$(DEPDIR) memory/$(DEPDIR) profile/$(DEPDIR) stats/$(DEPDIR) sys/$(DEPDIR) sys/topo/base/$(DEPDIR) time/$(DEPDIR) type/$(DEPDIR) vfs/base/$(DEPDIR) + -rm -f Makefile + maintainer-clean-am: distclean-am maintainer-clean-generic + +diff --git a/src/ucs/arch/atomic.h b/src/ucs/arch/atomic.h +index 52be711..6b53cb3 100644 +--- a/src/ucs/arch/atomic.h ++++ b/src/ucs/arch/atomic.h +@@ -15,6 +15,8 @@ + # include "generic/atomic.h" + #elif defined(__aarch64__) + # include "generic/atomic.h" ++#elif defined(__loongarch__) ++# include "generic/atomic.h" + #else + # error "Unsupported architecture" + #endif +diff --git a/src/ucs/arch/bitops.h b/src/ucs/arch/bitops.h +index e89a37d..7047a46 100644 +--- a/src/ucs/arch/bitops.h ++++ b/src/ucs/arch/bitops.h +@@ -20,6 +20,8 @@ BEGIN_C_DECLS + # include "ppc64/bitops.h" + #elif defined(__aarch64__) + # include "aarch64/bitops.h" ++#elif defined(__loongarch__) ++# include "loongarch64/bitops.h" + #else + # error "Unsupported architecture" + #endif +diff --git a/src/ucs/arch/cpu.h b/src/ucs/arch/cpu.h +index a59561c..727ffc8 100644 +--- a/src/ucs/arch/cpu.h ++++ b/src/ucs/arch/cpu.h +@@ -98,6 +98,8 @@ typedef struct ucs_cpu_builtin_memcpy { + # include "ppc64/cpu.h" + #elif defined(__aarch64__) + # include "aarch64/cpu.h" ++#elif defined(__loongarch__) ++# include "loongarch64/cpu.h" + #else + # error "Unsupported architecture" + #endif +diff --git a/src/ucs/arch/global_opts.h b/src/ucs/arch/global_opts.h +index 75d0861..c8ad5b8 100644 +--- a/src/ucs/arch/global_opts.h ++++ b/src/ucs/arch/global_opts.h +@@ -15,6 +15,8 @@ + # include "ppc64/global_opts.h" + #elif defined(__aarch64__) + # include "aarch64/global_opts.h" ++#elif defined(__loongarch__) ++# include "loongarch64/global_opts.h" + #else + # error "Unsupported architecture" + #endif +diff --git a/src/ucs/arch/loongarch64/bitops.h b/src/ucs/arch/loongarch64/bitops.h +new file mode 100644 +index 0000000..86ad7f1 +--- /dev/null ++++ b/src/ucs/arch/loongarch64/bitops.h +@@ -0,0 +1,42 @@ ++/** ++* Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED. ++* ++* See file LICENSE for terms. ++*/ ++ ++#ifndef UCS_LOONGARCH64_BITOPS_H_ ++#define UCS_LOONGARCH64_BITOPS_H_ ++ ++#include ++#include ++ ++ ++static UCS_F_ALWAYS_INLINE unsigned __ucs_ilog2_u32(uint32_t n) ++{ ++ int bit; ++ asm ("clz.w %0,%1" : "=r" (bit) : "r" (n)); ++ return 31 - bit; ++} ++ ++static UCS_F_ALWAYS_INLINE unsigned __ucs_ilog2_u64(uint64_t n) ++{ ++ int bit; ++ asm ("clz.d %0,%1" : "=r" (bit) : "r" (n)); ++ return 63 - bit; ++} ++ ++static UCS_F_ALWAYS_INLINE unsigned ucs_ffs32(uint32_t n) ++{ ++ int bit; ++ asm ("ctz.w %0,%1" : "=r" (bit) : "r" (n)); ++ return 31 - bit; ++} ++ ++static UCS_F_ALWAYS_INLINE unsigned ucs_ffs64(uint64_t n) ++{ ++ int bit; ++ asm ("ctz.d %0,%1" : "=r" (bit) : "r" (n)); ++ return 63 - bit; ++} ++ ++#endif +diff --git a/src/ucs/arch/loongarch64/cpu.h b/src/ucs/arch/loongarch64/cpu.h +new file mode 100644 +index 0000000..51b153b +--- /dev/null ++++ b/src/ucs/arch/loongarch64/cpu.h +@@ -0,0 +1,101 @@ ++/** ++* Copyright (C) Mellanox Technologies Ltd. 2001-2013. ALL RIGHTS RESERVED. ++* Copyright (C) ARM Ltd. 2016-2017. ALL RIGHTS RESERVED. ++* ++* See file LICENSE for terms. ++*/ ++ ++ ++#ifndef UCS_LOONGARCH64_CPU_H_ ++#define UCS_LOONGARCH64_CPU_H_ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++BEGIN_C_DECLS ++ ++/** @file cpu.h */ ++ ++#define UCS_ARCH_CACHE_LINE_SIZE 64 ++ ++/* Assume the worst - weak memory ordering */ ++#define ucs_memory_bus_fence() asm volatile ("dbar 0"::: "memory") ++#define ucs_memory_bus_store_fence() ucs_memory_bus_fence() ++#define ucs_memory_bus_load_fence() ucs_memory_bus_fence() ++#define ucs_memory_bus_cacheline_wc_flush() ++#define ucs_memory_cpu_fence() ucs_memory_bus_fence() ++#define ucs_memory_cpu_store_fence() asm volatile ("dbar 0 \n" \ ++ ::: "memory") ++#define ucs_memory_cpu_load_fence() asm volatile ("dbar 0 \n" \ ++ "dbar 0 \n" \ ++ ::: "memory") ++#define ucs_memory_cpu_wc_fence() ucs_memory_bus_fence() ++ ++ ++static inline uint64_t ucs_arch_read_hres_clock() ++{ ++ uint64_t tb; ++ __drdtime_t tsc; ++ tsc = __rdtime_d(); ++ tb = tsc.dvalue; ++ return tb; ++} ++ ++static inline double ucs_arch_get_clocks_per_sec() { ++ uint64_t freq; ++ freq = 100 * 1000 * 1000; ++ return (double) freq; ++} ++ ++static inline ucs_cpu_model_t ucs_arch_get_cpu_model() ++{ ++ return UCS_CPU_MODEL_UNKNOWN; ++} ++ ++static inline ucs_cpu_vendor_t ucs_arch_get_cpu_vendor() ++{ ++ return UCS_CPU_VENDOR_UNKNOWN; ++} ++ ++static inline int ucs_arch_get_cpu_flag() ++{ ++ return UCS_CPU_FLAG_UNKNOWN; ++} ++ ++static inline void ucs_cpu_init() ++{ ++} ++ ++#define ucs_arch_wait_mem ucs_arch_generic_wait_mem ++ ++#if !HAVE___CLEAR_CACHE ++static inline void ucs_arch_clear_cache(void *start, void *end) ++{ ++ ucs_memory_cpu_fence(); ++} ++#endif ++ ++static inline void *ucs_memcpy_relaxed(void *dst, const void *src, size_t len) ++{ ++ return memcpy(dst, src, len); ++} ++ ++static UCS_F_ALWAYS_INLINE void ++ucs_memcpy_nontemporal(void *dst, const void *src, size_t len) ++{ ++ memcpy(dst, src, len); ++} ++ ++static inline ucs_status_t ucs_arch_get_cache_size(size_t *cache_sizes) ++{ ++ return UCS_ERR_UNSUPPORTED; ++} ++ ++END_C_DECLS ++ ++#endif +diff --git a/src/ucs/arch/loongarch64/global_opts.c b/src/ucs/arch/loongarch64/global_opts.c +new file mode 100644 +index 0000000..17f7a2a +--- /dev/null ++++ b/src/ucs/arch/loongarch64/global_opts.c +@@ -0,0 +1,24 @@ ++/** ++* Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED. ++* ++* See file LICENSE for terms. ++*/ ++ ++#if defined(__loongarch__) ++ ++#ifdef HAVE_CONFIG_H ++# include "config.h" ++#endif ++ ++#include ++#include ++ ++ucs_config_field_t ucs_arch_global_opts_table[] = { ++ {NULL} ++}; ++ ++void ucs_arch_print_memcpy_limits(ucs_arch_global_opts_t *config) ++{ ++} ++ ++#endif +diff --git a/src/ucs/arch/loongarch64/global_opts.h b/src/ucs/arch/loongarch64/global_opts.h +new file mode 100644 +index 0000000..b43786c +--- /dev/null ++++ b/src/ucs/arch/loongarch64/global_opts.h +@@ -0,0 +1,24 @@ ++/** ++* Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED. ++* ++* See file LICENSE for terms. ++*/ ++ ++ ++#ifndef UCS_LOONGARCH64_GLOBAL_OPTS_H_ ++#define UCS_LOONGARCH64_GLOBAL_OPTS_H_ ++ ++#include ++ ++BEGIN_C_DECLS ++ ++#define UCS_ARCH_GLOBAL_OPTS_INITALIZER {} ++ ++/* built-in memcpy config */ ++typedef struct ucs_arch_global_opts { ++ char dummy; ++} ucs_arch_global_opts_t; ++ ++END_C_DECLS ++ ++#endif +-- +2.39.3 + diff --git a/ucx.spec b/ucx.spec index c3dca96..acf4367 100644 --- a/ucx.spec +++ b/ucx.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 %{!?configure_options: %global configure_options %{nil}} %bcond_without cma %bcond_with cuda @@ -17,18 +18,20 @@ Name: ucx Version: 1.15.0 -Release: 2%{?dist} +Release: 2%{anolis_release}%{?dist} Summary: UCX is a communication library implementing high-performance messaging License: BSD URL: http://www.openucx.org Source: https://github.com/openucx/%{name}/releases/download/v%{version}/ucx-%{version}.tar.gz +Patch0001: 0001-add-loongarch64-support-for-ucx.patch + BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) Prefix: %{_prefix} # UCX currently supports only the following architectures -ExclusiveArch: aarch64 ppc64le x86_64 +ExclusiveArch: aarch64 ppc64le x86_64 loongarch64 %if %{defined extra_deps} Requires: %{?extra_deps} @@ -91,7 +94,7 @@ Provides header files and examples for developing with UCX. %prep %setup -q - +%patch0001 -p1 %build %define _with_arg() %{expand:%%{?with_%{1}:--with-%{2}}%%{!?with_%{1}:--without-%{2}}} %define _enable_arg() %{expand:%%{?with_%{1}:--enable-%{2}}%%{!?with_%{1}:--disable-%{2}}} @@ -101,6 +104,9 @@ Provides header files and examples for developing with UCX. --disable-assertions \ --disable-params-check \ --without-java \ +%ifarch loongarch64 + --without-go \ +%endif %_enable_arg cma cma \ %_with_arg cuda cuda \ %_with_arg gdrcopy gdrcopy \ @@ -309,6 +315,9 @@ library internals, protocol objects, transports status, and more. %endif %changelog +* Mon Jul 15 2024 Wenlong Zhang - 1.15.0-2.0.1 +- Add loongarch64 support for ucx + * Thu Nov 09 2023 Kamal Heib - 1.15.0-2 - Fix requirement error - Resolves: RHEL-932 -- Gitee