summaryrefslogtreecommitdiff
path: root/src/cl_api_device_id.c
blob: 4ffef78505fd76b3426c342b2a0b63e79861ff4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * Copyright © 2012 Intel Corporation
 *
 * This library 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.
 *
 * This library 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 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "cl_device_id.h"
#include "cl_platform_id.h"

cl_int
clGetDeviceIDs(cl_platform_id platform,
               cl_device_type device_type,
               cl_uint num_entries,
               cl_device_id *devices,
               cl_uint *num_devices)
{
  const cl_device_type valid_type = CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_CPU |
                                    CL_DEVICE_TYPE_ACCELERATOR | CL_DEVICE_TYPE_DEFAULT |
                                    CL_DEVICE_TYPE_CUSTOM;

  /* Check parameter consistency */
  if (UNLIKELY(devices == NULL && num_devices == NULL))
    return CL_INVALID_VALUE;
  if (UNLIKELY(platform && platform != cl_get_platform_default()))
    return CL_INVALID_PLATFORM;
  if (UNLIKELY(devices && num_entries == 0))
    return CL_INVALID_VALUE;
  if ((device_type & valid_type) == 0)
    return CL_INVALID_DEVICE_TYPE;

  return cl_get_device_ids(platform, device_type, num_entries, devices, num_devices);
}

cl_int
clGetDeviceInfo(cl_device_id device,
                cl_device_info param_name,
                size_t param_value_size,
                void *param_value,
                size_t *param_value_size_ret)
{
  if (!CL_OBJECT_IS_DEVICE(device)) {
    return CL_INVALID_DEVICE;
  }

  return cl_get_device_info(device, param_name, param_value_size,
                            param_value, param_value_size_ret);
}

cl_int
clRetainDevice(cl_device_id device)
{
  // XXX stub for C++ Bindings
  return CL_SUCCESS;
}

cl_int
clReleaseDevice(cl_device_id device)
{
  // XXX stub for C++ Bindings
  return CL_SUCCESS;
}

cl_int
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)
{
  /* Check parameter consistency */
  if (UNLIKELY(out_devices == NULL && num_devices_ret == NULL))
    return CL_INVALID_VALUE;
  if (UNLIKELY(in_device == NULL && properties == NULL))
    return CL_INVALID_VALUE;

  *num_devices_ret = 0;
  return CL_INVALID_DEVICE_PARTITION_COUNT;
}