diff --git src/ucs/Makefile.am src/ucs/Makefile.am index ba869dbf..c588cd9d 100644 --- src/ucs/Makefile.am +++ src/ucs/Makefile.am @@ -25,6 +25,8 @@ nobase_dist_libucs_la_HEADERS = \ arch/generic/cpu.h \ arch/ppc64/bitops.h \ arch/ppc64/cpu.h \ + arch/s390x/bitops.h \ + arch/s390x/cpu.h \ arch/x86_64/atomic.h \ arch/x86_64/bitops.h \ arch/x86_64/cpu.h \ diff --git src/ucs/arch/atomic.h src/ucs/arch/atomic.h index 7649971b..7bb2bc36 100644 --- src/ucs/arch/atomic.h +++ src/ucs/arch/atomic.h @@ -15,6 +15,8 @@ # include "generic/atomic.h" #elif defined(__aarch64__) # include "generic/atomic.h" +#elif defined(__s390x__) +# include "generic/atomic.h" #else # error "Unsupported architecture" #endif diff --git src/ucs/arch/bitops.h src/ucs/arch/bitops.h index f4dd3ab4..de53bde0 100644 --- src/ucs/arch/bitops.h +++ src/ucs/arch/bitops.h @@ -14,6 +14,8 @@ # include "ppc64/bitops.h" #elif defined(__aarch64__) # include "aarch64/bitops.h" +#elif defined(__s390x__) +# include "s390x/bitops.h" #else # error "Unsupported architecture" #endif diff --git src/ucs/arch/cpu.h src/ucs/arch/cpu.h index d5127b3d..817ac0d2 100644 --- src/ucs/arch/cpu.h +++ src/ucs/arch/cpu.h @@ -52,6 +52,8 @@ typedef enum ucs_cpu_flag { # include "ppc64/cpu.h" #elif defined(__aarch64__) # include "aarch64/cpu.h" +#elif defined(__s390x__) +# include "s390x/cpu.h" #else # error "Unsupported architecture" #endif diff --git src/ucs/arch/s390x/bitops.h src/ucs/arch/s390x/bitops.h new file mode 100644 index 00000000..39ad1251 --- /dev/null +++ src/ucs/arch/s390x/bitops.h @@ -0,0 +1,32 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED. +* +* See file LICENSE for terms. +*/ + +#ifndef UCS_S390X_BITOPS_H_ +#define UCS_S390X_BITOPS_H_ + +#include + + +static inline unsigned __ucs_ilog2_u32(uint32_t n) +{ + if (!n) + return 0; + return 31 - __builtin_clz(n); +} + +static inline unsigned __ucs_ilog2_u64(uint64_t n) +{ + if (!n) + return 0; + return 63 - __builtin_clz(n); +} + +static inline unsigned ucs_ffs64(uint64_t n) +{ + return __ucs_ilog2_u64(n & -n); +} + +#endif diff --git src/ucs/arch/s390x/cpu.h src/ucs/arch/s390x/cpu.h new file mode 100644 index 00000000..f5131ea3 --- /dev/null +++ src/ucs/arch/s390x/cpu.h @@ -0,0 +1,51 @@ +/** +* 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_S390X_CPU_H_ +#define UCS_S390X_CPU_H_ + +#include +#include +#include + + +#define UCS_ARCH_CACHE_LINE_SIZE 256 + +/* Assume the worst - weak memory ordering */ +#define ucs_memory_bus_fence() asm volatile (""::: "memory") +#define ucs_memory_bus_store_fence() ucs_memory_bus_fence() +#define ucs_memory_bus_load_fence() 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() + + +static inline uint64_t ucs_arch_read_hres_clock() +{ + unsigned long clk; + asm volatile("stck %0" : "=Q" (clk) : : "cc"); + return clk >> 2; +} +#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 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 + +#endif