aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2019-12-07 21:17:53 +0200
committerGitHub <noreply@github.com>2019-12-07 21:17:53 +0200
commit06cc98ab542bacd0d06c88d9ebcfb271ba6d17d9 (patch)
treef99e9a8af251e3d8adc9a88418ff6926d48bb0b4 /test cases
parent1031c96d311f8e6aa6d768987ab7c88b69ea2566 (diff)
parent44ab23dff89fac913b4823a2089c602f6d3a7791 (diff)
downloadmeson-06cc98ab542bacd0d06c88d9ebcfb271ba6d17d9.zip
meson-06cc98ab542bacd0d06c88d9ebcfb271ba6d17d9.tar.gz
meson-06cc98ab542bacd0d06c88d9ebcfb271ba6d17d9.tar.bz2
Merge pull request #6228 from scivision/scalapack
deps: add Scalapack
Diffstat (limited to 'test cases')
-rw-r--r--test cases/frameworks/30 scalapack/cmake/FindSCALAPACK.cmake220
-rw-r--r--test cases/frameworks/30 scalapack/main.c34
-rw-r--r--test cases/frameworks/30 scalapack/main.f9025
-rw-r--r--test cases/frameworks/30 scalapack/meson.build27
4 files changed, 306 insertions, 0 deletions
diff --git a/test cases/frameworks/30 scalapack/cmake/FindSCALAPACK.cmake b/test cases/frameworks/30 scalapack/cmake/FindSCALAPACK.cmake
new file mode 100644
index 0000000..17f4b3b
--- /dev/null
+++ b/test cases/frameworks/30 scalapack/cmake/FindSCALAPACK.cmake
@@ -0,0 +1,220 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+
+FindSCALAPACK
+-------------
+
+* Michael Hirsch, Ph.D. www.scivision.dev
+
+Let Michael know if there are more MKL / Lapack / compiler combination you want.
+Refer to https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor
+
+Finds SCALAPACK libraries for MKL, OpenMPI and MPICH.
+Intel MKL relies on having environment variable MKLROOT set, typically by sourcing
+mklvars.sh beforehand.
+
+Parameters
+^^^^^^^^^^
+
+``MKL``
+ Intel MKL for MSVC, ICL, ICC, GCC and PGCC. Working with IntelMPI (default Window, Linux), MPICH (default Mac) or OpenMPI (Linux only).
+
+``IntelMPI``
+ MKL BLACS IntelMPI
+
+``MKL64``
+ MKL only: 64-bit integers (default is 32-bit integers)
+
+``OpenMPI``
+ SCALAPACK + OpenMPI
+
+``MPICH``
+ SCALAPACK + MPICH
+
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+``SCALAPACK_FOUND``
+ SCALapack libraries were found
+``SCALAPACK_<component>_FOUND``
+ SCALAPACK <component> specified was found
+``SCALAPACK_LIBRARIES``
+ SCALapack library files
+``SCALAPACK_INCLUDE_DIRS``
+ SCALapack include directories
+
+
+References
+^^^^^^^^^^
+
+* Pkg-Config and MKL: https://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool
+* MKL for Windows: https://software.intel.com/en-us/mkl-windows-developer-guide-static-libraries-in-the-lib-intel64-win-directory
+* MKL Windows directories: https://software.intel.com/en-us/mkl-windows-developer-guide-high-level-directory-structure
+#]=======================================================================]
+
+#===== functions
+function(mkl_scala)
+
+set(_mkl_libs ${ARGV})
+
+foreach(s ${_mkl_libs})
+ find_library(SCALAPACK_${s}_LIBRARY
+ NAMES ${s}
+ PATHS ENV MKLROOT ENV I_MPI_ROOT ENV TBBROOT
+ PATH_SUFFIXES
+ lib/intel64 lib/intel64_win
+ intel64/lib/release
+ lib/intel64/gcc4.7 ../tbb/lib/intel64/gcc4.7
+ lib/intel64/vc_mt ../tbb/lib/intel64/vc_mt
+ ../compiler/lib/intel64
+ HINTS ${MKL_LIBRARY_DIRS} ${MKL_LIBDIR}
+ NO_DEFAULT_PATH)
+ if(NOT SCALAPACK_${s}_LIBRARY)
+ message(WARNING "MKL component not found: " ${s})
+ return()
+ endif()
+
+ list(APPEND SCALAPACK_LIB ${SCALAPACK_${s}_LIBRARY})
+endforeach()
+
+
+find_path(SCALAPACK_INCLUDE_DIR
+ NAMES mkl_scalapack.h
+ PATHS ENV MKLROOT ENV I_MPI_ROOT ENV TBBROOT
+ PATH_SUFFIXES
+ include
+ include/intel64/${_mkl_bitflag}lp64
+ HINTS ${MKL_INCLUDE_DIRS})
+
+if(NOT SCALAPACK_INCLUDE_DIR)
+ message(WARNING "MKL Include Dir not found")
+ return()
+endif()
+
+list(APPEND SCALAPACK_INCLUDE_DIR
+ ${MKL_INCLUDE_DIRS})
+
+set(SCALAPACK_LIBRARY ${SCALAPACK_LIB} PARENT_SCOPE)
+set(SCALAPACK_INCLUDE_DIR ${SCALAPACK_INCLUDE_DIR} PARENT_SCOPE)
+
+endfunction(mkl_scala)
+
+#==== main program
+
+cmake_policy(VERSION 3.11)
+
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
+ cmake_policy(SET CMP0074 NEW)
+ cmake_policy(SET CMP0075 NEW)
+endif()
+
+if(NOT (OpenMPI IN_LIST SCALAPACK_FIND_COMPONENTS
+ OR MPICH IN_LIST SCALAPACK_FIND_COMPONENTS
+ OR MKL IN_LIST SCALAPACK_FIND_COMPONENTS))
+ if(DEFINED ENV{MKLROOT})
+ if(APPLE)
+ list(APPEND SCALAPACK_FIND_COMPONENTS MKL MPICH)
+ else()
+ list(APPEND SCALAPACK_FIND_COMPONENTS MKL IntelMPI)
+ endif()
+ else()
+ list(APPEND SCALAPACK_FIND_COMPONENTS OpenMPI)
+ endif()
+endif()
+
+find_package(PkgConfig)
+
+if(NOT WIN32)
+ find_package(Threads) # not required--for example Flang
+endif()
+
+if(MKL IN_LIST SCALAPACK_FIND_COMPONENTS)
+
+ if(BUILD_SHARED_LIBS)
+ set(_mkltype dynamic)
+ else()
+ set(_mkltype static)
+ endif()
+
+ if(MKL64 IN_LIST SCALAPACK_FIND_COMPONENTS)
+ set(_mkl_bitflag i)
+ else()
+ set(_mkl_bitflag)
+ endif()
+
+
+ if(WIN32)
+ set(_impi impi)
+ else()
+ unset(_impi)
+ endif()
+
+
+ pkg_check_modules(MKL mkl-${_mkltype}-${_mkl_bitflag}lp64-iomp)
+
+ if(OpenMPI IN_LIST SCALAPACK_FIND_COMPONENTS)
+ mkl_scala(mkl_scalapack_${_mkl_bitflag}lp64 mkl_blacs_openmpi_${_mkl_bitflag}lp64)
+ if(SCALAPACK_LIBRARY)
+ set(SCALAPACK_OpenMPI_FOUND true)
+ endif()
+ elseif(MPICH IN_LIST SCALAPACK_FIND_COMPONENTS)
+ if(APPLE)
+ mkl_scala(mkl_scalapack_${_mkl_bitflag}lp64 mkl_blacs_mpich_${_mkl_bitflag}lp64)
+ elseif(WIN32)
+ mkl_scala(mkl_scalapack_${_mkl_bitflag}lp64 mkl_blacs_mpich2_${_mkl_bitflag}lp64.lib mpi.lib fmpich2.lib)
+ else() # linux, yes it's just like IntelMPI
+ mkl_scala(mkl_scalapack_${_mkl_bitflag}lp64 mkl_blacs_intelmpi_${_mkl_bitflag}lp64)
+ endif()
+ if(SCALAPACK_LIBRARY)
+ set(SCALAPACK_MPICH_FOUND true)
+ endif()
+ else() # IntelMPI
+ mkl_scala(mkl_scalapack_${_mkl_bitflag}lp64 mkl_blacs_intelmpi_${_mkl_bitflag}lp64 ${_impi})
+ if(SCALAPACK_LIBRARY)
+ set(SCALAPACK_IntelMPI_FOUND true)
+ endif()
+ endif()
+
+ if(SCALAPACK_LIBRARY)
+ set(SCALAPACK_MKL_FOUND true)
+ endif()
+
+elseif(OpenMPI IN_LIST SCALAPACK_FIND_COMPONENTS)
+
+ pkg_check_modules(SCALAPACK scalapack-openmpi)
+
+ find_library(SCALAPACK_LIBRARY
+ NAMES scalapack scalapack-openmpi
+ HINTS ${SCALAPACK_LIBRARY_DIRS} ${SCALAPACK_LIBDIR})
+
+ if(SCALAPACK_LIBRARY)
+ set(SCALAPACK_OpenMPI_FOUND true)
+ endif()
+
+elseif(MPICH IN_LIST SCALAPACK_FIND_COMPONENTS)
+ find_library(SCALAPACK_LIBRARY
+ NAMES scalapack-mpich scalapack-mpich2)
+
+ if(SCALAPACK_LIBRARY)
+ set(SCALAPACK_MPICH_FOUND true)
+ endif()
+
+endif()
+
+# Finalize
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ SCALAPACK
+ REQUIRED_VARS SCALAPACK_LIBRARY
+ HANDLE_COMPONENTS)
+
+if(SCALAPACK_FOUND)
+ set(SCALAPACK_LIBRARIES ${SCALAPACK_LIBRARY})
+ set(SCALAPACK_INCLUDE_DIRS ${SCALAPACK_INCLUDE_DIR})
+endif()
+
+mark_as_advanced(SCALAPACK_LIBRARY SCALAPACK_INCLUDE_DIR)
diff --git a/test cases/frameworks/30 scalapack/main.c b/test cases/frameworks/30 scalapack/main.c
new file mode 100644
index 0000000..ca01977
--- /dev/null
+++ b/test cases/frameworks/30 scalapack/main.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+// #include <mkl.h>
+// #include <mkl_scalapack.h>
+// #include <mkl_blacs.h>
+
+extern float pslamch_(const int *, const char *);
+extern void blacs_pinfo_(int *, int *);
+extern void blacs_get_(const int *, const int *, int *);
+extern void blacs_gridinit_(int *, const char *, const int *, const int *);
+extern void blacs_gridinfo_(const int *, int *, int *, int *, int *);
+extern void blacs_gridexit_(const int *);
+extern void blacs_exit_(const int *);
+
+int main(void){
+
+int myid, nprocs, ictxt, mycol, myrow, npcol=2, nprow=2;
+const int i0=0, i1=1, in1=-1;
+
+blacs_pinfo_(&myid, &nprocs);
+blacs_get_(&in1, &i0, &ictxt);
+blacs_gridinit_(&ictxt, "C", &nprocs, &i1);
+
+blacs_gridinfo_(&ictxt, &nprow, &npcol, &myrow, &mycol);
+
+float eps = pslamch_(&ictxt, "E");
+
+if (myrow == mycol) printf("OK: Scalapack C: eps= %f\n", eps);
+
+blacs_gridexit_(&ictxt);
+blacs_exit_(&i0);
+
+return 0;
+} \ No newline at end of file
diff --git a/test cases/frameworks/30 scalapack/main.f90 b/test cases/frameworks/30 scalapack/main.f90
new file mode 100644
index 0000000..53b5fb9
--- /dev/null
+++ b/test cases/frameworks/30 scalapack/main.f90
@@ -0,0 +1,25 @@
+! minimal Scalapack demo
+implicit none
+
+integer :: ictxt, myid, nprocs, mycol, myrow, npcol, nprow
+real :: eps
+real, external :: pslamch
+
+! arbitrary test parameters
+npcol = 2
+nprow = 2
+
+call blacs_pinfo(myid, nprocs)
+call blacs_get(-1, 0, ictxt)
+call blacs_gridinit(ictxt, "C", nprocs, 1)
+
+call blacs_gridinfo(ictxt, nprow, npcol, myrow, mycol)
+
+eps = pslamch(ictxt, 'E')
+
+if(myrow == mycol) print '(A, F10.6)', "OK: Scalapack Fortran eps=", eps
+
+call blacs_gridexit(ictxt)
+call blacs_exit(0)
+
+end program
diff --git a/test cases/frameworks/30 scalapack/meson.build b/test cases/frameworks/30 scalapack/meson.build
new file mode 100644
index 0000000..430f54f
--- /dev/null
+++ b/test cases/frameworks/30 scalapack/meson.build
@@ -0,0 +1,27 @@
+project('test scalapack', 'c')
+
+mpi_c = dependency('mpi', language: 'c', required: false)
+if not mpi_c.found()
+ error('MESON_SKIP_TEST: MPI library not available')
+endif
+
+
+scalapack = dependency('scalapack', required: false)
+if not scalapack.found()
+ error('MESON_SKIP_TEST: scalapack library not available')
+endif
+
+c_exe = executable('scalapack_c', 'main.c',
+ dependencies: [scalapack, mpi_c])
+test('scalapack_c', c_exe, timeout: 30)
+
+if add_languages('fortran')
+ mpi_f = dependency('mpi', language: 'fortran', required: false)
+ if not mpi_f.found()
+ error('MESON_SKIP_TEST: MPI Fortran library not available')
+ endif
+
+ f_exe = executable('scalapack_fortran', 'main.f90',
+ dependencies: [scalapack, mpi_f])
+ test('scalapack_fortran', f_exe, timeout: 30)
+endif