2 * Copyright © 2012 Blaž Tomažič <blaz.tomazic@gmail.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
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
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * @file get-program-info.c
29 * cl_int clGetProgramInfo (cl_program program,
30 * cl_program_info param_name,
31 * size_t param_value_size,
33 * size_t *param_value_size_ret)
36 #include "piglit-framework-cl-api.h"
39 PIGLIT_CL_API_TEST_CONFIG_BEGIN
41 config
.name
= "clGetProgramInfo";
42 config
.version_min
= 10;
44 config
.run_per_platform
= true;
45 config
.create_context
= true;
47 config
.program_source
= "kernel void dummy_kernel() {}";
49 PIGLIT_CL_API_TEST_CONFIG_END
53 piglit_cl_test(const int argc
,
55 const struct piglit_cl_api_test_config
* config
,
56 const struct piglit_cl_api_test_env
* env
)
58 enum piglit_result result
= PIGLIT_PASS
;
63 size_t param_value_size
;
66 int num_program_infos
= PIGLIT_CL_ENUM_NUM(cl_program_info
, env
->version
);
67 const cl_program_info
* program_infos
= PIGLIT_CL_ENUM_ARRAY(cl_program_info
);
69 /*** Normal usage ***/
70 for(i
= 0; i
< num_program_infos
; i
++) {
71 printf("%s ", piglit_cl_get_enum_name(program_infos
[i
]));
73 errNo
= clGetProgramInfo(env
->program
,
78 if(!piglit_cl_check_error(errNo
, CL_SUCCESS
)) {
80 "Failed (error code: %s): Get size of %s.\n",
81 piglit_cl_get_error_name(errNo
),
82 piglit_cl_get_enum_name(program_infos
[i
]));
83 piglit_merge_result(&result
, PIGLIT_FAIL
);
87 param_value
= malloc(param_value_size
);
88 if(program_infos
[i
] != CL_PROGRAM_BINARIES
) {
89 errNo
= clGetProgramInfo(env
->program
,
94 if(!piglit_cl_check_error(errNo
, CL_SUCCESS
)) {
96 "Failed (error code: %s): Get value of %s.\n",
97 piglit_cl_get_error_name(errNo
),
98 piglit_cl_get_enum_name(program_infos
[i
]));
99 piglit_merge_result(&result
, PIGLIT_FAIL
);
104 size_t binary_sizes_size
;
105 size_t* binary_sizes
;
107 errNo
= clGetProgramInfo(env
->program
,
108 CL_PROGRAM_BINARY_SIZES
,
112 if(piglit_cl_check_error(errNo
, CL_SUCCESS
)) {
113 binary_sizes
= malloc(binary_sizes_size
);
115 errNo
= clGetProgramInfo(env
->program
,
116 CL_PROGRAM_BINARY_SIZES
,
120 if(piglit_cl_check_error(errNo
, CL_SUCCESS
)) {
121 for(j
= 0; j
< binary_sizes_size
/sizeof(size_t); j
++) {
122 ((unsigned char**)param_value
)[j
] = malloc(binary_sizes
[j
]);
125 errNo
= clGetProgramInfo(env
->program
,
130 if(piglit_cl_check_error(errNo
, CL_SUCCESS
)) {
134 for(j
= 0; j
< binary_sizes_size
/sizeof(size_t); j
++) {
135 free(((unsigned char***)param_value
)[j
]);
144 "Failed (error code: %s): Get value of %s.\n",
145 piglit_cl_get_error_name(errNo
),
146 piglit_cl_get_enum_name(program_infos
[i
]));
147 piglit_merge_result(&result
, PIGLIT_FAIL
);
151 //TODO: output returned values
159 * CL_INVALID_VALUE if param_name is not one of the supported
160 * values or if size in bytes specified by param_value_size is
161 * less than size of return type and param_value is not a NULL
164 errNo
= clGetProgramInfo(env
->program
,
169 if(!piglit_cl_check_error(errNo
, CL_INVALID_VALUE
)) {
171 "Failed (error code: %s): Trigger CL_INVALID_VALUE if param_name is not one of the supported values.\n",
172 piglit_cl_get_error_name(errNo
));
173 piglit_merge_result(&result
, PIGLIT_FAIL
);
176 errNo
= clGetProgramInfo(env
->program
,
177 CL_PROGRAM_REFERENCE_COUNT
,
181 if(!piglit_cl_check_error(errNo
, CL_INVALID_VALUE
)) {
183 "Failed (error code: %s): Trigger CL_INVALID_VALUE if size in bytes specified by param_value is less than size of return type and param_value is not a NULL value.\n",
184 piglit_cl_get_error_name(errNo
));
185 piglit_merge_result(&result
, PIGLIT_FAIL
);
189 * CL_INVALID_PROGRAM if program is not a valid program object.
191 errNo
= clGetProgramInfo(NULL
,
192 CL_PROGRAM_REFERENCE_COUNT
,
196 if(!piglit_cl_check_error(errNo
, CL_INVALID_PROGRAM
)) {
198 "Failed (error code: %s): Trigger CL_INVALID_PROGRAM if program is not a valid program object.\n",
199 piglit_cl_get_error_name(errNo
));
200 piglit_merge_result(&result
, PIGLIT_FAIL
);
204 * CL_INVALID_PROGRAM_EXECUTABLE if param_name is CL_PROGRAM_NUM_KERNELS or
205 * CL_PROGRAM_KERNEL_NAMES and a successful program executable has not been
206 * built for at least one device in the list of devices associated with