1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
//
// 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_BASIC_COMMAND_BUFFER_H
#define _CL_KHR_BASIC_COMMAND_BUFFER_H
#include "command_buffer_test_base.h"
#include "harness/typeWrappers.h"
#define ADD_PROP(prop) \
{ \
prop, #prop \
}
#define CHECK_VERIFICATION_ERROR(reference, result, index) \
{ \
if (reference != result) \
{ \
log_error("Expected %d was %d at index %u\n", reference, result, \
index); \
return TEST_FAIL; \
} \
}
// Helper test fixture for constructing OpenCL objects used in testing
// a variety of simple command-buffer enqueue scenarios.
struct BasicCommandBufferTest : CommandBufferTestBase
{
BasicCommandBufferTest(cl_device_id device, cl_context context,
cl_command_queue queue);
virtual bool Skip();
virtual cl_int SetUpKernel(void);
virtual cl_int SetUpKernelArgs(void);
virtual cl_int SetUp(int elements);
// Test body returning an OpenCL error code
virtual cl_int Run() = 0;
protected:
virtual size_t data_size() const { return num_elements * sizeof(cl_int); }
cl_context context;
clCommandQueueWrapper queue;
clProgramWrapper program;
clKernelWrapper kernel;
clMemWrapper in_mem, out_mem, off_mem;
size_t num_elements;
// Device support query results
bool simultaneous_use_support;
bool out_of_order_support;
// user request for simultaneous use
bool simultaneous_use_requested;
unsigned buffer_size_multiplier;
clCommandBufferWrapper command_buffer;
};
template <class T>
int MakeAndRunTest(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
{
CHECK_COMMAND_BUFFER_EXTENSION_AVAILABLE(device);
try
{
auto test_fixture = T(device, context, queue);
if (test_fixture.Skip())
{
return TEST_SKIPPED_ITSELF;
}
cl_int error = test_fixture.SetUp(num_elements);
test_error_ret(error, "Error in test initialization", TEST_FAIL);
error = test_fixture.Run();
test_error_ret(error, "Test Failed", TEST_FAIL);
} catch (const std::runtime_error &e)
{
log_error("%s", e.what());
return TEST_FAIL;
}
return TEST_PASS;
}
#endif // _CL_KHR_BASIC_COMMAND_BUFFER_H
|