diff --git a/ports/magma/clang-cuda.patch b/ports/magma/clang-cuda.patch new file mode 100644 index 00000000000000..5aaee14ff8e448 --- /dev/null +++ b/ports/magma/clang-cuda.patch @@ -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 +- $<$:--compiler-options;${FORTRAN_CONVENTION}> +- ) ++ if(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang") ++ target_compile_options(magma_nvcc_flags ++ INTERFACE ++ $<$:--compiler-options;${FORTRAN_CONVENTION}> ++ ) ++ else() ++ target_compile_options(magma_nvcc_flags ++ INTERFACE ++ $<$:${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 + #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 diff --git a/ports/magma/disable-openmp-msvc.patch b/ports/magma/disable-openmp-msvc.patch new file mode 100644 index 00000000000000..b1439952a7f053 --- /dev/null +++ b/ports/magma/disable-openmp-msvc.patch @@ -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" ) diff --git a/ports/magma/no-tests.patch b/ports/magma/no-tests.patch new file mode 100644 index 00000000000000..4a7d92636fe7ff --- /dev/null +++ b/ports/magma/no-tests.patch @@ -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} ) diff --git a/ports/magma/portfile.cmake b/ports/magma/portfile.cmake new file mode 100644 index 00000000000000..fc117d65588585 --- /dev/null +++ b/ports/magma/portfile.cmake @@ -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") diff --git a/ports/magma/vcpkg.json b/ports/magma/vcpkg.json new file mode 100644 index 00000000000000..eec7bc6a8665be --- /dev/null +++ b/ports/magma/vcpkg.json @@ -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 + } + ] +} diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index b2d7633a8eb9e7..84888e10949f0b 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -679,6 +679,7 @@ log4cpp:x64-linux=fail # dynamic exception specifications loguru:arm-neon-android=fail loguru:arm64-android=fail loguru:x64-android=fail +magma:x64-linux=fail mchehab-zbar:arm-neon-android=fail mchehab-zbar:arm64-android=fail mchehab-zbar:x64-android=fail diff --git a/versions/baseline.json b/versions/baseline.json index e5f01355e2cd31..5a983f0b30db43 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5400,6 +5400,10 @@ "baseline": "2019-09-02", "port-version": 3 }, + "magma": { + "baseline": "2.7.2", + "port-version": 0 + }, "magnum": { "baseline": "2020.06", "port-version": 17 diff --git a/versions/m-/magma.json b/versions/m-/magma.json new file mode 100644 index 00000000000000..29a77b62f926a6 --- /dev/null +++ b/versions/m-/magma.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "44b519ef789c70ffb247ac2fc1686038b0616515", + "version": "2.7.2", + "port-version": 0 + } + ] +}