stfc / PSyclone

Domain-specific compiler and code transformation system for Finite Difference/Volume/Element Earth-system models in Fortran
BSD 3-Clause "New" or "Revised" License
104 stars 27 forks source link

Bugs when transforming mixed-precision kernels #2716

Open arporter opened 2 weeks ago

arporter commented 2 weeks ago

As found here: https://github.com/stfc/PSyclone/issues/2663#issuecomment-2332037300

The problem seems to be that we rename the interface rather than the actual subroutine that is being called.

arporter commented 2 weeks ago

Fixing the interface renaming was relatively simple and I've now done that. Unfortunately, while testing I discovered that our 'clever' code that attempts to return the correct Routine PSyIR by looking at the signature takes no account of precision! This is because it uses LFRicTypes and it seems that that class doesn't account for precision. I can't remember what the thinking was here - I need to search through the Issues and see what I can find.

arporter commented 1 week ago

Sergi suggested trying to ModuleInline the kernel first and then apply ACCRoutineTrans to it. However, that doesn't help because KernelModuleInlineTrans uses the same broken code to get the PSyIR of the routine to inline.

arporter commented 1 week ago

In fact, calling ACCRoutineTrans on the inlined kernel also fails because:

 Transformation Error: routine 'matrix_vector_code_r_double' calls another routine 'MATMUL(matrix(:,:,ik), x_e)' which is not available on the accelerator device and therefore cannot have ACCRoutineTrans applied to it (TODO #342).

I thought we had MATMUL tagged as being available on the GPU?

EDIT: it's not but perhaps it could be?

arporter commented 25 minutes ago

I'm making good progress with the plumbing but am now hitting errors because of the plain Symbols that are created in a kernel's symbol table for all of the reserved names. I need to work out why that isn't a problem on master.