Initial command-buffer extension tests (#1368)

* Initial command-buffer tests

Introduce some basic testing of the
[cl_khr_command_buffer](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_command_buffer)
extension. This is intended as a starting point from which we can iteratively build up tests
for the extension collaboratively.

* Move tests into derived classes

* Move tests from methods into derived classes implementing
  a `Run()` interface.
* Fix memory leak when command_buffer isn't freed when a test
  is skipped.
* Print correct error code for
  `CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR`
* Pass `nullptr` for queue parameter to command recording entry-points

* Define command-buffer type wrapper

Other OpenCL object have a wrapper to reference count their use
and free the wrapped object. The command-buffer object can't use
the generic type wrappers which are templated on the appropriate
release/retain function, as the release/retain functions are
queried at runtime.

Instead, define our own command-buffer wrapper class where a base
object is passed on construction which contains function pointers
to the release/retain functions that can be used in the wrapper.

* Use create_single_kernel_helper_create_program

Use `create_single_kernel_helper_create_program` rather than
hardcoding `clCreateProgramWithSource` to allow for other types
of program input.

Also fix bug using wrong enum for passing properties on command-buffer
creation, should be `CL_COMMAND_BUFFER_FLAGS_KHR`

* Add out-of-order command-buffer test

Introduce a basic test for checking sync-point use
with out-of-order command-buffers.

This also includes better checking of required queue properties.
This commit is contained in:
Ewan Crawford
2022-08-30 17:54:50 +01:00
committed by GitHub
parent f4eb852b6d
commit 8f5a2f0ae8
6 changed files with 844 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
//
// Copyright (c) 2022 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef _CL_KHR_COMMAND_BUFFER_PROCS_H
#define _CL_KHR_COMMAND_BUFFER_PROCS_H
#include <CL/cl.h>
// Basic command-buffer tests
extern int test_single_ndrange(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_interleaved_enqueue(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mixed_commands(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_explicit_flush(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_user_events(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_out_of_order(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
#endif /*_CL_KHR_COMMAND_BUFFER_PROCS_H*/