diff --git a/math/hptt/Portfile b/math/hptt/Portfile new file mode 100644 index 000000000000..afa2266c1099 --- /dev/null +++ b/math/hptt/Portfile @@ -0,0 +1,62 @@ +# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 + +PortSystem 1.0 +PortGroup cmake 1.1 +PortGroup compiler_blacklist_versions 1.0 +PortGroup github 1.0 + +github.setup springer13 hptt 942538649b51ff14403a0c73a35d9825eab2d7de +version 1.0.5 +revision 0 +categories math +license BSD +maintainers {@barracuda156 gmail.com:vital.had} openmaintainer +description High-Performance Tensor Transpose library +long_description {*}${description} +checksums rmd160 7cbc53545b2841eb7c8f59126c315805e39bdc3b \ + sha256 26ff7b4661ecfde7fb44b13154679c589bd9a87010f0bcba13ef56641a0cf7ee \ + size 635723 + +patch.pre_args -p1 +patchfiles 0001-CMakeLists-add-PPC-support-unbreak-build-on-Darwin.patch \ + 0002-CMakeLists-fix-install-path-for-headers.patch \ + 0003-Add-hptt.pc-config-file.patch + +# It does not build with new clang: https://github.com/springer13/hptt/issues/21 +# See also: https://bugs.llvm.org/show_bug.cgi?id=36915 +compiler.blacklist-append \ + *clang* +compiler.fallback-append \ + macports-gcc-12 macports-gcc-11 +compiler.cxx_standard 2011 + +configure.args-append \ + -DENABLE_ARM=OFF \ + -DENABLE_AVX=OFF \ + -DENABLE_IBM=OFF \ + -DENABLE_PPC=OFF + +post-patch { + reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/misc/hptt.pc + reinplace "s,@VERSION@,${version}," ${worksrcpath}/misc/hptt.pc +} + +platform powerpc { + if {${os.platform} eq "darwin"} { + # Needed only for Rosetta, has no effect on native PPC: + post-patch { + reinplace "s,-march=native,," ${worksrcpath}/CMakeLists.txt + } + configure.args-replace \ + -DENABLE_PPC=OFF -DENABLE_PPC=ON + } else { + # On non-Apple OSs this is likely a correct choice: + configure.args-replace \ + -DENABLE_IBM=OFF -DENABLE_IBM=ON + } +} + +post-destroot { + xinstall -d ${destroot}/lib/pkgconfig/ + copy ${worksrcpath}/misc/hptt.pc ${destroot}${prefix}/lib/pkgconfig/ +} diff --git a/math/hptt/files/0001-CMakeLists-add-PPC-support-unbreak-build-on-Darwin.patch b/math/hptt/files/0001-CMakeLists-add-PPC-support-unbreak-build-on-Darwin.patch new file mode 100644 index 000000000000..ae999c296c21 --- /dev/null +++ b/math/hptt/files/0001-CMakeLists-add-PPC-support-unbreak-build-on-Darwin.patch @@ -0,0 +1,57 @@ +From ea1ba734a76ced4df64d5374fb0fb11ce2ac065f Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Sat, 7 Jan 2023 15:14:42 +0700 +Subject: [PATCH 1/3] CMakeLists: add PPC support, unbreak build on Darwin + +--- + CMakeLists.txt | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 582ada3..25673f0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,16 +6,29 @@ set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set(ENABLE_IBM OFF) ++set(ENABLE_PPC OFF) + + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le") + set(ENABLE_IBM ON) + endif() + ++# For now this should do. Notice, however, that ppc32 is used with *BSD and Linux as well, ++# so at some point a finer approach may be needed. ++if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc|ppc64") ++ if(APPLE) ++ set(ENABLE_PPC ON) ++ else() ++ set(ENABLE_IBM ON) ++ endif() ++endif() ++ + if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set(HPTT_CXX_FLAGS ${HPTT_CXX_FLAGS} -qopenmp -xhost) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(ENABLE_IBM) + set(HPTT_CXX_FLAGS ${HPTT_CXX_FLAGS} -fopenmp) ++ elseif(ENABLE_PPC) ++ set(HPTT_CXX_FLAGS ${HPTT_CXX_FLAGS} -fopenmp -mtune=native) + else() + set(HPTT_CXX_FLAGS ${HPTT_CXX_FLAGS} -fopenmp -march=native -mtune=native) + endif() +@@ -33,6 +46,10 @@ elseif(ENABLE_ARM) + set(HPTT_CXX_FLAGS ${HPTT_CXX_FLAGS} -mfpu=neon -DHPTT_ARCH_ARM) + elseif(ENABLE_IBM) + set(HPTT_CXX_FLAGS ${HPTT_CXX_FLAGS} -mtune=native -DHPTT_ARCH_IBM -maltivec -mabi=altivec) ++# If the code will move to use VSX insns, please retain non-VSX version for macOS PPC. ++# Until then perhaps a common define can be used. ++elseif(ENABLE_PPC) ++ set(HPTT_CXX_FLAGS ${HPTT_CXX_FLAGS} -mtune=native -DHPTT_ARCH_IBM -faltivec) + endif() + + set(HPTT_SRCS src/hptt.cpp src/plan.cpp src/transpose.cpp src/utils.cpp) +-- +2.39.0 + diff --git a/math/hptt/files/0002-CMakeLists-fix-install-path-for-headers.patch b/math/hptt/files/0002-CMakeLists-fix-install-path-for-headers.patch new file mode 100644 index 000000000000..c8570ad0e0db --- /dev/null +++ b/math/hptt/files/0002-CMakeLists-fix-install-path-for-headers.patch @@ -0,0 +1,22 @@ +From b7271560a144459e93762452f1e7cd8d2dad8328 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Sat, 7 Jan 2023 20:17:21 +0700 +Subject: [PATCH 2/3] CMakeLists: fix install path for headers + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 25673f0..748e427 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -74,4 +74,4 @@ set(HPTT_INCLUDES + include/transpose.h) + + install(FILES ${HPTT_INCLUDES} +- DESTINATION ${CMAKE_INSTALL_PREFIX}/include) ++ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/hptt) +-- +2.39.0 + diff --git a/math/hptt/files/0003-Add-hptt.pc-config-file.patch b/math/hptt/files/0003-Add-hptt.pc-config-file.patch new file mode 100644 index 000000000000..f847d1337639 --- /dev/null +++ b/math/hptt/files/0003-Add-hptt.pc-config-file.patch @@ -0,0 +1,29 @@ +From 51c18fe1c67a4333c2636ea642285113ce18b188 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Sat, 7 Jan 2023 20:21:16 +0700 +Subject: [PATCH 3/3] Add hptt.pc config file + +--- + misc/hptt.pc | 10 ++++++++++ + 1 file changed, 10 insertions(+) + create mode 100644 misc/hptt.pc + +diff --git a/misc/hptt.pc b/misc/hptt.pc +new file mode 100644 +index 0000000..d995ebf +--- /dev/null ++++ b/misc/hptt.pc +@@ -0,0 +1,10 @@ ++prefix=@PREFIX@ ++exec_prefix=${prefix} ++libdir=${exec_prefix}/lib ++includedir=${prefix}/include ++ ++Name: hptt ++Description: High-Performance Tensor Transpose library ++Version: @VERSION@ ++Cflags: -I${includedir}/hptt ++Libs: -L${libdir} -lhptt +-- +2.39.0 +