Files
OpenCL-CTS/test_conformance/math_brute_force/common.h
Sven van Haastregt b6941b6c61 Add fp16 testing to conversions and bruteforce (#1975)
Merge the `fp16-staging` branch into `main`, adding fp16 (`half`)
testing to the conversions and math bruteforce tests.

---------

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Guo, Yilong <yilong.guo@intel.com>
Signed-off-by: John Kesapides <john.kesapides@arm.com>
Co-authored-by: Marcin Hajder <marcin.hajder@gmail.com>
Co-authored-by: Ewan Crawford <ewan@codeplay.com>
Co-authored-by: Wawiorko, Grzegorz <grzegorz.wawiorko@intel.com>
Co-authored-by: Sreelakshmi Haridas Maruthur <sharidas@quicinc.com>
Co-authored-by: Harald van Dijk <harald@gigawatt.nl>
Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
Co-authored-by: Haonan Yang <haonan.yang@intel.com>
Co-authored-by: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com>
Co-authored-by: niranjanjoshi121 <43807392+niranjanjoshi121@users.noreply.github.com>
Co-authored-by: Wenwan Xing <wenwan.xing@intel.com>
Co-authored-by: Yilong Guo <yilong.guo@intel.com>
Co-authored-by: Romaric Jodin <89833130+rjodinchr@users.noreply.github.com>
Co-authored-by: joshqti <127994991+joshqti@users.noreply.github.com>
Co-authored-by: Pekka Jääskeläinen <pekka.jaaskelainen@tuni.fi>
Co-authored-by: imilenkovic00 <155085410+imilenkovic00@users.noreply.github.com>
Co-authored-by: John Kesapides <46718829+JohnKesapidesARM@users.noreply.github.com>
Co-authored-by: Aharon Abramson <aharon.abramson@mobileye.com>
2024-06-18 09:43:11 -07:00

98 lines
3.4 KiB
C++

//
// Copyright (c) 2021-2024 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 COMMON_H
#define COMMON_H
#include "harness/typeWrappers.h"
#include "utility.h"
#include <array>
#include <string>
#include <vector>
// Array of thread-specific kernels for each vector size.
using KernelMatrix =
std::array<std::vector<clKernelWrapper>, VECTOR_SIZE_COUNT>;
// Array of programs for each vector size.
using Programs = std::array<clProgramWrapper, VECTOR_SIZE_COUNT>;
// Array of buffers for each vector size.
using Buffers = std::array<clMemWrapper, VECTOR_SIZE_COUNT>;
// Types supported for kernel code generation.
enum class ParameterType
{
Half,
Float,
Double,
Short,
UShort,
Int,
UInt,
Long,
ULong,
};
// Return kernel name suffixed with vector size.
std::string GetKernelName(int vector_size_index);
// Generate kernel code for the given builtin function/operator.
std::string GetUnaryKernel(const std::string &kernel_name, const char *builtin,
ParameterType retType, ParameterType type1,
int vector_size_index);
std::string GetUnaryKernel(const std::string &kernel_name, const char *builtin,
ParameterType retType1, ParameterType retType2,
ParameterType type1, int vector_size_index);
std::string GetBinaryKernel(const std::string &kernel_name, const char *builtin,
ParameterType retType, ParameterType type1,
ParameterType type2, int vector_size_index);
std::string GetBinaryKernel(const std::string &kernel_name, const char *builtin,
ParameterType retType1, ParameterType retType2,
ParameterType type1, ParameterType type2,
int vector_size_index);
std::string GetTernaryKernel(const std::string &kernel_name,
const char *builtin, ParameterType retType,
ParameterType type1, ParameterType type2,
ParameterType type3, int vector_size_index);
// Information to generate OpenCL kernels.
struct BuildKernelInfo
{
// Number of kernels to build, one for each thread to avoid data races.
cl_uint threadCount;
KernelMatrix &kernels;
Programs &programs;
// Function, macro or symbol tested by the kernel.
const char *nameInCode;
// Whether to build with -cl-fast-relaxed-math.
bool relaxedMode;
};
using SourceGenerator = std::string (*)(const std::string &kernel_name,
const char *builtin,
cl_uint vector_size_index);
/// Build kernels for all threads in "info" for the given job_id.
cl_int BuildKernels(BuildKernelInfo &info, cl_uint job_id,
SourceGenerator generator);
#endif /* COMMON_H */