diff options
-rw-r--r-- | gnu/local.mk | 1 | ||||
-rw-r--r-- | gnu/packages/maths.scm | 30 | ||||
-rw-r--r-- | gnu/packages/patches/fp16-system-libraries.patch | 105 |
3 files changed, 136 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 3d07bc2700..897bdcd0e4 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1028,6 +1028,7 @@ dist_patch_DATA = \ %D%/packages/patches/foomatic-filters-CVE-2015-8327.patch \ %D%/packages/patches/foomatic-filters-CVE-2015-8560.patch \ %D%/packages/patches/fontconfig-hurd-path-max.patch \ + %D%/packages/patches/fp16-system-libraries.patch \ %D%/packages/patches/fpc-reproducibility.patch \ %D%/packages/patches/fplll-std-fenv.patch \ %D%/packages/patches/freedink-engine-fix-sdl-hints.patch \ diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm index e170fd4db9..1afe72659a 100644 --- a/gnu/packages/maths.scm +++ b/gnu/packages/maths.scm @@ -6688,3 +6688,33 @@ multiplication. FXdiv implements an algorithm to replace an integer division with a multiplication and two shifts. This algorithm improves performance when an application performs repeated divisions by the same divisor.") (license license:expat)))) + +(define-public fp16 + ;; There is currently no tag in this repo. + (let ((commit "0a92994d729ff76a58f692d3028ca1b64b145d91") + (version "0.0") + (revision "1")) + (package + (name "fp16") + (version (git-version version revision commit)) + (home-page "https://github.com/Maratyszcza/FP16") + (source (origin + (method git-fetch) + (uri (git-reference (url home-page) (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "05mm4vrxsac35hjf5djif9r6rdxj9ippg97ia3p6q6b8lrp7srwv")) + (patches (search-patches "fp16-system-libraries.patch")))) + (build-system cmake-build-system) + (native-inputs + `(("python-wrapper" ,python-wrapper))) + (inputs + `(("psimd" ,psimd) + ("googletest" ,googletest) + ("googlebenchmark" ,googlebenchmark))) + (synopsis "C++ library for half-precision floating point formats") + (description + "This header-only C++ library implements conversion to and from +half-precision floating point formats.") + (license license:expat)))) diff --git a/gnu/packages/patches/fp16-system-libraries.patch b/gnu/packages/patches/fp16-system-libraries.patch new file mode 100644 index 0000000000..7f52936c14 --- /dev/null +++ b/gnu/packages/patches/fp16-system-libraries.patch @@ -0,0 +1,105 @@ +This patch allows the build process to use the provided dependencies instead +of adding their source as CMake sub-directories (in which case "make install" +would install googletest's and googlebenchmark's libraries and headers). + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5e7d127..4b269b9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -28,7 +28,7 @@ MACRO(FP16_TARGET_ENABLE_CXX11 target) + ENDMACRO() + + # ---[ Download deps +-IF(NOT DEFINED PSIMD_SOURCE_DIR) ++IF(FALSE) + MESSAGE(STATUS "Downloading PSimd to ${CMAKE_BINARY_DIR}/psimd-source (define PSIMD_SOURCE_DIR to avoid it)") + CONFIGURE_FILE(cmake/DownloadPSimd.cmake "${CMAKE_BINARY_DIR}/psimd-download/CMakeLists.txt") + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . +@@ -38,7 +38,7 @@ IF(NOT DEFINED PSIMD_SOURCE_DIR) + SET(PSIMD_SOURCE_DIR "${CMAKE_BINARY_DIR}/psimd-source" CACHE STRING "PSimd source directory") + ENDIF() + +-IF(FP16_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR) ++IF(FALSE) + MESSAGE(STATUS "Downloading Google Test to ${CMAKE_BINARY_DIR}/googletest-source (define GOOGLETEST_SOURCE_DIR to avoid it)") + CONFIGURE_FILE(cmake/DownloadGoogleTest.cmake "${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt") + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . +@@ -48,7 +48,7 @@ IF(FP16_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR) + SET(GOOGLETEST_SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-source" CACHE STRING "Google Test source directory") + ENDIF() + +-IF(FP16_BUILD_BENCHMARKS AND NOT DEFINED GOOGLEBENCHMARK_SOURCE_DIR) ++IF(FALSE) + MESSAGE(STATUS "Downloading Google Benchmark to ${CMAKE_BINARY_DIR}/googlebenchmark-source (define GOOGLEBENCHMARK_SOURCE_DIR to avoid it)") + CONFIGURE_FILE(cmake/DownloadGoogleBenchmark.cmake "${CMAKE_BINARY_DIR}/googlebenchmark-download/CMakeLists.txt") + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . +@@ -84,22 +84,7 @@ INSTALL(FILES + include/fp16/avx2.py + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fp16) + +-# ---[ Configure psimd +-IF(NOT TARGET psimd) +- ADD_SUBDIRECTORY( +- "${PSIMD_SOURCE_DIR}" +- "${CMAKE_BINARY_DIR}/psimd") +-ENDIF() +- + IF(FP16_BUILD_TESTS) +- # ---[ Build google test +- IF(NOT TARGET gtest) +- SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +- ADD_SUBDIRECTORY( +- "${GOOGLETEST_SOURCE_DIR}" +- "${CMAKE_BINARY_DIR}/googletest") +- ENDIF() +- + # ---[ Build FP16 unit tests + ADD_EXECUTABLE(ieee-to-fp32-bits-test test/ieee-to-fp32-bits.cc test/tables.cc) + TARGET_INCLUDE_DIRECTORIES(ieee-to-fp32-bits-test PRIVATE test) +@@ -137,40 +122,32 @@ IF(FP16_BUILD_TESTS) + ENDIF() + + IF(FP16_BUILD_BENCHMARKS) +- # ---[ Build google benchmark +- IF(NOT TARGET benchmark) +- SET(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "") +- ADD_SUBDIRECTORY( +- "${GOOGLEBENCHMARK_SOURCE_DIR}" +- "${CMAKE_BINARY_DIR}/googlebenchmark") +- ENDIF() +- + # ---[ Build FP16 benchmarks + ADD_EXECUTABLE(ieee-element-bench bench/ieee-element.cc) + TARGET_COMPILE_DEFINITIONS(ieee-element-bench PRIVATE FP16_COMPARATIVE_BENCHMARKS=1) + TARGET_INCLUDE_DIRECTORIES(ieee-element-bench PRIVATE ${PROJECT_SOURCE_DIR}) +- TARGET_LINK_LIBRARIES(ieee-element-bench fp16 psimd benchmark) ++ TARGET_LINK_LIBRARIES(ieee-element-bench fp16 benchmark) + + ADD_EXECUTABLE(alt-element-bench bench/alt-element.cc) +- TARGET_LINK_LIBRARIES(alt-element-bench fp16 psimd benchmark) ++ TARGET_LINK_LIBRARIES(alt-element-bench fp16 benchmark) + + ADD_EXECUTABLE(from-ieee-array-bench bench/from-ieee-array.cc) + FP16_TARGET_ENABLE_CXX11(from-ieee-array-bench) + TARGET_COMPILE_DEFINITIONS(from-ieee-array-bench PRIVATE FP16_COMPARATIVE_BENCHMARKS=1) + TARGET_INCLUDE_DIRECTORIES(from-ieee-array-bench PRIVATE ${PROJECT_SOURCE_DIR}) +- TARGET_LINK_LIBRARIES(from-ieee-array-bench fp16 psimd benchmark) ++ TARGET_LINK_LIBRARIES(from-ieee-array-bench fp16 benchmark) + + ADD_EXECUTABLE(from-alt-array-bench bench/from-alt-array.cc) + FP16_TARGET_ENABLE_CXX11(from-alt-array-bench) +- TARGET_LINK_LIBRARIES(from-alt-array-bench fp16 psimd benchmark) ++ TARGET_LINK_LIBRARIES(from-alt-array-bench fp16 benchmark) + + ADD_EXECUTABLE(to-ieee-array-bench bench/to-ieee-array.cc) + FP16_TARGET_ENABLE_CXX11(to-ieee-array-bench) + TARGET_COMPILE_DEFINITIONS(to-ieee-array-bench PRIVATE FP16_COMPARATIVE_BENCHMARKS=1) + TARGET_INCLUDE_DIRECTORIES(to-ieee-array-bench PRIVATE ${PROJECT_SOURCE_DIR}) +- TARGET_LINK_LIBRARIES(to-ieee-array-bench fp16 psimd benchmark) ++ TARGET_LINK_LIBRARIES(to-ieee-array-bench fp16 benchmark) + + ADD_EXECUTABLE(to-alt-array-bench bench/to-alt-array.cc) + FP16_TARGET_ENABLE_CXX11(to-alt-array-bench) +- TARGET_LINK_LIBRARIES(to-alt-array-bench fp16 psimd benchmark) ++ TARGET_LINK_LIBRARIES(to-alt-array-bench fp16 benchmark) + ENDIF() |