Debian Codegraph @

debian/tests/build1

raw
1 #!/bin/sh
2 # autopkgtest check: Build and run a program against alglib
3 # (C) 2013 Thomas Moulard
4 # (C) 2014 Anton Gladky
5 # Author: Thomas Moulard <[email protected]>
6 # Anton Gladky <[email protected]>
7
8 set -e
9
10 WORKDIR=$(mktemp -d)
11 echo $WORKDIR
12 trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
13 cd $WORKDIR
14 mkdir src
15 cd src
16
17 cat <<EOF > CMakeLists.txt
18 cmake_minimum_required(VERSION 3.18)
19 project(demo)
20 find_package(ALGLIB REQUIRED)
21 include_directories(\${ALGLIB_INCLUDE_DIRS})
22
23 add_executable(demo demo.cpp)
24 target_link_libraries(demo \${ALGLIB_LIB})
25 install(TARGETS demo DESTINATION bin)
26
27 EOF
28
29 cat <<EOF > demo.cpp
30 #include <stdio.h>
31 #include "linalg.h"
32
33 int main()
34 {
35 alglib::real_2d_array a, b, c;
36 int n = 2000;
37 int i, j;
38 double timeneeded, flops;
39
40 // Initialize arrays
41 a.setlength(n, n);
42 b.setlength(n, n);
43 c.setlength(n, n);
44 for(i=0; i<n; i++)
45 for(j=0; j<n; j++)
46 {
47 a[i][j] = alglib::randomreal()-0.5;
48 b[i][j] = alglib::randomreal()-0.5;
49 c[i][j] = 0.0;
50 }
51
52 // Set number of worker threads: "4" means "use 4 cores".
53 // This line is ignored if AE_OS is UNDEFINED.
54 alglib::setnworkers(4);
55
56 // Perform matrix-matrix product.
57 // We call function with "smp_" prefix, which means that ALGLIB
58 // will try to execute it in parallel manner whenever it is possible.
59 flops = 2*pow((double)n, (double)3);
60 alglib::rmatrixgemm(
61 n, n, n,
62 1.0,
63 a, 0, 0, 0,
64 b, 0, 0, 1,
65 0.0,
66 c, 0, 0);
67
68 return 0;
69 }
70
71 EOF
72
73 cd ..
74 mkdir build
75 cd build
76 cmake -DCMAKE_INSTALL_PREFIX=./../inst ./../src
77 make
78 make install
79 echo "build: OK"
80 [ -x demo ]
81 ./demo
82 echo "run: OK"