[Developers] ifndef in DXYDG_guts.h

Erik Schnetter schnetter at cct.lsu.edu
Wed Mar 14 08:20:01 CST 2007


On Mar 13, 2007, at 18:05:01, jtao at cct.lsu.edu wrote:

> I don't know if this was considered as a bug and has been fixed
> in the development version of CactusEinstein. I saw the following
> statments in DXYDG_guts.h,
>
> #ifndef DXYDG_GUTS
> #define DXYDG_DECLARE
>
> Where DXYDG_GUTS is never defined anywere.

This is clearly an error.  Luckily a harmless one; code won't be  
skipped but only duplicated, which can at most result in errors,  
given how the code is structured.  Thanks!

> I am also concerned about the usage of the spatial order
> parameter in the loops. Shouldn't it be better to define the
> order of spatial derivatives with a macro and keep the same
> interface for all the derivatives ? Conditional statments
> will not appear in the loops and it is still easy to
> go to other orders.
>
> e.g.
>
> #define FD_ORDER 8
> #if FD_ORDER == 2
> #define DX(var,i,j,k)   i2dx*(var(i+1,j,k) - var(i-1,j,k))
> ...
> #elif FD_ORDER == 4
> #define DX(var,i,j,k)   i4dx*(-var(i+2,j,k) + var(i-2,j,k) \
>                          + 8.d0*(var(i+1,j,k) - var(i-1,j,k)))
> ...
> #elif FD_ORDER == 8
> #define DX(var,i,j,k) i8dx* \
>          (  3.d0*(var(-4 + i,j,k) - var(4 + i,j,k)) \
>          - 32.d0*(var(-3 + i,j,k) - var(3 + i,j,k)) \
>          +168.d0*(var(-2 + i,j,k) - var(2 + i,j,k)) \
>          -672.d0*(var(-1 + i,j,k) - var(1 + i,j,k)))
> ...
> #endif

This would make it impossible to choose the order at run time.

We have measured the performance of the code, and we find that these  
if statements to not decrease performance.  I know that there is  
folklore that if statements in loop are very expensive, but this is  
not the case for this code.  We assume that we either benefit from  
branch prediction or that the other operations are so expensive that  
branch misprediction is not relevant.

-erik

-- 
Erik Schnetter <schnetter at cct.lsu.edu>

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://www.cactuscode.org/pipermail/developers/attachments/20070314/b99387e4/attachment.bin 


More information about the Developers mailing list