Merge lp:~schnetter/pocl/pocl into lp:~pocl/pocl/trunk

Proposed by Erik Schnetter
Status: Merged
Merged at revision: 344
Proposed branch: lp:~schnetter/pocl/pocl
Merge into: lp:~pocl/pocl/trunk
Diff against target: 191 lines (+134/-16)
4 files modified
lib/CL/clCreateBuffer.c (+1/-0)
lib/CL/clCreateImage2D.c (+1/-0)
lib/CL/clGetKernelInfo.c (+71/-7)
lib/CL/clGetMemObjectInfo.c (+61/-9)
To merge this branch: bzr merge lp:~schnetter/pocl/pocl
Reviewer Review Type Date Requested Status
pocl maintaners Pending
Review via email: mp+120489@code.launchpad.net

Description of the change

I implemented clGetMemObjectInfo and clGetKernelInfo.

To post a comment you must log in.
Revision history for this message
Erik Schnetter (schnetter) wrote :

Please review version 349 instead of 348.

lp:~schnetter/pocl/pocl updated
341. By Pekka Jääskeläinen

Forgot to add the 'workgroup' to the subdirs.

342. By Kalle Raiskila

Add support for compiling against LLVM3.2

343. By Pekka Jääskeläinen

Fix TCE device build (missing includes).
Link pocl-llvm-ld against the LLVM dynlib as --libs returns static
libs which are not always built with LLVM.

344. By Pekka Jääskeläinen

Merged clGetMemObjectInfo and clGetKernelInfo work from Erik's branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/CL/clCreateBuffer.c'
2--- lib/CL/clCreateBuffer.c 2012-05-25 16:05:51 +0000
3+++ lib/CL/clCreateBuffer.c 2012-08-21 01:51:22 +0000
4@@ -48,6 +48,7 @@
5 mem->parent = NULL;
6 mem->map_count = 0;
7 mem->mappings = NULL;
8+ mem->type = CL_MEM_OBJECT_BUFFER;
9 mem->flags = flags;
10 mem->is_image = CL_FALSE;
11 POCL_INIT_ICD_OBJECT(mem);
12
13=== modified file 'lib/CL/clCreateImage2D.c'
14--- lib/CL/clCreateImage2D.c 2012-05-25 17:10:55 +0000
15+++ lib/CL/clCreateImage2D.c 2012-08-21 01:51:22 +0000
16@@ -30,6 +30,7 @@
17 mem->parent = NULL;
18 mem->map_count = 0;
19 mem->mappings = NULL;
20+ mem->type = CL_MEM_OBJECT_IMAGE2D;
21 mem->flags = flags;
22 mem->is_image = CL_TRUE;
23
24
25=== modified file 'lib/CL/clGetKernelInfo.c'
26--- lib/CL/clGetKernelInfo.c 2012-05-22 21:26:29 +0000
27+++ lib/CL/clGetKernelInfo.c 2012-08-21 01:51:22 +0000
28@@ -1,12 +1,76 @@
29+/* OpenCL runtime library: clGetDeviceInfo()
30+
31+ Copyright (c) 2012 Erik Schnetter
32+
33+ Permission is hereby granted, free of charge, to any person obtaining a copy
34+ of this software and associated documentation files (the "Software"), to deal
35+ in the Software without restriction, including without limitation the rights
36+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37+ copies of the Software, and to permit persons to whom the Software is
38+ furnished to do so, subject to the following conditions:
39+
40+ The above copyright notice and this permission notice shall be included in
41+ all copies or substantial portions of the Software.
42+
43+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
49+ THE SOFTWARE.
50+*/
51+
52 #include "pocl_cl.h"
53+#include <string.h>
54+
55+
56+
57+#define POCL_RETURN_KERNEL_INFO(__TYPE__, __VALUE__) \
58+ { \
59+ size_t const value_size = sizeof(__TYPE__); \
60+ if (param_value) { \
61+ if (param_value_size < value_size) return CL_INVALID_VALUE; \
62+ *(__TYPE__*)param_value = __VALUE__; \
63+ } \
64+ if (param_value_size_ret) \
65+ *param_value_size_ret = value_size; \
66+ return CL_SUCCESS; \
67+ }
68+
69+#define POCL_RETURN_KERNEL_INFO_STR(__STR__) \
70+ { \
71+ size_t const value_size = strlen(__STR__) + 1; \
72+ if (param_value) { \
73+ if (param_value_size < value_size) return CL_INVALID_VALUE; \
74+ memcpy(param_value, __STR__, value_size); \
75+ } \
76+ if (param_value_size_ret) \
77+ *param_value_size_ret = value_size; \
78+ return CL_SUCCESS; \
79+ } \
80+
81+
82+
83 CL_API_ENTRY cl_int CL_API_CALL
84-clGetKernelInfo(cl_kernel kernel ,
85- cl_kernel_info param_name ,
86- size_t param_value_size ,
87- void * param_value ,
88- size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_0
89+clGetKernelInfo(cl_kernel kernel ,
90+ cl_kernel_info param_name ,
91+ size_t param_value_size ,
92+ void * param_value ,
93+ size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
94 {
95- POCL_ABORT_UNIMPLEMENTED();
96- return CL_SUCCESS;
97+ switch (param_name) {
98+ case CL_KERNEL_FUNCTION_NAME:
99+ POCL_RETURN_KERNEL_INFO_STR(kernel->name);
100+ case CL_KERNEL_NUM_ARGS:
101+ POCL_RETURN_KERNEL_INFO(cl_uint, kernel->num_args);
102+ case CL_KERNEL_REFERENCE_COUNT:
103+ POCL_RETURN_KERNEL_INFO(cl_uint, kernel->pocl_refcount);
104+ case CL_KERNEL_CONTEXT:
105+ POCL_RETURN_KERNEL_INFO(cl_context, kernel->context);
106+ case CL_KERNEL_PROGRAM:
107+ POCL_RETURN_KERNEL_INFO(cl_program, kernel->program);
108+ }
109+ return CL_INVALID_VALUE;
110 }
111
112
113=== modified file 'lib/CL/clGetMemObjectInfo.c'
114--- lib/CL/clGetMemObjectInfo.c 2012-05-22 21:26:29 +0000
115+++ lib/CL/clGetMemObjectInfo.c 2012-08-21 01:51:22 +0000
116@@ -1,14 +1,66 @@
117+/* OpenCL runtime library: clGetDeviceInfo()
118+
119+ Copyright (c) 2012 Erik Schnetter
120+
121+ Permission is hereby granted, free of charge, to any person obtaining a copy
122+ of this software and associated documentation files (the "Software"), to deal
123+ in the Software without restriction, including without limitation the rights
124+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
125+ copies of the Software, and to permit persons to whom the Software is
126+ furnished to do so, subject to the following conditions:
127+
128+ The above copyright notice and this permission notice shall be included in
129+ all copies or substantial portions of the Software.
130+
131+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
134+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
135+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
136+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
137+ THE SOFTWARE.
138+*/
139+
140 #include "pocl_cl.h"
141
142-
143+
144+
145+#define POCL_RETURN_MEM_INFO(__TYPE__, __VALUE__) \
146+ { \
147+ size_t const value_size = sizeof(__TYPE__); \
148+ if (param_value) { \
149+ if (param_value_size < value_size) return CL_INVALID_VALUE; \
150+ *(__TYPE__*)param_value = __VALUE__; \
151+ } \
152+ if (param_value_size_ret) \
153+ *param_value_size_ret = value_size; \
154+ return CL_SUCCESS; \
155+ }
156+
157+
158+
159 CL_API_ENTRY cl_int CL_API_CALL
160-clGetMemObjectInfo(cl_mem memobj ,
161- cl_mem_info param_name ,
162- size_t param_value_size ,
163- void * param_value ,
164- size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_0
165+clGetMemObjectInfo(cl_mem memobj ,
166+ cl_mem_info param_name ,
167+ size_t param_value_size ,
168+ void * param_value ,
169+ size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
170 {
171- POCL_ABORT_UNIMPLEMENTED();
172- return CL_SUCCESS;
173+ switch (param_name) {
174+ case CL_MEM_TYPE:
175+ POCL_RETURN_MEM_INFO(cl_mem_object_type, memobj->type);
176+ case CL_MEM_FLAGS:
177+ POCL_RETURN_MEM_INFO(cl_mem_flags, memobj->flags);
178+ case CL_MEM_SIZE:
179+ POCL_RETURN_MEM_INFO(size_t, memobj->size);
180+ case CL_MEM_HOST_PTR:
181+ POCL_RETURN_MEM_INFO(void *, memobj->mem_host_ptr);
182+ case CL_MEM_MAP_COUNT:
183+ POCL_RETURN_MEM_INFO(cl_uint, memobj->map_count);
184+ case CL_MEM_REFERENCE_COUNT:
185+ POCL_RETURN_MEM_INFO(cl_uint, memobj->pocl_refcount);
186+ case CL_MEM_CONTEXT:
187+ POCL_RETURN_MEM_INFO(cl_context, memobj->context);
188+ }
189+ return CL_INVALID_VALUE;
190 }
191-