HPAC / TTC

TTC: A high-performance Compiler for Tensor Transpositions
GNU General Public License v3.0
20 stars 0 forks source link

tmp/util.cpp(16): error: identifier "creal" is undefined #4

Open jeffhammond opened 8 years ago

jeffhammond commented 8 years ago

From what I can tell, you are using C99's creal in C++ code. I see this issue observed on Stackoverflow but have not figured out how to solve it yet.

TTC-github jrhammon$ ./scripts/ttc --perm=1,0,2 --size=1000,768,16 --dataType=d --alpha=1.0 --beta=1.0 --numThreads=120 --architecture=avx -v
WARNING: you did not specify an thread affinity. We are using: KMP_AFFINITY=compact,1 by default
--------------Settings---------------------
#threads:           120
thread affinity:    KMP_AFFINITY=compact,1
Compiler:           icpc (ICC) 16.0.2 20160204
-------------------------------------------
[generate] Generate all versions
Generation of 97 implementations took 0.049422 seconds        
[make] Compile all versions
/Applications/Xcode.app/Contents/Developer/usr/bin/make clean 
rm -rf tmp/*.o transpose.exe
/Applications/Xcode.app/Contents/Developer/usr/bin/make intel2
icpc -O3  -qopenmp -xhost  -c tmp/main.cpp -o tmp/main.o
icpc -O3  -qopenmp -xhost  -c tmp/measure0.cpp -o tmp/measure0.o
icpc -O3  -qopenmp -xhost  -c tmp/measure1.cpp -o tmp/measure1.o
icpc -O3  -qopenmp -xhost  -c tmp/transpose.cpp -o tmp/transpose.o
icpc -O3  -qopenmp -xhost  -c tmp/transpose0.cpp -o tmp/transpose0.o
icpc -O3  -qopenmp -xhost  -c tmp/transpose1.cpp -o tmp/transpose1.o
icpc -O3  -qopenmp -xhost  -c tmp/util.cpp -o tmp/util.o
tmp/util.cpp(16): error: identifier "creal" is undefined
           printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                  ^

tmp/util.cpp(16): error: identifier "cimag" is undefined
           printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                                             ^

compilation aborted for tmp/util.cpp (code 2)
make[1]: *** [tmp/util.o] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [icpc] Error 2
[TTC] [Error] compilation failed. Retry with '-v' option to see the compilation errors.
jeffhammond commented 8 years ago

This may be relevant:

TTC-github jrhammon$ icpc -v
icpc version 16.0.2 (gcc version 4.9.0 compatibility)
jeffhammond commented 8 years ago

You might need to use C's _Complex instead of the macro complex, since that confuses C++. Source

springer13 commented 8 years ago

I've added a quick bug fix. Please try again. I will look into _Complex vs complex if the problem should still exist.

jeffhammond commented 8 years ago

Change does not help. It happens with both Intel and Clang though, so it could be a Mac-specific issue.

ttc jrhammon$ clang++ -c tmp/util.cpp -o tmp/util.o
tmp/util.cpp:7:33: error: use of undeclared identifier 'creal'
         printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                ^
tmp/util.cpp:7:60: error: use of undeclared identifier 'cimag'
         printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                                           ^
2 errors generated.
ttc jrhammon$ icpc -c tmp/util.cpp -o tmp/util.o
tmp/util.cpp(7): error: identifier "creal" is undefined
           printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                  ^

tmp/util.cpp(7): error: identifier "cimag" is undefined
           printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                                             ^

compilation aborted for tmp/util.cpp (code 2)

The source that reproduces this is quite simple:

#include <cstdio> // or stdio.h
#include <ccomplex> // or complex.h

void printMatrix2Dcomplex(const double *A, int *size){
   for(int i=0;i < size[0]; ++i){
      for(int j=0;j < size[1]; ++j){
         printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
      }
   }
}
jeffhammond commented 8 years ago

I posted a question on StackOverflow: http://stackoverflow.com/questions/36747506/identifier-creal-is-undefined-seen-on-mac-but-not-on-linux

springer13 commented 8 years ago

are you sure that you installed the updates as well (i.e., "python setup.py install --user")? There should not be any call to creal in the generated code anymore.

The example that you mentioned is compiling on our linux system with icpc 16.0.1

jeffhammond commented 8 years ago

I did not do that. Sorry.

It is a different issue, but python setup.py install --user does not work for me. I have been doing python setup.py build.

jeffhammond commented 8 years ago

This is my current status:

awillard-mobl4:TTC-github jrhammon$ git pull
Already up-to-date.
awillard-mobl4:TTC-github jrhammon$ git clean -dfx
Removing build/
Removing log.txt
Removing ttc/log.txt
Removing ttc/tmp/
Removing ttc/ttc.db
awillard-mobl4:TTC-github jrhammon$ python setup.py build
running build
running build_py
creating build
creating build/lib
creating build/lib/ttc
copying ttc/__init__.py -> build/lib/ttc
copying ttc/CUDAtranspose.py -> build/lib/ttc
copying ttc/generatePlots.py -> build/lib/ttc
copying ttc/GPUreference.py -> build/lib/ttc
copying ttc/GPUtransposeGenerator.py -> build/lib/ttc
copying ttc/sql_util.py -> build/lib/ttc
copying ttc/transpose.py -> build/lib/ttc
copying ttc/transposeGenerator.py -> build/lib/ttc
copying ttc/ttc.py -> build/lib/ttc
copying ttc/ttc_util.py -> build/lib/ttc
creating build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_16x16_float_avx512.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_16x16_float_knc.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_2x2_complex_power.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_2x2_doubleComplex_avx.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_2x2_doubleComplex_power.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_4x4_complex_avx.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_4x4_double_avx.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_4x4_double_power.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_4x4_float_power.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_8x8_float_avx.kernel -> build/lib/ttc/micro-kernels
copying ttc/Makefile -> build/lib/ttc
running build_scripts
creating build/scripts-2.7
copying and adjusting scripts/ttc -> build/scripts-2.7
changing mode of build/scripts-2.7/ttc from 644 to 755

##############################################################################################
# IMPORTANT: execute 'export TTC_ROOT=/Users/jrhammon/Work/LinearAlgebra/TENSORS/TTC-github' #
##############################################################################################

awillard-mobl4:TTC-github jrhammon$ export TTC_ROOT=/Users/jrhammon/Work/LinearAlgebra/TENSORS/TTC-github
awillard-mobl4:TTC-github jrhammon$ ./scripts/ttc --perm=1,0,2 --size=1000,768,16 --dataType=d --alpha=1.0 --beta=1.0 --numThreads=120 --architecture=avx -v
WARNING: you did not specify an thread affinity. We are using: KMP_AFFINITY=compact,1 by default
--------------Settings---------------------
#threads:           120
thread affinity:    KMP_AFFINITY=compact,1
Compiler:           icpc (ICC) 16.0.2 20160204
-------------------------------------------
[generate] Generate all versions
Generation of 97 implementations took 0.047930 seconds        
[make] Compile all versions
/Applications/Xcode.app/Contents/Developer/usr/bin/make clean 
rm -rf tmp/*.o transpose.exe
/Applications/Xcode.app/Contents/Developer/usr/bin/make intel2
icpc -O3  -std=c++11 -qopenmp -xhost  -c tmp/main.cpp -o tmp/main.o
icpc -O3  -std=c++11 -qopenmp -xhost  -c tmp/measure0.cpp -o tmp/measure0.o
icpc -O3  -std=c++11 -qopenmp -xhost  -c tmp/measure1.cpp -o tmp/measure1.o
icpc -O3  -std=c++11 -qopenmp -xhost  -c tmp/transpose.cpp -o tmp/transpose.o
icpc -O3  -std=c++11 -qopenmp -xhost  -c tmp/transpose0.cpp -o tmp/transpose0.o
icpc -O3  -std=c++11 -qopenmp -xhost  -c tmp/transpose1.cpp -o tmp/transpose1.o
icpc -O3  -std=c++11 -qopenmp -xhost  -c tmp/util.cpp -o tmp/util.o
tmp/util.cpp(16): error: identifier "creal" is undefined
           printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                  ^

tmp/util.cpp(16): error: identifier "cimag" is undefined
           printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                                             ^

compilation aborted for tmp/util.cpp (code 2)
make[1]: *** [tmp/util.o] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [icpc] Error 2
[TTC] [Error] compilation failed. Retry with '-v' option to see the compilation errors.
springer13 commented 8 years ago

this needs to be an issue related to the build/installation process because util.cpp should not have any calls to creal any more (compare https://github.com/HPAC/TTC/blob/master/ttc/transposeGenerator.py line 384). On my system util.cpp indeed does not have any creal calls any more.

I would guess that TTC is including an old version of transposeGenerator.py from some other location.

jeffhammond commented 8 years ago

I'm really confused, because I nuked the entire directory and started over, yet the same issue appeared. This happened twice.

I can only assume TTC is getting something from outside the directory tree. Do you know where?

jrhammon-mac01:TENSORS jrhammon$ rm -rf TTC-github/
jrhammon-mac01:TENSORS jrhammon$ git clone https://github.com/HPAC/TTC.git TTC-github
Cloning into 'TTC-github'...
remote: Counting objects: 250, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 250 (delta 1), reused 0 (delta 0), pack-reused 241
Receiving objects: 100% (250/250), 246.53 KiB | 0 bytes/s, done.
Resolving deltas: 100% (158/158), done.
Checking connectivity... done.
jrhammon-mac01:TENSORS jrhammon$ cd TTC-github/
(reverse-i-search)`build': ll build/
jrhammon-mac01:TTC-github jrhammon$ python setup.py build
running build
running build_py
creating build
creating build/lib
creating build/lib/ttc
copying ttc/__init__.py -> build/lib/ttc
copying ttc/CUDAtranspose.py -> build/lib/ttc
copying ttc/generatePlots.py -> build/lib/ttc
copying ttc/GPUreference.py -> build/lib/ttc
copying ttc/GPUtransposeGenerator.py -> build/lib/ttc
copying ttc/sql_util.py -> build/lib/ttc
copying ttc/transpose.py -> build/lib/ttc
copying ttc/transposeGenerator.py -> build/lib/ttc
copying ttc/ttc.py -> build/lib/ttc
copying ttc/ttc_util.py -> build/lib/ttc
creating build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_16x16_float_avx512.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_16x16_float_knc.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_2x2_complex_power.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_2x2_doubleComplex_avx.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_2x2_doubleComplex_power.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_4x4_complex_avx.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_4x4_double_avx.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_4x4_double_power.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_4x4_float_power.kernel -> build/lib/ttc/micro-kernels
copying ttc/micro-kernels/transpose_8x8_float_avx.kernel -> build/lib/ttc/micro-kernels
copying ttc/Makefile -> build/lib/ttc
running build_scripts
creating build/scripts-2.7
copying and adjusting scripts/ttc -> build/scripts-2.7
changing mode of build/scripts-2.7/ttc from 644 to 755

##############################################################################################
# IMPORTANT: execute 'export TTC_ROOT=/Users/jrhammon/Work/LinearAlgebra/TENSORS/TTC-github' #
##############################################################################################

jrhammon-mac01:TTC-github jrhammon$ export TTC_ROOT=/Users/jrhammon/Work/LinearAlgebra/TENSORS/TTC-github
jrhammon-mac01:TTC-github jrhammon$ ./scripts/ttc --perm=1,0,2 --size=1000,768,16 --dataType=d --alpha=1.0 --beta=1.0 --numThreads=120 --architecture=avx -v
WARNING: you did not specify an thread affinity. We are using: KMP_AFFINITY=compact,1 by default
--------------Settings---------------------
#threads:           120
thread affinity:    KMP_AFFINITY=compact,1
Compiler:           icpc (ICC) 16.0.2 20160204
-------------------------------------------
[generate] Generate all versions
Generation of 97 implementations took 0.053661 seconds        
[make] Compile all versions
/Applications/Xcode.app/Contents/Developer/usr/bin/make clean 
rm -rf tmp/*.o transpose.exe
/Applications/Xcode.app/Contents/Developer/usr/bin/make intel2
icpc -O3  -openmp -xhost  -c tmp/main.cpp -o tmp/main.o
icpc -O3  -openmp -xhost  -c tmp/measure0.cpp -o tmp/measure0.o
icpc: command line remark #10411: option '-openmp' is deprecated and will be removed in a future release. Please use the replacement option '-qopenmp'
icpc: command line remark #10411: option '-openmp' is deprecated and will be removed in a future release. Please use the replacement option '-qopenmp'
icpc -O3  -openmp -xhost  -c tmp/measure1.cpp -o tmp/measure1.o
icpc: command line remark #10411: option '-openmp' is deprecated and will be removed in a future release. Please use the replacement option '-qopenmp'
icpc -O3  -openmp -xhost  -c tmp/transpose.cpp -o tmp/transpose.o
icpc: command line remark #10411: option '-openmp' is deprecated and will be removed in a future release. Please use the replacement option '-qopenmp'
icpc -O3  -openmp -xhost  -c tmp/transpose0.cpp -o tmp/transpose0.o
icpc: command line remark #10411: option '-openmp' is deprecated and will be removed in a future release. Please use the replacement option '-qopenmp'
icpc -O3  -openmp -xhost  -c tmp/transpose1.cpp -o tmp/transpose1.o
icpc: command line remark #10411: option '-openmp' is deprecated and will be removed in a future release. Please use the replacement option '-qopenmp'
icpc -O3  -openmp -xhost  -c tmp/util.cpp -o tmp/util.o
icpc: command line remark #10411: option '-openmp' is deprecated and will be removed in a future release. Please use the replacement option '-qopenmp'
tmp/util.cpp(16): error: identifier "creal" is undefined
           printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                  ^

tmp/util.cpp(16): error: identifier "cimag" is undefined
           printf("(%.2e,%.2e) ", creal(A[i + j * size[0]]), cimag(A[i + j * size[0]]));
                                                             ^

compilation aborted for tmp/util.cpp (code 2)
make[1]: *** [tmp/util.o] Error 2
make: *** [icpc] Error 2
[TTC] [Error] compilation failed. Retry with '-v' option to see the compilation errors.
jeffhammond commented 8 years ago

Ok, I found it. Need to resolve my issues with install.

springer13 commented 8 years ago

is it possible that you used "python setup.py install --user" or "python setup.py install" before? In that case TTC will be installed in the directory of your python folder (for me this would be /usr/local/lib/python2.7/site-packages/ttc/). You might have to delte the files there first.

jeffhammond commented 8 years ago

Yeah, that's what happened. I purged the files but I guess I need to install again. Is there any way to install without modifying files outside of my directory tree?