60 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// This file contains the conformance test of the cosf16 function.11///12//===----------------------------------------------------------------------===//13 14#include "mathtest/CommandLineExtras.hpp"15#include "mathtest/ExhaustiveGenerator.hpp"16#include "mathtest/IndexedRange.hpp"17#include "mathtest/TestConfig.hpp"18#include "mathtest/TestRunner.hpp"19#include "mathtest/TypeExtras.hpp"20 21#include "llvm/ADT/StringRef.h"22 23#include <cstdlib>24#include <math.h>25 26using namespace mathtest;27 28extern "C" float16 cosf16(float16);29 30namespace mathtest {31 32template <> struct FunctionConfig<cosf16> {33 static constexpr llvm::StringRef Name = "cosf16";34 static constexpr llvm::StringRef KernelName = "cosf16Kernel";35 36 // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,37 // Table 69 (Full Profile), Khronos Registry [July 10, 2025].38 static constexpr uint64_t UlpTolerance = 2;39};40} // namespace mathtest41 42int main(int argc, const char **argv) {43 llvm::cl::ParseCommandLineOptions(argc, argv,44 "Conformance test of the cosf16 function");45 46 using namespace mathtest;47 48 IndexedRange<float16> Range;49 ExhaustiveGenerator<float16> Generator(Range);50 51 const auto Configs = cl::getTestConfigs();52 const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;53 const bool IsVerbose = cl::IsVerbose;54 55 bool Passed =56 runTests<cosf16>(Generator, Configs, DeviceBinaryDir, IsVerbose);57 58 return Passed ? EXIT_SUCCESS : EXIT_FAILURE;59}60