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
=== 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:51:22 +0000
@@ -48,6 +48,7 @@
48 mem->parent = NULL;48 mem->parent = NULL;
49 mem->map_count = 0;49 mem->map_count = 0;
50 mem->mappings = NULL;50 mem->mappings = NULL;
51 mem->type = CL_MEM_OBJECT_BUFFER;
51 mem->flags = flags;52 mem->flags = flags;
52 mem->is_image = CL_FALSE;53 mem->is_image = CL_FALSE;
53 POCL_INIT_ICD_OBJECT(mem);54 POCL_INIT_ICD_OBJECT(mem);
5455
=== 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:51:22 +0000
@@ -30,6 +30,7 @@
30 mem->parent = NULL;30 mem->parent = NULL;
31 mem->map_count = 0;31 mem->map_count = 0;
32 mem->mappings = NULL;32 mem->mappings = NULL;
33 mem->type = CL_MEM_OBJECT_IMAGE2D;
33 mem->flags = flags;34 mem->flags = flags;
34 mem->is_image = CL_TRUE;35 mem->is_image = CL_TRUE;
35 36
3637
=== 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:51:22 +0000
@@ -1,12 +1,76 @@
1/* OpenCL runtime library: clGetDeviceInfo()
2
3 Copyright (c) 2012 Erik Schnetter
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22*/
23
1#include "pocl_cl.h"24#include "pocl_cl.h"
25#include <string.h>
26
27
28
29#define POCL_RETURN_KERNEL_INFO(__TYPE__, __VALUE__) \
30 { \
31 size_t const value_size = sizeof(__TYPE__); \
32 if (param_value) { \
33 if (param_value_size < value_size) return CL_INVALID_VALUE; \
34 *(__TYPE__*)param_value = __VALUE__; \
35 } \
36 if (param_value_size_ret) \
37 *param_value_size_ret = value_size; \
38 return CL_SUCCESS; \
39 }
40
41#define POCL_RETURN_KERNEL_INFO_STR(__STR__) \
42 { \
43 size_t const value_size = strlen(__STR__) + 1; \
44 if (param_value) { \
45 if (param_value_size < value_size) return CL_INVALID_VALUE; \
46 memcpy(param_value, __STR__, value_size); \
47 } \
48 if (param_value_size_ret) \
49 *param_value_size_ret = value_size; \
50 return CL_SUCCESS; \
51 } \
52
53
54
2CL_API_ENTRY cl_int CL_API_CALL55CL_API_ENTRY cl_int CL_API_CALL
3clGetKernelInfo(cl_kernel kernel ,56clGetKernelInfo(cl_kernel kernel ,
4 cl_kernel_info param_name ,57 cl_kernel_info param_name ,
5 size_t param_value_size ,58 size_t param_value_size ,
6 void * param_value ,59 void * param_value ,
7 size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_060 size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
8{61{
9 POCL_ABORT_UNIMPLEMENTED();62 switch (param_name) {
10 return CL_SUCCESS;63 case CL_KERNEL_FUNCTION_NAME:
64 POCL_RETURN_KERNEL_INFO_STR(kernel->name);
65 case CL_KERNEL_NUM_ARGS:
66 POCL_RETURN_KERNEL_INFO(cl_uint, kernel->num_args);
67 case CL_KERNEL_REFERENCE_COUNT:
68 POCL_RETURN_KERNEL_INFO(cl_uint, kernel->pocl_refcount);
69 case CL_KERNEL_CONTEXT:
70 POCL_RETURN_KERNEL_INFO(cl_context, kernel->context);
71 case CL_KERNEL_PROGRAM:
72 POCL_RETURN_KERNEL_INFO(cl_program, kernel->program);
73 }
74 return CL_INVALID_VALUE;
11}75}
1276
1377
=== 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:51:22 +0000
@@ -1,14 +1,66 @@
1/* OpenCL runtime library: clGetDeviceInfo()
2
3 Copyright (c) 2012 Erik Schnetter
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22*/
23
1#include "pocl_cl.h"24#include "pocl_cl.h"
225
3 26
27
28#define POCL_RETURN_MEM_INFO(__TYPE__, __VALUE__) \
29 { \
30 size_t const value_size = sizeof(__TYPE__); \
31 if (param_value) { \
32 if (param_value_size < value_size) return CL_INVALID_VALUE; \
33 *(__TYPE__*)param_value = __VALUE__; \
34 } \
35 if (param_value_size_ret) \
36 *param_value_size_ret = value_size; \
37 return CL_SUCCESS; \
38 }
39
40
41
4CL_API_ENTRY cl_int CL_API_CALL42CL_API_ENTRY cl_int CL_API_CALL
5clGetMemObjectInfo(cl_mem memobj ,43clGetMemObjectInfo(cl_mem memobj ,
6 cl_mem_info param_name , 44 cl_mem_info param_name ,
7 size_t param_value_size ,45 size_t param_value_size ,
8 void * param_value ,46 void * param_value ,
9 size_t * param_value_size_ret ) CL_API_SUFFIX__VERSION_1_047 size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0
10{48{
11 POCL_ABORT_UNIMPLEMENTED();49 switch (param_name) {
12 return CL_SUCCESS;50 case CL_MEM_TYPE:
51 POCL_RETURN_MEM_INFO(cl_mem_object_type, memobj->type);
52 case CL_MEM_FLAGS:
53 POCL_RETURN_MEM_INFO(cl_mem_flags, memobj->flags);
54 case CL_MEM_SIZE:
55 POCL_RETURN_MEM_INFO(size_t, memobj->size);
56 case CL_MEM_HOST_PTR:
57 POCL_RETURN_MEM_INFO(void *, memobj->mem_host_ptr);
58 case CL_MEM_MAP_COUNT:
59 POCL_RETURN_MEM_INFO(cl_uint, memobj->map_count);
60 case CL_MEM_REFERENCE_COUNT:
61 POCL_RETURN_MEM_INFO(cl_uint, memobj->pocl_refcount);
62 case CL_MEM_CONTEXT:
63 POCL_RETURN_MEM_INFO(cl_context, memobj->context);
64 }
65 return CL_INVALID_VALUE;
13}66}
14