Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reenable quad and double precision in libm #545

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ if (SLEEF_ENFORCE_FLOAT128 AND NOT COMPILER_SUPPORTS_FLOAT128)
message(FATAL_ERROR "SLEEF_ENFORCE_FLOAT128 is specified and that feature is disabled or not supported by the compiler")
endif()

if(COMPILER_SUPPORTS_FLOAT128)
CHECK_C_SOURCE_COMPILES("
#include <quadmath.h>
int main() { __float128 r = 1;
}" COMPILER_SUPPORTS_QUADMATH)
endif()

# SSE2

option(SLEEF_DISABLE_SSE2 "Disable SSE2" OFF)
Expand Down
13 changes: 11 additions & 2 deletions src/common/misc.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Naoki Shibata and contributors 2010 - 2023.
// Copyright Naoki Shibata and contributors 2010 - 2024.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -158,6 +158,10 @@
#define stringify(s) stringify_(s)
#define stringify_(s) #s

#if !defined(SLEEF_GENHEADER)
typedef long double longdouble;
#endif

#if !defined(Sleef_double2_DEFINED) && !defined(SLEEF_GENHEADER)
#define Sleef_double2_DEFINED
typedef struct {
Expand All @@ -172,7 +176,12 @@ typedef struct {
} Sleef_float2;
#endif

//
#if !defined(Sleef_longdouble2_DEFINED) && !defined(SLEEF_GENHEADER)
#define Sleef_longdouble2_DEFINED
typedef struct {
long double x, y;
} Sleef_longdouble2;
#endif

#if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER)

Expand Down
47 changes: 46 additions & 1 deletion src/common/quaddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#if !defined(Sleef_quad_DEFINED)
#define Sleef_quad_DEFINED
typedef struct { uint64_t x, y; } Sleef_uint64_2t;
#if defined(SLEEF_FLOAT128_IS_IEEEQP)
#if defined(SLEEF_FLOAT128_IS_IEEEQP) || defined(ENABLEFLOAT128)
typedef __float128 Sleef_quad;
#define SLEEF_QUAD_C(x) (x ## Q)
#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP)
Expand All @@ -27,6 +27,51 @@ typedef Sleef_uint64_2t Sleef_quad;
#endif
#endif

#if !defined(Sleef_quad1_DEFINED)
#define Sleef_quad1_DEFINED
typedef union {
struct {
Sleef_quad x;
};
Sleef_quad s[1];
} Sleef_quad1;
#endif

#if !defined(Sleef_quad2_DEFINED)
#define Sleef_quad2_DEFINED
typedef union {
struct {
Sleef_quad x, y;
};
Sleef_quad s[2];
} Sleef_quad2;
#endif

#if !defined(Sleef_quad4_DEFINED)
#define Sleef_quad4_DEFINED
typedef union {
struct {
Sleef_quad x, y, z, w;
};
Sleef_quad s[4];
} Sleef_quad4;
#endif

#if !defined(Sleef_quad8_DEFINED)
#define Sleef_quad8_DEFINED
typedef union {
Sleef_quad s[8];
} Sleef_quad8;
#endif

#if defined(__ARM_FEATURE_SVE) && !defined(Sleef_quadx_DEFINED)
#define Sleef_quadx_DEFINED
typedef union {
Sleef_quad s[32];
} Sleef_quadx;
#endif


#else // #if !defined(SLEEF_GENHEADER)

SLEEFSHARPif !defined(SLEEFXXX__NVCC__) && ((defined(SLEEFXXX__SIZEOF_FLOAT128__) && SLEEFXXX__SIZEOF_FLOAT128__ == 16) || (defined(SLEEFXXX__linux__) && defined(SLEEFXXX__GNUC__) && (defined(SLEEFXXX__i386__) || defined(SLEEFXXX__x86_64__))) || (defined(SLEEFXXX__PPC64__) && defined(SLEEFXXX__GNUC__) && !defined(SLEEFXXX__clang__) && SLEEFXXX__GNUC__ >= 8))
Expand Down
18 changes: 12 additions & 6 deletions src/libm-tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -422,25 +422,31 @@ endif()

if(LIB_MPFR AND NOT MINGW)
# Build tester2 scalar
foreach(P dp sp)
set(PRECISIONS dp sp)
if(COMPILER_SUPPORTS_LONG_DOUBLE)
list(APPEND PRECISIONS ld)
endif()
if(COMPILER_SUPPORTS_QUADMATH)
list(APPEND PRECISIONS qp)
set(LIBQUADMATH "-lquadmath")
set(ENABLEFLOAT128 PRIVATE ENABLEFLOAT128=1)
endif()
foreach(P ${PRECISIONS})
set(T "tester2${P}")
add_executable(${T} tester2${P}.c testerutil.c)
target_compile_definitions(${T} PRIVATE USEMPFR=1 ${COMMON_TARGET_DEFINITIONS})
target_compile_definitions(${T} PRIVATE USEMPFR=1 ${ENABLEFLOAT128} ${COMMON_TARGET_DEFINITIONS})
set_target_properties(${T} PROPERTIES ${COMMON_TARGET_PROPERTIES})
if (FORCE_AAVPCS)
target_compile_definitions(${T} PRIVATE ENABLE_AAVPCS=1)
endif(FORCE_AAVPCS)
if (MPFR_INCLUDE_DIR)
target_include_directories(${T} PRIVATE ${MPFR_INCLUDE_DIR})
endif()

target_link_libraries(${T} ${TARGET_LIBSLEEF} ${LIB_MPFR} ${LIBM} ${LIBGMP})
target_link_libraries(${T} ${TARGET_LIBSLEEF} ${LIBQUADMATH} ${LIB_MPFR} ${LIBM} ${LIBGMP})
add_dependencies(${T} ${TARGET_HEADERS})
add_dependencies(${T} ${TARGET_LIBSLEEF})
endforeach()

# No test defined with tester2

# Compile executable 'tester'
add_host_executable(${TARGET_TESTER} tester.c testerutil.c)
if (NOT CMAKE_CROSSCOMPILING)
Expand Down
Loading
Loading