From fa755c62c098d4e1cb8124b728226faaac37fe33 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Fri, 14 Jun 2024 16:07:56 +0200 Subject: [PATCH 1/8] Test new CI. --- .github/workflows/ci.yml | 49 +++++++++++++++++++++++++++++++++++++++ .github/workflows/gcc.yml | 35 ---------------------------- 2 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/gcc.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..43bc039 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: ci + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + toolchain: {compiler: gcc, version: 12, flags: ['-cpp -O3 -march=native -mtune=native']} + - os: ubuntu-latest + toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3 -march=native -mtune=native']} + - os: ubuntu-latest + toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O3 -xhost']} + - os: ubuntu-latest + toolchain: {compiler: intel, version: '2024.1', flags: ['-fpp -O3 -xhost']} + - os: ubuntu-latest + toolchain: {compiler: nvidia-hpc, version: '24.1', flags: ['-Mpreprocess -Ofast']} + - os: windows-latest + toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3 -march=native -mtune=native']} + - os: windows-latest + toolchain: {compiler: intel-classic, version: '2021.10', flags: ["/fpp /O3"]} + - os: windows-latest + toolchain: {compiler: intel, version: '2024.1', flags: ["/fpp /O3"]} + - os: macos-12 + toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3 -march=native -mtune=native']} + - os: macos-12 + toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O3 -xhost']} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - uses: fortran-lang/setup-fortran@main + id: setup-fortran + with: + compiler: ${{ matrix.toolchain.compiler }} + version: ${{ matrix.toolchain.version }} + + - name: Setup Fortran Package Manager + uses: fortran-lang/setup-fpm@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - run: | + fpm test --flag "${{ join(matrix.toolchain.flags, ' ') }}" diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml deleted file mode 100644 index d24bd8b..0000000 --- a/.github/workflows/gcc.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: GCC - -on: - workflow_dispatch: - push: - branches: - - master - - main - pull_request: - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - main: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Dependencies - run: sudo apt update && sudo apt install -y gfortran - - - name: Install fpm - uses: fortran-lang/setup-fpm@v5 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Run Tests - run: - - fpm test --verbose --flag "-Wall -Wextra -g -fbacktrace -fbounds-check" - - fpm test --flag "-O3 -march=native -funroll-loops -ffast-math" From 1c4b747fca520e44142e73bc9bff47fc04f395a2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Fri, 14 Jun 2024 17:24:46 +0200 Subject: [PATCH 2/8] Remove explicit link to blas and lapack (included in stdlib). --- fpm.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/fpm.toml b/fpm.toml index a55417d..87c5bab 100644 --- a/fpm.toml +++ b/fpm.toml @@ -11,8 +11,6 @@ auto-executables = true auto-tests = true auto-examples = true module-naming = false -link = ["blas", "lapack"] -#link = ["openblas"] [install] library = true From 702f00926c3db33c67b449fae5ddee244a71258c Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Fri, 14 Jun 2024 17:25:10 +0200 Subject: [PATCH 3/8] Removed duplicated public declarations of opts objects. --- src/Utils.f90 | 6 ------ src/Utils.fypp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/Utils.f90 b/src/Utils.f90 index 44c15a9..e217a30 100644 --- a/src/Utils.f90 +++ b/src/Utils.f90 @@ -40,12 +40,6 @@ module lightkrylov_utils ! Re-orders the Schur factorization of A. public :: ordschur - public :: abstract_opts - public :: gmres_sp_opts - public :: cg_sp_opts - public :: gmres_dp_opts - public :: cg_dp_opts - public :: log2_rsp public :: norml_rsp public :: log2_rdp diff --git a/src/Utils.fypp b/src/Utils.fypp index a91baab..a21c5e9 100644 --- a/src/Utils.fypp +++ b/src/Utils.fypp @@ -42,12 +42,6 @@ module lightkrylov_utils ! Re-orders the Schur factorization of A. public :: ordschur - public :: abstract_opts - #:for kind in REAL_KINDS - public :: gmres_${kind}$_opts - public :: cg_${kind}$_opts - #:endfor - #:for kind, type in RC_KINDS_TYPES #:if type[0] == "r" public :: log2_${type[0]}$${kind}$ From f83dcdf609fbd3d45fc09d20527848e596ea0fc0 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Fri, 14 Jun 2024 17:36:55 +0200 Subject: [PATCH 4/8] Removed duplicated declarations in LightKrylov.f90 --- src/LightKrylov.f90 | 4 ---- src/LightKrylov.fypp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/LightKrylov.f90 b/src/LightKrylov.f90 index 6f1ce98..2908dcc 100644 --- a/src/LightKrylov.f90 +++ b/src/LightKrylov.f90 @@ -28,10 +28,6 @@ module LightKrylov public :: cg_sp_opts public :: gmres_dp_opts public :: cg_dp_opts - public :: gmres_sp_opts - public :: cg_sp_opts - public :: gmres_dp_opts - public :: cg_dp_opts ! AbstractVectors exports. public :: abstract_vector diff --git a/src/LightKrylov.fypp b/src/LightKrylov.fypp index 23ee2b0..620cfa6 100644 --- a/src/LightKrylov.fypp +++ b/src/LightKrylov.fypp @@ -26,7 +26,7 @@ module LightKrylov public :: dp, atol_dp, rtol_dp ! Utils exports. - #:for kind, type in RC_KINDS_TYPES + #:for kind in REAL_KINDS public :: gmres_${kind}$_opts public :: cg_${kind}$_opts #:endfor From eb8d6ced5e5503aa4e6cbc6b18a7c3f957bf2782 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Fri, 14 Jun 2024 17:54:29 +0200 Subject: [PATCH 5/8] Hopefully fixing tests for ifort. --- test/TestLinops.f90 | 24 ++++++++++++++++-------- test/TestLinops.fypp | 20 ++++++++++++++++---- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/test/TestLinops.f90 b/test/TestLinops.f90 index 7ff4420..76cebe8 100644 --- a/test/TestLinops.f90 +++ b/test/TestLinops.f90 @@ -593,6 +593,7 @@ subroutine test_matvec_csp(error) type(vector_csp), allocatable :: x, y ! Test LinOp. type(linop_csp), allocatable :: A + real(sp), dimension(test_size, test_size, 2) :: Adata ! Initialize vectors. x = vector_csp() ; call x%rand() @@ -600,7 +601,7 @@ subroutine test_matvec_csp(error) ! Initialize matrix. A = linop_csp() - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) ! Compute matrix-vector product. call A%matvec(x, y) @@ -618,6 +619,7 @@ subroutine test_rmatvec_csp(error) type(vector_csp), allocatable :: x, y ! Test LinOp. type(linop_csp), allocatable :: A + real(sp), dimension(test_size, test_size, 2) :: Adata ! Initialize vectors. x = vector_csp() ; call x%rand() @@ -625,7 +627,7 @@ subroutine test_rmatvec_csp(error) ! Initialize matrix. A = linop_csp() - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) ! Compute matrix-vector product. call A%rmatvec(x, y) @@ -644,13 +646,14 @@ subroutine test_adjoint_matvec_csp(error) ! Test LinOp. type(linop_csp), allocatable :: A type(adjoint_linop_csp), allocatable :: B + real(sp), dimension(test_size, test_size, 2) :: Adata ! Internal variable. real(sp) :: alpha ! Initialize matrix. A = linop_csp() - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) ! Adjoint operator. allocate(B) ; B%A = A @@ -678,13 +681,14 @@ subroutine test_adjoint_rmatvec_csp(error) ! Test LinOp. type(linop_csp), allocatable :: A type(adjoint_linop_csp), allocatable :: B + real(sp), dimension(test_size, test_size, 2) :: Adata ! Internal variable. real(sp) :: alpha ! Initialize matrix. A = linop_csp() - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) ! Adjoint operator. allocate(B) ; B%A = A @@ -724,6 +728,7 @@ subroutine test_matvec_cdp(error) type(vector_cdp), allocatable :: x, y ! Test LinOp. type(linop_cdp), allocatable :: A + real(dp), dimension(test_size, test_size, 2) :: Adata ! Initialize vectors. x = vector_cdp() ; call x%rand() @@ -731,7 +736,7 @@ subroutine test_matvec_cdp(error) ! Initialize matrix. A = linop_cdp() - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) ! Compute matrix-vector product. call A%matvec(x, y) @@ -749,6 +754,7 @@ subroutine test_rmatvec_cdp(error) type(vector_cdp), allocatable :: x, y ! Test LinOp. type(linop_cdp), allocatable :: A + real(dp), dimension(test_size, test_size, 2) :: Adata ! Initialize vectors. x = vector_cdp() ; call x%rand() @@ -756,7 +762,7 @@ subroutine test_rmatvec_cdp(error) ! Initialize matrix. A = linop_cdp() - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) ! Compute matrix-vector product. call A%rmatvec(x, y) @@ -775,13 +781,14 @@ subroutine test_adjoint_matvec_cdp(error) ! Test LinOp. type(linop_cdp), allocatable :: A type(adjoint_linop_cdp), allocatable :: B + real(dp), dimension(test_size, test_size, 2) :: Adata ! Internal variable. real(dp) :: alpha ! Initialize matrix. A = linop_cdp() - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) ! Adjoint operator. allocate(B) ; B%A = A @@ -809,13 +816,14 @@ subroutine test_adjoint_rmatvec_cdp(error) ! Test LinOp. type(linop_cdp), allocatable :: A type(adjoint_linop_cdp), allocatable :: B + real(dp), dimension(test_size, test_size, 2) :: Adata ! Internal variable. real(dp) :: alpha ! Initialize matrix. A = linop_cdp() - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) ! Adjoint operator. allocate(B) ; B%A = A diff --git a/test/TestLinops.fypp b/test/TestLinops.fypp index 8b7ca12..f0b0d8d 100644 --- a/test/TestLinops.fypp +++ b/test/TestLinops.fypp @@ -161,6 +161,9 @@ contains type(vector_${type[0]}$${kind}$), allocatable :: x, y ! Test LinOp. type(linop_${type[0]}$${kind}$), allocatable :: A + #:if type[0] == "c" + real(${kind}$), dimension(test_size, test_size, 2) :: Adata + #:endif ! Initialize vectors. x = vector_${type[0]}$${kind}$() ; call x%rand() @@ -169,7 +172,7 @@ contains ! Initialize matrix. A = linop_${type[0]}$${kind}$() #:if type[0] == "c" - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) #:else call random_number(A%data) #:endif @@ -194,6 +197,9 @@ contains type(vector_${type[0]}$${kind}$), allocatable :: x, y ! Test LinOp. type(linop_${type[0]}$${kind}$), allocatable :: A + #:if type[0] == "c" + real(${kind}$), dimension(test_size, test_size, 2) :: Adata + #:endif ! Initialize vectors. x = vector_${type[0]}$${kind}$() ; call x%rand() @@ -202,7 +208,7 @@ contains ! Initialize matrix. A = linop_${type[0]}$${kind}$() #:if type[0] == "c" - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) #:else call random_number(A%data) #:endif @@ -228,6 +234,9 @@ contains ! Test LinOp. type(linop_${type[0]}$${kind}$), allocatable :: A type(adjoint_linop_${type[0]}$${kind}$), allocatable :: B + #:if type[0] == "c" + real(${kind}$), dimension(test_size, test_size, 2) :: Adata + #:endif ! Internal variable. real(${kind}$) :: alpha @@ -235,7 +244,7 @@ contains ! Initialize matrix. A = linop_${type[0]}$${kind}$() #:if type[0] == "c" - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) #:else call random_number(A%data) #:endif @@ -270,6 +279,9 @@ contains ! Test LinOp. type(linop_${type[0]}$${kind}$), allocatable :: A type(adjoint_linop_${type[0]}$${kind}$), allocatable :: B + #:if type[0] == "c" + real(${kind}$), dimension(test_size, test_size, 2) :: Adata + #:endif ! Internal variable. real(${kind}$) :: alpha @@ -277,7 +289,7 @@ contains ! Initialize matrix. A = linop_${type[0]}$${kind}$() #:if type[0] == "c" - call random_number(A%data%re) ; call random_number(A%data%im) + call random_number(Adata) ; A%data%re = Adata(:, :, 1) ; A%data%im = Adata(:, :, 2) #:else call random_number(A%data) #:endif From 3d7f40ff089e5b4411a02432e2976d0772ca94e5 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Fri, 14 Jun 2024 18:09:57 +0200 Subject: [PATCH 6/8] Change fmt in testdrive following the github readme. --- test/Tests.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Tests.f90 b/test/Tests.f90 index 8298f69..479b5ad 100644 --- a/test/Tests.f90 +++ b/test/Tests.f90 @@ -19,7 +19,7 @@ program Tester ! Unit-test related. integer :: status, is, num_tests type(testsuite_type), allocatable :: testsuites(:) - character(len=*), parameter :: fmt = '("+", *(1x, a))' + character(len=*), parameter :: fmt = '("#", *(1x, a))' ! Display information about the version of LightKrylov being tested. call greetings() @@ -99,7 +99,7 @@ program Tester do is = 1, size(testsuites) write (*, *) "-------------------------------" - write (error_unit, fmt) "Testing :", testsuites(is)%name + write (error_unit, fmt) "Testing:", testsuites(is)%name write (*, *) "-------------------------------" write (*, *) call run_testsuite(testsuites(is)%collect, error_unit, status) @@ -179,7 +179,7 @@ program Tester do is = 1, size(testsuites) write (*, *) "-------------------------------" - write (error_unit, fmt) "Testing :", testsuites(is)%name + write (error_unit, fmt) "Testing:", testsuites(is)%name write (*, *) "-------------------------------" write (*, *) call run_testsuite(testsuites(is)%collect, error_unit, status) From a07b2f31889beef0d1e210de8ff3107eddc6374d Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Fri, 14 Jun 2024 22:16:25 +0200 Subject: [PATCH 7/8] Removed overloaded = operator causing ifort failures. --- src/AbstractLinops.f90 | 12 ------------ src/AbstractLinops.fypp | 12 ------------ src/AbstractVectors.f90 | 12 ------------ src/AbstractVectors.fypp | 12 ------------ 4 files changed, 48 deletions(-) diff --git a/src/AbstractLinops.f90 b/src/AbstractLinops.f90 index b665104..0df2059 100644 --- a/src/AbstractLinops.f90 +++ b/src/AbstractLinops.f90 @@ -8,10 +8,6 @@ module lightkrylov_AbstractLinops character*128, parameter :: this_module = 'Lightkrylov_AbstractLinops' type, abstract, public :: abstract_linop - contains - private - procedure, pass(from), public :: copy - generic, public :: assignment(=) => copy end type abstract_linop !------------------------------------------------------------------------------ @@ -390,14 +386,6 @@ end subroutine abstract_matvec_cdp contains - subroutine copy(out, from) - class(abstract_linop), intent(in) :: from - class(abstract_linop), allocatable, intent(out) :: out - if (allocated(out)) deallocate(out) - allocate(out, source=from) - return - end subroutine copy - subroutine id_matvec_rsp(self, vec_in, vec_out) class(Id_rsp), intent(in) :: self class(abstract_vector_rsp), intent(in) :: vec_in diff --git a/src/AbstractLinops.fypp b/src/AbstractLinops.fypp index 729628d..096a545 100644 --- a/src/AbstractLinops.fypp +++ b/src/AbstractLinops.fypp @@ -10,10 +10,6 @@ module lightkrylov_AbstractLinops character*128, parameter :: this_module = 'Lightkrylov_AbstractLinops' type, abstract, public :: abstract_linop - contains - private - procedure, pass(from), public :: copy - generic, public :: assignment(=) => copy end type abstract_linop #:for kind, type in RC_KINDS_TYPES @@ -153,14 +149,6 @@ module lightkrylov_AbstractLinops #:endfor contains - subroutine copy(out, from) - class(abstract_linop), intent(in) :: from - class(abstract_linop), allocatable, intent(out) :: out - if (allocated(out)) deallocate(out) - allocate(out, source=from) - return - end subroutine copy - #:for kind, type in RC_KINDS_TYPES subroutine id_matvec_${type[0]}$${kind}$(self, vec_in, vec_out) class(Id_${type[0]}$${kind}$), intent(in) :: self diff --git a/src/AbstractVectors.f90 b/src/AbstractVectors.f90 index b7f8e6d..b2d137c 100644 --- a/src/AbstractVectors.f90 +++ b/src/AbstractVectors.f90 @@ -57,10 +57,6 @@ module lightkrylov_AbstractVectors type, abstract, public :: abstract_vector - contains - private - procedure, pass(from), public :: copy => copy_vec - generic, public :: assignment(=) => copy end type abstract_vector @@ -364,14 +360,6 @@ end function abstract_dot_cdp contains - subroutine copy_vec(out, from) - class(abstract_vector), intent(in) :: from - class(abstract_vector), allocatable, intent(out) :: out - if (allocated(out)) deallocate(out) - allocate(out, source=from) - return - end subroutine copy_vec - function norm_rsp(self) result(alpha) !! Compute the norm of an `abstract_vector`. class(abstract_vector_rsp), intent(in) :: self diff --git a/src/AbstractVectors.fypp b/src/AbstractVectors.fypp index 0721930..bb340c5 100644 --- a/src/AbstractVectors.fypp +++ b/src/AbstractVectors.fypp @@ -48,10 +48,6 @@ module lightkrylov_AbstractVectors type, abstract, public :: abstract_vector - contains - private - procedure, pass(from), public :: copy => copy_vec - generic, public :: assignment(=) => copy end type abstract_vector @@ -135,14 +131,6 @@ module lightkrylov_AbstractVectors #:endfor contains - subroutine copy_vec(out, from) - class(abstract_vector), intent(in) :: from - class(abstract_vector), allocatable, intent(out) :: out - if (allocated(out)) deallocate(out) - allocate(out, source=from) - return - end subroutine copy_vec - #:for kind, type in RC_KINDS_TYPES function norm_${type[0]}$${kind}$(self) result(alpha) !! Compute the norm of an `abstract_vector`. From 18ff7dd920a592edce9dde75ec54ccd1b8cbaf62 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Date: Fri, 14 Jun 2024 22:32:20 +0200 Subject: [PATCH 8/8] Removed consistently failing compilers + reduced optimization level for intel (test). --- .github/workflows/ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43bc039..3ef8ac7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,21 +14,21 @@ jobs: - os: ubuntu-latest toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3 -march=native -mtune=native']} - os: ubuntu-latest - toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O3 -xhost']} + toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O0 -g']} - os: ubuntu-latest - toolchain: {compiler: intel, version: '2024.1', flags: ['-fpp -O3 -xhost']} - - os: ubuntu-latest - toolchain: {compiler: nvidia-hpc, version: '24.1', flags: ['-Mpreprocess -Ofast']} + toolchain: {compiler: intel, version: '2024.1', flags: ['-fpp -O0 -g']} + # - os: ubuntu-latest + # toolchain: {compiler: nvidia-hpc, version: '24.1', flags: ['-Mpreprocess -Ofast']} - os: windows-latest toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3 -march=native -mtune=native']} - - os: windows-latest - toolchain: {compiler: intel-classic, version: '2021.10', flags: ["/fpp /O3"]} - - os: windows-latest - toolchain: {compiler: intel, version: '2024.1', flags: ["/fpp /O3"]} + # - os: windows-latest + # toolchain: {compiler: intel-classic, version: '2021.10', flags: ["/fpp /O3"]} + # - os: windows-latest + # toolchain: {compiler: intel, version: '2024.1', flags: ["/fpp /O3"]} - os: macos-12 toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3 -march=native -mtune=native']} - - os: macos-12 - toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O3 -xhost']} + # - os: macos-12 + # toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O3 -xhost']} steps: - name: Checkout code