On 24/03/2025 21:17, Sandra Loosemore wrote:
On 3/24/25 08:20, Paul-Antoine Arras wrote:
On 21/03/2025 20:17, Sandra Loosemore wrote:
Does the attached patch reflect what you have in mind?

diff --git libgomp/libgomp_g.h libgomp/libgomp_g.h
index 8993ec610fb..274f4937680 100644
--- libgomp/libgomp_g.h
+++ libgomp/libgomp_g.h
@@ -359,9 +359,10 @@ extern void GOMP_teams (unsigned int, unsigned int);
 extern bool GOMP_teams4 (unsigned int, unsigned int, unsigned int, bool);
 extern void *GOMP_target_map_indirect_ptr (void *);
 struct interop_obj_t;
-extern void GOMP_interop (int, int, struct interop_obj_t ***, const int *,
-              const char **, int, struct interop_obj_t **, int,
-              struct interop_obj_t ***, unsigned, void **);
+extern void GOMP_interop (int, int, struct interop_obj_t **const *, const int *,
+              const char *const *, int, struct interop_obj_t **,
+              int, struct interop_obj_t **const *, unsigned,
+              void **);

 /* teams.c */

diff --git libgomp/target.c libgomp/target.c
index 36ed797b0a9..54c244e0f13 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -5279,11 +5279,11 @@ ialias (omp_get_interop_rc_desc)
 struct interop_data_t
 {
   int device_num, n_init, n_use, n_destroy;
-  struct interop_obj_t ***init;
+  struct interop_obj_t **const *init;
   struct interop_obj_t **use;
-  struct interop_obj_t ***destroy;
+  struct interop_obj_t **const *destroy;
   const int *target_targetsync;
-  const char **prefer_type;
+  const char *const *prefer_type;
 };

 static void
@@ -5348,10 +5348,10 @@ gomp_interop_internal (void *data)
    'flags' is used for the 'nowait' clause.  */

 void
-GOMP_interop (int device_num, int n_init, struct interop_obj_t ***init,
-          const int *target_targetsync, const char **prefer_type, int n_use,
-          struct interop_obj_t **use, int n_destroy,
-          struct interop_obj_t ***destroy, unsigned int flags,
+GOMP_interop (int device_num, int n_init, struct interop_obj_t **const *init,
+          const int *target_targetsync, const char *const *prefer_type,
+          int n_use, struct interop_obj_t **use, int n_destroy,
+          struct interop_obj_t **const *destroy, unsigned int flags,
           void **depend)
 {
   struct interop_data_t args;

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.

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? 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...

Thanks,
--
PA

Reply via email to