From: Junyan He <junyan...@intel.com>

Signed-off-by: Junyan He <junyan...@intel.com>
---
 runtime/cl_api_platform_id.c | 101 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)
 create mode 100644 runtime/cl_api_platform_id.c

diff --git a/runtime/cl_api_platform_id.c b/runtime/cl_api_platform_id.c
new file mode 100644
index 0000000..441d40c
--- /dev/null
+++ b/runtime/cl_api_platform_id.c
@@ -0,0 +1,101 @@
+/*
+ * 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);
+}
+
+cl_int
+clGetPlatformIDs(cl_uint num_entries,
+                 cl_platform_id *platforms,
+                 cl_uint *num_platforms)
+{
+  if (platforms == NULL && num_platforms == NULL)
+    return CL_INVALID_VALUE;
+
+  if (num_entries == 0 && platforms != NULL)
+    return CL_INVALID_VALUE;
+
+  return cl_platform_get_ids(num_entries, platforms, num_platforms);
+}
+
+cl_int
+clUnloadCompiler(void)
+{
+  return CL_SUCCESS;
+}
+
+cl_int
+clUnloadPlatformCompiler(cl_platform_id platform)
+{
+  return CL_SUCCESS;
+}
+
+void *
+clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,
+                                         const char *func_name)
+{
+  if (platform != NULL && platform != cl_get_platform_default())
+    return NULL;
+
+  return cl_platform_get_extension_function_address(func_name);
+}
-- 
2.7.4



_______________________________________________
Beignet mailing list
Beignet@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to