1 //
2 // Copyright (c) 2020 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #include "harness/errorHelpers.h"
17 #include "harness/typeWrappers.h"
18 #include <iostream>
19 #include "procs.h"
20
test_kernel_private_memory_size(cl_device_id deviceID,cl_context context,cl_command_queue queue,int num_elements)21 int test_kernel_private_memory_size(cl_device_id deviceID, cl_context context,
22 cl_command_queue queue, int num_elements)
23 {
24 const char* TEST_KERNEL =
25 R"(__kernel void private_memory( __global uint *buffer ){
26 volatile __private uint x[1];
27 buffer[0] = x[0];
28 })";
29
30 clProgramWrapper program;
31 clKernelWrapper kernel;
32 cl_int err = create_single_kernel_helper(context, &program, &kernel, 1,
33 &TEST_KERNEL, "private_memory");
34 test_error(err, "create_single_kernel_helper");
35 cl_ulong size = CL_ULONG_MAX;
36 err = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_PRIVATE_MEM_SIZE,
37 sizeof(cl_ulong), &size, nullptr);
38
39 test_error(err, "clGetKernelWorkGroupInfo");
40
41 return TEST_PASS;
42 }
43