Skip to content

Commit

Permalink
[CUDA] Include purec header from CUDA (shibatch#394)
Browse files Browse the repository at this point in the history
With this patch, the pure C inline header can be included from CUDA programs along with the CUDA inline header.
  • Loading branch information
shibatch authored Jan 17, 2021
1 parent 295a8b6 commit bf50d61
Show file tree
Hide file tree
Showing 27 changed files with 238 additions and 195 deletions.
6 changes: 4 additions & 2 deletions Configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,13 @@ if(SLEEF_SHOW_ERROR_LOG)
if (EXISTS ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeError.log)
file(READ ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeError.log FILE_CONTENT)
message("")
message("===== Content of CMakeError.log =====")
message("")
message("====== Content of CMakeError.log ======")
message("")
message("${FILE_CONTENT}")
message("")
message("=======================================")
message("======== End of CMakeError.log ========")
message("")
message("")
endif()
endif(SLEEF_SHOW_ERROR_LOG)
Expand Down
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ build_script:
- if "%DO_TEST%" == "TRUE" call p.bat
- if "%DO_TEST%" == "TRUE" "C:\\Cygwin64\\bin\\bash" -c 'mkdir build-mingw;cd build-mingw;CC=x86_64-w64-mingw32-gcc cmake -G Ninja .. -DRUNNING_ON_APPVEYOR=TRUE -DBUILD_SHARED_LIBS=FALSE -DBUILD_QUAD=TRUE -DBUILD_DFT=TRUE -DENFORCE_SSE2=TRUE -DENFORCE_SSE4=TRUE;ninja'
- if "%DO_TEST%" == "TRUE" cd "%BUILDFOLDER%"
- if "%DO_TEST%" == "TRUE" "C:\\Cygwin64\\bin\\bash" -c 'mkdir build-cygwin;cd build-cygwin;cmake -G Ninja -DRUNNING_ON_APPVEYOR=TRUE -DBUILD_QUAD=TRUE -DBUILD_DFT=TRUE -DBUILD_INLINE_HEADERS=TRUE -DENFORCE_SSE2=TRUE -DENFORCE_SSE2=TRUE -DENFORCE_SSE4=TRUE ..;ninja'
- if "%DO_TEST%" == "TRUE" "C:\\Cygwin64\\bin\\bash" -c 'mkdir build-cygwin;cd build-cygwin;cmake -G Ninja -DRUNNING_ON_APPVEYOR=TRUE -DBUILD_QUAD=TRUE -DBUILD_DFT=FALSE -DBUILD_INLINE_HEADERS=TRUE -DENFORCE_SSE2=TRUE -DENFORCE_SSE2=TRUE -DENFORCE_SSE4=TRUE ..;ninja'
- if "%DO_TEST%" == "TRUE" cd "%BUILDFOLDER%"
- if "%DO_TEST%" == "TRUE" "C:\\Cygwin64\\bin\\bash" -c 'cd build-cygwin;ctest -j `nproc`'
- if "%DO_TEST%" == "TRUE" cd "%BUILDFOLDER%"
- if "%DO_TEST%" == "TRUE" del /Q /F build-cygwin\bin\iut*
- if "%DO_TEST%" == "TRUE" echo PATH %ORGPATH%;c:\Cygwin64\bin;c:\Cygwin64\usr\bin;%CD%\build-cygwin\bin;%CD%\build\bin > q.bat
Expand Down
18 changes: 0 additions & 18 deletions include/sleefdft.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,6 @@ IMPORT struct SleefDFT *SleefDFT_float_init1d(uint32_t n, const float *in, float
IMPORT struct SleefDFT *SleefDFT_float_init2d(uint32_t n, uint32_t m, const float *in, float *out, uint64_t mode);
IMPORT void SleefDFT_float_execute(struct SleefDFT *ptr, const float *in, float *out);

IMPORT struct SleefDFT *SleefDFT_longdouble_init1d(uint32_t n, const long double *in, long double *out, uint64_t mode);
IMPORT struct SleefDFT *SleefDFT_longdouble_init2d(uint32_t n, uint32_t m, const long double *in, long double *out, uint64_t mode);
IMPORT void SleefDFT_longdouble_execute(struct SleefDFT *ptr, const long double *in, long double *out);

#if defined(ENABLEFLOAT128) && !defined(Sleef_quad2_DEFINED)
#define Sleef_quad2_DEFINED
typedef __float128 Sleef_quad;
typedef struct {
Sleef_quad x, y;
} Sleef_quad2;
#endif

#if defined(Sleef_quad2_DEFINED)
IMPORT struct SleefDFT *SleefDFT_quad_init1d(uint32_t n, const Sleef_quad *in, Sleef_quad *out, uint64_t mode);
IMPORT struct SleefDFT *SleefDFT_quad_init2d(uint32_t n, uint32_t m, const Sleef_quad *in, Sleef_quad *out, uint64_t mode);
IMPORT void SleefDFT_quad_execute(struct SleefDFT *ptr, const Sleef_quad *in, Sleef_quad *out);
#endif

IMPORT void SleefDFT_dispose(struct SleefDFT *ptr);

IMPORT void SleefDFT_setPath(struct SleefDFT *ptr, char *pathStr);
Expand Down
14 changes: 5 additions & 9 deletions src/arch/helperpurec_scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,12 @@ typedef int64_t vint2;
typedef int64_t vint64;
typedef uint64_t vuint64;

typedef struct {
vmask x, y;
} vquad;

#if defined(ENABLEFLOAT128) && CONFIG != 3
typedef __float128 vargquad;
#elif defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && defined(__aarch64__) && CONFIG != 3
typedef long double vargquad;
typedef Sleef_uint64_2t vquad;

#if CONFIG != 3
typedef Sleef_quad vargquad;
#else
typedef vquad vargquad;
typedef Sleef_uint64_2t vargquad;
#endif

//
Expand Down
3 changes: 3 additions & 0 deletions src/common/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -679,3 +679,6 @@ fma_tdx_tdx_tdx_tdx
hypot_tdx_tdx_tdx
ilogb_vi_tdx
ldexp_tdx_tdx_vi
Sleef_rempitabsp
Sleef_rempitabdp
Sleef_rempitabqp
13 changes: 0 additions & 13 deletions src/common/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,6 @@ typedef struct {
} Sleef_float2;
#endif

#if !defined(Sleef_quad_DEFINED) && !defined(SLEEF_GENHEADER)
#define Sleef_quad_DEFINED
#if defined(ENABLEFLOAT128)
typedef __float128 Sleef_quad;
#define SLEEF_QUAD_C(x) (x ## Q)
#elif defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__))
typedef long double Sleef_quad;
#define SLEEF_QUAD_C(x) (x ## L)
#else
typedef struct { uint64_t x, y; } Sleef_quad;
#endif
#endif

//

#if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER)
Expand Down
54 changes: 54 additions & 0 deletions src/common/quaddef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright Naoki Shibata and contributors 2010 - 2021.
// 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)

#if !defined(SLEEF_GENHEADER)

#if (defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8)
#define SLEEF_FLOAT128_IS_IEEEQP
#endif

#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__))
#define SLEEF_LONGDOUBLE_IS_IEEEQP
#endif

#if !defined(Sleef_quad_DEFINED)
#define Sleef_quad_DEFINED
typedef struct { uint64_t x, y; } Sleef_uint64_2t;
#if defined(SLEEF_FLOAT128_IS_IEEEQP)
typedef __float128 Sleef_quad;
#define SLEEF_QUAD_C(x) (x ## Q)
#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP)
typedef long double Sleef_quad;
#define SLEEF_QUAD_C(x) (x ## L)
#else
typedef Sleef_uint64_2t Sleef_quad;
#endif
#endif

#else // #if !defined(SLEEF_GENHEADER)

SLEEFSHARPif (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)
SLEEFSHARPdefine SLEEFXXXSLEEF_FLOAT128_IS_IEEEQP
SLEEFSHARPendif

SLEEFSHARPif !defined(SLEEFXXXSLEEF_FLOAT128_IS_IEEEQP) && defined(SLEEFXXX__SIZEOF_LONG_DOUBLE__) && SLEEFXXX__SIZEOF_LONG_DOUBLE__ == 16 && (defined(SLEEFXXX__aarch64__) || defined(SLEEFXXX__zarch__))
SLEEFSHARPdefine SLEEFXXXSLEEF_LONGDOUBLE_IS_IEEEQP
SLEEFSHARPendif

SLEEFSHARPif !defined(SLEEFXXXSleef_quad_DEFINED)
SLEEFSHARPdefine SLEEFXXXSleef_quad_DEFINED
typedef struct { uint64_t x, y; } Sleef_uint64_2t;
SLEEFSHARPif defined(SLEEFXXXSLEEF_FLOAT128_IS_IEEEQP)
typedef __float128 Sleef_quad;
SLEEFSHARPdefine SLEEFXXXSLEEF_QUAD_C(x) (x ## Q)
SLEEFSHARPelif defined(SLEEFXXXSLEEF_LONGDOUBLE_IS_IEEEQP)
typedef long double Sleef_quad;
SLEEFSHARPdefine SLEEFXXXSLEEF_QUAD_C(x) (x ## L)
SLEEFSHARPelse
typedef Sleef_uint64_2t Sleef_quad;
SLEEFSHARPendif
SLEEFSHARPendif

#endif // #if !defined(SLEEF_GENHEADER)
2 changes: 1 addition & 1 deletion src/libm-tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ set(IUT_LIST ${TARGET_IUT})
if (BUILD_INLINE_HEADERS AND SED_COMMAND AND CMAKE_CUDA_COMPILER)
add_executable(iutcuda iutcuda.cu)
set_target_properties(iutcuda PROPERTIES LINKER_LANGUAGE CUDA)
target_compile_options(iutcuda PRIVATE "--fmad=false")
target_compile_options(iutcuda PRIVATE "--fmad=false;-Xcompiler;-ffp-contract=off")
add_dependencies(iutcuda ${TARGET_INLINE_HEADERS})
add_test_iut(iutcuda 20.0)
list(APPEND IUT_LIST iutcuda)
Expand Down
1 change: 1 addition & 0 deletions src/libm-tester/iutcuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <stdint.h>
#include <cuda.h>

#include "sleefinline_purec_scalar.h"
#include "sleefinline_cuda.h"

#define STDIN_FILENO 0
Expand Down
1 change: 1 addition & 0 deletions src/libm-tester/iutsimd.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <signal.h>
#endif

#include "quaddef.h"
#include "misc.h"

#if !defined(USE_INLINE_HEADER)
Expand Down
1 change: 1 addition & 0 deletions src/libm-tester/tester2simddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#endif

#include "sleef.h"
#include "quaddef.h"
#include "testerutil.h"

#ifdef ENABLE_SSE2
Expand Down
2 changes: 1 addition & 1 deletion src/libm-tester/tester2simdsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/random.h>
#endif

#include "sleef.h"
#include "quaddef.h"
#include "testerutil.h"

#ifdef ENABLE_SSE2
Expand Down
Loading

0 comments on commit bf50d61

Please sign in to comment.