Bladeren bron

SOCL: deletion of the virtual device

SOCL does not return a virtual device anymore. Instead, command queues created with `device` set to NULL are used to submit commands that may be executed by any device of the command queue context.

Currently, any device (not only those contained in the context) may be used by StarPU. This will have to be modified once Andra's scheduling contexts will be ready for production code ;-)
Sylvain Henry 12 jaren geleden
bovenliggende
commit
60c61b498a

+ 3 - 3
socl/examples/basic/basic.c

@@ -81,7 +81,7 @@ int main(int UNUSED(argc), char** UNUSED(argv)) {
    printf("Querying devices...\n");
    unsigned int platform_idx;
    for (platform_idx=0; platform_idx<num_platforms; platform_idx++) {
-      err = clGetDeviceIDs(platforms[platform_idx], CL_DEVICE_TYPE_ACCELERATOR, sizeof(devices)/sizeof(cl_device_id), devices, &num_devices);
+      err = clGetDeviceIDs(platforms[platform_idx], CL_DEVICE_TYPE_ALL, sizeof(devices)/sizeof(cl_device_id), devices, &num_devices);
       check(err, "clGetDeviceIDs");
       if (num_devices != 0)
          break;
@@ -120,9 +120,9 @@ int main(int UNUSED(argc), char** UNUSED(argv)) {
    cl_event eventW1, eventW2, eventK, eventR;
 
 #ifdef PROFILING
-   cq = clCreateCommandQueue(context, devices[0], CL_QUEUE_PROFILING_ENABLE, &err);
+   cq = clCreateCommandQueue(context, NULL, CL_QUEUE_PROFILING_ENABLE, &err);
 #else
-   cq = clCreateCommandQueue(context, devices[0], 0, &err);
+   cq = clCreateCommandQueue(context, NULL, 0, &err);
 #endif
    check(err, "clCreateCommandQueue");
 

+ 0 - 2
socl/src/Makefile.am

@@ -28,7 +28,6 @@ noinst_HEADERS =				\
   command_list.h				\
   command_queue.h				\
   debug.h					\
-  devices.h					\
   event.h					\
   gc.h						\
   getinfo.h					\
@@ -56,7 +55,6 @@ libsocl_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 						\
   command_list.c \
   command_queue.c \
   debug.c \
-  devices.c \
   event.c \
   gc.c \
   init.c \

+ 1 - 1
socl/src/cl_enqueuecopybuffer.c

@@ -85,7 +85,7 @@ cl_int command_copy_buffer_submit(command_copy_buffer cmd) {
 	task->cl = &codelet_copybuffer;
 
 	/* Execute the task on a specific worker? */
-	if (cmd->_command.cq->device != &socl_virtual_device) {
+	if (cmd->_command.cq->device != NULL) {
 	  task->execute_on_a_specific_worker = 1;
 	  task->workerid = (int)(intptr_t)cmd->_command.cq->device;
 	}

+ 1 - 1
socl/src/cl_enqueuendrangekernel.c

@@ -128,7 +128,7 @@ cl_int command_ndrange_kernel_submit(command_ndrange_kernel cmd) {
 	task->cl_arg_size = sizeof(cmd);
 
 	/* Execute the task on a specific worker? */
-	if (cmd->_command.cq->device != &socl_virtual_device) {
+	if (cmd->_command.cq->device != NULL) {
 	  task->execute_on_a_specific_worker = 1;
 	  task->workerid = (int)(intptr_t)cmd->_command.cq->device;
 	}

+ 1 - 1
socl/src/cl_enqueuereadbuffer.c

@@ -83,7 +83,7 @@ cl_int command_read_buffer_submit(command_read_buffer cmd) {
 	task->cl = &codelet_readbuffer;
 
 	/* Execute the task on a specific worker? */
-	if (cmd->_command.cq->device != &socl_virtual_device) {
+	if (cmd->_command.cq->device != NULL) {
 	  task->execute_on_a_specific_worker = 1;
 	  task->workerid = (int)(intptr_t)cmd->_command.cq->device;
 	}

+ 1 - 1
socl/src/cl_enqueuewritebuffer.c

@@ -105,7 +105,7 @@ cl_int command_write_buffer_submit(command_write_buffer cmd) {
 	task->cl_arg_size = sizeof(struct arg_writebuffer);
 
 	/* Execute the task on a specific worker? */
-	if (cmd->_command.cq->device != &socl_virtual_device) {
+	if (cmd->_command.cq->device != NULL) {
 	  task->execute_on_a_specific_worker = 1;
 	  task->workerid = (int)(intptr_t)cmd->_command.cq->device;
 	}

+ 1 - 6
socl/src/cl_getdeviceids.c

@@ -50,18 +50,13 @@ soclGetDeviceIDs(cl_platform_id   platform,
       && (device_type != CL_DEVICE_TYPE_ALL))
       return CL_INVALID_DEVICE_TYPE;
 
-   unsigned int num = 0;
-   if (socl_virtual_device.type & device_type) {
-      if (devices != NULL && num < num_entries) devices[num] = (cl_device_id)&socl_virtual_device;
-      num++;
-   }
-
    int ndevs = starpu_worker_get_count_by_type(STARPU_OPENCL_WORKER);
 
    int workers[ndevs];
    starpu_worker_get_ids_by_type(STARPU_OPENCL_WORKER, workers, ndevs);
 
    int i;
+   unsigned int num = 0;
    for (i=0; i < ndevs; i++) {
       int devid = starpu_worker_get_devid(workers[i]);
       cl_device_id dev;

+ 7 - 58
socl/src/cl_getdeviceinfo.c

@@ -30,63 +30,12 @@ soclGetDeviceInfo(cl_device_id    device,
    /* if (device != &socl_virtual_device && device is not a valid StarPU worker identifier)
       return CL_INVALID_DEVICE;*/
 
-   if (device == &socl_virtual_device) {
-      switch (param_name) {
-         INFO_CASE(CL_DEVICE_TYPE, device->type)
-         INFO_CASE(CL_DEVICE_VENDOR_ID, SOCL_DEVICE_VENDOR_ID)
-         INFO_CASE(CL_DEVICE_MAX_COMPUTE_UNITS, device->max_compute_units)
-         INFO_CASE(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, device->max_work_item_dimensions)
-         INFO_CASE(CL_DEVICE_MAX_WORK_ITEM_SIZES, device->max_work_item_sizes)
-         INFO_CASE(CL_DEVICE_MAX_WORK_GROUP_SIZE, device->max_work_group_size)
-         INFO_CASE(CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, device->preferred_vector_widths[0])
-         INFO_CASE(CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, device->preferred_vector_widths[1])
-         INFO_CASE(CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, device->preferred_vector_widths[2])
-         INFO_CASE(CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, device->preferred_vector_widths[3])
-         INFO_CASE(CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, device->preferred_vector_widths[4])
-         INFO_CASE(CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, device->preferred_vector_widths[5])
-         INFO_CASE(CL_DEVICE_MAX_CLOCK_FREQUENCY, device->max_clock_frequency)
-         INFO_CASE(CL_DEVICE_ADDRESS_BITS, device->address_bits)
-         INFO_CASE(CL_DEVICE_MAX_MEM_ALLOC_SIZE, device->max_mem_alloc_size)
-         INFO_CASE(CL_DEVICE_IMAGE_SUPPORT, device->image_support)
-         INFO_CASE(CL_DEVICE_MAX_PARAMETER_SIZE, device->max_parameter_size)
-         INFO_CASE(CL_DEVICE_MEM_BASE_ADDR_ALIGN, device->mem_base_addr_align)
-         INFO_CASE(CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, device->min_data_type_align_size)
-         INFO_CASE(CL_DEVICE_SINGLE_FP_CONFIG, device->single_fp_config)
-         INFO_CASE(CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, device->global_mem_cache_type)
-         INFO_CASE(CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, device->global_mem_cacheline_size)
-         INFO_CASE(CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, device->global_mem_cache_size)
-         INFO_CASE(CL_DEVICE_GLOBAL_MEM_SIZE, device->global_mem_size)
-         INFO_CASE(CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, device->max_constant_buffer_size)
-         INFO_CASE(CL_DEVICE_MAX_CONSTANT_ARGS, device->max_constant_args)
-         INFO_CASE(CL_DEVICE_LOCAL_MEM_TYPE, device->local_mem_type)
-         INFO_CASE(CL_DEVICE_LOCAL_MEM_SIZE, device->local_mem_size)
-         INFO_CASE(CL_DEVICE_ERROR_CORRECTION_SUPPORT, device->error_correction_support)
-         INFO_CASE(CL_DEVICE_PROFILING_TIMER_RESOLUTION, device->profiling_timer_resolution)
-         INFO_CASE(CL_DEVICE_ENDIAN_LITTLE, device->endian_little)
-         INFO_CASE(CL_DEVICE_AVAILABLE, device->available)
-         INFO_CASE(CL_DEVICE_COMPILER_AVAILABLE, device->compiler_available)
-         INFO_CASE(CL_DEVICE_EXECUTION_CAPABILITIES, device->execution_capabilities)
-         INFO_CASE(CL_DEVICE_QUEUE_PROPERTIES, device->queue_properties)
-         case CL_DEVICE_PLATFORM: {
-                                  cl_platform_id p = &socl_platform;
-                                  INFO_CASE_EX2(p);
-                               }
-         INFO_CASE_STRING(CL_DEVICE_NAME, device->name)
-         INFO_CASE_STRING(CL_DEVICE_VENDOR, SOCL_VENDOR)
-         INFO_CASE_STRING(CL_DRIVER_VERSION, SOCL_DRIVER_VERSION)
-         INFO_CASE_STRING(CL_DEVICE_PROFILE, SOCL_PROFILE)
-         INFO_CASE_STRING(CL_DEVICE_VERSION, SOCL_VERSION)
-         INFO_CASE_STRING(CL_DEVICE_EXTENSIONS, device->extensions)
-         default:
-            return CL_INVALID_VALUE;
-      }
-   }
-   else {
-      int devid = starpu_worker_get_devid((int)(intptr_t)device);
-      cl_device_id dev;
-      starpu_opencl_get_device(devid, &dev);
-      return clGetDeviceInfo(dev, param_name, param_value_size, param_value, param_value_size_ret);
-   }
+  int devid = starpu_worker_get_devid((int)(intptr_t)device);
+  cl_device_id dev;
+  
+  starpu_opencl_get_device(devid, &dev);
+  int ret = clGetDeviceInfo(dev, param_name, param_value_size, param_value, param_value_size_ret);
+
+  return ret;
 
-   return CL_SUCCESS;
 }

+ 0 - 59
socl/src/devices.c

@@ -1,59 +0,0 @@
-/* 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"
-#include "devices.h"
-
-// OpenCL 1.0 : Mandatory format: major_number.minor_number
-const char * __attribute__ ((aligned (16))) SOCL_DRIVER_VERSION = "0.1";
-
-const cl_uint __attribute__ ((aligned (16))) SOCL_DEVICE_VENDOR_ID = 666;
-
-const struct _cl_device_id socl_virtual_device = {
-   .dispatch = &socl_master_dispatch,
-   .type = CL_DEVICE_TYPE_ACCELERATOR,
-   .max_compute_units = 1,
-   .max_work_item_dimensions = 3,
-   .max_work_item_sizes = {1,1,1},
-   .max_work_group_size = 1,
-   .preferred_vector_widths = {16,8,4,2,4,2},
-   .max_clock_frequency = 3000,
-   .address_bits = 64,
-   .max_mem_alloc_size = 1024*1024*1024,
-   .image_support = CL_FALSE,
-   .max_parameter_size = 256,
-   .mem_base_addr_align = 0,
-   .min_data_type_align_size = 0,
-   .single_fp_config = CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN,
-   .global_mem_cache_type = CL_READ_WRITE_CACHE,
-   .global_mem_cacheline_size = 128,
-   .global_mem_cache_size = 16*1024,
-   .global_mem_size = (cl_ulong)4*1024*1024*1024,
-   .max_constant_args = 8,
-   .local_mem_type = CL_GLOBAL,
-   .local_mem_size = 16*1024,
-   .error_correction_support = CL_FALSE,
-   .profiling_timer_resolution = 100,
-   .endian_little = CL_TRUE,
-   .available = CL_TRUE,
-   .compiler_available = CL_TRUE,
-   .execution_capabilities = CL_EXEC_KERNEL,
-   .queue_properties = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_PROFILING_ENABLE,
-   .name = "SOCL Virtual Device",
-   .extensions = ""
-};

+ 0 - 65
socl/src/devices.h

@@ -1,65 +0,0 @@
-/* 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.
- */
-
-#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
-   size_t            max_work_item_sizes[3];   //array size should be set accordingly to the maximum max_work_item_dimensions
-   size_t            max_work_group_size;      //OpenCL 1.0: minimum value is 1
-   cl_uint           preferred_vector_widths[6]; //Char, Short, Int, Long, Float, Double
-   cl_uint           max_clock_frequency;
-   cl_uint           address_bits;             //OpenCL 1.0: 32 or 64
-   cl_ulong          max_mem_alloc_size;       //OpenCL 1.0: minimum value is max(CL_DEVICE_GLOBAL_MEM_SIZE/4, 128*1024*1024)
-   cl_bool           image_support;
-   //image fields not present
-   size_t            max_parameter_size;       //OpenCL 1.0: minimum is 256
-   cl_uint           mem_base_addr_align;
-   cl_uint           min_data_type_align_size;
-   cl_device_fp_config single_fp_config;       //OpenCL 1.0: CL_FP_ROUND_TO_NEAREST and CL_FP_INF_NAN are mandatory
-   cl_device_mem_cache_type global_mem_cache_type;
-   cl_uint           global_mem_cacheline_size;
-   cl_ulong          global_mem_cache_size;
-   cl_ulong          global_mem_size;
-   cl_ulong          max_constant_buffer_size; //OpenCL 1.0: minimum value is 64KB
-   cl_uint           max_constant_args;        //OpenCL 1.0: minimum value is 8
-   cl_device_local_mem_type local_mem_type;
-   cl_ulong          local_mem_size;           //OpenCL 1.0: minimum value is 16KB
-   cl_bool           error_correction_support;
-   size_t            profiling_timer_resolution;
-   cl_bool           endian_little;
-   cl_bool           available;
-   cl_bool           compiler_available;       //OpenCL 1.0: mandatory for FULL_PROFILE platforms
-   cl_device_exec_capabilities execution_capabilities; //OpenCL 1.0: CL_EXEC_KERNEL is mandatory
-   cl_command_queue_properties queue_properties; //OpenCL 1.0: CL_QUEUE_PROFILING_ENABLE is mandatory
-   char              name[40];                 //Array size has been arbitrarily defined
-   //versions, profile and vendor are statically defined for all devices
-   char              extensions[100];          //Array size has been arbitrarily defined
-};
-
-const struct _cl_device_id socl_virtual_device;
-
-#endif /* SOCL_DEVICES_H */

+ 0 - 1
socl/src/socl.h

@@ -51,7 +51,6 @@ typedef struct entity * entity;
 #include "command_list.h"
 #include "command_queue.h"
 #include "debug.h"
-#include "devices.h"
 #include "event.h"
 #include "gc.h"
 #include "mem_objects.h"