PROJ icon indicating copy to clipboard operation
PROJ copied to clipboard

geodetic 27% faster

Open wblangdon opened this issue 1 year ago • 5 comments

Speed up geodetic(PJ_XYZ cart, PJ *P) 27%

In normal_radius_of_curvature() remove if (es == 0) as unneeded and actually 1.5% slower with it

Add invhypot() so can replace division by multiplication with reciprocal, double precision multiplication is considerably faster than double precision division

Use invhypot() in geocentric_radius() and geodetic()

In geodetic() store result in intermediate variables rather than call a function multiple times.

Passes all 9.3.1 ctest No changes to API Magpie version cart.cpp_29-feb-2024

wblangdon avatar Mar 05 '24 14:03 wblangdon

Use invhypot()

do you have a reference to a standard that defines that function? I can hardly find any reference to it. "grep -r invhypot /usr/include" doesn't get any match on my Ubuntu 20.04, there's no match for it in https://learn.microsoft.com/en-us/search/?scope=C%2B%2B&view=msvc-170&terms=invhypot . So I'm wondering if it is available on all platforms. Perhaps we should have a CMake check for its availability

rouault avatar Mar 05 '24 14:03 rouault

nevermind my above comment about invhypot. I missed it was is defined in your code...

rouault avatar Mar 05 '24 14:03 rouault

quick update: so far I am trying g++ -m32, will restart this afternoon. Hmm stuck on 32bit cmake. It looks like we may be missing a 32 bit system library libstdc++_nonshared.a. Have put a call to our tech support. Tech support say newest redhat/centos GCC does not support 32 bit runtime library. Neil suggests using old version of GCC. I am trying gcc 4.8.5 but now looking for compatible sqlite3 which is 32 bits. In the end could not get cmake here to produce 32 bit version, so have put new code inside conditional compilation so invhypot does not even get compiled if in 32bit mode. Naturally still passes 64bit version of ctest. Now running automated tests...

wblangdon avatar Mar 12 '24 09:03 wblangdon

Magpie version cart.cpp_14-mar-2024 appears to have pass 64bit tests but failed in 32bit mode just like the first version:-( I have the log file, 0_linux_gcc_32bit.txt, is it possible to get more information? Is it possible to see g++ command lines? Is it possible to download .o and .so files? Is it possible to download 'target dist' ? Bill

wblangdon avatar Mar 14 '24 18:03 wblangdon

See PR #4087 for an alternative implementation

rouault avatar Mar 14 '24 20:03 rouault

closing as superseded with now merged PR #4087

rouault avatar Mar 25 '24 21:03 rouault