> Index: libgomp/libgomp.map
> ===================================================================
> --- libgomp/libgomp.map       (revision 226039)
> +++ libgomp/libgomp.map       (working copy)
> @@ -234,6 +234,12 @@ GOMP_4.0.1 {
>       GOMP_offload_unregister;
>  } GOMP_4.0;
>  
> +GOMP_4.0.2 {
> +  global:
> +     GOMP_offload_register_ver;
> +     GOMP_offload_unregister_ver;
> +} GOMP_4.0.1;
> +

This will hopefully be just GOMP_4.1 instead in the end, but it can
change when gomp-4_1-branch is merged to trunk, we don't guarantee
ABI stability at this point.

> @@ -642,7 +643,8 @@ gomp_update (struct gomp_device_descr *d
>     emitting variable and functions in the same order.  */
>  
>  static void
> -gomp_load_image_to_device (struct gomp_device_descr *devicep,
> +gomp_load_image_to_device (unsigned version,
> +                        struct gomp_device_descr *devicep,

I'd prefer version to go after devicep argument rather than before.

>                          const void *host_table, const void *target_data,
>                          bool is_register_lock)
>  {
> @@ -658,16 +660,28 @@ gomp_load_image_to_device (struct gomp_d
>  
>    /* Load image to device and get target addresses for the image.  */
>    struct addr_pair *target_table = NULL;
> -  int i, num_target_entries
> -    = devicep->load_image_func (devicep->target_id, target_data,
> -                             &target_table);
> +  int i, num_target_entries;
> +
> +  if (devicep->version_func)
> +    num_target_entries
> +      = devicep->load_image.ver_func (version, devicep->target_id,
> +                                     target_data, &target_table);
> +  else if (GOMP_VERSION_DEV (version))
> +    gomp_fatal ("Plugin too old for offload data (0 < %u)",
> +             GOMP_VERSION_DEV (version));
> +  else
> +    num_target_entries
> +      = devicep->load_image.unver_func (devicep->target_id,
> +                                       target_data, &target_table);

And really don't have ver_func vs. unver_func, just a single
callback that will take the version argument too (again, if possible
after target_id).

>  static void
> -gomp_unload_image_from_device (struct gomp_device_descr *devicep,
> +gomp_unload_image_from_device (unsigned version,
> +                            struct gomp_device_descr *devicep,
>                              const void *host_table, const void *target_data)
>  {
>    void **host_func_table = ((void ***) host_table)[0];

Likewise.

> @@ -756,8 +771,12 @@ gomp_unload_image_from_device (struct go
>        k.host_end = k.host_start + 1;
>        node = splay_tree_lookup (&devicep->mem_map, &k);
>      }
> -  
> -  devicep->unload_image_func (devicep->target_id, target_data);
> +
> +  if (devicep->version_func)
> +    devicep->unload_image.ver_func (version,
> +                                 devicep->target_id, target_data);
> +  else
> +    devicep->unload_image.unver_func (devicep->target_id, target_data);

And here too.

> @@ -815,13 +841,20 @@ GOMP_offload_register (const void *host_
>    gomp_mutex_unlock (&register_lock);
>  }
>  
> +void
> +GOMP_offload_register (const void *host_table, int target_type,
> +                    const void *target_data)
> +{
> +  GOMP_offload_register_ver (0, host_table, target_type, target_data);
> +}

This is ok.

> @@ -862,8 +903,9 @@ gomp_init_device (struct gomp_device_des
>      {
>        struct offload_image_descr *image = &offload_images[i];
>        if (image->type == devicep->type)
> -     gomp_load_image_to_device (devicep, image->host_table,
> -                                image->target_data, false);
> +     gomp_load_image_to_device (image->version, devicep,
> +                                image->host_table, image->target_data,
> +                                false);
>      }
>  
>    devicep->is_initialized = true;
> @@ -881,7 +923,8 @@ gomp_unload_device (struct gomp_device_d
>       {
>         struct offload_image_descr *image = &offload_images[i];
>         if (image->type == devicep->type)
> -         gomp_unload_image_from_device (devicep, image->host_table,
> +         gomp_unload_image_from_device (image->version, devicep,
> +                                        image->host_table,
>                                          image->target_data);

Again, please swap the first two arguments.

> +
> +  if (DLSYM_OPT (version, version))

I'd prefer requiring version always (i.e. DLSYM (version);
plus the v != GOMP_VERSION checking).

        Jakub

Reply via email to