atlas: add install_test
This commit is contained in:
		| @@ -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 @@ def install(self, spec, prefix): | ||||
|                     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 @@ def setup_dependent_package(self, module, dspec): | ||||
|         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) | ||||
|   | ||||
							
								
								
									
										49
									
								
								var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								var/spack/repos/builtin/packages/atlas/test_cblas_dgemm.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| #include <cblas.h> | ||||
| #include <stdio.h> | ||||
|  | ||||
| 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; | ||||
| } | ||||
| @@ -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 | ||||
		Reference in New Issue
	
	Block a user
	 Denis Davydov
					Denis Davydov