I am having some problems compiling a UPC code with complex numbers on my laptop (Mac OS-X; code will eventually run on a Linux CentOS machine) . I was trying to use FFTW in the code, but that returned a lot of errors.
#include </Users/avinash/Programs/fftwinstall/include/fftw3.h>
Error during remote HTTP translation:
upcc: error during UPC-to-C translation (sgiupc stage):
In file included from code1xc.upc:9:
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: syntax error before `fftwq_complex'
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: warning: type defaults to `int' in declaration of `fftwq_complex'
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: warning: data definition has no type or storage class
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: syntax error before `fftwq_complex'
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: syntax error before `fftwq_complex'
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: syntax error before `fftwq_complex'
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: syntax error before `fftwq_complex'
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: syntax error before `fftwq_complex'
/Users/avinash/Programs/fftwinstall/include/fftw3.h:373: syntax error before `fftwq_complex'
......
Then I did some google searching and I came across this link – https://hpcrdm.lbl.gov/pipermail/upc-users/2013-December/001758.html
Apparently, BUPC doesn't work with complex numbers on some platforms - http://upc.lbl.gov/docs/user/index.shtml
Programs which #include complex.h, and/or tgmath.h do not work on
certain platforms.
So tried to compile this simple code using complex.h mentioned in the online query and even that returned errors.
#include <upc.h>
#include <complex.h>
int main()
{
return 0;
}
Error during remote HTTP translation:
upcc: error during UPC-to-C translation (sgiupc stage):
In file included from code1xc.upc:7:
/usr/include/complex.h:45: syntax error before `cacosf'
/usr/include/complex.h:46: syntax error before `cacos'
/usr/include/complex.h:47: syntax error before `cacosl'
/usr/include/complex.h:49: syntax error before `casinf'
/usr/include/complex.h:50: syntax error before `casin'
....
So, what exactly am I doing wrong ? I will appreciate any help. Is this an issue only for Berkeley UPC or for GNU UPC as well ? My project requires shared complex arrays. I think there must be a way as FFTs have been mentioned many times in online lectures. Thanks for your help !!
Portable UPC programs do not rely upon C99's complex.h header, because it is not universally supported by all compilers/systems. Instead they often define their own complex type as a two-element struct.
For example see this simple FT implementation
Another common approach is to keep separate arrays of real and imaginary components, depending on the needs of the application and the data layout expected by any client math libraries.
However neither of these is likely to be helpful if you need to complex trigonometry or use a library that relies specifically on C99 complex. Assuming you have a C compiler that supports complex, you could use it to compile a serial module linked to your UPC program. Alternatively you could try the clang UPC frontend, which I believe supports C99 complex on some platforms.