Browse Source

SOCL: add ICD support

SOCL now supports ICD extension allowing several OpenCL implementations
to be used at the same time. This patch has been provided by Brice
Videau and Vincent Danjean.
Sylvain Henry 13 years ago
parent
commit
5806bbffe4

+ 4 - 2
socl/src/Makefile.am

@@ -35,7 +35,8 @@ noinst_HEADERS =				\
   mem_objects.h					\
   socl.h					\
   task.h					\
-  util.h
+  util.h					\
+  init.h
 
 libsocl_@STARPU_EFFECTIVE_VERSION@_la_LDFLAGS = $(ldflags) -no-undefined			\
   -version-info $(LIBSOCL_INTERFACE_CURRENT):$(LIBSOCL_INTERFACE_REVISION):$(LIBSOCL_INTERFACE_AGE)
@@ -118,7 +119,8 @@ libsocl_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 						\
   cl_enqueuendrangekernel.c \
   cl_enqueuenativekernel.c \
   cl_geteventprofilinginfo.c \
-  cl_getextensionfunctionaddress.c
+  cl_getextensionfunctionaddress.c \
+  cl_icdgetplatformidskhr.c
 
 
 

+ 6 - 1
socl/src/cl_createcontextfromtype.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -15,6 +17,7 @@
  */
 
 #include "socl.h"
+#include "init.h"
 
 CL_API_ENTRY cl_context CL_API_CALL
 soclCreateContextFromType(const cl_context_properties * properties,
@@ -23,6 +26,8 @@ soclCreateContextFromType(const cl_context_properties * properties,
                         void *                        user_data,
                         cl_int *                      errcode_ret) CL_API_SUFFIX__VERSION_1_0
 {
+   if( ! _starpu_init )
+      socl_init_starpu(); 
    //We assume clCreateContext doesn't support devices
    //TODO:use devices
    return soclCreateContext(properties, 0, NULL, pfn_notify, user_data, errcode_ret);

+ 6 - 2
socl/src/cl_getdeviceids.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -15,7 +17,7 @@
  */
 
 #include "socl.h"
-
+#include "init.h"
 
 /**
  * \brief Return one device of each kind
@@ -29,6 +31,8 @@ soclGetDeviceIDs(cl_platform_id   platform,
                cl_device_id *   devices, 
                cl_uint *        num_devices) CL_API_SUFFIX__VERSION_1_0
 {
+   if( ! _starpu_init )
+      socl_init_starpu(); 
    if (platform != NULL && platform != &socl_platform)
       return CL_INVALID_PLATFORM;
 

+ 11 - 1
socl/src/cl_getextensionfunctionaddress.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -14,6 +16,7 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
+#include <string.h>
 #include "socl.h"
 
 CL_API_ENTRY void * CL_API_CALL
@@ -22,3 +25,10 @@ soclGetExtensionFunctionAddress(const char * UNUSED(func_name)) CL_API_SUFFIX__V
    //TODO
    return NULL;
 }
+
+CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(
+             const char *   func_name) CL_API_SUFFIX__VERSION_1_0 {
+  if( func_name != NULL &&  strcmp("clIcdGetPlatformIDsKHR", func_name) == 0 )
+    return (void *)soclIcdGetPlatformIDsKHR;
+  return NULL;
+}

+ 4 - 1
socl/src/cl_getplatforminfo.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -39,6 +41,7 @@ soclGetPlatformInfo(cl_platform_id   platform,
 	INFO_CASE_STRING(CL_PLATFORM_NAME,    SOCL_PLATFORM_NAME);
 	INFO_CASE_STRING(CL_PLATFORM_VENDOR,  SOCL_VENDOR);
 	INFO_CASE_STRING(CL_PLATFORM_EXTENSIONS, SOCL_PLATFORM_EXTENSIONS);
+	INFO_CASE_STRING(CL_PLATFORM_ICD_SUFFIX_KHR, SOCL_PLATFORM_ICD_SUFFIX_KHR);
    default:
          return CL_INVALID_VALUE;
    }

+ 40 - 0
socl/src/cl_icdgetplatformidskhr.c

@@ -0,0 +1,40 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include "socl.h"
+
+extern int _starpu_init_failed;
+
+CL_API_ENTRY cl_int CL_API_CALL soclIcdGetPlatformIDsKHR(
+             cl_uint num_entries,
+             cl_platform_id *platforms,
+             cl_uint *num_platforms) CL_EXT_SUFFIX__VERSION_1_0{
+     if ((num_entries == 0 && platforms != NULL)
+	 || (num_platforms == NULL && platforms == NULL))
+	  return CL_INVALID_VALUE;
+
+     else {
+	  if (platforms != NULL)
+	       platforms[0] = &socl_platform;
+
+	  if (num_platforms != NULL)
+	       *num_platforms = 1;
+     }
+
+   return CL_SUCCESS;
+}

+ 5 - 2
socl/src/command_queue.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -144,7 +146,8 @@ void command_queue_enqueue_ex(cl_command_queue cq, cl_command cmd, cl_uint num_e
 	int is_barrier = 0;
 	if (cmd->typ == CL_COMMAND_BARRIER) {
 		is_barrier = 1;
-		/* OpenCL has no CL_COMMAND_BARRIER type, so we fall back on CL_COMMAND_MARKER */
+		/* OpenCL has no CL_COMMAND_BARRIER type, so we fall back on CL_COMMAND_MARKER 
+                   WARNING OpenCL has CL_COMMAND_BARRIER in 1.2*/
 		cmd->typ = CL_COMMAND_MARKER;
 	}
 

+ 11 - 1
socl/src/devices.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -24,6 +26,7 @@ const cl_uint __attribute__ ((aligned (16))) SOCL_DEVICE_VENDOR_ID = 666;
 
 const struct _cl_device_id socl_devices[] = {
    { 
+      .dispatch = &socl_master_dispatch,
       .type = CL_DEVICE_TYPE_CPU,
       .max_compute_units = 1,
       .max_work_item_dimensions = 3,
@@ -56,6 +59,7 @@ const struct _cl_device_id socl_devices[] = {
       .extensions = ""
    },
    {
+      .dispatch = &socl_master_dispatch,
       .type = CL_DEVICE_TYPE_GPU,
       .max_compute_units = 12,
       .max_work_item_dimensions = 3,
@@ -88,6 +92,7 @@ const struct _cl_device_id socl_devices[] = {
       .extensions = ""
    },
    {
+      .dispatch = &socl_master_dispatch,
       .type = CL_DEVICE_TYPE_GPU,
       .max_compute_units = 12,
       .max_work_item_dimensions = 3,
@@ -120,6 +125,7 @@ const struct _cl_device_id socl_devices[] = {
       .extensions = ""
    },
    {
+      .dispatch = &socl_master_dispatch,
       .type = CL_DEVICE_TYPE_GPU,
       .max_compute_units = 12,
       .max_work_item_dimensions = 3,
@@ -152,6 +158,7 @@ const struct _cl_device_id socl_devices[] = {
       .extensions = ""
    },
    {
+      .dispatch = &socl_master_dispatch,
       .type = CL_DEVICE_TYPE_GPU,
       .max_compute_units = 12,
       .max_work_item_dimensions = 3,
@@ -184,6 +191,7 @@ const struct _cl_device_id socl_devices[] = {
       .extensions = ""
    },
    {
+      .dispatch = &socl_master_dispatch,
       .type = CL_DEVICE_TYPE_GPU,
       .max_compute_units = 12,
       .max_work_item_dimensions = 3,
@@ -216,6 +224,7 @@ const struct _cl_device_id socl_devices[] = {
       .extensions = ""
    },
    {
+      .dispatch = &socl_master_dispatch,
       .type = CL_DEVICE_TYPE_GPU,
       .max_compute_units = 12,
       .max_work_item_dimensions = 3,
@@ -248,6 +257,7 @@ const struct _cl_device_id socl_devices[] = {
       .extensions = ""
    },
    {
+      .dispatch = &socl_master_dispatch,
       .type = CL_DEVICE_TYPE_GPU,
       .max_compute_units = 12,
       .max_work_item_dimensions = 3,

+ 4 - 2
socl/src/devices.h

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -16,13 +17,14 @@
 
 #ifndef SOCL_DEVICES_H
 #define SOCL_DEVICES_H
-
+#include "socl.h"
 // OpenCL 1.0 : Mandatory format: major_number.minor_number
 const char * SOCL_DRIVER_VERSION;
 
 const cl_uint SOCL_DEVICE_VENDOR_ID;
 
 struct _cl_device_id {
+   struct _cl_icd_dispatch * dispatch;
    cl_device_type    type;
    cl_uint           max_compute_units;        //OpenCL 1.0: minimum value is 1
    cl_uint           max_work_item_dimensions; //OpenCL 1.0: minimum value is 3

+ 4 - 1
socl/src/gc.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -141,6 +143,7 @@ int gc_entity_release_ex(entity e) {
 void gc_entity_init(void *arg, void (*release_callback)(void*)) {
   struct entity * e = (entity)arg;
 
+  e->dispatch = &socl_master_dispatch;
   e->refs = 1;
   e->release_callback = release_callback;
   e->prev = NULL;

+ 39 - 21
socl/src/init.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -14,29 +16,29 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
+#include <pthread.h>
 #include "socl.h"
 #include "gc.h"
 #include "mem_objects.h"
 
 int _starpu_init_failed;
+int _starpu_init = 0;
+pthread_mutex_t _socl_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-/**
- * Initialize SOCL
- */
-__attribute__((constructor)) static void socl_init() {
+void socl_init_starpu(void) {
+  pthread_mutex_lock(&_socl_mutex);
+  if( ! _starpu_init ){
+    struct starpu_conf conf;
+    starpu_conf_init(&conf);
+    conf.ncuda = 0;
 
-  struct starpu_conf conf;
-  starpu_conf_init(&conf);
-  conf.ncuda = 0;
 
-  mem_object_init();
-
-  _starpu_init_failed = starpu_init(&conf);
-  if (_starpu_init_failed != 0)
-  {
+    _starpu_init_failed = starpu_init(&conf);
+    if (_starpu_init_failed != 0)
+    {
        DEBUG_MSG("Error when calling starpu_init: %d\n", _starpu_init_failed);
-  }
-  else {
+    }
+    else {
        if (starpu_cpu_worker_get_count() == 0)
        {
 	    DEBUG_MSG("StarPU did not find any CPU device. SOCL needs at least 1 CPU.\n");
@@ -47,10 +49,22 @@ __attribute__((constructor)) static void socl_init() {
 	    DEBUG_MSG("StarPU didn't find any OpenCL device. Try disabling CUDA support in StarPU (export STARPU_NCUDA=0).\n");
 	    _starpu_init_failed = -ENODEV;
        }
+    }
+
+    /* Disable dataflow implicit dependencies */
+    starpu_data_set_default_sequential_consistency_flag(0);
+    _starpu_init = 1;
   }
+  pthread_mutex_unlock(&_socl_mutex);
 
-  /* Disable dataflow implicit dependencies */
-  starpu_data_set_default_sequential_consistency_flag(0);
+}
+/**
+ * Initialize SOCL
+ */
+__attribute__((constructor)) static void socl_init() {
+
+
+  mem_object_init();
 
   gc_start();
 }
@@ -59,17 +73,21 @@ __attribute__((constructor)) static void socl_init() {
  * Shutdown SOCL
  */
 __attribute__((destructor)) static void socl_shutdown() {
-
-  starpu_task_wait_for_all();
+  pthread_mutex_lock(&_socl_mutex);
+  if( _starpu_init )
+    starpu_task_wait_for_all();
 
   gc_stop();
 
-  starpu_task_wait_for_all();
+  if( _starpu_init )
+    starpu_task_wait_for_all();
 
   int active_entities = gc_active_entity_count();
 
   if (active_entities != 0)
     DEBUG_MSG("Unreleased entities: %d\n", active_entities);
 
-  starpu_shutdown();
+  if( _starpu_init )
+    starpu_shutdown();
+  pthread_mutex_unlock(&_socl_mutex);
 }

+ 29 - 0
socl/src/init.h

@@ -0,0 +1,29 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include <pthread.h>
+#include "socl.h"
+#include "gc.h"
+#include "mem_objects.h"
+
+extern int _starpu_init_failed;
+extern volatile int _starpu_init;
+/**
+ * Initialize StarPU
+ */
+
+void socl_init_starpu(void);

+ 907 - 0
socl/src/ocl_icd.h

@@ -0,0 +1,907 @@
+/**
+Copyright (c) 2012, Brice Videau <brice.videau@imag.fr>
+Copyright (c) 2012, Vincent Danjean <Vincent.Danjean@ens-lyon.org>
+All rights reserved.
+      
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+        
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Do not edit this file. It is automatically generated.
+
+*/
+
+#define CL_USE_DEPRECATED_OPENCL_1_0_APIS
+#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
+#include <CL/cl.h>
+#include <CL/cl_gl.h>
+#include <CL/cl_ext.h>
+
+#define OCL_ICD_API_VERSION	1
+#define OCL_ICD_IDENTIFIED_FUNCTIONS	102
+
+struct _cl_icd_dispatch {
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetPlatformIDs)(
+    cl_uint          /* num_entries */,
+    cl_platform_id * /* platforms */,
+    cl_uint *        /* num_platforms */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*
+  clGetPlatformInfo)(
+    cl_platform_id   /* platform */,
+    cl_platform_info /* param_name */,
+    size_t           /* param_value_size */,
+    void *           /* param_value */,
+    size_t *         /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetDeviceIDs)(
+    cl_platform_id   /* platform */,
+    cl_device_type   /* device_type */,
+    cl_uint          /* num_entries */,
+    cl_device_id *   /* devices */,
+    cl_uint *        /* num_devices */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetDeviceInfo)(
+    cl_device_id    /* device */,
+    cl_device_info  /* param_name */,
+    size_t          /* param_value_size */,
+    void *          /* param_value */,
+    size_t *        /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_context (CL_API_CALL*clCreateContext)(
+    const cl_context_properties * /* properties */,
+    cl_uint                       /* num_devices */,
+    const cl_device_id *          /* devices */,
+    void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *),
+    void *                        /* user_data */,
+    cl_int *                      /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_context (CL_API_CALL*clCreateContextFromType)(
+    const cl_context_properties * /* properties */,
+    cl_device_type                /* device_type */,
+    void (CL_CALLBACK *     /* pfn_notify*/ )(const char *, const void *, size_t, void *),
+    void *                        /* user_data */,
+    cl_int *                      /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clRetainContext)(
+    cl_context /* context */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clReleaseContext)(
+    cl_context /* context */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetContextInfo)(
+    cl_context         /* context */,
+    cl_context_info    /* param_name */,
+    size_t             /* param_value_size */,
+    void *             /* param_value */,
+    size_t *           /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_command_queue (CL_API_CALL*clCreateCommandQueue)(
+    cl_context                     /* context */,
+    cl_device_id                   /* device */,
+    cl_command_queue_properties    /* properties */,
+    cl_int *                       /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clRetainCommandQueue)(
+    cl_command_queue /* command_queue */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clReleaseCommandQueue)(
+    cl_command_queue /* command_queue */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetCommandQueueInfo)(
+    cl_command_queue      /* command_queue */,
+    cl_command_queue_info /* param_name */,
+    size_t                /* param_value_size */,
+    void *                /* param_value */,
+    size_t *              /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clSetCommandQueueProperty)(
+    cl_command_queue              /* command_queue */,
+    cl_command_queue_properties   /* properties */,
+    cl_bool                        /* enable */,
+    cl_command_queue_properties * /* old_properties */) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateBuffer)(
+    cl_context   /* context */,
+    cl_mem_flags /* flags */,
+    size_t       /* size */,
+    void *       /* host_ptr */,
+    cl_int *     /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateImage2D)(
+    cl_context              /* context */,
+    cl_mem_flags            /* flags */,
+    const cl_image_format * /* image_format */,
+    size_t                  /* image_width */,
+    size_t                  /* image_height */,
+    size_t                  /* image_row_pitch */,
+    void *                  /* host_ptr */,
+    cl_int *                /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateImage3D)(
+    cl_context              /* context */,
+    cl_mem_flags            /* flags */,
+    const cl_image_format * /* image_format */,
+    size_t                  /* image_width */,
+    size_t                  /* image_height */,
+    size_t                  /* image_depth */,
+    size_t                  /* image_row_pitch */,
+    size_t                  /* image_slice_pitch */,
+    void *                  /* host_ptr */,
+    cl_int *                /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clRetainMemObject)(
+    cl_mem /* memobj */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clReleaseMemObject)(
+    cl_mem /* memobj */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetSupportedImageFormats)(
+    cl_context           /* context */,
+    cl_mem_flags         /* flags */,
+    cl_mem_object_type   /* image_type */,
+    cl_uint              /* num_entries */,
+    cl_image_format *    /* image_formats */,
+    cl_uint *            /* num_image_formats */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetMemObjectInfo)(
+    cl_mem           /* memobj */,
+    cl_mem_info      /* param_name */,
+    size_t           /* param_value_size */,
+    void *           /* param_value */,
+    size_t *         /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetImageInfo)(
+    cl_mem           /* image */,
+    cl_image_info    /* param_name */,
+    size_t           /* param_value_size */,
+    void *           /* param_value */,
+    size_t *         /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_sampler (CL_API_CALL*clCreateSampler)(
+    cl_context          /* context */,
+    cl_bool             /* normalized_coords */,
+    cl_addressing_mode  /* addressing_mode */,
+    cl_filter_mode      /* filter_mode */,
+    cl_int *            /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clRetainSampler)(
+    cl_sampler /* sampler */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clReleaseSampler)(
+    cl_sampler /* sampler */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetSamplerInfo)(
+    cl_sampler         /* sampler */,
+    cl_sampler_info    /* param_name */,
+    size_t             /* param_value_size */,
+    void *             /* param_value */,
+    size_t *           /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_program (CL_API_CALL*clCreateProgramWithSource)(
+    cl_context        /* context */,
+    cl_uint           /* count */,
+    const char **     /* strings */,
+    const size_t *    /* lengths */,
+    cl_int *          /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_program (CL_API_CALL*clCreateProgramWithBinary)(
+    cl_context                     /* context */,
+    cl_uint                        /* num_devices */,
+    const cl_device_id *           /* device_list */,
+    const size_t *                 /* lengths */,
+    const unsigned char **         /* binaries */,
+    cl_int *                       /* binary_status */,
+    cl_int *                       /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clRetainProgram)(
+    cl_program /* program */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clReleaseProgram)(
+    cl_program /* program */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clBuildProgram)(
+    cl_program           /* program */,
+    cl_uint              /* num_devices */,
+    const cl_device_id * /* device_list */,
+    const char *         /* options */,
+    void (CL_CALLBACK *  /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+    void *               /* user_data */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clUnloadCompiler)(
+    void
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetProgramInfo)(
+    cl_program         /* program */,
+    cl_program_info    /* param_name */,
+    size_t             /* param_value_size */,
+    void *             /* param_value */,
+    size_t *           /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetProgramBuildInfo)(
+    cl_program            /* program */,
+    cl_device_id          /* device */,
+    cl_program_build_info /* param_name */,
+    size_t                /* param_value_size */,
+    void *                /* param_value */,
+    size_t *              /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_kernel (CL_API_CALL*clCreateKernel)(
+    cl_program      /* program */,
+    const char *    /* kernel_name */,
+    cl_int *        /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clCreateKernelsInProgram)(
+    cl_program     /* program */,
+    cl_uint        /* num_kernels */,
+    cl_kernel *    /* kernels */,
+    cl_uint *      /* num_kernels_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clRetainKernel)(
+    cl_kernel    /* kernel */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clReleaseKernel)(
+    cl_kernel   /* kernel */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clSetKernelArg)(
+    cl_kernel    /* kernel */,
+    cl_uint      /* arg_index */,
+    size_t       /* arg_size */,
+    const void * /* arg_value */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetKernelInfo)(
+    cl_kernel       /* kernel */,
+    cl_kernel_info  /* param_name */,
+    size_t          /* param_value_size */,
+    void *          /* param_value */,
+    size_t *        /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetKernelWorkGroupInfo)(
+    cl_kernel                  /* kernel */,
+    cl_device_id               /* device */,
+    cl_kernel_work_group_info  /* param_name */,
+    size_t                     /* param_value_size */,
+    void *                     /* param_value */,
+    size_t *                   /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clWaitForEvents)(
+    cl_uint             /* num_events */,
+    const cl_event *    /* event_list */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetEventInfo)(
+    cl_event         /* event */,
+    cl_event_info    /* param_name */,
+    size_t           /* param_value_size */,
+    void *           /* param_value */,
+    size_t *         /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clRetainEvent)(
+    cl_event /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clReleaseEvent)(
+    cl_event /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetEventProfilingInfo)(
+    cl_event            /* event */,
+    cl_profiling_info   /* param_name */,
+    size_t              /* param_value_size */,
+    void *              /* param_value */,
+    size_t *            /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clFlush)(
+    cl_command_queue /* command_queue */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clFinish)(
+    cl_command_queue /* command_queue */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueReadBuffer)(
+    cl_command_queue    /* command_queue */,
+    cl_mem              /* buffer */,
+    cl_bool             /* blocking_read */,
+    size_t              /* offset */,
+    size_t              /* cb */,
+    void *              /* ptr */,
+    cl_uint             /* num_events_in_wait_list */,
+    const cl_event *    /* event_wait_list */,
+    cl_event *          /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueWriteBuffer)(
+    cl_command_queue   /* command_queue */,
+    cl_mem             /* buffer */,
+    cl_bool            /* blocking_write */,
+    size_t             /* offset */,
+    size_t             /* cb */,
+    const void *       /* ptr */,
+    cl_uint            /* num_events_in_wait_list */,
+    const cl_event *   /* event_wait_list */,
+    cl_event *         /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueCopyBuffer)(
+    cl_command_queue    /* command_queue */,
+    cl_mem              /* src_buffer */,
+    cl_mem              /* dst_buffer */,
+    size_t              /* src_offset */,
+    size_t              /* dst_offset */,
+    size_t              /* cb */,
+    cl_uint             /* num_events_in_wait_list */,
+    const cl_event *    /* event_wait_list */,
+    cl_event *          /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueReadImage)(
+    cl_command_queue     /* command_queue */,
+    cl_mem               /* image */,
+    cl_bool              /* blocking_read */,
+    const size_t *       /* origin[3] */,
+    const size_t *       /* region[3] */,
+    size_t               /* row_pitch */,
+    size_t               /* slice_pitch */,
+    void *               /* ptr */,
+    cl_uint              /* num_events_in_wait_list */,
+    const cl_event *     /* event_wait_list */,
+    cl_event *           /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueWriteImage)(
+    cl_command_queue    /* command_queue */,
+    cl_mem              /* image */,
+    cl_bool             /* blocking_write */,
+    const size_t *      /* origin[3] */,
+    const size_t *      /* region[3] */,
+    size_t              /* input_row_pitch */,
+    size_t              /* input_slice_pitch */,
+    const void *        /* ptr */,
+    cl_uint             /* num_events_in_wait_list */,
+    const cl_event *    /* event_wait_list */,
+    cl_event *          /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueCopyImage)(
+    cl_command_queue     /* command_queue */,
+    cl_mem               /* src_image */,
+    cl_mem               /* dst_image */,
+    const size_t *       /* src_origin[3] */,
+    const size_t *       /* dst_origin[3] */,
+    const size_t *       /* region[3] */,
+    cl_uint              /* num_events_in_wait_list */,
+    const cl_event *     /* event_wait_list */,
+    cl_event *           /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueCopyImageToBuffer)(
+    cl_command_queue /* command_queue */,
+    cl_mem           /* src_image */,
+    cl_mem           /* dst_buffer */,
+    const size_t *   /* src_origin[3] */,
+    const size_t *   /* region[3] */,
+    size_t           /* dst_offset */,
+    cl_uint          /* num_events_in_wait_list */,
+    const cl_event * /* event_wait_list */,
+    cl_event *       /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueCopyBufferToImage)(
+    cl_command_queue /* command_queue */,
+    cl_mem           /* src_buffer */,
+    cl_mem           /* dst_image */,
+    size_t           /* src_offset */,
+    const size_t *   /* dst_origin[3] */,
+    const size_t *   /* region[3] */,
+    cl_uint          /* num_events_in_wait_list */,
+    const cl_event * /* event_wait_list */,
+    cl_event *       /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY void * (CL_API_CALL*clEnqueueMapBuffer)(
+    cl_command_queue /* command_queue */,
+    cl_mem           /* buffer */,
+    cl_bool          /* blocking_map */,
+    cl_map_flags     /* map_flags */,
+    size_t           /* offset */,
+    size_t           /* cb */,
+    cl_uint          /* num_events_in_wait_list */,
+    const cl_event * /* event_wait_list */,
+    cl_event *       /* event */,
+    cl_int *         /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY void * (CL_API_CALL*clEnqueueMapImage)(
+    cl_command_queue  /* command_queue */,
+    cl_mem            /* image */,
+    cl_bool           /* blocking_map */,
+    cl_map_flags      /* map_flags */,
+    const size_t *    /* origin[3] */,
+    const size_t *    /* region[3] */,
+    size_t *          /* image_row_pitch */,
+    size_t *          /* image_slice_pitch */,
+    cl_uint           /* num_events_in_wait_list */,
+    const cl_event *  /* event_wait_list */,
+    cl_event *        /* event */,
+    cl_int *          /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueUnmapMemObject)(
+    cl_command_queue /* command_queue */,
+    cl_mem           /* memobj */,
+    void *           /* mapped_ptr */,
+    cl_uint          /* num_events_in_wait_list */,
+    const cl_event *  /* event_wait_list */,
+    cl_event *        /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueNDRangeKernel)(
+    cl_command_queue /* command_queue */,
+    cl_kernel        /* kernel */,
+    cl_uint          /* work_dim */,
+    const size_t *   /* global_work_offset */,
+    const size_t *   /* global_work_size */,
+    const size_t *   /* local_work_size */,
+    cl_uint          /* num_events_in_wait_list */,
+    const cl_event * /* event_wait_list */,
+    cl_event *       /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueTask)(
+    cl_command_queue  /* command_queue */,
+    cl_kernel         /* kernel */,
+    cl_uint           /* num_events_in_wait_list */,
+    const cl_event *  /* event_wait_list */,
+    cl_event *        /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueNativeKernel)(
+    cl_command_queue  /* command_queue */,
+    void (*user_func)(void *),
+    void *            /* args */,
+    size_t            /* cb_args */,
+    cl_uint           /* num_mem_objects */,
+    const cl_mem *    /* mem_list */,
+    const void **     /* args_mem_loc */,
+    cl_uint           /* num_events_in_wait_list */,
+    const cl_event *  /* event_wait_list */,
+    cl_event *        /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueMarker)(
+    cl_command_queue    /* command_queue */,
+    cl_event *          /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueWaitForEvents)(
+    cl_command_queue /* command_queue */,
+    cl_uint          /* num_events */,
+    const cl_event * /* event_list */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueBarrier)(
+    cl_command_queue /* command_queue */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY void * (CL_API_CALL*clGetExtensionFunctionAddress)(
+    const char * /* func_name */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateFromGLBuffer)(
+    cl_context     /* context */,
+    cl_mem_flags   /* flags */,
+    cl_GLuint      /* bufobj */,
+    int *          /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateFromGLTexture2D)(
+    cl_context      /* context */,
+    cl_mem_flags    /* flags */,
+    cl_GLenum       /* target */,
+    cl_GLint        /* miplevel */,
+    cl_GLuint       /* texture */,
+    cl_int *        /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateFromGLTexture3D)(
+    cl_context      /* context */,
+    cl_mem_flags    /* flags */,
+    cl_GLenum       /* target */,
+    cl_GLint        /* miplevel */,
+    cl_GLuint       /* texture */,
+    cl_int *        /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateFromGLRenderbuffer)(
+    cl_context   /* context */,
+    cl_mem_flags /* flags */,
+    cl_GLuint    /* renderbuffer */,
+    cl_int *     /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetGLObjectInfo)(
+    cl_mem                /* memobj */,
+    cl_gl_object_type *   /* gl_object_type */,
+    cl_GLuint *              /* gl_object_name */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetGLTextureInfo)(
+    cl_mem               /* memobj */,
+    cl_gl_texture_info   /* param_name */,
+    size_t               /* param_value_size */,
+    void *               /* param_value */,
+    size_t *             /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueAcquireGLObjects)(
+    cl_command_queue      /* command_queue */,
+    cl_uint               /* num_objects */,
+    const cl_mem *        /* mem_objects */,
+    cl_uint               /* num_events_in_wait_list */,
+    const cl_event *      /* event_wait_list */,
+    cl_event *            /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueReleaseGLObjects)(
+    cl_command_queue      /* command_queue */,
+    cl_uint               /* num_objects */,
+    const cl_mem *        /* mem_objects */,
+    cl_uint               /* num_events_in_wait_list */,
+    const cl_event *      /* event_wait_list */,
+    cl_event *            /* event */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetGLContextInfoKHR)(
+    const cl_context_properties * /* properties */,
+    cl_gl_context_info            /* param_name */,
+    size_t                        /* param_value_size */,
+    void *                        /* param_value */,
+    size_t *                      /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_0;
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown75)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown76)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown77)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown78)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown79)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown80)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clSetEventCallback)(
+    cl_event    /* event */,
+    cl_int      /* command_exec_callback_type */,
+    void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *),
+    void *      /* user_data */
+  ) CL_API_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateSubBuffer)(
+    cl_mem                   /* buffer */,
+    cl_mem_flags             /* flags */,
+    cl_buffer_create_type    /* buffer_create_type */,
+    const void *             /* buffer_create_info */,
+    cl_int *                 /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clSetMemObjectDestructorCallback)(
+    cl_mem /* memobj */,
+    void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
+    void * /*user_data */ )             CL_API_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_event (CL_API_CALL*clCreateUserEvent)(
+    cl_context    /* context */,
+    cl_int *      /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clSetUserEventStatus)(
+    cl_event   /* event */,
+    cl_int     /* execution_status */
+  ) CL_API_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueReadBufferRect)(
+    cl_command_queue    /* command_queue */,
+    cl_mem              /* buffer */,
+    cl_bool             /* blocking_read */,
+    const size_t *      /* buffer_origin */,
+    const size_t *      /* host_origin */,
+    const size_t *      /* region */,
+    size_t              /* buffer_row_pitch */,
+    size_t              /* buffer_slice_pitch */,
+    size_t              /* host_row_pitch */,
+    size_t              /* host_slice_pitch */,
+    void *              /* ptr */,
+    cl_uint             /* num_events_in_wait_list */,
+    const cl_event *    /* event_wait_list */,
+    cl_event *          /* event */
+  ) CL_API_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueWriteBufferRect)(
+    cl_command_queue    /* command_queue */,
+    cl_mem              /* buffer */,
+    cl_bool             /* blocking_write */,
+    const size_t *      /* buffer_origin */,
+    const size_t *      /* host_origin */,
+    const size_t *      /* region */,
+    size_t              /* buffer_row_pitch */,
+    size_t              /* buffer_slice_pitch */,
+    size_t              /* host_row_pitch */,
+    size_t              /* host_slice_pitch */,
+    const void *        /* ptr */,
+    cl_uint             /* num_events_in_wait_list */,
+    const cl_event *    /* event_wait_list */,
+    cl_event *          /* event */
+  ) CL_API_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueCopyBufferRect)(
+    cl_command_queue    /* command_queue */,
+    cl_mem              /* src_buffer */,
+    cl_mem              /* dst_buffer */,
+    const size_t *      /* src_origin */,
+    const size_t *      /* dst_origin */,
+    const size_t *      /* region */,
+    size_t              /* src_row_pitch */,
+    size_t              /* src_slice_pitch */,
+    size_t              /* dst_row_pitch */,
+    size_t              /* dst_slice_pitch */,
+    cl_uint             /* num_events_in_wait_list */,
+    const cl_event *    /* event_wait_list */,
+    cl_event *          /* event */
+  ) CL_API_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*    clCreateSubDevicesEXT)(
+    cl_device_id /*in_device*/,
+    const cl_device_partition_property_ext * /* properties */,
+    cl_uint /*num_entries*/,
+    cl_device_id * /*out_devices*/,
+    cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*    clRetainDeviceEXT)(
+    cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*    clReleaseDeviceEXT)(
+    cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown92)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clCreateSubDevices)(
+    cl_device_id                         /* in_device */,
+    const cl_device_partition_property * /* properties */,
+    cl_uint                              /* num_devices */,
+    cl_device_id *                       /* out_devices */,
+    cl_uint *                            /* num_devices_ret */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clRetainDevice)(
+    cl_device_id /* device */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clReleaseDevice)(
+    cl_device_id /* device */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateImage)(
+    cl_context              /* context */,
+    cl_mem_flags            /* flags */,
+    const cl_image_format * /* image_format */,
+    const cl_image_desc *   /* image_desc */,
+    void *                  /* host_ptr */,
+    cl_int *                /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_program (CL_API_CALL*clCreateProgramWithBuiltInKernels)(
+    cl_context            /* context */,
+    cl_uint               /* num_devices */,
+    const cl_device_id *  /* device_list */,
+    const char *          /* kernel_names */,
+    cl_int *              /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clCompileProgram)(
+    cl_program           /* program */,
+    cl_uint              /* num_devices */,
+    const cl_device_id * /* device_list */,
+    const char *         /* options */,
+    cl_uint              /* num_input_headers */,
+    const cl_program *   /* input_headers */,
+    const char **        /* header_include_names */,
+    void (CL_CALLBACK *  /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+    void *               /* user_data */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_program (CL_API_CALL*clLinkProgram)(
+    cl_context           /* context */,
+    cl_uint              /* num_devices */,
+    const cl_device_id * /* device_list */,
+    const char *         /* options */,
+    cl_uint              /* num_input_programs */,
+    const cl_program *   /* input_programs */,
+    void (CL_CALLBACK *  /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+    void *               /* user_data */,
+    cl_int *             /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clUnloadPlatformCompiler)(
+    cl_platform_id /* platform */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clGetKernelArgInfo)(
+    cl_kernel       /* kernel */,
+    cl_uint         /* arg_indx */,
+    cl_kernel_arg_info  /* param_name */,
+    size_t          /* param_value_size */,
+    void *          /* param_value */,
+    size_t *        /* param_value_size_ret */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueFillBuffer)(
+    cl_command_queue   /* command_queue */,
+    cl_mem             /* buffer */,
+    const void *       /* pattern */,
+    size_t             /* pattern_size */,
+    size_t             /* offset */,
+    size_t             /* size */,
+    cl_uint            /* num_events_in_wait_list */,
+    const cl_event *   /* event_wait_list */,
+    cl_event *         /* event */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueFillImage)(
+    cl_command_queue   /* command_queue */,
+    cl_mem             /* image */,
+    const void *       /* fill_color */,
+    const size_t *     /* origin[3] */,
+    const size_t *     /* region[3] */,
+    cl_uint            /* num_events_in_wait_list */,
+    const cl_event *   /* event_wait_list */,
+    cl_event *         /* event */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueMigrateMemObjects)(
+    cl_command_queue       /* command_queue */,
+    cl_uint                /* num_mem_objects */,
+    const cl_mem *         /* mem_objects */,
+    cl_mem_migration_flags /* flags */,
+    cl_uint                /* num_events_in_wait_list */,
+    const cl_event *       /* event_wait_list */,
+    cl_event *             /* event */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueMarkerWithWaitList)(
+    cl_command_queue /* command_queue */,
+    cl_uint           /* num_events_in_wait_list */,
+    const cl_event *  /* event_wait_list */,
+    cl_event *        /* event */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL*clEnqueueBarrierWithWaitList)(
+    cl_command_queue /* command_queue */,
+    cl_uint           /* num_events_in_wait_list */,
+    const cl_event *  /* event_wait_list */,
+    cl_event *        /* event */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY void * (CL_API_CALL*
+  clGetExtensionFunctionAddressForPlatform)(
+    cl_platform_id /* platform */,
+    const char *   /* func_name */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_mem (CL_API_CALL*clCreateFromGLTexture)(
+    cl_context      /* context */,
+    cl_mem_flags    /* flags */,
+    cl_GLenum       /* target */,
+    cl_GLint        /* miplevel */,
+    cl_GLuint       /* texture */,
+    cl_int *        /* errcode_ret */
+  ) CL_API_SUFFIX__VERSION_1_2;
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown109)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown110)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown111)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown112)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown113)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown114)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown115)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown116)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown117)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown118)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown119)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown120)(
+    void);
+
+  CL_API_ENTRY cl_int (CL_API_CALL* clUnknown121)(
+    void);
+
+};
+

+ 133 - 4
socl/src/socl.c

@@ -1,6 +1,8 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
+ * Copyright (C) 2012 Vincent Danjean <Vincent.Danjean@ens-lyon.org>
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -16,13 +18,140 @@
 
 #include "socl.h"
 
-struct _cl_platform_id socl_platform = {};
+struct _cl_icd_dispatch socl_master_dispatch = {
+  soclGetPlatformIDs,
+  soclGetPlatformInfo,
+  soclGetDeviceIDs,
+  soclGetDeviceInfo,
+  soclCreateContext,
+  soclCreateContextFromType,
+  soclRetainContext,
+  soclReleaseContext,
+  soclGetContextInfo,
+  soclCreateCommandQueue,
+  soclRetainCommandQueue,
+  soclReleaseCommandQueue,
+  soclGetCommandQueueInfo,
+  soclSetCommandQueueProperty,
+  soclCreateBuffer,
+  soclCreateImage2D,
+  soclCreateImage3D,
+  soclRetainMemObject,
+  soclReleaseMemObject,
+  soclGetSupportedImageFormats,
+  soclGetMemObjectInfo,
+  soclGetImageInfo,
+  soclCreateSampler,
+  soclRetainSampler,
+  soclReleaseSampler,
+  soclGetSamplerInfo,
+  soclCreateProgramWithSource,
+  soclCreateProgramWithBinary,
+  soclRetainProgram,
+  soclReleaseProgram,
+  soclBuildProgram,
+  soclUnloadCompiler,
+  soclGetProgramInfo,
+  soclGetProgramBuildInfo,
+  soclCreateKernel,
+  soclCreateKernelsInProgram,
+  soclRetainKernel,
+  soclReleaseKernel,
+  soclSetKernelArg,
+  soclGetKernelInfo,
+  soclGetKernelWorkGroupInfo,
+  soclWaitForEvents,
+  soclGetEventInfo,
+  soclRetainEvent,
+  soclReleaseEvent,
+  soclGetEventProfilingInfo,
+  soclFlush,
+  soclFinish,
+  soclEnqueueReadBuffer,
+  soclEnqueueWriteBuffer,
+  soclEnqueueCopyBuffer,
+  soclEnqueueReadImage,
+  soclEnqueueWriteImage,
+  soclEnqueueCopyImage,
+  soclEnqueueCopyImageToBuffer,
+  soclEnqueueCopyBufferToImage,
+  soclEnqueueMapBuffer,
+  soclEnqueueMapImage,
+  soclEnqueueUnmapMemObject,
+  soclEnqueueNDRangeKernel,
+  soclEnqueueTask,
+  soclEnqueueNativeKernel,
+  soclEnqueueMarker,
+  soclEnqueueWaitForEvents,
+  soclEnqueueBarrier,
+  soclGetExtensionFunctionAddress,
+  (void *) NULL, //  clCreateFromGLBuffer,
+  (void *) NULL, //  clCreateFromGLTexture2D,
+  (void *) NULL, //  clCreateFromGLTexture3D,
+  (void *) NULL, //  clCreateFromGLRenderbuffer,
+  (void *) NULL, //  clGetGLObjectInfo,
+  (void *) NULL, //  clGetGLTextureInfo,
+  (void *) NULL, //  clEnqueueAcquireGLObjects,
+  (void *) NULL, //  clEnqueueReleaseGLObjects,
+  (void *) NULL, //  clGetGLContextInfoKHR,
+  (void *) NULL, //
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL, //  clSetEventCallback,
+  (void *) NULL, //  clCreateSubBuffer,
+  (void *) NULL, //  clSetMemObjectDestructorCallback,
+  (void *) NULL, //  clCreateUserEvent,
+  (void *) NULL, //  clSetUserEventStatus,
+  (void *) NULL, //  clEnqueueReadBufferRect,
+  (void *) NULL, //  clEnqueueWriteBufferRect,
+  (void *) NULL, //  clEnqueueCopyBufferRect,
+  (void *) NULL, //  clCreateSubDevicesEXT,
+  (void *) NULL, //  clRetainDeviceEXT,
+  (void *) NULL, //  clReleaseDeviceEXT,
+  (void *) NULL,
+  (void *) NULL, //  clCreateSubDevices,
+  (void *) NULL, //  clRetainDevice,
+  (void *) NULL, //  clReleaseDevice,
+  (void *) NULL, //  clCreateImage,
+  (void *) NULL, //  clCreateProgramWithBuiltInKernels,
+  (void *) NULL, //  clCompileProgram,
+  (void *) NULL, //  clLinkProgram,
+  (void *) NULL, //  clUnloadPlatformCompiler,
+  (void *) NULL, //  clGetKernelArgInfo,
+  (void *) NULL, //  clEnqueueFillBuffer,
+  (void *) NULL, //  clEnqueueFillImage,
+  (void *) NULL, //  clEnqueueMigrateMemObjects,
+  (void *) NULL, //  clEnqueueMarkerWithWaitList,
+  (void *) NULL, //  clEnqueueBarrierWithWaitList,
+  (void *) NULL, //  clGetExtensionFunctionAddressForPlatform,
+  (void *) NULL, //  clCreateFromGLTexture,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL,
+  (void *) NULL
+};
 
-const char * __attribute__ ((aligned (16))) SOCL_PROFILE = "FULL_PROFILE" ;
+
+struct _cl_platform_id socl_platform = {&socl_master_dispatch};
+
+const char * __attribute__ ((aligned (16))) SOCL_PROFILE = "FULL_PROFILE";
 const char * __attribute__ ((aligned (16))) SOCL_VERSION = "OpenCL 1.0 StarPU Edition (0.0.1)";
 const char * __attribute__ ((aligned (16))) SOCL_PLATFORM_NAME    = "StarPU Platform";
 const char * __attribute__ ((aligned (16))) SOCL_VENDOR  = "INRIA";
-const char * __attribute__ ((aligned (16))) SOCL_PLATFORM_EXTENSIONS = "";
+const char * __attribute__ ((aligned (16))) SOCL_PLATFORM_EXTENSIONS = "cl_khr_icd";
+const char * __attribute__ ((aligned (16))) SOCL_PLATFORM_ICD_SUFFIX_KHR ="SOCL";
 
 
 /* Command queues with profiling enabled

+ 18 - 4
socl/src/socl.h

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011 University of Bordeaux
+ * Copyright (C) 2010-2012 University of Bordeaux
+ * Copyright (C) 2012 CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -24,13 +25,16 @@
 #endif
 
 /* Additional command type */
-#define CL_COMMAND_BARRIER 0x99987
+#ifndef CL_COMMAND_BARRIER
+#define CL_COMMAND_BARRIER 0x1205
+#endif
 
 #include <string.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <unistd.h>
 #include <pthread.h>
+#include "ocl_icd.h"
 
 #include <starpu.h>
 #include <starpu_opencl.h>
@@ -66,6 +70,7 @@ typedef struct entity * entity;
 
 
 struct entity {
+  struct _cl_icd_dispatch * dispatch;
   /* Reference count */
   size_t refs;
 
@@ -81,7 +86,8 @@ struct entity {
  * this macro as their first field */
 #define CL_ENTITY struct entity _entity;
 
-struct _cl_platform_id {};
+
+struct _cl_platform_id {struct _cl_icd_dispatch *dispatch;};
 
 #define RETURN_EVENT(cmd, event) \
 	if (event != NULL) { \
@@ -109,12 +115,12 @@ struct _cl_platform_id {};
 	}
 
 /* Constants */
-struct _cl_platform_id socl_platform;
 const char * SOCL_PROFILE;
 const char * SOCL_VERSION;
 const char * SOCL_PLATFORM_NAME;
 const char * SOCL_VENDOR;
 const char * SOCL_PLATFORM_EXTENSIONS;
+const char * SOCL_PLATFORM_ICD_SUFFIX_KHR;
 
 struct _cl_context {
   CL_ENTITY;
@@ -746,4 +752,12 @@ soclEnqueueBarrier(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_
 extern CL_API_ENTRY void * CL_API_CALL
 soclGetExtensionFunctionAddress(const char * /* func_name */) CL_API_SUFFIX__VERSION_1_0;
 
+extern CL_API_ENTRY cl_int CL_API_CALL
+soclIcdGetPlatformIDsKHR(cl_uint          /* num_entries */,
+                 cl_platform_id * /* platforms */,
+                 cl_uint *        /* num_platforms */) CL_EXT_SUFFIX__VERSION_1_0;
+
+
+struct _cl_icd_dispatch socl_master_dispatch;
+struct _cl_platform_id socl_platform;
 #endif /* SOCL_H */

+ 4 - 0
src/drivers/opencl/driver_opencl.c

@@ -350,6 +350,10 @@ void _starpu_opencl_init(void)
 						platform_valid = 0;
 					}
 				}
+				if(strcmp(name, "StarPU Platform") == 0) {
+					platform_valid = 0;
+					_STARPU_DEBUG("Skipping StarPU's SOCL Platform\n");
+				}
 #ifdef STARPU_VERBOSE
 				if (platform_valid)
 					_STARPU_DEBUG("Platform: %s - %s\n", name, vendor);