Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Factory:RISCV
openucx
riscv.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File riscv.patch of Package openucx
Index: ucx-1.15.0/src/tools/info/sys_info.c =================================================================== --- ucx-1.15.0.orig/src/tools/info/sys_info.c +++ ucx-1.15.0/src/tools/info/sys_info.c @@ -46,6 +46,7 @@ static const char* cpu_vendor_names[] = [UCS_CPU_VENDOR_AMD] = "AMD", [UCS_CPU_VENDOR_GENERIC_ARM] = "Generic ARM", [UCS_CPU_VENDOR_GENERIC_PPC] = "Generic PPC", + [UCS_CPU_VENDOR_GENERIC_RISCV] = "Generic RISCV", [UCS_CPU_VENDOR_FUJITSU_ARM] = "Fujitsu ARM", [UCS_CPU_VENDOR_ZHAOXIN] = "Zhaoxin" }; Index: ucx-1.15.0/src/ucm/Makefile.am =================================================================== --- ucx-1.15.0.orig/src/ucm/Makefile.am +++ ucx-1.15.0/src/ucm/Makefile.am @@ -31,6 +31,7 @@ noinst_HEADERS = \ bistro/bistro.h \ bistro/bistro_x86_64.h \ bistro/bistro_aarch64.h \ + bistro/bistro_riscv64.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_riscv64.c \ bistro/bistro_ppc64.c if HAVE_UCM_PTMALLOC286 Index: ucx-1.15.0/src/ucm/bistro/bistro.c =================================================================== --- ucx-1.15.0.orig/src/ucm/bistro/bistro.c +++ ucx-1.15.0/src/ucm/bistro/bistro.c @@ -63,7 +63,7 @@ ucs_status_t ucm_bistro_apply_patch(void return status; } -#if defined(__x86_64__) || defined (__aarch64__) +#if defined(__x86_64__) || defined (__aarch64__) || defined(__riscv) struct ucm_bistro_restore_point { void *addr; /* address of function to restore */ size_t patch_len; /* patch length */ Index: ucx-1.15.0/src/ucm/bistro/bistro.h =================================================================== --- ucx-1.15.0.orig/src/ucm/bistro/bistro.h +++ ucx-1.15.0/src/ucm/bistro/bistro.h @@ -20,6 +20,8 @@ typedef struct ucm_bistro_restore_point # include "bistro_aarch64.h" #elif defined(__x86_64__) # include "bistro_x86_64.h" +#elif defined(__riscv) && __riscv_xlen == 64 +# include "bistro_riscv64.h" #else # error "Unsupported architecture" #endif Index: ucx-1.15.0/src/ucm/bistro/bistro_riscv64.c =================================================================== --- /dev/null +++ ucx-1.15.0/src/ucm/bistro/bistro_riscv64.c @@ -0,0 +1,57 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +/* ******************************************************* + * RISC-V processors family * + * ***************************************************** */ +#if defined(__riscv) && __riscv_xlen == 64 + +#include <sys/mman.h> +#include <dlfcn.h> +#include <string.h> +#include <stdlib.h> + +#include <ucm/bistro/bistro.h> +#include <ucm/bistro/bistro_int.h> +#include <ucm/util/sys.h> +#include <ucs/sys/math.h> +#include <ucs/arch/cpu.h> +#include <ucs/debug/assert.h> + +#define AUIPC 0x00000297 +#define LD 0x0102b283 +#define JR 0x00028067 +#define NOP 0x00000013 + +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 = { + .auipc = AUIPC, + .ld = LD, + .jr = JR, + .nop = NOP, + .hook = (uintptr_t) hook, + }; + 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 Index: ucx-1.15.0/src/ucm/bistro/bistro_riscv64.h =================================================================== --- /dev/null +++ ucx-1.15.0/src/ucm/bistro/bistro_riscv64.h @@ -0,0 +1,39 @@ +#ifndef UCM_BISTRO_BISTRO_RISCV64_H_ +#define UCM_BISTRO_BISTRO_RISCV64_H_ + +#include <stdint.h> + +#include <ucs/type/status.h> +#include <ucs/sys/compiler_def.h> + +#define UCM_BISTRO_PROLOGUE +#define UCM_BISTRO_EPILOGUE + +typedef struct ucm_bistro_patch { + uint32_t auipc; + uint32_t ld; + uint32_t jr; + uint32_t nop; + uintptr_t hook; +} 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 Index: ucx-1.15.0/src/ucs/Makefile.am =================================================================== --- ucx-1.15.0.orig/src/ucs/Makefile.am +++ ucx-1.15.0/src/ucs/Makefile.am @@ -22,6 +22,7 @@ libucs_la_LIBADD = $(LIBM) $(top_build nobase_dist_libucs_la_HEADERS = \ arch/aarch64/bitops.h \ arch/ppc64/bitops.h \ + arch/riscv64/bitops.h \ arch/x86_64/bitops.h \ arch/bitops.h \ algorithm/crc.h \ @@ -82,12 +83,14 @@ nobase_dist_libucs_la_HEADERS = \ arch/aarch64/global_opts.h \ arch/generic/atomic.h \ arch/ppc64/global_opts.h \ + arch/riscv64/global_opts.h \ arch/global_opts.h noinst_HEADERS = \ arch/aarch64/cpu.h \ arch/generic/cpu.h \ arch/ppc64/cpu.h \ + arch/riscv64/cpu.h \ arch/x86_64/cpu.h \ arch/cpu.h \ config/ucm_opts.h \ @@ -140,6 +143,7 @@ libucs_la_SOURCES = \ arch/aarch64/global_opts.c \ arch/ppc64/timebase.c \ arch/ppc64/global_opts.c \ + arch/riscv64/global_opts.c \ arch/x86_64/cpu.c \ arch/x86_64/global_opts.c \ arch/cpu.c \ Index: ucx-1.15.0/src/ucs/arch/atomic.h =================================================================== --- ucx-1.15.0.orig/src/ucs/arch/atomic.h +++ ucx-1.15.0/src/ucs/arch/atomic.h @@ -15,6 +15,8 @@ # include "generic/atomic.h" #elif defined(__aarch64__) # include "generic/atomic.h" +#elif defined(__riscv) +# include "generic/atomic.h" #else # error "Unsupported architecture" #endif Index: ucx-1.15.0/src/ucs/arch/bitops.h =================================================================== --- ucx-1.15.0.orig/src/ucs/arch/bitops.h +++ ucx-1.15.0/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(__riscv) +# include "riscv64/bitops.h" #else # error "Unsupported architecture" #endif Index: ucx-1.15.0/src/ucs/arch/cpu.c =================================================================== --- ucx-1.15.0.orig/src/ucs/arch/cpu.c +++ ucx-1.15.0/src/ucs/arch/cpu.c @@ -63,6 +63,10 @@ const ucs_cpu_builtin_memcpy_t ucs_cpu_b .min = UCS_MEMUNITS_INF, .max = UCS_MEMUNITS_INF }, + [UCS_CPU_VENDOR_GENERIC_RISCV] = { + .min = UCS_MEMUNITS_INF, + .max = UCS_MEMUNITS_INF + }, [UCS_CPU_VENDOR_FUJITSU_ARM] = { .min = UCS_MEMUNITS_INF, .max = UCS_MEMUNITS_INF @@ -79,6 +83,7 @@ const size_t ucs_cpu_est_bcopy_bw[UCS_CP [UCS_CPU_VENDOR_AMD] = UCS_CPU_EST_BCOPY_BW_AMD, [UCS_CPU_VENDOR_GENERIC_ARM] = UCS_CPU_EST_BCOPY_BW_DEFAULT, [UCS_CPU_VENDOR_GENERIC_PPC] = UCS_CPU_EST_BCOPY_BW_DEFAULT, + [UCS_CPU_VENDOR_GENERIC_RISCV] = UCS_CPU_EST_BCOPY_BW_DEFAULT, [UCS_CPU_VENDOR_FUJITSU_ARM] = UCS_CPU_EST_BCOPY_BW_FUJITSU_ARM, [UCS_CPU_VENDOR_ZHAOXIN] = UCS_CPU_EST_BCOPY_BW_DEFAULT }; Index: ucx-1.15.0/src/ucs/arch/cpu.h =================================================================== --- ucx-1.15.0.orig/src/ucs/arch/cpu.h +++ ucx-1.15.0/src/ucs/arch/cpu.h @@ -64,6 +64,7 @@ typedef enum ucs_cpu_vendor { UCS_CPU_VENDOR_AMD, UCS_CPU_VENDOR_GENERIC_ARM, UCS_CPU_VENDOR_GENERIC_PPC, + UCS_CPU_VENDOR_GENERIC_RISCV, UCS_CPU_VENDOR_FUJITSU_ARM, UCS_CPU_VENDOR_ZHAOXIN, UCS_CPU_VENDOR_LAST @@ -99,6 +100,8 @@ typedef struct ucs_cpu_builtin_memcpy { # include "ppc64/cpu.h" #elif defined(__aarch64__) # include "aarch64/cpu.h" +#elif defined(__riscv) +# include "riscv64/cpu.h" #else # error "Unsupported architecture" #endif Index: ucx-1.15.0/src/ucs/arch/global_opts.h =================================================================== --- ucx-1.15.0.orig/src/ucs/arch/global_opts.h +++ ucx-1.15.0/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(__riscv) +# include "riscv64/global_opts.h" #else # error "Unsupported architecture" #endif Index: ucx-1.15.0/src/ucs/arch/riscv64/bitops.h =================================================================== --- /dev/null +++ ucx-1.15.0/src/ucs/arch/riscv64/bitops.h @@ -0,0 +1,37 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED. +* +* See file LICENSE for terms. +*/ + +#ifndef UCS_RISCV64_BITOPS_H_ +#define UCS_RISCV64_BITOPS_H_ + +#include <stdint.h> + + +static UCS_F_ALWAYS_INLINE unsigned __ucs_ilog2_u32(uint32_t n) +{ + if (!n) + return 0; + return 31 - __builtin_clz(n); +} + +static UCS_F_ALWAYS_INLINE unsigned __ucs_ilog2_u64(uint64_t n) +{ + if (!n) + return 0; + return 63 - __builtin_clzl(n); +} + +static UCS_F_ALWAYS_INLINE unsigned ucs_ffs32(uint32_t n) +{ + return __ucs_ilog2_u32(n & -n); +} + +static UCS_F_ALWAYS_INLINE unsigned ucs_ffs64(uint64_t n) +{ + return __ucs_ilog2_u64(n & -n); +} + +#endif Index: ucx-1.15.0/src/ucs/arch/riscv64/cpu.h =================================================================== --- /dev/null +++ ucx-1.15.0/src/ucs/arch/riscv64/cpu.h @@ -0,0 +1,78 @@ +/** +* 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_RISCV64_CPU_H_ +#define UCS_RISCV64_CPU_H_ + +#include <ucs/sys/compiler.h> +#include <ucs/arch/generic/cpu.h> +#include <stdint.h> +#include <string.h> +#include <ucs/type/status.h> + + +#define UCS_ARCH_CACHE_LINE_SIZE 256 + +BEGIN_C_DECLS + +#define ucs_memory_bus_fence() asm volatile ("fence iorw,iorw"::: "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() ucs_memory_bus_fence() +#define ucs_memory_cpu_fence() ucs_memory_bus_fence() +#define ucs_memory_cpu_store_fence() ucs_memory_bus_fence() +#define ucs_memory_cpu_load_fence() ucs_memory_bus_fence() +#define ucs_memory_cpu_wc_fence() ucs_memory_bus_fence() + + +#define ucs_arch_read_hres_clock ucs_arch_generic_read_hres_clock +#define ucs_arch_get_clocks_per_sec ucs_arch_generic_get_clocks_per_sec + + +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_GENERIC_RISCV; +} + +static inline int ucs_arch_get_cpu_flag() +{ + return UCS_CPU_FLAG_UNKNOWN; +} + +double ucs_arch_get_clocks_per_sec(); + +#define ucs_arch_wait_mem ucs_arch_generic_wait_mem + +static inline void ucs_cpu_init() +{ +} + +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 Index: ucx-1.15.0/src/ucs/arch/riscv64/global_opts.c =================================================================== --- /dev/null +++ ucx-1.15.0/src/ucs/arch/riscv64/global_opts.c @@ -0,0 +1,24 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED. +* +* See file LICENSE for terms. +*/ + +#if defined(__riscv) + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <ucs/arch/global_opts.h> +#include <ucs/config/parser.h> + +ucs_config_field_t ucs_arch_global_opts_table[] = { + {NULL} +}; + +void ucs_arch_print_memcpy_limits(ucs_arch_global_opts_t *config) +{ +} + +#endif Index: ucx-1.15.0/src/ucs/arch/riscv64/global_opts.h =================================================================== --- /dev/null +++ ucx-1.15.0/src/ucs/arch/riscv64/global_opts.h @@ -0,0 +1,25 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED. +* +* See file LICENSE for terms. +*/ + + +#ifndef UCS_RISCV64_GLOBAL_OPTS_H_ +#define UCS_RISCV64_GLOBAL_OPTS_H_ + +#include <ucs/sys/compiler_def.h> + +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 +
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor