PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

Update SIR to use Dawn intrinsics (min, max etc).

Open rupertford opened this issue 3 years ago • 6 comments

At the moment Fortran intrinsics are replaced by equivalent code before being transformed to SIR. However, Dawn does support a number of intrinsics so these can be translated directly.

rupertford avatar Aug 04 '22 09:08 rupertford

The Fortran intrinsics used in the tracer advection example are MAX, SIGN, MIN and ABS.

rupertford avatar Aug 04 '22 09:08 rupertford

I can't find any examples of using intrinsics in the dawn repo or in any previously supplied code so I've contacted Matthias requesting an example.

rupertford avatar Aug 04 '22 10:08 rupertford

Created branch 1826_sir_intrinsics

rupertford avatar Aug 04 '22 10:08 rupertford

Matthias has kindly pointed me at the following https://github.com/MeteoSwiss-APN/dawn/blob/407c03b2024e5a224548b173a39e7ba2245ca060/dawn/test/integration-test/dawn4py-tests/ICON_laplacian_diamond_stencil.py#L179

Essentially the structure appears to be ...

serial_utils.make_fun_call_expr("intrinsic",[args])

rupertford avatar Aug 04 '22 13:08 rupertford

Done a first implementation which probably has various syntax errors but they can be simply fixed. The main question is how to deal with sign as apparently C does not have a standard implementation of SIGN. Perhaps I should just use the transformation. I'll ask Matthias what he thinks as he has talked about using an intrinsic in the past.

rupertford avatar Aug 04 '22 16:08 rupertford

C does have its own implementation of copysign since C99: https://en.cppreference.com/w/c/numeric/math/copysign

Is this different to Fortran's? I remember using it (or my own implementation of it due to performance) in the Regent version of NemoLite2D

LonelyCat124 avatar Aug 08 '22 09:08 LonelyCat124