summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTony Theodore <tonyt@logyst.com>2013-09-16 07:24:36 (GMT)
committerTony Theodore <tonyt@logyst.com>2013-09-16 07:24:36 (GMT)
commitd4fc118e1c01bee5e8c2dc819fd1187cc32fecc4 (patch)
tree853911c858210ff75e6f4b08c9b247623e677839 /src
parenta51cf3f2a25835506230b4a8f071005c32b1766c (diff)
downloadmxe-d4fc118e1c01bee5e8c2dc819fd1187cc32fecc4.zip
mxe-d4fc118e1c01bee5e8c2dc819fd1187cc32fecc4.tar.gz
mxe-d4fc118e1c01bee5e8c2dc819fd1187cc32fecc4.tar.bz2
package lapack: enable C interface and add cblas link test
Diffstat (limited to 'src')
-rw-r--r--src/lapack-test.c55
-rw-r--r--src/lapack.mk12
2 files changed, 65 insertions, 2 deletions
diff --git a/src/lapack-test.c b/src/lapack-test.c
new file mode 100644
index 0000000..00bf092
--- /dev/null
+++ b/src/lapack-test.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+/* taken from http://www.netlib.org/lapack/lapacke.html */
+
+/* Calling CGEQRF and CUNGQR to compute Q with workspace querying */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <lapacke_utils.h>
+#include <cblas.h>
+
+int main (int argc, const char * argv[])
+{
+ (void)argc;
+ (void)argv;
+
+ lapack_complex_float *a,*tau,*r,*work,one,zero,query;
+ lapack_int info,m,n,lda,lwork;
+ int i,j;
+ float err;
+ m = 10; n = 5; lda = m;
+ one = lapack_make_complex_float(1.0,0.0);
+ zero= lapack_make_complex_float(0.0,0.0);
+ a = calloc(m*n,sizeof(lapack_complex_float));
+ r = calloc(n*n,sizeof(lapack_complex_float));
+ tau = calloc(m,sizeof(lapack_complex_float));
+ for(j=0;j<n;j++)
+ for(i=0;i<m;i++)
+ a[i+j*m] = lapack_make_complex_float(i+1,j+1);
+ info = LAPACKE_cgeqrf_work(LAPACK_COL_MAJOR,m,n,a,lda,tau,&query,-1);
+ lwork = (lapack_int)query;
+ info = LAPACKE_cungqr_work(LAPACK_COL_MAJOR,m,n,n,a,lda,tau,&query,-1);
+ lwork = MAX(lwork,(lapack_int)query);
+ work = calloc(lwork,sizeof(lapack_complex_float));
+ info = LAPACKE_cgeqrf_work(LAPACK_COL_MAJOR,m,n,a,lda,tau,work,lwork);
+ info = LAPACKE_cungqr_work(LAPACK_COL_MAJOR,m,n,n,a,lda,tau,work,lwork);
+ for(j=0;j<n;j++)
+ for(i=0;i<n;i++)
+ r[i+j*n]=(i==j)?-one:zero;
+ cblas_cgemm(CblasColMajor,CblasConjTrans,CblasNoTrans,
+ n,n,m,&one,a,lda,a,lda,&one,r,n);
+ err=0.0;
+ for(i=0;i<n;i++)
+ for(j=0;j<n;j++)
+ err=MAX(err,cabs(r[i+j*n]));
+ printf("error=%e\n",err);
+ free(work);
+ free(tau);
+ free(r);
+ free(a);
+ return(info);
+}
diff --git a/src/lapack.mk b/src/lapack.mk
index 53c6a98..a39c163 100644
--- a/src/lapack.mk
+++ b/src/lapack.mk
@@ -8,7 +8,7 @@ $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tgz
$(PKG)_URL := http://www.netlib.org/$(PKG)/$($(PKG)_FILE)
$(PKG)_URL_2 := ftp://ftp.eq.uc.pt/pub/software/math/netlib/$(PKG)/$($(PKG)_FILE)
-$(PKG)_DEPS := gcc
+$(PKG)_DEPS := gcc cblas
define $(PKG)_UPDATE
$(WGET) -q -O- 'http://www.netlib.org/lapack/' | \
@@ -21,11 +21,19 @@ define $(PKG)_BUILD
-DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
-DCMAKE_AR='$(PREFIX)/bin/$(TARGET)-ar' \
-DCMAKE_RANLIB='$(PREFIX)/bin/$(TARGET)-ranlib' \
+ -DLAPACKE=ON \
.
- $(MAKE) -C '$(1)/SRC' -j '$(JOBS)' install
+ cp '$(1)/lapacke/include/lapacke_mangling_with_flags.h' '$(1)/lapacke/include/lapacke_mangling.h'
+ $(MAKE) -C '$(1)/SRC' -j '$(JOBS)' install
+ $(MAKE) -C '$(1)/lapacke' -j '$(JOBS)' install
'$(TARGET)-gfortran' \
-W -Wall -Werror -pedantic \
'$(2).f' -o '$(PREFIX)/$(TARGET)/bin/test-lapack.exe' \
-llapack
+
+ '$(TARGET)-gcc' \
+ -W -Wall -Werror -pedantic \
+ '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-lapacke.exe' \
+ -llapacke -llapack -lcblas -lblas -lgfortran
endef