[magma] add port (#35928)

* Add magma port

* fix patch

* no cmake config to fix

* deleted wrong dir

* mark magma fail in ci baseline

* v db

* fix Cflags

* v db

---------

Co-authored-by: MonicaLiu <liuyumei01@beyondsoft.com>
This commit is contained in:
Alexander Neumann 2024-01-18 00:50:19 +01:00 committed by GitHub
parent 234d20e484
commit 97dd26728e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 184 additions and 0 deletions

View File

@ -0,0 +1,50 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eeb0bb0b8f..6a5e0a747a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -310,10 +309,17 @@ if (MAGMA_ENABLE_CUDA)
)
else()
# No Position Independent Code on Windows. Compiler will complain if you add that flag.
- target_compile_options(magma_nvcc_flags
- INTERFACE
- $<$<COMPILE_LANGUAGE:CUDA>:--compiler-options;${FORTRAN_CONVENTION}>
- )
+ if(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
+ target_compile_options(magma_nvcc_flags
+ INTERFACE
+ $<$<COMPILE_LANGUAGE:CUDA>:--compiler-options;${FORTRAN_CONVENTION}>
+ )
+ else()
+ target_compile_options(magma_nvcc_flags
+ INTERFACE
+ $<$<COMPILE_LANGUAGE:CUDA>:${FORTRAN_CONVENTION}>
+ )
+ endif()
endif(COMPILER_SUPPORTS_FPIC)
set(MAGMA_HAVE_CUDA "1")
diff --git a/control/magma_internal.h b/control/magma_internal.h
index 2310659235..c4d0eb8f6b 100644
--- a/control/magma_internal.h
+++ b/control/magma_internal.h
@@ -33,7 +33,7 @@
// functions where Microsoft fails to provide C99 standard
// (only with Microsoft, not with nvcc on Windows)
// in both magma_internal.h and testings.h
- #ifndef __NVCC__
+ #if !defined(__NVCC__) && !defined(__clang__)
#include <float.h>
#define copysign(x,y) _copysign(x,y)
@@ -42,7 +42,9 @@
#define isfinite(x) _finite(x)
// note _snprintf has slightly different semantics than snprintf
#define snprintf _snprintf
-
+ #elif !defined(__NVCC__)
+ // make sure this actually uses the C version and not the C++ overloads
+ #define copysign(x,y) copysign((double)x,(double)y)
#endif
#else

View File

@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 828911d05f..a4f5b35ef3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -103,6 +103,10 @@ endif()
# ----------------------------------------
# locate OpenMP
+if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ set(CMAKE_DISBLE_FIND_PACKAGE_OpenMP ON)
+ # MSVC OpenMP is not enough to compile
+endif()
find_package( OpenMP )
if (OPENMP_FOUND)
message( STATUS "Found OpenMP" )

View File

@ -0,0 +1,35 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4f5b35ef3..eeb0bb0b8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -663,7 +670,7 @@ target_link_libraries( lapacktest
# ----------------------------------------
# compile tester library
-add_library( tester ${libtest_all} )
+add_library( tester EXCLUDE_FROM_ALL ${libtest_all} )
target_link_libraries( tester
magma
lapacktest
@@ -726,11 +726,12 @@ foreach( filename ${testing_all} )
list( APPEND testing_all_cpp ${filename} )
endif()
endforeach()
+set(testing_all_cpp "")
foreach( TEST ${testing_all_cpp} )
string( REGEX REPLACE "\\.(cpp|f90|F90)" "" EXE ${TEST} )
string( REGEX REPLACE "testing/" "" EXE ${EXE} )
#message( "${TEST} --> ${EXE}" )
- add_executable( ${EXE} ${TEST} )
+ add_executable( ${EXE} EXCLUDE_FROM_ALL ${TEST} )
target_link_libraries( ${EXE} tester lapacktest magma )
list( APPEND testing ${EXE} )
endforeach()
@@ -749,6 +750,7 @@ endif()
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${SPARSE_TEST_DIR}" )
cmake_policy( SET CMP0037 OLD)
+set(sparse_testing_all "")
foreach( TEST ${sparse_testing_all} )
string( REGEX REPLACE "\\.(cpp|f90|F90)" "" EXE ${TEST} )
string( REGEX REPLACE "${SPARSE_TEST_DIR}/" "" EXE ${EXE} )

View File

@ -0,0 +1,54 @@
set(opts "")
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(opts
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS:BOOL=ON
-DCMAKE_CUDA_SEPARABLE_COMPILATION:BOOL=OFF
)
endif()
vcpkg_download_distfile(
dist_file
URLS https://icl.utk.edu/projectsfiles/magma/downloads/magma-${VERSION}.tar.gz
FILENAME magma-${VERSION}.tar.gz
SHA512 7ab52ad09f452f7b997da573f74465d5bc8c83392f724747b131a7015b1445c457defdb59ae7a2fd4930e2cdc5bce3c7b99a069f04db1752a5df36ddc6e84987
)
vcpkg_extract_source_archive(
src_path
ARCHIVE "${dist_file}"
PATCHES
disable-openmp-msvc.patch
no-tests.patch
clang-cuda.patch
)
vcpkg_cmake_configure(
SOURCE_PATH "${src_path}"
OPTIONS
-DMAGMA_ENABLE_CUDA=ON
-DMAGMA_ENABLE_HIP=OFF # HIP is backend and seems additive?!
-DUSE_FORTRAN=OFF
${opts}
)
vcpkg_cmake_install()
vcpkg_fixup_pkgconfig()
file(READ "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/magma.pc" contents)
string(REGEX REPLACE "Cflags: [^\n]+" "Cflags: -I\${includedir}" contents "${contents}")
file(WRITE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/magma.pc" "${contents}")
if(NOT VCPKG_BUILD_TYPE)
file(READ "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/magma.pc" contents)
string(REGEX REPLACE "Cflags: [^\n]+" "Cflags: -I\${includedir}" contents "${contents}")
file(WRITE "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/magma.pc" "${contents}")
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
)
vcpkg_install_copyright(FILE_LIST "${src_path}/COPYRIGHT")

16
ports/magma/vcpkg.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "magma",
"version": "2.7.2",
"description": "Matrix Algebra on GPU and Multi-core Architectures (MAGMA) is a collection of next-generation linear algebra libraries for heterogeneous computing",
"homepage": "https://icl.utk.edu/magma/",
"license": null,
"dependencies": [
"blas",
"cuda",
"lapack",
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View File

@ -679,6 +679,7 @@ log4cpp:x64-linux=fail # dynamic exception specifications
loguru:arm-neon-android=fail loguru:arm-neon-android=fail
loguru:arm64-android=fail loguru:arm64-android=fail
loguru:x64-android=fail loguru:x64-android=fail
magma:x64-linux=fail
mchehab-zbar:arm-neon-android=fail mchehab-zbar:arm-neon-android=fail
mchehab-zbar:arm64-android=fail mchehab-zbar:arm64-android=fail
mchehab-zbar:x64-android=fail mchehab-zbar:x64-android=fail

View File

@ -5400,6 +5400,10 @@
"baseline": "2019-09-02", "baseline": "2019-09-02",
"port-version": 3 "port-version": 3
}, },
"magma": {
"baseline": "2.7.2",
"port-version": 0
},
"magnum": { "magnum": {
"baseline": "2020.06", "baseline": "2020.06",
"port-version": 17 "port-version": 17

9
versions/m-/magma.json Normal file
View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "44b519ef789c70ffb247ac2fc1686038b0616515",
"version": "2.7.2",
"port-version": 0
}
]
}