From f6a4a6b00f9e5a112f450b2e5b278003bfa10250 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Wed, 13 Jul 2016 23:29:11 +0200 Subject: atlas: add install_test --- var/spack/repos/builtin/packages/atlas/package.py | 16 +++++++ .../builtin/packages/atlas/test_cblas_dgemm.c | 49 ++++++++++++++++++++++ .../builtin/packages/atlas/test_cblas_dgemm.output | 12 ++++++ 3 files changed, 77 insertions(+) create mode 100644 var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.c create mode 100644 var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.output (limited to 'var') diff --git a/var/spack/repos/builtin/packages/atlas/package.py b/var/spack/repos/builtin/packages/atlas/package.py index 20ac0a7879..0cb15de411 100644 --- a/var/spack/repos/builtin/packages/atlas/package.py +++ b/var/spack/repos/builtin/packages/atlas/package.py @@ -23,9 +23,11 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * +from spack.package_test import * from spack.util.executable import Executable import os.path + class Atlas(Package): """ Automatically Tuned Linear Algebra Software, generic shared ATLAS is an approach for the automatic generation and @@ -101,6 +103,7 @@ class Atlas(Package): make('shared_all') make("install") + self.install_test() def setup_dependent_package(self, module, dspec): # libsatlas.[so,dylib,dll ] contains all serial APIs (serial lapack, @@ -114,3 +117,16 @@ class Atlas(Package): if '+shared' in self.spec: self.spec.blas_shared_lib = join_path(libdir, name) self.spec.lapack_shared_lib = self.spec.blas_shared_lib + + def install_test(self): + source_file = join_path(os.path.dirname(self.module.__file__), + 'test_cblas_dgemm.c') + blessed_file = join_path(os.path.dirname(self.module.__file__), + 'test_cblas_dgemm.output') + + include_flags = ["-I%s" % join_path(self.spec.prefix, "include")] + link_flags = ["-L%s" % join_path(self.spec.prefix, "lib"), + "-lsatlas"] + + output = compile_c_and_execute(source_file, include_flags, link_flags) + compare_output_file(output, blessed_file) diff --git a/var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.c b/var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.c new file mode 100644 index 0000000000..2cb90fb883 --- /dev/null +++ b/var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.c @@ -0,0 +1,49 @@ +#include +#include + +double m[] = { + 3, 1, 3, + 1, 5, 9, + 2, 6, 5 +}; + +double x[] = { + -1, 3, -3 +}; + +#ifdef __cplusplus +extern "C" { +#endif + + void dgesv_(int *n, int *nrhs, double *a, int *lda, + int *ipivot, double *b, int *ldb, int *info); + +#ifdef __cplusplus +} +#endif + +int main(void) { + int i; + // blas: + double A[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0}; + double B[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0}; + double C[9] = {.5, .5, .5, .5, .5, .5, .5, .5, .5}; + cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans, + 3, 3, 2, 1, A, 3, B, 3, 2, C, 3); + for (i = 0; i < 9; i++) + printf("%f\n", C[i]); + + // lapack: + int ipiv[3]; + int j; + int info; + int n = 1; + int nrhs = 1; + int lda = 3; + int ldb = 3; + dgesv_(&n,&nrhs, &m[0], &lda, ipiv, &x[0], &ldb, &info); + for (i=0; i<3; ++i) + printf("%5.1f\n", x[i]); + + return 0; +} diff --git a/var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.output b/var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.output new file mode 100644 index 0000000000..01404462c4 --- /dev/null +++ b/var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.output @@ -0,0 +1,12 @@ +11.000000 +-9.000000 +5.000000 +-9.000000 +21.000000 +-1.000000 +5.000000 +-1.000000 +3.000000 + -0.3 + 3.0 + -3.0 -- cgit v1.2.3-60-g2f50