On 3/21/25 11:35, Paul-Antoine Arras wrote:
Thanks Sandra and Jakub for your comments.
Here is attached an updated version of the patch:
* Removed special case for n==1, now use an array even when only one
interop object is passed.
* Updated scan dumps; added C/C++ disjunction where needed.
* Updated the signature of GOMP_interop to actual rather than generic
types.
* Renamed 'nowait' argument into 'flags' to allow for future extension.
* Added comments.
* Fixed style and formatting.
I have one more nit about this interface:
+/* Process the OpenMP interop directive. 'init' and 'destroy' take an array
+ of 'omp_interop_t *', 'use' an array of 'omp_interop_t', where
+ 'omp_interop_t' is internally 'struct interop_obj_t *';
+ 'flag' 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,
+ void **depend)
Is it possible to make the init and destroy arrays const? I think the
right C syntax for that would be "struct interop_obj_t ** const * init"
(I admit I always find this syntax confusing, though, so don't take my
word for it without checking).
Basically, I'm thinking that if you have #pragma omp dispatch with a
variant call that implicitly constructs/destructs omp_interop_t objects,
we ought to be able to pass the same array to both GOMP_interop calls
and know that the constructor call doesn't clobber the contents of the
array itself (only the objects its elements point to.) And if you have
such a thing in a loop, the optimizers ought to be able to hoist the
array initialization completely out of the loop so that it only happens
once.
Likewise I think prefer_type could be declared as "const char * const
prefer_type"?
-Sandra