Skip to content

Commit

Permalink
correct undefined symbol checking in testlddlink in configure. Make p…
Browse files Browse the repository at this point in the history
…ython tests exist with an error code if the ydont pass so travis build fails
  • Loading branch information
solomonik committed Jan 10, 2018
1 parent 217f773 commit 046b9da
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 25 deletions.
55 changes: 30 additions & 25 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ EOF
}

#Usage: 'testldlink $1 $2 $3' for checking symbol with dynamic library where
# $1 - library link line
# $2 - symbol (function)
# $3 - 0 if no printouts, 1 if verbose
# $1 - shared library link path
# $2 - shared library libs
# $3 - symbol (function)
# $4 - 0 if no printouts, 1 if verbose
function testldlink
{
rm -f a.out
Expand All @@ -98,29 +99,33 @@ function testldlink
#if __cplusplus
extern "C"
#endif
void $2();
void func(){ $2(); }
void $3();
void func(){ $3(); }
int main(){ return 0; }
EOF
TMP_LD_LIB_PATH=${1//"-L"/"-Wl,-rpath="}
TMP_LD_LIB_PATH="$1 $TMP_LD_LIB_PATH"
if [ $3 -eq 1 ]; then
( set -x; $CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $TMP_LD_LIB_PATH $LDFLAGS 2>&1 )
TMP_LD_LIBS="$2"
if [ $4 -eq 1 ]; then
( set -x; $CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $TMP_LD_LIB_PATH $TMP_LD_LIBS $LDFLAGS 2>&1 )
else
$CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $TMP_LD_LIB_PATH $LDFLAGS > /dev/null 2>&1
$CXX $DEFS $WARNFLAGS $CXXFLAGS $INCLUDES .test.cxx $TMP_LD_LIB_PATH $TMP_LD_LIBS $LDFLAGS > /dev/null 2>&1
fi
if [ -x a.out ]; then
status=0
if [ $3 -eq 1 ]; then
( set -x; LD_LIBRARY_PATH="$LD_LIB_PATH:$LD_LIBRARY_PATH" ./a.out 2>&1 )
TMP_RAW_LD_LIB_PATH=${TMP_LD_LIB_PATH//" -L"/":"}
TMP_RAW_LD_LIB_PATH=${RAW_LD_LIB_PATH//"-L"/""}
TMP_RAW_LD_LIB_PATH=${RAW_LD_LIB_PATH//" "/""}
if [ $4 -eq 1 ]; then
( set -x; LD_LIBRARY_PATH="$TMP_RAW_LD_LIB_PATH:$LD_LIBRARY_PATH" ./a.out 2>&1 )
else
LD_LIBRARY_PATH="$LD_LIB_PATH:$LD_LIBRARY_PATH" ./a.out > /dev/null 2>&1
LD_LIBRARY_PATH="$TMP_RAW_LD_LIB_PATH:$LD_LIBRARY_PATH" ./a.out > /dev/null 2>&1
fi
if [ $? -eq 0 ]; then
UDEFSYMB=$(nm ./a.out | grep -c "U $2")
if [ "x$UDEFSYMB" = "x" ]; then
UDEFSYMB=$(nm ./a.out | grep "$3" | grep -c "U")
if [ $UDEFSYMB -eq 0 ]; then
status=1
if [ $3 -eq 1 ]; then
if [ $4 -eq 1 ]; then
echo "Undefined symbol not found, so we did not really link to dynamic library (but rather static)"
( set -x; nm ./a.out; )
fi
Expand Down Expand Up @@ -741,11 +746,11 @@ if [ $WITH_STATIC = 1 ]; then
fi
if [ $WITH_DYNAMIC = 1 ]; then
echo -n 'Checking for dynamic BLAS library... '
if testldlink "$LD_LIB_PATH $LD_LIBS" dgemm_ 0; then
if testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm_ 0; then
UNDERSCORE=1
echo 'dynamic BLAS library found, with underscores.'
else
if testldlink "$LD_LIB_PATH $LD_LIBS" dgemm 0; then
if testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm 0; then
UNDERSCORE= 0
echo 'dynamic BLAS library found, without underscores.'
else
Expand All @@ -755,19 +760,19 @@ if [ $WITH_DYNAMIC = 1 ]; then
LD_LIBS="$LD_LIBS -mkl"
DEFS="$DEFS -DUSE_MKL=1"
SPMKL_COMMENT=""
elif testldlink "$LD_LIB_PATH -Wl,-Bdynamic -lblas $LD_LIBS" dgemm_ 0; then
elif testldlink "$LD_LIB_PATH -Wl,-Bdynamic -lblas" "$LD_LIBS" dgemm_ 0; then
UNDERSCORE=1
echo 'detected that -Wl,-Bdynamic -lblas works, speculatively using -Wl,-Bdynamic -lblas (with underscores).'
LD_LIBS="$LD_LIBS -Wl,-Bdynamic -lblas"
elif testldlink "$LD_LIB_PATH -Wl,-Bdynamic -lblas $LD_LIBS" dgemm 0; then
elif testldlink "$LD_LIB_PATH -Wl,-Bdynamic -lblas" "$LD_LIBS" dgemm 0; then
UNDERSCORE=0
echo 'detected that -Wl,-Bdynamic -lblas works, speculatively using -Wl,-Bdynamic -lblas (without underscores).'
LD_LIBS="$LD_LIBS -Wl,-Bdynamic -lblas"
else
UNDERSCORE=1
echo
echo ' WARNING: dynamic BLAS libirary did not work, python executables will not run (error below),'
testldlink "$LD_LIB_PATH $LD_LIBS" dgemm_ 1
testldlink "$LD_LIB_PATH" "$LD_LIBS" dgemm_ 1
echo ' please specify correct LD_LIB_PATH and LD_LIBS (run ./configure --help to see all options),'
echo ' CTF library can still build (via make), but executables will not!'
echo
Expand Down Expand Up @@ -832,13 +837,13 @@ if [ $WITH_STATIC = 1 ]; then
fi
if [ $WITH_DYNAMIC = 1 ]; then
echo -n 'Checking for dynamic LAPACK library... '
if testldlink "$LD_LIB_PATH $LD_LIBS" $DGEQRF 0; then
if testldlink "$LD_LIB_PATH" "$LD_LIBS" $DGEQRF 0; then
echo 'dynamic LAPACK found.'
if [ $USING_LAPACK = 0 ]; then
DEFS="$DEFS -DUSE_LAPACK"
fi
else
if testldlink "$LD_LIB_PATH -Wl,-Bdynamic -llapack $LD_LIBS" $DGEQRF 0; then
if testldlink "$LD_LIB_PATH -Wl,-Bdynamic -llapack" "$LD_LIBS" $DGEQRF 0; then
echo 'dynamic LAPACK library found (-Wl,-Bdynamic -llapack).'
LD_LIBS="$LD_LIBS -Wl,-Bdynamic -llapack"
if [ $USING_LAPACK = 0 ]; then
Expand All @@ -849,7 +854,7 @@ if [ $WITH_DYNAMIC = 1 ]; then
echo ' LAPACK not found, will build with LAPACK-dependent functionality anyway, since --with-lapackwas specified.'
echo ' WARNING: you may not be able to build CTF tests and benchmarks in this configuration (but you can build the library and use in conjunction with a lapack library)'
echo ' WARNING: executables will not build until you provide a BLAS library (error below),'
testldlink "$LD_LIB_PATH $LD_LIBS" $DGEQRF 1
testldlink "$LD_LIB_PATH" "$LD_LIBS" $DGEQRF 1
echo ' please specify correct LD_LIB_PATH and LD_LIBS (run ./configure --help to see all options),'
echo ' CTF library can still build (via make), but executables will not!'
if [ $USING_LAPACK = 0 ]; then
Expand Down Expand Up @@ -946,13 +951,13 @@ fi

if [ $WITH_DYNAMIC = 1 ]; then
echo -n 'Checking for dynamic ScaLAPACK... '
if testldlink "$LD_LIB_PATH $LD_LIBS" $PDGEMM 0; then
if testldlink "$LD_LIB_PATH" "$LD_LIBS" $PDGEMM 0; then
echo 'dynamic SCALAPACK found.'
if [ $USING_SCALA = 0 ]; then
DEFS="$DEFS -DUSE_SCALAPACK"
fi
else
if testldlink "$LD_LIB_PATH -Wl,-Bdynamic -lscalapack $LD_LIBS" $PDGEMM 0; then
if testldlink "$LD_LIB_PATH -Wl,-Bdynamic -lscalapack" "$LD_LIBS" $PDGEMM 0; then
echo 'SCALAPACK library found (-Wl,-Bdynamic -lscalapack).'
LD_LIBS="-Wl,-Bdynamic -lscalapack $LD_LIBS"
if [ $USING_SCALA = 0 ]; then
Expand All @@ -963,7 +968,7 @@ if [ $WITH_DYNAMIC = 1 ]; then
echo ' dynamic ScaLAPACK not found, will build with ScaLAPACK-dependent functionality anyway, since --with-scalapack was specified.'
echo ' WARNING: you may not be able to build ctf tests and benchmarks in this configuration (but you can build the library and use in conjunction with a scalapack library)'
echo ' WARNING: executables will not build until you provide a scalapack library (error below),'
testldlink "$LD_LIB_PATH -lscalapack $LD_LIBS" $PDGEMM 1
testldlink "$LD_LIB_PATH" "$LD_LIBS" $PDGEMM 1
echo ' please specify correct LD_LIB_PATH and LD_LIBS (run ./configure --help to see all options),'
echo ' CTF library can still build (via make), but executables will not!'
if [ $USING_SCALA = 0 ]; then
Expand Down
2 changes: 2 additions & 0 deletions test/python/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy
import ctf
import os
import sys


class KnowValues(unittest.TestCase):
Expand Down Expand Up @@ -337,3 +338,4 @@ def test_hstack(self):
print("Tests for basic numpy ndarray functionality")
result = unittest.TextTestRunner().run(unittest.TestSuite(unittest.TestLoader().loadTestsFromTestCase(KnowValues)))
ctf.MPI_Stop()
sys.exit(not result)
2 changes: 2 additions & 0 deletions test/python/test_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy
import ctf
import os
import sys


def allclose(a, b):
Expand Down Expand Up @@ -50,3 +51,4 @@ def test_tensordot(self):
print("Tests for dot")
result = unittest.TextTestRunner().run(unittest.TestSuite(unittest.TestLoader().loadTestsFromTestCase(KnowValues)))
ctf.MPI_Stop()
sys.exit(not result)
2 changes: 2 additions & 0 deletions test/python/test_einsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy
import ctf
import os
import sys

def allclose(a, b):
if abs(ctf.to_nparray(a) - ctf.to_nparray(b)).sum() > 1e-10:
Expand Down Expand Up @@ -135,4 +136,5 @@ def test_einsum_mix_types(self):
print("Tests for einsum")
result = unittest.TextTestRunner().run(unittest.TestSuite(unittest.TestLoader().loadTestsFromTestCase(KnowValues)))
ctf.MPI_Stop()
sys.exit(not result)

2 changes: 2 additions & 0 deletions test/python/test_fancyindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ctf
import ctf.random
import os
import sys

def allclose(a, b):
return abs(ctf.to_nparray(a) - ctf.to_nparray(b)).sum() < 1e-14
Expand Down Expand Up @@ -293,4 +294,5 @@ def test_noslice_sym_3d(self):
print("Tests for fancy index")
result = unittest.TextTestRunner().run(unittest.TestSuite(unittest.TestLoader().loadTestsFromTestCase(KnowValues)))
ctf.MPI_Stop()
sys.exit(not result)

2 changes: 2 additions & 0 deletions test/python/test_svd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import ctf
import sys

from ctf import random

Expand All @@ -23,4 +24,5 @@
print("failure, norm is ", err_nrm)

ctf.MPI_Stop()
sys.exit(not success)

2 changes: 2 additions & 0 deletions test/python/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy
import ctf
import os
import sys


def allclose(a, b):
Expand Down Expand Up @@ -234,4 +235,5 @@ def test_get_item(self):
print("Tests for univeral functions")
result = unittest.TextTestRunner().run(unittest.TestSuite(unittest.TestLoader().loadTestsFromTestCase(KnowValues)))
ctf.MPI_Stop()
sys.exit(not result)

0 comments on commit 046b9da

Please sign in to comment.