Problem with making testing_zlange.cpp

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)

Problem with making testing_zlange.cpp

Postby brianborchers » Sun Dec 10, 2017 11:57 pm

Trying to build magma 2.3 this evening, on an Ubuntu 16.04 system with gcc 5.4.0, I encountered the following problem with testing_zlange.cpp in the testing directory

g++ -fPIC -fopenmp -Wl,-rpath,../lib \
-o testing/testing_zlag2c testing/testing_zlag2c.o \
-L./testing -ltest \
-L./lib -lmagma \
-L./testing/lin -llapacktest \
-L/usr/local/cuda/lib64 -L/opt/openblas/lib -lopenblas -lcublas -lcusparse -lcudart -lcudadevrt
g++ -O3 -fPIC -DNDEBUG -DADD_ -Wall -fopenmp -std=c++11 -DHAVE_CUBLAS -DMIN_CUDA_ARCH=600 -I/usr/local/cuda/include -I./include -I./testing -c -o testing/testing_zlange.o testing/testing_zlange.cpp
testing/testing_zlange.cpp: In function ‘int main(int, char**)’:
testing/testing_zlange.cpp:156:61: error: ‘isnan’ was not declared in this scope
bool nan_okay; nan_okay = isnan(norm_magma);
^


Changing "isnan" to "std::isnan" got past this error, only to turn up a similar error with "isinf" Changing "isinf" to "std::isinf" got past that error, but similar problems kept turning up in other files in the testing directory.
brianborchers
 
Posts: 4
Joined: Sun Dec 10, 2017 11:36 pm

Re: Problem with making testing_zlange.cpp

Postby brianborchers » Mon Dec 11, 2017 1:00 am

After using sed to change all occurrences of " isnan(" to " std::isnan(" and similarly for isinf, make completed without further problems. I'm now running the tests, which appear to be producing good results.
brianborchers
 
Posts: 4
Joined: Sun Dec 10, 2017 11:36 pm

Re: Problem with making testing_zlange.cpp

Postby mgates3 » Sat Dec 16, 2017 4:09 pm

Thanks for the note. It's odd since our tests with g++ didn't raise this issue. isnan and isinf have some portability problems between different compilers, so it's not clear that we can just change everything to std::isnan and std::isinf. It will take some testing.

-mark
mgates3
 
Posts: 817
Joined: Fri Jan 06, 2012 2:13 pm

Re: Problem with making testing_zlange.cpp [isinf, isnan]

Postby mgates3 » Sat Dec 16, 2017 7:28 pm

Can you try compiling the attached problems to replicate the issue? These are all combinations of including math.h and cmath, and using isnan or std::isnan. I expect some combinations to fail. Please also report what OS version and compiler version you are using. For instance (note make -j1 -k flags):

Code: Select all
prompt>  g++ --version
g++ (GCC) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.

prompt>  make -j1 -k
g++ -Wall -std=c++11 -c -o isnan_macro_cmath.o isnan_macro_cmath.cpp
isnan_macro_cmath.cpp: In function ‘int main(int, char**)’:
isnan_macro_cmath.cpp:11:23: error: ‘isnan’ was not declared in this scope
     int iz = isnan( z );
                       ^
isnan_macro_cmath.cpp:11:23: note: suggested alternative:
In file included from isnan_macro_cmath.cpp:2:0:
/usr/local/include/c++/6.3.0/cmath:662:5: note:   ‘std::isnan’
     isnan(_Tp __x)
     ^~~~~
make: *** [isnan_macro_cmath.o] Error 1
g++ -Wall -std=c++11 -c -o isnan_macro_cmath_math.o isnan_macro_cmath_math.cpp
g++ -o isnan_macro_cmath_math isnan_macro_cmath_math.o
g++ -Wall -std=c++11 -c -o isnan_macro_math.o isnan_macro_math.cpp
g++ -o isnan_macro_math isnan_macro_math.o
g++ -Wall -std=c++11 -c -o isnan_macro_math_cmath.o isnan_macro_math_cmath.cpp
g++ -o isnan_macro_math_cmath isnan_macro_math_cmath.o
g++ -Wall -std=c++11 -c -o isnan_std_cmath.o isnan_std_cmath.cpp
g++ -o isnan_std_cmath isnan_std_cmath.o
g++ -Wall -std=c++11 -c -o isnan_std_cmath_math.o isnan_std_cmath_math.cpp
g++ -o isnan_std_cmath_math isnan_std_cmath_math.o
g++ -Wall -std=c++11 -c -o isnan_std_math.o isnan_std_math.cpp
g++ -o isnan_std_math isnan_std_math.o
g++ -Wall -std=c++11 -c -o isnan_std_math_cmath.o isnan_std_math_cmath.cpp
g++ -o isnan_std_math_cmath isnan_std_math_cmath.o
gcc -Wall -std=c99 -c -o isnan_macro_math_c.o isnan_macro_math_c.c
g++ -o isnan_macro_math_c isnan_macro_math_c.o
make: Target `all' not remade because of errors.



Here are errors I get with various compilers:

Code: Select all
macOS Sierra 10.12.2
================================================================================
gnu g++ 6.3.0
isnan_macro_cmath.cpp:11:23: error: ‘isnan’ was not declared in this scope
This is unsurprising: cmath defines std::isnan, and isn't required to define plain isnan

clang c++ 8.0.0
isnan_std_math.cpp:11:14: error: use of undeclared identifier 'std'
This is unsurprising: math.h doesn't define std::isnan.


Linux - Scientific Linux release 7.3 (Nitrogen)
================================================================================
g++ 4.8.5
isnan_std_math.cpp:11:19: error: expected unqualified-id before ‘(’ token
Again, unsurprising.

g++ 4.9.4
isnan_std_math.cpp:11:19: error: expected unqualified-id before ‘(’ token
Again, unsurprising.

g++ 5.4.0
isnan_std_math.cpp:11:19: error: expected unqualified-id before ‘(’ token
Again, unsurprising.

g++ 6.2.0, 6.3.0, 7.1.0
no errors

Intel icpc 2016 (16.0.0)
isnan_std_math.cpp       (11): error: expected an identifier
Again, unsurprising.

isnan_std_cmath_math.cpp (11): error: expected an identifier
isnan_std_math_cmath.cpp (11): error: expected an identifier
This is surprising -- cmath is included, but std::isnan is not working. This seems to be the error here:
https://software.intel.com/en-us/forums/intel-c-compiler/topic/638013
(referred to in http://icl.cs.utk.edu/magma/forum/viewtopic.php?f=2&t=1657)

Intel icpc 2017 (17.0.4)
no errors

Intel icpc 2018 (18.0.0)
no errors
Attachments
2017-12-16-isnan.tar.gz
(1.04 KiB) Downloaded 27 times
mgates3
 
Posts: 817
Joined: Fri Jan 06, 2012 2:13 pm

Re: Problem with making testing_zlange.cpp

Postby brianborchers » Sat Dec 16, 2017 11:43 pm

Here are my results. This is on an Ubuntu 16.04.5 (LTS) system with the Ubuntu version of gcc 5.4.0.

tower-5810%>g++ --version

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

tower-5810%>make -j1 -k
g++ -Wall -std=c++11 -c -o isnan_std_cmath_math.o isnan_std_cmath_math.cpp
g++ -o isnan_std_cmath_math isnan_std_cmath_math.o
g++ -Wall -std=c++11 -c -o isnan_macro_math.o isnan_macro_math.cpp
g++ -o isnan_macro_math isnan_macro_math.o
g++ -Wall -std=c++11 -c -o isnan_macro_math_cmath.o isnan_macro_math_cmath.cpp
isnan_macro_math_cmath.cpp: In function 'int main(int, char**)':
isnan_macro_math_cmath.cpp:11:23: error: 'isnan' was not declared in this scope
int iz = isnan( z );
^
isnan_macro_math_cmath.cpp:11:23: note: suggested alternative:
In file included from isnan_macro_math_cmath.cpp:3:0:
/usr/include/c++/5/cmath:641:5: note: 'std::isnan'
isnan(_Tp __x)
^
Makefile:20: recipe for target 'isnan_macro_math_cmath.o' failed
make: *** [isnan_macro_math_cmath.o] Error 1
g++ -Wall -std=c++11 -c -o isnan_std_math.o isnan_std_math.cpp
isnan_std_math.cpp: In function 'int main(int, char**)':
isnan_std_math.cpp:11:14: error: '__builtin_isnan' is not a member of 'std'
int iz = std::isnan( z );
^
isnan_std_math.cpp:11:14: note: suggested alternative:
<built-in>: note: '__builtin_isnan'
Makefile:20: recipe for target 'isnan_std_math.o' failed
make: *** [isnan_std_math.o] Error 1
g++ -Wall -std=c++11 -c -o isnan_macro_cmath.o isnan_macro_cmath.cpp
isnan_macro_cmath.cpp: In function 'int main(int, char**)':
isnan_macro_cmath.cpp:11:23: error: 'isnan' was not declared in this scope
int iz = isnan( z );
^
isnan_macro_cmath.cpp:11:23: note: suggested alternative:
In file included from isnan_macro_cmath.cpp:2:0:
/usr/include/c++/5/cmath:641:5: note: 'std::isnan'
isnan(_Tp __x)
^
Makefile:20: recipe for target 'isnan_macro_cmath.o' failed
make: *** [isnan_macro_cmath.o] Error 1
g++ -Wall -std=c++11 -c -o isnan_std_cmath.o isnan_std_cmath.cpp
g++ -o isnan_std_cmath isnan_std_cmath.o
g++ -Wall -std=c++11 -c -o isnan_macro_cmath_math.o isnan_macro_cmath_math.cpp
isnan_macro_cmath_math.cpp: In function 'int main(int, char**)':
isnan_macro_cmath_math.cpp:11:23: error: 'isnan' was not declared in this scope
int iz = isnan( z );
^
isnan_macro_cmath_math.cpp:11:23: note: suggested alternative:
In file included from isnan_macro_cmath_math.cpp:2:0:
/usr/include/c++/5/cmath:641:5: note: 'std::isnan'
isnan(_Tp __x)
^
Makefile:20: recipe for target 'isnan_macro_cmath_math.o' failed
make: *** [isnan_macro_cmath_math.o] Error 1
g++ -Wall -std=c++11 -c -o isnan_std_math_cmath.o isnan_std_math_cmath.cpp
g++ -o isnan_std_math_cmath isnan_std_math_cmath.o
gcc -Wall -std=c99 -c -o isnan_macro_math_c.o isnan_macro_math_c.c
g++ -o isnan_macro_math_c isnan_macro_math_c.o
make: Target 'all' not remade because of errors.
brianborchers
 
Posts: 4
Joined: Sun Dec 10, 2017 11:36 pm

Re: Problem with making testing_zlange.cpp

Postby diogo4u » Sun Dec 17, 2017 11:03 am

I noticed something that might be related to this problem: magma_types.h includes <complex>, and <complex> includes <cmath> (at least in my gcc 5.4.0). The moment <cmath> is included, it undefines the C99 macros (isnan, isinf, etc.) and defines them as functions inside the std namespace.
diogo4u
 
Posts: 1
Joined: Sat Dec 16, 2017 7:47 am

Re: Problem with making testing_zlange.cpp

Postby mgates3 » Sun Dec 17, 2017 2:48 pm

magma_types.h includes <complex> only if HAVE_CUDA is not defined, and HAVE_MIC is defined -- i.e., only for the Xeon Phi version (MAGMAmic).

However, testing/magma_lapack.hpp includes <complex>. So that's why it is failing in testing, but not when compiling the MAGMA library per se.

Diogo Ferreira's pull request should fix it.
https://bitbucket.org/icl/magma/pull-re ... n-std/diff
However, that may break compilation on other systems. More testing will be required, so a final fix may take a while.

-mark
mgates3
 
Posts: 817
Joined: Fri Jan 06, 2012 2:13 pm

Re: Problem with making testing_zlange.cpp

Postby mgates3 » Tue Apr 17, 2018 2:23 pm

This should be fixed now (in Bitbucket). Let us know if there are still issues. (I actually can't replicate the problem with our compilers; it seems dependent on the version of the compiler and C++ headers.)
-mark
mgates3
 
Posts: 817
Joined: Fri Jan 06, 2012 2:13 pm


Return to User discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron