Andreas Kloeckner <[email protected]> writes:
> Thanks for your quick response! Unfortunately, something must be off
> still, as CL_MEM_TYPE for what should be a buffer object gives
> 1071312404, i.e. what looks essentially like a random number. Which is
> not quite surprising, because clCreateBuffer doesn't set that
> entry... :)
Trivial patch attached to fix this. This makes at least PyOpenCL's
example/demo.py work.
Andreas
=== modified file 'lib/CL/clCreateBuffer.c'
--- lib/CL/clCreateBuffer.c 2012-05-25 16:05:51 +0000
+++ lib/CL/clCreateBuffer.c 2012-08-21 01:24:56 +0000
@@ -48,6 +48,7 @@
mem->parent = NULL;
mem->map_count = 0;
mem->mappings = NULL;
+ mem->type = CL_MEM_OBJECT_BUFFER;
mem->flags = flags;
mem->is_image = CL_FALSE;
POCL_INIT_ICD_OBJECT(mem);
=== modified file 'lib/CL/clCreateImage2D.c'
--- lib/CL/clCreateImage2D.c 2012-05-25 17:10:55 +0000
+++ lib/CL/clCreateImage2D.c 2012-08-21 01:25:36 +0000
@@ -30,6 +30,7 @@
mem->parent = NULL;
mem->map_count = 0;
mem->mappings = NULL;
+ mem->type = CL_MEM_OBJECT_IMAGE2D;
mem->flags = flags;
mem->is_image = CL_TRUE;
=== modified file 'lib/CL/clGetKernelInfo.c'
--- lib/CL/clGetKernelInfo.c 2012-05-22 21:26:29 +0000
+++ lib/CL/clGetKernelInfo.c 2012-08-21 01:12:01 +0000
@@ -1,12 +1,76 @@
+/* OpenCL runtime library: clGetDeviceInfo()
+
+ Copyright (c) 2012 Erik Schnetter
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
#include "pocl_cl.h"
+#include <string.h>
+
+
+
+#define POCL_RETURN_KERNEL_INFO(__TYPE__, __VALUE__) \
+ { \
+ size_t const value_size = sizeof(__TYPE__); \
+ if (param_value) { \
+ if (param_value_size < value_size) return CL_INVALID_VALUE; \
+ *(__TYPE__*)param_value = __VALUE__; \
+ } \
+ if (param_value_size_ret) \
+ *param_value_size_ret = value_size; \
+ return CL_SUCCESS; \
+ }
+
+#define POCL_RETURN_KERNEL_INFO_STR(__STR__) \
+ { \
+ size_t const value_size = strlen(__STR__) + 1; \
+ if (param_value) { \
+ if (param_value_size < value_size) return CL_INVALID_VALUE; \
+ memcpy(param_value, __STR__, value_size); \
+ } \
+ if (param_value_size_ret) \
+ *param_value_size_ret = value_size; \
+ return CL_SUCCESS; \
+ } \
+
+
+
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
+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
{
- POCL_ABORT_UNIMPLEMENTED();
- return CL_SUCCESS;
+ switch (param_name) {
+ case CL_KERNEL_FUNCTION_NAME:
+ POCL_RETURN_KERNEL_INFO_STR(kernel->name);
+ case CL_KERNEL_NUM_ARGS:
+ POCL_RETURN_KERNEL_INFO(cl_uint, kernel->num_args);
+ case CL_KERNEL_REFERENCE_COUNT:
+ POCL_RETURN_KERNEL_INFO(cl_uint, kernel->pocl_refcount);
+ case CL_KERNEL_CONTEXT:
+ POCL_RETURN_KERNEL_INFO(cl_context, kernel->context);
+ case CL_KERNEL_PROGRAM:
+ POCL_RETURN_KERNEL_INFO(cl_program, kernel->program);
+ }
+ return CL_INVALID_VALUE;
}
=== modified file 'lib/CL/clGetMemObjectInfo.c'
--- lib/CL/clGetMemObjectInfo.c 2012-05-22 21:26:29 +0000
+++ lib/CL/clGetMemObjectInfo.c 2012-08-21 01:12:01 +0000
@@ -1,14 +1,66 @@
+/* OpenCL runtime library: clGetDeviceInfo()
+
+ Copyright (c) 2012 Erik Schnetter
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+*/
+
#include "pocl_cl.h"
-
+
+
+#define POCL_RETURN_MEM_INFO(__TYPE__, __VALUE__) \
+ { \
+ size_t const value_size = sizeof(__TYPE__); \
+ if (param_value) { \
+ if (param_value_size < value_size) return CL_INVALID_VALUE; \
+ *(__TYPE__*)param_value = __VALUE__; \
+ } \
+ if (param_value_size_ret) \
+ *param_value_size_ret = value_size; \
+ return CL_SUCCESS; \
+ }
+
+
+
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
+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
{
- POCL_ABORT_UNIMPLEMENTED();
- return CL_SUCCESS;
+ switch (param_name) {
+ case CL_MEM_TYPE:
+ POCL_RETURN_MEM_INFO(cl_mem_object_type, memobj->type);
+ case CL_MEM_FLAGS:
+ POCL_RETURN_MEM_INFO(cl_mem_flags, memobj->flags);
+ case CL_MEM_SIZE:
+ POCL_RETURN_MEM_INFO(size_t, memobj->size);
+ case CL_MEM_HOST_PTR:
+ POCL_RETURN_MEM_INFO(void *, memobj->mem_host_ptr);
+ case CL_MEM_MAP_COUNT:
+ POCL_RETURN_MEM_INFO(cl_uint, memobj->map_count);
+ case CL_MEM_REFERENCE_COUNT:
+ POCL_RETURN_MEM_INFO(cl_uint, memobj->pocl_refcount);
+ case CL_MEM_CONTEXT:
+ POCL_RETURN_MEM_INFO(cl_context, memobj->context);
+ }
+ return CL_INVALID_VALUE;
}
-
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
pocl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pocl-devel