On 3/25/25 09:25, Paul-Antoine Arras wrote:
On 24/03/2025 21:17, Sandra Loosemore wrote:
[snip]

I think you also need to update BUILT_IN_GOMP_INTEROP in omp- builtins.def; at least, that is the source of the decl used for the implicit creation/destruction of interop objects in "declare variant" expansion.

I took some time to check how other functions defined in target.c are declared in omp-builtins.def. It appears that the convention seems to be to omit const qualifiers, except in very simple cases like omp_get_mapped_ptr.

I'm not sure what the convention is elsewhere. But GOMP_interop isn't a user-visible function in libgomp; it's only called implicitly from the code GCC generates when expanding the interop directive and "declare variant". And both of those places use the declaration provided by BUILT_IN_GOMP_INTEROP rather than anything in libgomp.h.

Besides, I am not sure how to encode complex types like (**const *). Does that require creating new definitions in gcc/builtin-types.def and gcc/fortran/types.def?

I don't understand what the Fortran front end has to do with this, BUILT_IN_GOMP_INTEROP is only referenced from gimplify.cc and omp-low.cc.

And what difference does it make to have an argument declared as BT_PTR instead of, say, BT_PTR_CONST_PTR_PTR? Is is just a matter of optimisation?
If someone could shed some light...

Well, the declaration used by GCC for code generation should match the definition in the library, right?

Mainly, I got to thinking about this because the "declare variant" interop creation/destruction code that Tobias had sketched out before handing it over to me included a bunch of explicit clobbers that confused the heck out of me. AFAICT, the only thing that GOMP_interop needs to modify is the actual interop objects whose pointers are in the init/destroy arrays, so in my final version of the code those are the only things clobbered after the interop objects are destroyed. If GCC knows the arrays themselves are const, that potentially also enables optimizations like hoisting the code to set up the argument arrays out a loop containing a variant call.

-Sandra

Reply via email to