Skip to content

Commit

Permalink
Go down to z14 to support older distros
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Krebbel <[email protected]>
  • Loading branch information
Andreas-Krebbel committed Nov 22, 2024
1 parent e976de7 commit 235f0d7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
4 changes: 2 additions & 2 deletions config.zdnn
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ case "${target}" in
CFLAGS_INIT="-O3 -mzvector -Wall -std=gnu99 -fstack-protector-all ${CFLAGS_INIT:-}"
CFLAGS_QUOTE_INIT="-Wall" # Not needed on Linux. Just repeat an option to prevent it from being empty.
CFLAGS_OPT_EXPENSIVE="-funroll-loops"
CFLAGS="-O3 -march=z16 -mzvector -Wall -std=gnu99 -fstack-protector-all ${CFLAGS_OPT_EXPENSIVE} ${CFLAGS:-}"
CFLAGS="-O3 -march=z14 -mzvector -Wall -std=gnu99 -fstack-protector-all ${CFLAGS_OPT_EXPENSIVE} ${CFLAGS:-}"
CFLAGS_QUOTE="-Wall"
CFLAGS_DEBUG="-O0 -g3 ${CFLAGS_DEBUG:-}"
CFLAGS_SHARED="-fPIC ${CFLAGS_SHARED:-}"
CFLAGS_ASM="-Wa,-adhln -fno-asynchronous-unwind-tables ${CFLAGS_ASM:-}"
CFLAGS_NOSEARCH=""
CXXFLAGS="-O3 -march=z16 -Wall ${CXXFLAGS:-}"
CXXFLAGS="-O3 -march=z14 -Wall ${CXXFLAGS:-}"
CPP_SYMCHECK_FLAGS="-E -o zdnn.i"
SODIR="${SODIR:-lib}"
LIBNAME="${LIBNAME:-libzdnn}"
Expand Down
35 changes: 30 additions & 5 deletions zdnn/zdnn_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,13 +589,12 @@ void aiu_vec_lengthen_to_fp32(vec_int16 a, vec_float32 *out1,
vec_int16 aiu_vec_convert_from_fp16(vec_int16 a);
vec_int16 aiu_vec_convert_to_fp16(vec_int16 a);

#ifdef __MVS__
#if defined(__MVS__) || (defined(__ARCH__) && __ARCH__ < 14)
#define VEC_ROUND_FROM_FP32(FP_HI, FP_LO) \
aiu_vec_round_from_fp32(*(vec_float32 *)((void *)&(FP_HI)), \
*(vec_float32 *)((void *)&(FP_LO)));
aiu_vec_round_from_fp32((vec_float32)(FP_HI), (vec_float32)(FP_LO));
#define VEC_LENGTHEN_TO_FP32(IN, OUT_HI, OUT_LO) \
aiu_vec_lengthen_to_fp32((IN), (vec_float32 *)((void *)&(OUT_HI)), \
(vec_float32 *)((void *)&(OUT_LO)));
aiu_vec_lengthen_to_fp32((IN), (vec_float32 *)&(OUT_HI), \
(vec_float32 *)&(OUT_LO));
#else
#define VEC_ROUND_FROM_FP32(FP_HI, FP_LO) \
(vec_int16) vec_round_from_fp32((FP_HI), (FP_LO), 0);
Expand Down Expand Up @@ -1542,6 +1541,32 @@ void dumpdata_ztensor(const zdnn_ztensor *ztensor, dump_mode mode,
#define PADDED(x) \
((uint32_t)CEIL(x, AIU_2BYTE_CELLS_PER_STICK) * AIU_2BYTE_CELLS_PER_STICK)

#if !defined(vec_float) || __ARCH__ < 13
#undef vec_float
#define vec_float(X) \
({ \
__vector float out; \
/* vcefb\t%[out],%[in],0,0 */ \
__asm__(".insn vrr,0xe700000020c3,%[out],%[in],0,2,0,0" \
: [out] "=v"(out) \
: [in] "v"(X)); \
out; \
})
#endif

#if defined(__GNUC__) && __GNUC__ <= 7
#undef vec_round
#define vec_round(X) \
({ \
__vector float out; \
/* vfisb %[out],%[in],4,4 */ \
__asm__(".insn vrr,0xe700000020c7,%[out],%[in],0,2,4,4" \
: [out] "=v"(out) \
: [in] "v"(X)); \
out; \
})
#endif

// -----------------------------------------------------------------------------
// Private global variables
// -----------------------------------------------------------------------------
Expand Down

0 comments on commit 235f0d7

Please sign in to comment.