[petsc-dev] [petsc-maint #129715] __float128 complex

Jose E. Roman jroman at dsic.upv.es
Thu Aug 23 11:02:19 CDT 2012


El 22/08/2012, a las 18:52, Jose E. Roman escribió:

> f2cblaslapack is more or less prepared for this case already (it is not much tested though, we will make some tests for the w* subroutines tomorrow).
> 
> What is not ready is PETSc itself. Some definitions are missing. For instance, PetscScalar is undefined, so one should add the following to petscmath.h:106:
> 
> #elif defined(PETSC_USE_REAL___FLOAT128)
> typedef __complex128 PetscScalar;
> 
> #define PetscRealPart(a)      crealq(a)
> #define PetscImaginaryPart(a) cimagq(a)
> #define PetscAbsScalar(a)     cabsq(a)
> #define PetscConj(a)          conjq(a)
> #define PetscSqrtScalar(a)    csqrtq(a)
> #define PetscPowScalar(a,b)   cpowq(a,b)
> #define PetscExpScalar(a)     cexpq(a)
> #define PetscLogScalar(a)     clogq(a)
> #define PetscSinScalar(a)     csinq(a)
> #define PetscCosScalar(a)     ccosq(a)
> 
> Similarly, MPIU_SCALAR should be defined. Maybe other as well.
> 
> Jose

I have pushed a change to petsc-dev that allows to configure --with-precision=__float128 --with-scalar-type=complex

I have tested this with src/ksp/ksp/examples/tutorials/ex12.c with 1 and 2 processes. It seems to work.

Please review the change, since I had to modify pinit.c

A couple of comments:

1) The f2cblaslapack interface to quad precision subroutines (q* and w*) is defined only in the case of "uscore" mangling. Maybe a test in configure should assure this.

2) I could not make it work --with-clanguage=c++ - I get compilation errors like this. Any idea?

/usr/include/c++/4.6/complex: In function ‘_Tp std::__complex_abs(const std::complex<_Tp>&) [with _Tp = __float128]’:
/usr/include/c++/4.6/complex:592:68:   instantiated from ‘_Tp std::abs(const std::complex<_Tp>&) [with _Tp = __float128]’
/home/jroman/soft/petsc-dev/src/sys/utils/sortd.c:116:26:   instantiated from here
/usr/include/c++/4.6/complex:571:50: error: call of overloaded ‘abs(__float128&)’ is ambiguous
/usr/include/c++/4.6/complex:571:50: note: candidates are:
/usr/include/c++/4.6/cmath:82:3: note: double std::abs(double)
/usr/include/c++/4.6/cmath:86:3: note: float std::abs(float)
/usr/include/c++/4.6/cmath:90:3: note: long double std::abs(long double)
/usr/include/c++/4.6/complex:571:50: error: call of overloaded ‘abs(__float128&)’ is ambiguous
/usr/include/c++/4.6/complex:571:50: note: candidates are:
/usr/include/c++/4.6/cmath:82:3: note: double std::abs(double)
/usr/include/c++/4.6/cmath:86:3: note: float std::abs(float)
/usr/include/c++/4.6/cmath:90:3: note: long double std::abs(long double)
/usr/include/c++/4.6/complex:576:46: error: call of overloaded ‘sqrt(__float128)’ is ambiguous
/usr/include/c++/4.6/complex:576:46: note: candidates are:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:158:1: note: double sqrt(double)
/usr/include/c++/4.6/cmath:416:3: note: float std::sqrt(float)
/usr/include/c++/4.6/cmath:420:3: note: long double std::sqrt(long double)






More information about the petsc-dev mailing list