summaryrefslogtreecommitdiff
path: root/src/cl_api_platform_id.c
blob: 10d88947a3954ab2f4fee1e4231e6a0a6ea392fb (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
/*
 * 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_platform_id.h"
#include "CL/cl_ext.h"

cl_int
clGetPlatformInfo(cl_platform_id platform,
                  cl_platform_info param_name,
                  size_t param_value_size,
                  void *param_value,
                  size_t *param_value_size_ret)
{
  const void *src_ptr = NULL;
  size_t src_size = 0;

  if (!CL_OBJECT_IS_PLATFORM(platform)) {
    return CL_INVALID_PLATFORM;
  }

  /* Only one platform now. */
  if (platform != cl_get_platform_default()) {
    return CL_INVALID_PLATFORM;
  }

  if (param_name == CL_PLATFORM_PROFILE) {
    src_ptr = platform->profile;
    src_size = platform->profile_sz;
  } else if (param_name == CL_PLATFORM_VERSION) {
    src_ptr = platform->version;
    src_size = platform->version_sz;
  } else if (param_name == CL_PLATFORM_NAME) {
    src_ptr = platform->name;
    src_size = platform->name_sz;
  } else if (param_name == CL_PLATFORM_VENDOR) {
    src_ptr = platform->vendor;
    src_size = platform->vendor_sz;
  } else if (param_name == CL_PLATFORM_EXTENSIONS) {
    src_ptr = platform->extensions;
    src_size = platform->extensions_sz;
  } else if (param_name == CL_PLATFORM_ICD_SUFFIX_KHR) {
    src_ptr = platform->icd_suffix_khr;
    src_size = platform->icd_suffix_khr_sz;
  } else {
    return CL_INVALID_VALUE;
  }

  return cl_get_info_helper(src_ptr, src_size,
                            param_value, param_value_size, param_value_size_ret);
}