# -*- 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           mpi 1.0
PortGroup           linear_algebra 1.0

name                hpl
version             2.3
revision            1
categories          science
platforms           darwin
license             BSD
maintainers         {dstrubbe @dstrubbe}

description         High Performance Computing Linpack Benchmark
long_description    See how your machine compares to the TOP500! \
                    HPL is a software package that solves a (random) dense linear \
                    system in double-precision (64-bit) arithmetic on \
                    distributed-memory computers. It can thus be regarded as a \
                    portable as well as freely available implementation of the \
                    High Performance Computing Linpack Benchmark.
homepage            http://www.netlib.org/benchmark/hpl
master_sites        ${homepage}

checksums           rmd160  02910b59a5a4378125b508b0a85013c998c35c74 \
                    sha256  32c5c17d22330e6f2337b681aded51637fb6008d3f0eb7c277b163fadd612830 \
                    size    660871

mpi.setup           require -fortran
linalg.setup        blas_only

#variant threads?

# patch enables parallel build
patchfiles          patch-Makefile.diff

use_configure       no

set archname        macos

pre-build {
    file copy ${worksrcpath}/setup/Make.FreeBSD_PIV_CBLAS ${worksrcpath}/Make.${archname}
}

build.args          ARCH=${archname} TOPdir=${worksrcpath} MPlib=
build.target        all-j arch=${archname}
use_parallel_build  yes

test.run  yes

destroot {
    xinstall ${worksrcpath}/bin/${archname}/xhpl ${destroot}${prefix}/bin/
    xinstall -d ${destroot}${prefix}/share/hpl
    xinstall ${worksrcpath}/bin/${archname}/HPL.dat ${destroot}${prefix}/share/hpl/
    xinstall ${worksrcpath}/TUNING ${destroot}${prefix}/share/hpl/
}

pre-build {
    build.args-append      CC=${mpi.cc} LINKER=${mpi.cc} LAlib="${linalglib}"
}

pre-test {
    test.dir        ${worksrcpath}/bin/${archname}
    test.cmd        ${mpi.exec} -n ${build.jobs} ./xhpl
}

pre-fetch {
    notes    "Execute as: cd ${prefix}/share/hpl && ${mpi.exec} -n ${build.jobs} xhpl"
}

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
