[alglib] 01/02: Add autopkgtests.
Anton Gladky
gladk at moszumanska.debian.org
Sat May 10 16:58:41 UTC 2014
This is an automated email from the git hooks/post-receive script.
gladk pushed a commit to branch master
in repository alglib.
commit c95abb4968e18566c4dca9441f8ee8b52d65dc07
Author: Anton Gladky <gladk at debian.org>
Date: Sat May 10 17:18:26 2014 +0200
Add autopkgtests.
---
debian/control | 1 +
debian/tests/build1 | 61 ++++++++++++++++++++++++
debian/tests/build2 | 76 +++++++++++++++++++++++++++++
debian/tests/build3 | 80 +++++++++++++++++++++++++++++++
debian/tests/build4 | 128 +++++++++++++++++++++++++++++++++++++++++++++++++
debian/tests/build5 | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++
debian/tests/control | 2 +
7 files changed, 480 insertions(+)
diff --git a/debian/control b/debian/control
index ac77eb3..136bf33 100644
--- a/debian/control
+++ b/debian/control
@@ -13,6 +13,7 @@ Section: libs
Homepage: http://www.alglib.net/
Vcs-Git: git://anonscm.debian.org/debian-science/packages/alglib.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=debian-science/packages/alglib.git
+XS-Testsuite: autopkgtest
Package: libalglib-dev
Priority: extra
diff --git a/debian/tests/build1 b/debian/tests/build1
new file mode 100755
index 0000000..50db9ab
--- /dev/null
+++ b/debian/tests/build1
@@ -0,0 +1,61 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libmedc
+# (C) 2013 Thomas Moulard
+# (C) 2014 Anton Gladky
+# Author: Thomas Moulard <thomas.moulard at gmail.com>
+# Anton Gladky <gladk at debian.org>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > demo.cpp
+#include <stdio.h>
+#include "linalg.h"
+
+int main()
+{
+ alglib::real_2d_array a, b, c;
+ int n = 2000;
+ int i, j;
+ double timeneeded, flops;
+
+ // Initialize arrays
+ a.setlength(n, n);
+ b.setlength(n, n);
+ c.setlength(n, n);
+ for(i=0; i<n; i++)
+ for(j=0; j<n; j++)
+ {
+ a[i][j] = alglib::randomreal()-0.5;
+ b[i][j] = alglib::randomreal()-0.5;
+ c[i][j] = 0.0;
+ }
+
+ // Set number of worker threads: "4" means "use 4 cores".
+ // This line is ignored if AE_OS is UNDEFINED.
+ alglib::setnworkers(4);
+
+ // Perform matrix-matrix product.
+ // We call function with "smp_" prefix, which means that ALGLIB
+ // will try to execute it in parallel manner whenever it is possible.
+ flops = 2*pow((double)n, (double)3);
+ alglib::smp_rmatrixgemm(
+ n, n, n,
+ 1.0,
+ a, 0, 0, 0,
+ b, 0, 0, 1,
+ 0.0,
+ c, 0, 0);
+
+ return 0;
+}
+
+EOF
+
+g++ -I/usr/include -lalglib -o demo demo.cpp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/build2 b/debian/tests/build2
new file mode 100755
index 0000000..cbe620d
--- /dev/null
+++ b/debian/tests/build2
@@ -0,0 +1,76 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libmedc
+# (C) 2013 Thomas Moulard
+# (C) 2014 Anton Gladky
+# Author: Thomas Moulard <thomas.moulard at gmail.com>
+# Anton Gladky <gladk at debian.org>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > demo.cpp
+#include <stdio.h>
+#include "interpolation.h"
+
+int main()
+{ alglib::real_1d_array x("[0,1,2,3]");
+ alglib::real_1d_array y("[1,5,3,9]");
+ alglib::real_1d_array y2("[1,5,3,9,0]");
+ alglib::spline1dinterpolant s;
+
+ alglib::spline1dbuildlinear(x, y, 4, s); // 'expert' interface is used
+ alglib::spline1dbuildlinear(x, y, s); // 'friendly' interface - input size is
+ // automatically determined
+
+ alglib::spline1dbuildlinear(x, y2, 4, s); // y2.length() is 5, but it will work
+
+
+
+ alglib::real_2d_array a;
+ alglib::matinvreport rep;
+ alglib::ae_int_t info;
+
+ //
+ // 'Friendly' interface: spdmatrixinverse() accepts and returns symmetric matrix
+ //
+
+ // symmetric positive definite matrix
+ a = "[[2,1],[1,2]]";
+
+ // after this line A will contain [[0.66,-0.33],[-0.33,0.66]]
+ // which is symmetric too
+ alglib::spdmatrixinverse(a, info, rep);
+
+ // you may try to pass nonsymmetric matrix
+ a = "[[2,1],[0,2]]";
+
+ {
+ alglib::real_2d_array a;
+ alglib::matinvreport rep;
+ alglib::ae_int_t info;
+
+ //
+ // 'Expert' interface, spdmatrixinverse()
+ //
+
+ // only upper triangle is used; a[1][0] is initialized by NAN,
+ // but it can be arbitrary number
+ a = "[[2,1],[NAN,2]]";
+
+ // after this line A will contain [[0.66,-0.33],[NAN,0.66]]
+ // only upper triangle is modified
+ alglib::spdmatrixinverse(a, 2 /* N */, true /* upper triangle is used */, info, rep);
+ }
+
+ return 0;
+}
+
+EOF
+
+g++ -I/usr/include -lalglib -o demo demo.cpp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/build3 b/debian/tests/build3
new file mode 100755
index 0000000..78d26b2
--- /dev/null
+++ b/debian/tests/build3
@@ -0,0 +1,80 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libmedc
+# (C) 2013 Thomas Moulard
+# (C) 2014 Anton Gladky
+# Author: Thomas Moulard <thomas.moulard at gmail.com>
+# Anton Gladky <gladk at debian.org>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > demo.cpp
+#include "stdafx.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include "linalg.h"
+
+using namespace alglib;
+
+
+int main(int argc, char **argv)
+{
+ //
+ // rmatrixsyrk() function allows us to calculate symmetric rank-K update
+ // C := beta*C + alpha*A'*A, where C is square N*N matrix, A is square K*N
+ // matrix, alpha and beta are scalars. It is also possible to update by
+ // adding A*A' instead of A'*A.
+ //
+ // Parameters of this function are:
+ // * N, K - matrix size
+ // * Alpha - coefficient before A
+ // * A, IA, JA - matrix and submatrix offsets
+ // * OpTypeA - multiplication type:
+ // * 0 - A*A^T is calculated
+ // * 2 - A^T*A is calculated
+ // * Beta - coefficient before C
+ // * C, IC, JC - preallocated input/output matrix and submatrix offsets
+ // * IsUpper - whether upper or lower triangle of C is updated;
+ // this function updates only one half of C, leaving
+ // other half unchanged (not referenced at all).
+ //
+ // Below we will show how to calculate simple product C:=A'*A
+ //
+ // NOTE: beta=0 and we do not use previous value of C, but still it
+ // MUST be preallocated.
+ //
+ ae_int_t n = 2;
+ ae_int_t k = 1;
+ double alpha = 1.0;
+ ae_int_t ia = 0;
+ ae_int_t ja = 0;
+ ae_int_t optypea = 2;
+ double beta = 0.0;
+ ae_int_t ic = 0;
+ ae_int_t jc = 0;
+ bool isupper = true;
+ real_2d_array a = "[[1,2]]";
+
+ // preallocate space to store result
+ real_2d_array c = "[[0,0],[0,0]]";
+
+ // calculate product, store result into upper part of c
+ rmatrixsyrk(n, k, alpha, a, ia, ja, optypea, beta, c, ic, jc, isupper);
+
+ // output result.
+ // IMPORTANT: lower triangle of C was NOT updated!
+ printf("%s\n", c.tostring(3).c_str()); // EXPECTED: [[1,2],[0,4]]
+ return 0;
+}
+
+
+EOF
+
+g++ -I/usr/include -lalglib -o demo demo.cpp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/build4 b/debian/tests/build4
new file mode 100755
index 0000000..267f1d3
--- /dev/null
+++ b/debian/tests/build4
@@ -0,0 +1,128 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libmedc
+# (C) 2013 Thomas Moulard
+# (C) 2014 Anton Gladky
+# Author: Thomas Moulard <thomas.moulard at gmail.com>
+# Anton Gladky <gladk at debian.org>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > demo.cpp
+#include "stdafx.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include "linalg.h"
+
+using namespace alglib;
+
+
+int main(int argc, char **argv)
+{
+ //
+ // In this example we assume that you already know how to work with
+ // rmatrixgemm() function. Below we concentrate on its multithreading
+ // capabilities.
+ //
+ // SMP edition of ALGLIB includes smp_rmatrixgemm() - multithreaded
+ // version of rmatrixgemm() function. In the basic edition of ALGLIB
+ // (GPL edition or commercial version without SMP support) this function
+ // just calls single-threaded stub. So, you may call this function from
+ // ANY edition of ALGLIB, but only in SMP edition it will work in really
+ // multithreaded mode.
+ //
+ // In order to use multithreading, you have to:
+ // 1) Install SMP edition of ALGLIB.
+ // 2) This step is specific for C++ users: you should activate OS-specific
+ // capabilities of ALGLIB by defining AE_OS=AE_POSIX (for *nix systems)
+ // or AE_OS=AE_WINDOWS (for Windows systems).
+ // C# users do not have to perform this step because C# programs are
+ // portable across different systems without OS-specific tuning.
+ // 3) Allow ALGLIB to know about number of worker threads to use:
+ // a) autodetection (C++, C#):
+ // ALGLIB will automatically determine number of CPU cores and
+ // (by default) will use all cores except for one. Say, on 4-core
+ // system it will use three cores - unless you manually told it
+ // to use more or less. It will keep your system responsive during
+ // lengthy computations.
+ // Such behavior may be changed with setnworkers() call:
+ // * alglib::setnworkers(0) = use all cores
+ // * alglib::setnworkers(-1) = leave one core unused
+ // * alglib::setnworkers(-2) = leave two cores unused
+ // * alglib::setnworkers(+2) = use 2 cores (even if you have more)
+ // b) manual specification (C++, C#):
+ // You may want to specify maximum number of worker threads during
+ // compile time by means of preprocessor definition AE_NWORKERS.
+ // For C++ it will be "AE_NWORKERS=X" where X can be any positive number.
+ // For C# it is "AE_NWORKERSX", where X should be replaced by number of
+ // workers (AE_NWORKERS2, AE_NWORKERS3, AE_NWORKERS4, ...).
+ // You can add this definition to compiler command line or change
+ // corresponding project settings in your IDE.
+ //
+ // After you installed and configured SMP edition of ALGLIB, you may choose
+ // between serial and multithreaded versions of SMP-capable functions:
+ // * serial version works as usual, in the context of the calling thread
+ // * multithreaded version (with "smp_" prefix) creates (or wakes up) worker
+ // threads, inserts task in the worker queue, and waits for completion of
+ // the task. All processing is done in context of worker thread(s).
+ //
+ // NOTE: because starting/stopping worker threads costs thousands of CPU cycles,
+ // you should not use multithreading for lightweight computational problems.
+ //
+ // NOTE: some old POSIX-compatible operating systems do not support
+ // sysconf(_SC_NPROCESSORS_ONLN) system call which is required in order
+ // to automatically determine number of active cores. On these systems
+ // you should specify number of cores manually at compile time.
+ // Without it ALGLIB will run in single-threaded mode.
+ //
+ // Now, back to our example. In this example we will show you:
+ // * how to call SMP version of rmatrixgemm(). Because we work with tiny 2x2
+ // matrices, we won't expect to see ANY speedup from using multithreading.
+ // The only purpose of this demo is to show how to call SMP functions.
+ // * how to modify number of worker threads used by ALGLIB
+ //
+ real_2d_array a = "[[2,1],[1,3]]";
+ real_2d_array b = "[[2,1],[0,1]]";
+ real_2d_array c = "[[0,0],[0,0]]";
+ ae_int_t m = 2;
+ ae_int_t n = 2;
+ ae_int_t k = 2;
+ double alpha = 1.0;
+ ae_int_t ia = 0;
+ ae_int_t ja = 0;
+ ae_int_t optypea = 0;
+ ae_int_t ib = 0;
+ ae_int_t jb = 0;
+ ae_int_t optypeb = 0;
+ double beta = 0.0;
+ ae_int_t ic = 0;
+ ae_int_t jc = 0;
+
+ // serial code
+ c = "[[0,0],[0,0]]";
+ rmatrixgemm(m, n, k, alpha, a, ia, ja, optypea, b, ib, jb, optypeb, beta, c, ic, jc);
+
+ // SMP code with default number of worker threads
+ c = "[[0,0],[0,0]]";
+ smp_rmatrixgemm(m, n, k, alpha, a, ia, ja, optypea, b, ib, jb, optypeb, beta, c, ic, jc);
+ printf("%s\n", c.tostring(3).c_str()); // EXPECTED: [[4,3],[2,4]]
+
+ // override number of worker threads - use two cores
+ alglib::setnworkers(+2);
+ c = "[[0,0],[0,0]]";
+ smp_rmatrixgemm(m, n, k, alpha, a, ia, ja, optypea, b, ib, jb, optypeb, beta, c, ic, jc);
+ printf("%s\n", c.tostring(3).c_str()); // EXPECTED: [[4,3],[2,4]]
+ return 0;
+}
+
+
+EOF
+
+g++ -I/usr/include -lalglib -o demo demo.cpp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/build5 b/debian/tests/build5
new file mode 100755
index 0000000..780b4c9
--- /dev/null
+++ b/debian/tests/build5
@@ -0,0 +1,132 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against libmedc
+# (C) 2013 Thomas Moulard
+# (C) 2014 Anton Gladky
+# Author: Thomas Moulard <thomas.moulard at gmail.com>
+# Anton Gladky <gladk at debian.org>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > demo.cpp
+#include "stdafx.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include "linalg.h"
+
+using namespace alglib;
+
+
+int main(int argc, char **argv)
+{
+ //
+ // In this example we assume that you already know how to work with
+ // rmatrixsyrk() function. Below we concentrate on its multithreading
+ // capabilities.
+ //
+ // SMP edition of ALGLIB includes smp_rmatrixsyrk() - multithreaded
+ // version of rmatrixsyrk() function. In the basic edition of ALGLIB
+ // (GPL edition or commercial version without SMP support) this function
+ // just calls single-threaded stub. So, you may call this function from
+ // ANY edition of ALGLIB, but only in SMP edition it will work in really
+ // multithreaded mode.
+ //
+ // In order to use multithreading, you have to:
+ // 1) Install SMP edition of ALGLIB.
+ // 2) This step is specific for C++ users: you should activate OS-specific
+ // capabilities of ALGLIB by defining AE_OS=AE_POSIX (for *nix systems)
+ // or AE_OS=AE_WINDOWS (for Windows systems).
+ // C# users do not have to perform this step because C# programs are
+ // portable across different systems without OS-specific tuning.
+ // 3) Allow ALGLIB to know about number of worker threads to use:
+ // a) autodetection (C++, C#):
+ // ALGLIB will automatically determine number of CPU cores and
+ // (by default) will use all cores except for one. Say, on 4-core
+ // system it will use three cores - unless you manually told it
+ // to use more or less. It will keep your system responsive during
+ // lengthy computations.
+ // Such behavior may be changed with setnworkers() call:
+ // * alglib::setnworkers(0) = use all cores
+ // * alglib::setnworkers(-1) = leave one core unused
+ // * alglib::setnworkers(-2) = leave two cores unused
+ // * alglib::setnworkers(+2) = use 2 cores (even if you have more)
+ // b) manual specification (C++, C#):
+ // You may want to specify maximum number of worker threads during
+ // compile time by means of preprocessor definition AE_NWORKERS.
+ // For C++ it will be "AE_NWORKERS=X" where X can be any positive number.
+ // For C# it is "AE_NWORKERSX", where X should be replaced by number of
+ // workers (AE_NWORKERS2, AE_NWORKERS3, AE_NWORKERS4, ...).
+ // You can add this definition to compiler command line or change
+ // corresponding project settings in your IDE.
+ //
+ // After you installed and configured SMP edition of ALGLIB, you may choose
+ // between serial and multithreaded versions of SMP-capable functions:
+ // * serial version works as usual, in the context of the calling thread
+ // * multithreaded version (with "smp_" prefix) creates (or wakes up) worker
+ // threads, inserts task in the worker queue, and waits for completion of
+ // the task. All processing is done in context of worker thread(s).
+ //
+ // NOTE: because starting/stopping worker threads costs thousands of CPU cycles,
+ // you should not use multithreading for lightweight computational problems.
+ //
+ // NOTE: some old POSIX-compatible operating systems do not support
+ // sysconf(_SC_NPROCESSORS_ONLN) system call which is required in order
+ // to automatically determine number of active cores. On these systems
+ // you should specify number of cores manually at compile time.
+ // Without it ALGLIB will run in single-threaded mode.
+ //
+ // Now, back to our example. In this example we will show you:
+ // * how to call SMP version of rmatrixsyrk(). Because we work with tiny 2x2
+ // matrices, we won't expect to see ANY speedup from using multithreading.
+ // The only purpose of this demo is to show how to call SMP functions.
+ // * how to modify number of worker threads used by ALGLIB
+ //
+ ae_int_t n = 2;
+ ae_int_t k = 1;
+ double alpha = 1.0;
+ ae_int_t ia = 0;
+ ae_int_t ja = 0;
+ ae_int_t optypea = 2;
+ double beta = 0.0;
+ ae_int_t ic = 0;
+ ae_int_t jc = 0;
+ bool isupper = true;
+ real_2d_array a = "[[1,2]]";
+ real_2d_array c = "[[]]";
+
+ //
+ // Default number of worker threads.
+ // Preallocate space to store result, call multithreaded version, test.
+ //
+ // NOTE: this function updates only one triangular part of C. In our
+ // example we choose to update upper triangle.
+ //
+ c = "[[0,0],[0,0]]";
+ smp_rmatrixsyrk(n, k, alpha, a, ia, ja, optypea, beta, c, ic, jc, isupper);
+ printf("%s\n", c.tostring(3).c_str()); // EXPECTED: [[1,2],[0,4]]
+
+ //
+ // Override default number of worker threads (set to 2).
+ // Preallocate space to store result, call multithreaded version, test.
+ //
+ // NOTE: this function updates only one triangular part of C. In our
+ // example we choose to update upper triangle.
+ //
+ alglib::setnworkers(+2);
+ c = "[[0,0],[0,0]]";
+ smp_rmatrixsyrk(n, k, alpha, a, ia, ja, optypea, beta, c, ic, jc, isupper);
+ printf("%s\n", c.tostring(3).c_str()); // EXPECTED: [[1,2],[0,4]]
+ return 0;
+}
+
+
+EOF
+
+g++ -I/usr/include -lalglib -o demo demo.cpp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..e5c8d4a
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,2 @@
+Tests: build1 build2 build3 build4 build5
+Depends: libalglib-dev, build-essential
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/alglib.git
More information about the debian-science-commits
mailing list