mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
subgroups: Fix Wformat warnings (#1549)
The main source of warnings was the use of `%d` for printing a templated type `T`, where `T` could be any cl_ scalar or vector type. Introduce `print_expected_obtained`. It takes const references to handle alignment of the cl_ types. Define `operator<<` for all types used by the subgroup tests. Ideally those would be template functions enabled by TypeManager data, but that requires some more work on the TypeManager (which we'd ideally do after more warnings have been enabled). So for now, define the `operator<<` instances using preprocessor defines. Also fix a few instances where the wrong format specifier was used for `size_t` types. Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com> Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
2110e45cce
commit
fc4260bdae
62
test_conformance/subgroups/subhelpers.cpp
Normal file
62
test_conformance/subgroups/subhelpers.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "subhelpers.h"
|
||||
|
||||
// Define operator<< for cl_ types, accessing the .s member.
|
||||
#define OP_OSTREAM(Ty, VecSize) \
|
||||
std::ostream& operator<<(std::ostream& os, const Ty##VecSize& val) \
|
||||
{ \
|
||||
os << +val.s[0]; /* unary plus forces char to be printed as number */ \
|
||||
for (unsigned i = 1; i < VecSize; i++) \
|
||||
{ \
|
||||
os << ", " << +val.s[i]; \
|
||||
} \
|
||||
return os; \
|
||||
}
|
||||
|
||||
// Define operator<< for subgroups::cl_ types, accessing the .data member and
|
||||
// forwarding to operator<< for the cl_ types.
|
||||
#define OP_OSTREAM_SUBGROUP(Ty, VecSize) \
|
||||
std::ostream& operator<<(std::ostream& os, const Ty##VecSize& val) \
|
||||
{ \
|
||||
return os << val.data; \
|
||||
}
|
||||
|
||||
// Define operator<< for all vector sizes.
|
||||
#define OP_OSTREAM_ALL_VEC(Ty) \
|
||||
OP_OSTREAM(Ty, 2) \
|
||||
OP_OSTREAM(Ty, 4) \
|
||||
OP_OSTREAM(Ty, 8) \
|
||||
OP_OSTREAM(Ty, 16) \
|
||||
OP_OSTREAM_SUBGROUP(subgroups::Ty, 3)
|
||||
|
||||
OP_OSTREAM_ALL_VEC(cl_char)
|
||||
OP_OSTREAM_ALL_VEC(cl_uchar)
|
||||
OP_OSTREAM_ALL_VEC(cl_short)
|
||||
OP_OSTREAM_ALL_VEC(cl_ushort)
|
||||
OP_OSTREAM_ALL_VEC(cl_int)
|
||||
OP_OSTREAM_ALL_VEC(cl_uint)
|
||||
OP_OSTREAM_ALL_VEC(cl_long)
|
||||
OP_OSTREAM_ALL_VEC(cl_ulong)
|
||||
OP_OSTREAM_ALL_VEC(cl_float)
|
||||
OP_OSTREAM_ALL_VEC(cl_double)
|
||||
OP_OSTREAM_ALL_VEC(cl_half)
|
||||
OP_OSTREAM_SUBGROUP(subgroups::cl_half, )
|
||||
OP_OSTREAM_SUBGROUP(subgroups::cl_half, 2)
|
||||
OP_OSTREAM_SUBGROUP(subgroups::cl_half, 4)
|
||||
OP_OSTREAM_SUBGROUP(subgroups::cl_half, 8)
|
||||
OP_OSTREAM_SUBGROUP(subgroups::cl_half, 16)
|
||||
Reference in New Issue
Block a user