diff --git a/CMakeLists.txt b/CMakeLists.txt
index c38219f1..dc45d5f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,24 @@ function(command_arguments PROPNAME)
set(${PROPNAME} ${quoted_args} PARENT_SCOPE)
endfunction()
+# Helper function for concatenating several files
+function(sleef_concat_files)
+ cmake_parse_arguments(concat_required "" "OUTPUT" "SOURCES" ${ARGN})
+ if("${concat_required_OUTPUT}" STREQUAL "")
+ message(FATAL_ERROR "Must pass OUTPUT to sleef_concat_files")
+ endif()
+
+ if(NOT concat_required_SOURCES)
+ message(FATAL_ERROR "sleef_concat_files not passed any SOURCES")
+ endif()
+
+ add_custom_command(
+ OUTPUT ${concat_required_OUTPUT}
+ COMMAND ${CMAKE_COMMAND} -E cat ${concat_required_SOURCES} > ${concat_required_OUTPUT}
+ DEPENDS ${concat_required_SOURCES}
+ COMMAND_EXPAND_LISTS)
+endfunction()
+
# Settings
set(SLEEF_ALL_SUPPORTED_EXTENSIONS
@@ -94,7 +112,7 @@ set(COSTOVERRIDE_RVVM2NOFMA 20)
#
-cmake_minimum_required(VERSION 3.4.3)
+cmake_minimum_required(VERSION 3.18)
if(${CMAKE_VERSION} VERSION_GREATER "3.14.99")
cmake_policy(SET CMP0091 NEW)
@@ -318,8 +336,3 @@ if(SLEEF_SHOW_CONFIG)
endif()
endif(SLEEF_SHOW_CONFIG)
-if (NOT CMAKE_MAKE_PROGRAM MATCHES "ninja")
- message("")
- message("*** Note: Parallel build is only supported with Ninja ***")
- message("")
-endif()
diff --git a/doc/build-with-cmake.md b/doc/build-with-cmake.md
index 257fe1eb..aa41c2f5 100644
--- a/doc/build-with-cmake.md
+++ b/doc/build-with-cmake.md
@@ -17,14 +17,14 @@ Before using CMake you will need to install/build the binaries on your system.
Most systems have cmake already installed or provided by the standard package
manager. If that is not the case for you, please
[download](https://cmake.org/download/) and install now.
-For building SLEEF, version 3.4.3 is the minimum required.
+For building SLEEF, version 3.18 is the minimum required.
# Quick start
1. Make sure cmake is available on the command-line.
```
$ cmake --version
-(should display a version number greater than or equal to 3.4.3)
+(should display a version number greater than or equal to 3.18)
```
2. Download the tar from the
diff --git a/doc/html/compile.xhtml b/doc/html/compile.xhtml
index c2a62864..7a1213eb 100644
--- a/doc/html/compile.xhtml
+++ b/doc/html/compile.xhtml
@@ -236,10 +236,6 @@ $ make test
$ sudo make install
-
- Parallel build is only supported with Ninja.
-
-
diff --git a/src/libm/CMakeLists.txt b/src/libm/CMakeLists.txt
index a0e4029d..314d8138 100644
--- a/src/libm/CMakeLists.txt
+++ b/src/libm/CMakeLists.txt
@@ -194,26 +194,20 @@ set(SLEEF_INCLUDE_HEADER ${sleef_BINARY_DIR}/include/sleef.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sleeflibm_header.h.org.in ${SLEEF_ORG_HEADER})
-set(SLEEF_HEADER_COMMANDS "")
-list(APPEND SLEEF_HEADER_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy ${SLEEF_ORG_HEADER} ${SLEEF_INCLUDE_HEADER})
+set(SLEEF_HEADER_SIMD_SECTIONS "")
foreach(SIMD ${SLEEF_HEADER_LIST})
- list(APPEND SLEEF_HEADER_COMMANDS COMMAND echo Generating sleef.h: ${TARGET_MKRENAME} ${HEADER_PARAMS_${SIMD}})
- list(APPEND SLEEF_HEADER_COMMANDS COMMAND $ ${HEADER_PARAMS_${SIMD}} >> ${SLEEF_INCLUDE_HEADER})
+ set(SIMD_SECTION_FILE ${CMAKE_CURRENT_BINARY_DIR}/sleeflibm_${SIMD}.h.tmp)
+ list(APPEND SLEEF_HEADER_SIMD_SECTIONS ${SIMD_SECTION_FILE})
+ add_custom_command(
+ OUTPUT ${SIMD_SECTION_FILE}
+ COMMAND $ ${HEADER_PARAMS_${SIMD}} > ${SIMD_SECTION_FILE}
+ DEPENDS ${TARGET_MKRENAME}
+ )
endforeach()
-if((MSVC OR MINGW AND WIN32) OR SLEEF_CLANG_ON_WINDOWS)
- string(REPLACE "/" "\\" sleef_footer_input_file "${SLEEF_ORG_FOOTER}")
- list(APPEND SLEEF_HEADER_COMMANDS COMMAND type ${sleef_footer_input_file} >> ${SLEEF_INCLUDE_HEADER})
-else()
- list(APPEND SLEEF_HEADER_COMMANDS COMMAND cat ${SLEEF_ORG_FOOTER} >> ${SLEEF_INCLUDE_HEADER})
-endif()
-
-add_custom_command(OUTPUT ${SLEEF_INCLUDE_HEADER}
- ${SLEEF_HEADER_COMMANDS}
- DEPENDS
- ${SLEEF_ORG_HEADER}
- ${SLEEF_ORG_FOOTER}
- ${TARGET_MKRENAME}
+sleef_concat_files(
+ OUTPUT ${SLEEF_INCLUDE_HEADER}
+ SOURCES ${SLEEF_ORG_HEADER} ${SLEEF_HEADER_SIMD_SECTIONS} ${SLEEF_ORG_FOOTER}
)
# --------------------------------------------------------------------
@@ -430,10 +424,18 @@ foreach(SIMD ${SLEEF_SUPPORTED_LIBM_EXTENSIONS})
)
else()
add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_dp.h.tmp
+ COMMAND $ ${ALIAS_PARAMS_${SIMD}_DP} > ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_dp.h.tmp
+ DEPENDS ${TARGET_MKALIAS}
+ )
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_sp.h.tmp
+ COMMAND $ ${ALIAS_PARAMS_${SIMD}_SP} > ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_sp.h.tmp
+ DEPENDS ${TARGET_MKALIAS}
+ )
+ sleef_concat_files(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/alias_${SIMDLC}.h
- COMMAND $ ${ALIAS_PARAMS_${SIMD}_SP} > ${CMAKE_CURRENT_BINARY_DIR}/include/alias_${SIMDLC}.h
- COMMAND $ ${ALIAS_PARAMS_${SIMD}_DP} >> ${CMAKE_CURRENT_BINARY_DIR}/include/alias_${SIMDLC}.h
- DEPENDS ${TARGET_MKALIAS}
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_sp.h.tmp ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_dp.h.tmp
)
add_custom_target(alias_${SIMDLC}.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/alias_${SIMDLC}.h)
add_dependencies(${OBJECT_${SIMD}} alias_${SIMDLC}.h_generated)
@@ -491,33 +493,60 @@ if(BUILD_INLINE_HEADERS)
set(INLINE_HEADER_FILES_GENERATED "")
if (SED_COMMAND)
- foreach(SIMD ${SLEEF_SUPPORTED_LIBM_EXTENSIONS})
- if(COMPILER_SUPPORTS_${SIMD})
+ foreach(SIMD ${SLEEF_SUPPORTED_LIBM_EXTENSIONS} CUDA)
+ if(COMPILER_SUPPORTS_${SIMD} OR ${SIMD} STREQUAL "CUDA")
string(TOLOWER ${SIMD} SIMDLC)
- if(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_TARGET)
+ if(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_TARGET AND NOT "${SIMD}" STREQUAL "CUDA" )
set(FLAG_TARGET --target=${CMAKE_C_COMPILER_TARGET})
endif()
+ if ("${SIMD}" STREQUAL "CUDA")
+ set(TARGET_PP_FLAGS ${FLAG_DEFINE}SLEEF_ALWAYS_INLINE=__device__
+ ${FLAG_DEFINE}SLEEF_INLINE=__device__
+ ${FLAG_DEFINE}SLEEF_CONST=__device__
+ ${FLAG_DEFINE}static=__device__)
+ set(INLINE_HEADER_ORG ${CMAKE_CURRENT_SOURCE_DIR}/sleefinline_cuda_header.h.org)
+ # Remove redundant __device__
+ set(TARGET_REPLACEMENTS -e "s/__device__ __device__/__device__/g" -e "s/__device__ __device__/__device__/g")
+ set(TARGET_ADDSUFFIX_KEYWORDS double2 double3 float2)
+ else()
+ set(TARGET_ADDSUFFIX_KEYWORDS Sleef_rempitabdp Sleef_rempitabsp)
+ set(INLINE_HEADER_ORG ${CMAKE_CURRENT_SOURCE_DIR}/sleefinline_header.h.org)
+ endif()
+
set(INLINE_HEADER_FILE ${PROJECT_BINARY_DIR}/include/sleefinline_${SIMDLC}.h)
add_custom_command(
- OUTPUT ${INLINE_HEADER_FILE}
-
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp
+
# Preprocess sleefsimddp.c with SLEEF_GENHEADER defined, comments are preserved
COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C
${FLAG_TARGET} ${FLAGS_ENABLE_${SIMD}} # -msse2
${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch
${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/libm/include
${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_SSE2 -DDORENAME
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp1 # /sleef/src/libm/sleefsimddp.c > /build/libm/sleefSSE2.h.tmp1
+ ${TARGET_PP_FLAGS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp # /sleef/src/libm/sleefsimddp.c > /build/libm/sleefsimddpSSE2.h.tmp
+
+ # ${HEADER_${SIMD}} listed here as sleefsimddp.c includes it for renaming
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c ${HEADER_${SIMD}}
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/macroonly${SIMD}.h
- # Remove all lines except those begin with "//@"
- COMMAND ${SED_COMMAND} -n -e "/^\\/\\/@#.*$/p" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp1 # sed -n -e "/^\\/\\/@#.*$/p" /build/src/libm/sleefSSE2.h.tmp1
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp2 # > /build/src/libm/sleefSSE2.h.tmp2
+ # Remove all lines except those begin with "//@", then remove "//@"
+ COMMAND ${SED_COMMAND} -e "/^\\/\\/@#.*$/!d"
+ -e "s/^\\/\\/@#/#/g"
+ ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp
+ > ${CMAKE_CURRENT_BINARY_DIR}/include/macroonly${SIMD}.h
- # Remove "//@"
- COMMAND ${SED_COMMAND} -e "s/^\\/\\/@#/#/g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp2 # sed -e "s/^\\/\\/@#/#/g" /build/src/libm/sleefSSE2.h.tmp2
- > ${CMAKE_CURRENT_BINARY_DIR}/include/macroonly${SIMD}.h # > /build/src/libm/include/macroonlySSE2.h
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp
+ VERBATIM
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleefsimdsp${SIMD}.h.tmp
# Preprocess sleefsimdsp.c with SLEEF_GENHEADER defined. Include macroonly*.h instead of helper*.h.
COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C
@@ -525,146 +554,86 @@ if(BUILD_INLINE_HEADERS)
${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch
${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/libm/include
${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_SSE2 -DDORENAME
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c >> ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp1 # /sleef/src/libm/sleefsimdsp.c >> /build/libm/sleefSSE2.h.tmp1
+ ${TARGET_PP_FLAGS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleefsimdsp${SIMD}.h.tmp # /sleef/src/libm/sleefsimdsp.c > /build/libm/sleefsimdspSSE2.h.tmp
+
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/include/macroonly${SIMD}.h ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c
# Remove lines beginning with "#" so that the resulting file can be preprocessed again.
- COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp1 # sed -e "s/^#.*//g" /build/src/libm/sleefSSE2.h.tmp1
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c # > /build/src/libm/sleefSSE2.h.c
+ COMMAND ${CMAKE_COMMAND} -E cat ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp
+ ${CMAKE_CURRENT_BINARY_DIR}/sleefsimdsp${SIMD}.h.tmp
+ | ${SED_COMMAND} -e "s/^#.*//g" > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c
+
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleefsimdsp${SIMD}.h.tmp ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp
+ VERBATIM
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3
# Preprocess the intemediate file again to remove comments
- COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} # gcc -E
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c # /build/src/libm/sleefSSE2.h.c
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3 # > /build/src/libm/sleefSSE2.h.tmp3
-
- # Embed version number into the header
- COMMAND ${SED_COMMAND} -e # sed -e
- "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL}/g" # "s/SLEEF_VERSION_SLEEF/3.5.0/g"
- -e "s/SLEEF_SIMD_SLEEF/${SIMD}/g" # -e "s/SLEEF_SIMD_SLEEF/SSE2/g"
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefinline_header.h.org # /sleef/src/libm/sleefinline_header.h.org
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 # > /build/src/libm/sleefSSE2.h.tmp4
-
- # Remove lines beginning with "#"
- COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3 # sed -e "s/^#.*//g" /build/src/libm/sleefSSE2.h.tmp3
- >> ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 # >> /build/src/libm/sleefSSE2.h.tmp4
-
- # Substitute "SLEEFSHARP" at the beginning of line with "#"
- COMMAND ${SED_COMMAND} -e "s/^SLEEFSHARP/#/g" # sed -e "s/^SLEEFSHARP/#/g"
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 # /build/src/libm/sleefSSE2.h.tmp4
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 # > /build/src/libm/sleefSSE2.h.tmp5
-
- # Remove SLEEFXXX
- COMMAND ${SED_COMMAND} -e "s/SLEEFXXX//g" # sed -e "s/SLEEFXXX//g"
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 # /build/src/libm/sleefSSE2.h.tmp5
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp6 # > /build/src/libm/sleefSSE2.h.tmp6
-
- # Replace multiple empty lines with a single empty line
- COMMAND ${SED_COMMAND} -e "s/^[[:space:]]*$//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp6 # sed -e "s/^[[:space:]]*$//g" /build/src/libm/sleefSSE2.h.tmp6
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp7 # > /build/src/libm/sleefSSE2.h.tmp7
- COMMAND ${SED_COMMAND} "/^$/N;/^\\n$/D" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp7 # sed -e "/^$/N;/^\n$/D" /build/src/libm/sleefSSE2.h.tmp7
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp8 # > /build/src/libm/sleefSSE2.h.tmp8
-
- COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp8 # addSuffix /build/src/libm/sleefSSE2.h.tmp8
- ${sleef_SOURCE_DIR}/src/common/keywords.txt "_${SIMDLC}_sleef" # keywords.txt "_sse2_sleef"
- Sleef_rempitabdp Sleef_rempitabsp # Sleef_rempitabdp Sleef_rempitabsp
- > ${PROJECT_BINARY_DIR}/include/sleefinline_${SIMDLC}.h # > /build/include/sleefinline_sse2.h
+ COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c
+ # Remove lines beginning with "#"
+ | ${SED_COMMAND} -e "s/^#.*//g"
+ > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c ${HEADER_${SIMD}}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c ${HEADER_${SIMD}} addSuffix
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c
VERBATIM
)
- list(APPEND INLINE_HEADER_FILES_GENERATED ${INLINE_HEADER_FILE})
- endif(COMPILER_SUPPORTS_${SIMD})
- endforeach()
-
- # Generate CUDA header file
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4
+
+ COMMAND ${CMAKE_COMMAND} -E cat
+ ${INLINE_HEADER_ORG}
+ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3
+ | ${SED_COMMAND}
+ # Embed version number into the header
+ -e "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL}/g"
+ -e "s/SLEEF_SIMD_SLEEF/${SIMD}/g"
+ # Substitute "SLEEFSHARP" at the beginning of line with "#"
+ -e "s/^SLEEFSHARP/#/g"
+ # Remove SLEEFXXX
+ -e "s/SLEEFXXX//g"
+ # Replace multiple empty lines with a single empty line (part 1)
+ -e "s/^[[:space:]]*$//g"
+ > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4
+
+ DEPENDS ${INLINE_HEADER_ORG} ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3
+ VERBATIM
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5
+
+ # Replace multiple empty lines with a single empty line
+ # (part 2 - cannot occur in same command as part 1)
+ COMMAND ${SED_COMMAND} -e "/^$/N" -e "/^\\n$/D" ${TARGET_REPLACEMENTS} ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4
+ > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5
+
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4
+ VERBATIM
+ )
- set(SIMD CUDA)
- string(TOLOWER ${SIMD} SIMDLC)
+ add_custom_command(
+ OUTPUT ${INLINE_HEADER_FILE}
- set(INLINE_HEADER_FILE ${PROJECT_BINARY_DIR}/include/sleefinline_cuda.h)
-
- add_custom_command(
- OUTPUT ${INLINE_HEADER_FILE}
-
- # Preprocess sleefsimddp.c with SLEEF_GENHEADER defined, comments are preserved
- COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C
- ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch
- ${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/libm/include
- ${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_CUDA -DDORENAME
- ${FLAG_DEFINE}SLEEF_ALWAYS_INLINE=__device__ ${FLAG_DEFINE}SLEEF_INLINE=__device__ # -DSLEEF_ALWAYS_INLINE=__device__ -DSLEEF_INLINE=__device__
- ${FLAG_DEFINE}SLEEF_CONST=__device__ ${FLAG_DEFINE}static=__device__ # -DSLEEF_CONST=__device__ -Dstatic=__device__
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp1 # /sleef/src/libm/sleefsimddp.c > /build/libm/sleefCUDA.h.tmp1
-
- # Remove all lines except those begin with "//@"
- COMMAND ${SED_COMMAND} -n -e "/^\\/\\/@#.*$/p" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp1 # sed -n -e "/^\\/\\/@#.*$/p" /build/src/libm/sleefCUDA.h.tmp1
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp2 # > /build/src/libm/sleefCUDA.h.tmp2
-
- # Remove "//@"
- COMMAND ${SED_COMMAND} -e "s/^\\/\\/@#/#/g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp2 # sed -e "s/^\\/\\/@#/#/g" /build/src/libm/sleefCUDA.h.tmp2
- > ${CMAKE_CURRENT_BINARY_DIR}/include/macroonly${SIMD}.h # > /build/src/libm/include/macroonlyCUDA.h
-
- # Preprocess sleefsimdsp.c with SLEEF_GENHEADER defined. Include macroonly*.h instead of helper*.h.
- COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C
- ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch
- ${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/libm/include
- ${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_CUDA -DDORENAME
- ${FLAG_DEFINE}SLEEF_ALWAYS_INLINE=__device__ ${FLAG_DEFINE}SLEEF_INLINE=__device__ # -DSLEEF_ALWAYS_INLINE=__device__ -DSLEEF_INLINE=__device__
- ${FLAG_DEFINE}SLEEF_CONST=__device__ ${FLAG_DEFINE}static=__device__ # -DSLEEF_CONST=__device__ -Dstatic=__device__
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c >> ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp1 # /sleef/src/libm/sleefsimdsp.c >> /build/libm/sleefCUDA.h.tmp1
-
- # Remove lines beginning with "#" so that the resulting file can be preprocessed again.
- COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp1 # sed -e "s/^#.*//g" /build/src/libm/sleefCUDA.h.tmp1
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c # > /build/src/libm/sleefCUDA.h.c
-
- # Preprocess the intemediate file again to remove comments
- COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} # gcc -E
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c # /build/src/libm/sleefCUDA.h.c
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3 # > /build/src/libm/sleefCUDA.h.tmp3
-
- # Embed version number into the header
- COMMAND ${SED_COMMAND} -e # sed -e
- "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL}/g" # "s/SLEEF_VERSION_SLEEF/3.5.0/g"
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefinline_cuda_header.h.org # /sleef/src/libm/sleefinline_header.h.org
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 # > /build/src/libm/sleefCUDA.h.tmp4
-
- # Remove lines beginning with "#"
- COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3 # sed -e "s/^#.*//g" /build/src/libm/sleefCUDA.h.tmp3
- >> ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 # >> /build/src/libm/sleefCUDA.h.tmp4
-
- # Substitute "SLEEFSHARP" at the beginning of line with "#"
- COMMAND ${SED_COMMAND} -e "s/^SLEEFSHARP/#/g" # sed -e "s/^SLEEFSHARP/#/g"
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 # /build/src/libm/sleefSSE2.h.tmp4
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 # > /build/src/libm/sleefSSE2.h.tmp5
-
- # Remove SLEEFXXX
- COMMAND ${SED_COMMAND} -e "s/SLEEFXXX//g" # sed -e "s/SLEEFXXX//g"
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 # /build/src/libm/sleefSSE2.h.tmp5
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp6 # > /build/src/libm/sleefSSE2.h.tmp6
-
- # Replace multiple empty lines with a single empty line
- COMMAND ${SED_COMMAND} -e "s/^[[:space:]]*$//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp6 # sed -e "s/^[[:space:]]*$//g" /build/src/libm/sleefCUDA.h.tmp6
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp7 # > /build/src/libm/sleefCUDA.h.tmp7
- COMMAND ${SED_COMMAND} "/^$/N;/^\\n$/D" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp7 # sed -e "/^$/N;/^\n$/D" /build/src/libm/sleefCUDA.h.tmp7
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp8 # > /build/src/libm/sleefCUDA.h.tmp8
-
- # Remove redundant __device__
- COMMAND ${SED_COMMAND} -e "s/__device__ __device__/__device__/g" # sed -e "s/__device__ __device__/__device__/g"
- -e "s/__device__ __device__/__device__/g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp8 # -e "s/__device__ __device__/__device__/g" /build/src/libm/sleefCUDA.h.tmp8
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp9 # > /build/src/libm/sleefCUDA.h.tmp9
-
- COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp9 # addSuffix /build/src/libm/sleefCUDA.h.tmp9
- ${sleef_SOURCE_DIR}/src/common/keywords.txt "_${SIMDLC}_sleef" double2 double3 float2 # keywords.txt "_cuda_sleef" double2 double3 float2
- > ${PROJECT_BINARY_DIR}/include/sleefinline_${SIMDLC}.h # > /build/include/sleefinline_cuda.h
-
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c ${HEADER_${SIMD}}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c ${HEADER_${SIMD}} addSuffix
- VERBATIM
- )
+ COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 # addSuffix /build/src/libm/sleefSSE2.h.tmp5
+ ${sleef_SOURCE_DIR}/src/common/keywords.txt "_${SIMDLC}_sleef" # keywords.txt "_sse2_sleef"
+ ${TARGET_ADDSUFFIX_KEYWORDS}
+ > ${PROJECT_BINARY_DIR}/include/sleefinline_${SIMDLC}.h # > /build/include/sleefinline_sse2.h
- list(APPEND INLINE_HEADER_FILES_GENERATED ${INLINE_HEADER_FILE})
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 addSuffix
+ VERBATIM
+ )
- #
+ list(APPEND INLINE_HEADER_FILES_GENERATED ${INLINE_HEADER_FILE})
+ endif(COMPILER_SUPPORTS_${SIMD} OR ${SIMD} STREQUAL "CUDA")
+ endforeach()
add_custom_target(${TARGET_INLINE_HEADERS}_util ALL
DEPENDS
@@ -707,12 +676,18 @@ target_sources(${TARGET_LIBSLEEF} PRIVATE $ 1 1 double float int32_t purec purecfma x >> ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/dispscalar_footer.c.org >> ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c
- DEPENDS ${TARGET_MKDISP} addSuffix
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c.body
+ COMMAND $ 1 1 double float int32_t purec purecfma x > ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c.body
+ DEPENDS ${TARGET_MKDISP}
)
+
+sleef_concat_files(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dispscalar.c.org
+ ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c.body
+ ${CMAKE_CURRENT_SOURCE_DIR}/dispscalar_footer.c.org
+)
add_custom_target(dispscalar.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c)
# Target renamedspscalar.h
@@ -734,43 +709,41 @@ target_sources(${TARGET_LIBSLEEF} PRIVATE $)
#
-if (SLEEF_ARCH_X86)
- # Target dispsse.c
-
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dispsse.c
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/dispsse.c.org ${CMAKE_CURRENT_BINARY_DIR}/dispsse.c
- COMMAND $ 2 4 __m128d __m128 __m128i sse2 sse4 avx2128 >> ${CMAKE_CURRENT_BINARY_DIR}/dispsse.c
+function(sleef_generate_disp_simd simd)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c.tmp
+ COMMAND $ "${ARGN}" > ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c.tmp
DEPENDS ${TARGET_MKDISP}
+ COMMAND_EXPAND_LISTS
)
- add_custom_target(dispsse.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dispsse.c)
-
- # Target renamedsp128.h
+ sleef_concat_files(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/disp${simd}.c.org ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c.tmp
+ )
+ add_custom_target(disp${simd}.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c)
+endfunction()
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h
- COMMAND $ - 2 4 > ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h
+function(sleef_generate_rename_simd simd)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/renamed${simd}.h
+ COMMAND $ "${ARGN}" > ${CMAKE_CURRENT_BINARY_DIR}/include/renamed${simd}.h
DEPENDS ${TARGET_MKRENAME}
+ COMMAND_EXPAND_LISTS
)
- add_custom_target(renamedsp128.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h)
+ add_custom_target(renamed${simd}.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/renamed${simd}.h)
+ endfunction()
- # Target dispavx.c
+if (SLEEF_ARCH_X86)
+ # Target dispsse.c
+ sleef_generate_disp_simd(sse 2 4 __m128d __m128 __m128i sse2 sse4 avx2128)
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dispavx.c
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/dispavx.c.org ${CMAKE_CURRENT_BINARY_DIR}/dispavx.c
- COMMAND $ 4 8 __m256d __m256 __m128i avx fma4 avx2 >> ${CMAKE_CURRENT_BINARY_DIR}/dispavx.c
- DEPENDS ${TARGET_MKDISP}
- )
- add_custom_target(dispavx.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dispavx.c)
+ # Target renamedsp128.h
+ sleef_generate_rename_simd(sp128 - 2 4)
- # Target renamedsp256.h
+ # Target dispavx.c
+ sleef_generate_disp_simd(avx 4 8 __m256d __m256 __m128i avx fma4 avx2)
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp256.h
- COMMAND $ - 4 8 > ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp256.h
- DEPENDS ${TARGET_MKRENAME}
- )
- add_custom_target(renamedsp256.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp256.h)
+ # Target renamedsp256.h
+ sleef_generate_rename_simd(sp256 - 4 8)
# Target dispsse_obj
-
if (COMPILER_SUPPORTS_FMA4)
set(DISPATCHER_DEFINITIONS ${DISPATCHER_DEFINITIONS} ENABLE_FMA4=1)
endif()
@@ -804,24 +777,12 @@ endif(SLEEF_ARCH_X86)
if (SLEEF_ARCH_PPC64)
# Target disppower_128.c
-
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/disppower_128.c
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/disppower_128.c.org ${CMAKE_CURRENT_BINARY_DIR}/disppower_128.c
- COMMAND $ 2 4 SLEEF_VECTOR_DOUBLE SLEEF_VECTOR_FLOAT SLEEF_VECTOR_INT vsx vsx3 x >> ${CMAKE_CURRENT_BINARY_DIR}/disppower_128.c
- DEPENDS ${TARGET_MKDISP}
- )
- add_custom_target(disppower_128.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/disppower_128.c)
+ sleef_generate_disp_simd(power_128 2 4 SLEEF_VECTOR_DOUBLE SLEEF_VECTOR_FLOAT SLEEF_VECTOR_INT vsx vsx3 x)
# Target renamedsp128.h
-
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h
- COMMAND $ - 2 4 > ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h
- DEPENDS ${TARGET_MKRENAME}
- )
- add_custom_target(renamedsp128.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h)
+ sleef_generate_rename_simd(sp128 - 2 4)
# Target disppower_128_obj
-
add_library(disppower_128_obj OBJECT disppower_128.c)
target_compile_options(disppower_128_obj PRIVATE ${FLAGS_ENABLE_VSX})
if(COMPILER_SUPPORTS_VSX3)
@@ -843,24 +804,12 @@ endif(SLEEF_ARCH_PPC64)
if (SLEEF_ARCH_S390X)
# Target disps390x_128.c
-
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/disps390x_128.c
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/disps390x_128.c.org ${CMAKE_CURRENT_BINARY_DIR}/disps390x_128.c
- COMMAND $ 2 4 SLEEF_VECTOR_DOUBLE SLEEF_VECTOR_FLOAT SLEEF_VECTOR_INT vxe vxe2 x >> ${CMAKE_CURRENT_BINARY_DIR}/disps390x_128.c
- DEPENDS ${TARGET_MKDISP}
- )
- add_custom_target(disps390x_128.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/disps390x_128.c)
+ sleef_generate_disp_simd(s390x_128 2 4 SLEEF_VECTOR_DOUBLE SLEEF_VECTOR_FLOAT SLEEF_VECTOR_INT vxe vxe2 x)
# Target renamedsp128.h
-
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h
- COMMAND $ - 2 4 > ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h
- DEPENDS ${TARGET_MKRENAME}
- )
- add_custom_target(renamedsp128.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/renamedsp128.h)
+ sleef_generate_rename_simd(sp128 - 2 4)
# Target disps390x_128_obj
-
add_library(disps390x_128_obj OBJECT disps390x_128.c)
target_compile_options(disps390x_128_obj PRIVATE ${FLAGS_ENABLE_VXE})
if(COMPILER_SUPPORTS_VXE2)
diff --git a/src/quad/CMakeLists.txt b/src/quad/CMakeLists.txt
index 5eae42da..a4857015 100644
--- a/src/quad/CMakeLists.txt
+++ b/src/quad/CMakeLists.txt
@@ -117,21 +117,20 @@ set(SLEEFQUAD_INCLUDE_HEADER ${sleef_BINARY_DIR}/include/sleefquad.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sleefquad_header.h.org.in ${SLEEFQUAD_ORG_HEADER})
-set(SLEEF_HEADER_COMMANDS "")
-list(APPEND SLEEF_HEADER_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy ${SLEEFQUAD_ORG_HEADER} ${SLEEFQUAD_INCLUDE_HEADER})
+set(SLEEF_HEADER_SIMD_SECTIONS "")
foreach(SIMD ${SLEEF_HEADER_LIST})
- list(APPEND SLEEF_HEADER_COMMANDS COMMAND echo Generating sleefquad.h: qmkrename ${QUAD_HEADER_PARAMS_${SIMD}})
- list(APPEND SLEEF_HEADER_COMMANDS COMMAND $ ${QUAD_HEADER_PARAMS_${SIMD}} >> ${SLEEFQUAD_INCLUDE_HEADER})
+ set(SIMD_SECTION_FILE ${CMAKE_CURRENT_BINARY_DIR}/sleefquad_${SIMD}.h.tmp)
+ list(APPEND SLEEF_HEADER_SIMD_SECTIONS ${SIMD_SECTION_FILE})
+ add_custom_command(
+ OUTPUT ${SIMD_SECTION_FILE}
+ COMMAND $ ${QUAD_HEADER_PARAMS_${SIMD}} > ${SIMD_SECTION_FILE}
+ DEPENDS qmkrename
+ )
endforeach()
-list(APPEND SLEEF_HEADER_COMMANDS COMMAND $ ${SLEEFQUAD_ORG_FOOTER} >> ${SLEEFQUAD_INCLUDE_HEADER})
-
-add_custom_command(OUTPUT ${SLEEFQUAD_INCLUDE_HEADER}
- ${SLEEF_HEADER_COMMANDS}
- DEPENDS
- ${SLEEFQUAD_ORG_HEADER}
- ${SLEEFQUAD_ORG_FOOTER}
- qmkrename addSuffix
+sleef_concat_files(
+ OUTPUT ${SLEEFQUAD_INCLUDE_HEADER}
+ SOURCES ${SLEEFQUAD_ORG_HEADER} ${SLEEF_HEADER_SIMD_SECTIONS} ${SLEEFQUAD_ORG_FOOTER}
)
# --------------------------------------------------------------------
@@ -230,170 +229,138 @@ if(BUILD_INLINE_HEADERS)
set(INLINE_HEADER_FILES_GENERATED "")
if (SED_COMMAND)
- foreach(SIMD ${SLEEF_SUPPORTED_QUAD_EXTENSIONS})
- if(COMPILER_SUPPORTS_${SIMD})
+ foreach(SIMD ${SLEEF_SUPPORTED_QUAD_EXTENSIONS} CUDA)
+ if(COMPILER_SUPPORTS_${SIMD} OR "${SIMD}" STREQUAL "CUDA")
string(TOLOWER ${SIMD} SIMDLC)
- if(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_TARGET)
+ if(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_TARGET AND NOT "${SIMD}" STREQUAL "CUDA" )
set(FLAG_TARGET --target=${CMAKE_C_COMPILER_TARGET})
endif()
+ if ("${SIMD}" STREQUAL "CUDA")
+ set(TARGET_PP_FLAGS ${FLAG_DEFINE}SLEEF_ALWAYS_INLINE=__device__
+ ${FLAG_DEFINE}SLEEF_INLINE=__device__
+ ${FLAG_DEFINE}SLEEF_CONST=__device__
+ ${FLAG_DEFINE}static=__device__)
+ set(INLINE_HEADER_ORG ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_cuda_header.h.org)
+ # Remove redundant __device__
+ set(TARGET_REPLACEMENTS -e "s/__device__ __device__/__device__/g" -e "s/__device__ __device__/__device__/g")
+ set(TARGET_ADDSUFFIX_KEYWORDS double2 double3 float2)
+ else()
+ set(TARGET_ADDSUFFIX_KEYWORDS Sleef_rempitabqp)
+ set(INLINE_HEADER_ORG ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_header.h.org)
+ endif()
+
+
set(INLINE_HEADER_FILE ${PROJECT_BINARY_DIR}/include/sleefquadinline_${SIMDLC}.h)
add_custom_command(
- OUTPUT ${INLINE_HEADER_FILE}
-
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1
+
# Preprocess sleefsimddp.c with SLEEF_GENHEADER defined, comments are preserved
COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C
${FLAG_TARGET} ${FLAGS_ENABLE_${SIMD}} # -msse2
${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch
${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/quad/include
${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_SSE2 -DDORENAME
+ ${TARGET_PP_FLAGS}
${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 # /sleef/src/quad/sleefsimdqp.c > /build/quad/sleefSSE2.h.qtmp1
- # Remove all lines except those begin with "//@"
- COMMAND ${SED_COMMAND} -n -e "/^\\/\\/@#.*$/p" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 # sed -n -e "/^\\/\\/@#.*$/p" /build/src/quad/sleefSSE2.h.qtmp1
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 # > /build/src/quad/sleefSSE2.h.qtmp2
+ # ${HEADER_${SIMD}} listed here as sleefsimdqp.c includes it for renaming
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c ${HEADER_${SIMD}}
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/qmacroonly${SIMD}.h
+
+ # Remove all lines except those begin with "//@", then remove "//@"
+ COMMAND ${SED_COMMAND} -e "/^\\/\\/@#.*$/!d" -e "s/^\\/\\/@#/#/g"
+ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1
+ > ${CMAKE_CURRENT_BINARY_DIR}/include/qmacroonly${SIMD}.h
- # Remove "//@"
- COMMAND ${SED_COMMAND} -e "s/^\\/\\/@#/#/g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 # sed -e "s/^\\/\\/@#/#/g" /build/src/common/sleefSSE2.h.qtmp2
- > ${CMAKE_CURRENT_BINARY_DIR}/include/qmacroonly${SIMD}.h # > /build/src/common/include/qmacroonlySSE2.h
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1
+ VERBATIM
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c
# Remove lines beginning with "#" so that the resulting file can be preprocessed again.
COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 # sed -e "s/^#.*//g" /build/src/quad/sleefSSE2.h.qtmp1
> ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c # > /build/src/quad/sleefquadSSE2.h.c
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1
+ VERBATIM
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2
+
# Preprocess the intemediate file again to remove comments
COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} # gcc -E
${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c # /build/src/quad/sleefquadSSE2.h.c
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp3 # > /build/src/quad/sleefSSE2.h.qtmp3
-
- # Embed version number into the header
- COMMAND ${SED_COMMAND} -e # sed -e
- "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL}/g" # "s/SLEEF_VERSION_SLEEF/3.5.0/g"
- -e "s/SLEEF_SIMD_SLEEF/${SIMD}/g" # -e "s/SLEEF_SIMD_SLEEF/SSE2/g"
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_header.h.org # /sleef/src/quad/sleefquadinline_header.h.org
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 # > /build/src/quad/sleefSSE2.h.qtmp4
-
# Remove lines beginning with "#"
- COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp3 # sed -e "s/^#.*//g" /build/src/quad/sleefSSE2.h.qtmp3
- >> ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 # >> /build/src/quad/sleefSSE2.h.qtmp4
+ | ${SED_COMMAND} -e "s/^#.*//g"
+ > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 # > /build/src/quad/sleefSSE2.h.qtmp2
- # Substitute "SLEEFSHARP" at the beginning of line with "#"
- COMMAND ${SED_COMMAND} -e "s/^SLEEFSHARP/#/g" # sed -e "s/^SLEEFSHARP/#/g"
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 # /build/src/libm/sleefSSE2.h.qtmp4
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp5 # > /build/src/libm/sleefSSE2.h.qtmp5
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c ${CMAKE_CURRENT_BINARY_DIR}/include/qmacroonly${SIMD}.h
+ VERBATIM
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4
+
+ COMMAND ${CMAKE_COMMAND} -E cat
+ ${INLINE_HEADER_ORG}
+ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2
+ | ${SED_COMMAND}
+ # Embed version number into the header
+ -e "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL}/g" # "s/SLEEF_VERSION_SLEEF/3.5.0/g"
+ -e "s/SLEEF_SIMD_SLEEF/${SIMD}/g" # -e "s/SLEEF_SIMD_SLEEF/SSE2/g"
+ # Substitute "SLEEFSHARP" at the beginning of line with "#"
+ -e "s/^SLEEFSHARP/#/g"
+ # Remove SLEEFXXX
+ -e "s/SLEEFXXX//g"
+ # Replace multiple empty lines with a single empty line (part 1)
+ -e "s/^[[:space:]]*$//g"
+ > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4
+
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_header.h.org ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2
+ VERBATIM
+ )
- # Remove SLEEFXXX
- COMMAND ${SED_COMMAND} -e "s/SLEEFXXX//g" # sed -e "s/SLEEFXXX//g"
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp5 # /build/src/libm/sleefSSE2.h.qtmp5
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp6 # > /build/src/libm/sleefSSE2.h.qtmp6
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8
# Replace multiple empty lines with a single empty line
- COMMAND ${SED_COMMAND} -e "s/^[[:space:]]*$//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp6 # sed -e "s/^[[:space:]]*$//g" /build/src/quad/sleefSSE2.h.qtmp6
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp7 # > /build/src/quad/sleefSSE2.h.qtmp7
- COMMAND ${SED_COMMAND} "/^$/N;/^\\n$/D" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp7 # sed -e "/^$/N;/^\n$/D" /build/src/quad/sleefSSE2.h.qtmp7
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 # > /build/src/quad/sleefSSE2.h.qtmp8
+ # (part 2 - cannot occur in same command as part 1)
+ COMMAND ${SED_COMMAND} -e "/^$/N" -e "/^\\n$/D" ${TARGET_REPLACEMENTS}
+ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4
+ > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8
+
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4
+ VERBATIM
+ )
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp9
COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 # addSuffix /build/src/quad/sleefSSE2.h.qtmp8
${sleef_SOURCE_DIR}/src/common/keywords.txt "_${SIMDLC}_sleefq" # keywords.txt "_sse2_sleefq"
- Sleef_rempitabqp # Sleef_rempitabdp Sleef_rempitabsp
- > ${PROJECT_BINARY_DIR}/include/sleefquadinline_${SIMDLC}.h # > /build/include/sleefquadinline_sse2.h
+ ${TARGET_ADDSUFFIX_KEYWORDS} # Sleef_rempitabdp Sleef_rempitabsp
+ > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp9
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_footer.h.org # addSuffix /build/src/quad/sleefquadinline_footer.h.org
- >> ${PROJECT_BINARY_DIR}/include/sleefquadinline_${SIMDLC}.h # >> /build/include/sleefquadinline_sse2.h
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 ${sleef_SOURCE_DIR} addSuffix
+ )
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c ${HEADER_${SIMD}}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c ${HEADER_${SIMD}} addSuffix
- VERBATIM
+ sleef_concat_files(
+ OUTPUT ${INLINE_HEADER_FILE}
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp9 ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_footer.h.org
)
list(APPEND INLINE_HEADER_FILES_GENERATED ${INLINE_HEADER_FILE})
- endif(COMPILER_SUPPORTS_${SIMD})
+ endif(COMPILER_SUPPORTS_${SIMD} OR "${SIMD}" STREQUAL "CUDA")
endforeach()
- # Generate CUDA header file
-
- set(SIMD CUDA)
- string(TOLOWER ${SIMD} SIMDLC)
-
- set(INLINE_HEADER_FILE ${PROJECT_BINARY_DIR}/include/sleefquadinline_cuda.h)
-
- add_custom_command(
- OUTPUT ${INLINE_HEADER_FILE}
-
- # Preprocess sleefsimddp.c with SLEEF_GENHEADER defined, comments are preserved
- COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C
- ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch
- ${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/quad/include
- ${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_CUDA -DDORENAME
- ${FLAG_DEFINE}SLEEF_ALWAYS_INLINE=__device__ ${FLAG_DEFINE}SLEEF_INLINE=__device__ # -DSLEEF_ALWAYS_INLINE=__device__ -DSLEEF_INLINE=__device__
- ${FLAG_DEFINE}SLEEF_CONST=__device__ ${FLAG_DEFINE}static=__device__ # -DSLEEF_CONST=__device__ -Dstatic=__device__
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 # /sleef/src/quad/sleefsimdqp.c > /build/quad/sleefCUDA.h.qtmp1
-
- # Remove all lines except those begin with "//@"
- COMMAND ${SED_COMMAND} -n -e "/^\\/\\/@#.*$/p" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 # sed -n -e "/^\\/\\/@#.*$/p" /build/src/common/sleefCUDA.h.qtmp1
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 # > /build/src/common/sleefCUDA.h.qtmp2
-
- # Remove "//@"
- COMMAND ${SED_COMMAND} -e "s/^\\/\\/@#/#/g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 # sed -e "s/^\\/\\/@#/#/g" /build/src/common/sleefCUDA.h.qtmp2
- > ${CMAKE_CURRENT_BINARY_DIR}/include/qmacroonly${SIMD}.h # > /build/src/common/include/qmacroonlyCUDA.h
-
- # Remove lines beginning with "#" so that the resulting file can be preprocessed again.
- COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 # sed -e "s/^#.*//g" /build/src/quad/sleefCUDA.h.qtmp1
- > ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c # > /build/src/quad/sleefquadCUDA.h.c
-
- # Preprocess the intemediate file again to remove comments
- COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} # gcc -E
- ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c # /build/src/quad/sleefquadCUDA.h.c
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp3 # > /build/src/quad/sleefCUDA.h.qtmp3
-
- # Embed version number into the header
- COMMAND ${SED_COMMAND} -e # sed -e
- "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL}/g" # "s/SLEEF_VERSION_SLEEF/3.5.0/g"
- ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_cuda_header.h.org # /sleef/src/quad/sleefquadinline_cuda_header.h.org
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 # > /build/src/quad/sleefCUDA.h.qtmp4
-
- # Remove lines beginning with "#"
- COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp3 # sed -e "s/^#.*//g" /build/src/quad/sleefCUDA.h.qtmp3
- >> ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 # >> /build/src/quad/sleefCUDA.h.qtmp4
-
- # Substitute "&" at the beginning of line with "#"
- COMMAND ${SED_COMMAND} -e "s/^SLEEFSHARP/#/g" # sed -e "s/^SLEEFSHARP/#/g"
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 # /build/src/libm/sleefSSE2.h.qtmp4
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp5 # > /build/src/libm/sleefSSE2.h.qtmp5
-
- # Remove SLEEFXXX
- COMMAND ${SED_COMMAND} -e "s/SLEEFXXX//g" # sed -e "s/SLEEFXXX//g"
- ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp5 # /build/src/libm/sleefSSE2.h.qtmp5
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp6 # > /build/src/libm/sleefSSE2.h.qtmp6
-
- # Replace multiple empty lines with a single empty line
- COMMAND ${SED_COMMAND} -e "s/^[[:space:]]*$//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp6 # sed -e "s/^[[:space:]]*$//g" /build/src/quad/sleefCUDA.h.qtmp6
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp7 # > /build/src/quad/sleefCUDA.h.qtmp7
- COMMAND ${SED_COMMAND} "/^$/N;/^\\n$/D" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp7 # sed -e "/^$/N;/^\n$/D" /build/src/quad/sleefCUDA.h.qtmp7
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 # > /build/src/quad/sleefCUDA.h.qtmp8
-
- # Remove redundant __device__
- COMMAND ${SED_COMMAND} -e "s/__device__ __device__/__device__/g" # sed -e "s/__device__ __device__/__device__/g"
- -e "s/__device__ __device__/__device__/g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 # -e "s/__device__ __device__/__device__/g" /build/src/common/sleefCUDA.h.qtmp8
- > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp9 # > /build/src/common/sleefCUDA.h.qtmp9
-
- COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp9 # addSuffix /build/src/quad/sleefCUDA.h.qtmp9
- ${sleef_SOURCE_DIR}/src/common/keywords.txt "_${SIMDLC}_sleefq" double2 double3 float2 # keywords.txt "_cuda_sleefq" double2 double3 float2
- > ${PROJECT_BINARY_DIR}/include/sleefquadinline_${SIMDLC}.h # > /build/include/sleefquadinline_cuda.h
-
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_footer.h.org # addSuffix /build/src/quad/sleefquadinline_footer.h.org
- >> ${PROJECT_BINARY_DIR}/include/sleefquadinline_${SIMDLC}.h # >> /build/include/sleefquadinline_cuda.h
-
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c ${HEADER_${SIMD}}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c ${HEADER_${SIMD}} addSuffix
- VERBATIM
- )
-
- list(APPEND INLINE_HEADER_FILES_GENERATED ${INLINE_HEADER_FILE})
-
- #
-
add_custom_target(${TARGET_QINLINE_HEADERS} ALL
DEPENDS
${INLINE_HEADER_FILES_GENERATED}
@@ -415,11 +382,16 @@ set_target_properties(qmkdisp PROPERTIES ${COMMON_TARGET_PROPERTIES})
# Target qdispscalar.c
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/qdispscalar.c.org ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c
- COMMAND $ 1 Sleef_quad double int32_t int64_t uint64_t purec purecfma >> ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body
+ COMMAND $ 1 Sleef_quad double int32_t int64_t uint64_t purec purecfma > ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body
DEPENDS qmkdisp
)
+sleef_concat_files(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/qdispscalar.c.org ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body
+ )
+
add_custom_target(qdispscalar.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c)
# Target renamedspscalar.h
@@ -443,11 +415,15 @@ target_sources(sleefquad PRIVATE $)
if(DEFINED QMKDISP_PARAMS_X2)
# Target qdispx2.c
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/qdispx2.c.org ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c
- COMMAND $ ${QMKDISP_PARAMS_X2} >> ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c.body
+ COMMAND $ ${QMKDISP_PARAMS_X2} > ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c.body
DEPENDS qmkdisp
)
+ sleef_concat_files(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/qdispx2.c.org ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c.body
+ )
add_custom_target(qdispx2.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c)
# Target renamedspx2.h