brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · a3d1650 Raw
81 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 sincos function.11///12//===----------------------------------------------------------------------===//13 14#include "mathtest/CommandLineExtras.hpp"15#include "mathtest/IndexedRange.hpp"16#include "mathtest/RandomGenerator.hpp"17#include "mathtest/RandomState.hpp"18#include "mathtest/TestConfig.hpp"19#include "mathtest/TestRunner.hpp"20 21#include "llvm/ADT/StringRef.h"22 23#include <cstdlib>24#include <math.h>25 26static inline double sincosSin(double X) {27  double SinX, CosX;28  sincos(X, &SinX, &CosX);29  return SinX;30}31 32static inline double sincosCos(double X) {33  double SinX, CosX;34  sincos(X, &SinX, &CosX);35  return CosX;36}37 38namespace mathtest {39 40template <> struct FunctionConfig<sincosSin> {41  static constexpr llvm::StringRef Name = "sincos (sin part)";42  static constexpr llvm::StringRef KernelName = "sincosSinKernel";43 44  // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,45  //         Table 68, Khronos Registry [July 10, 2025].46  static constexpr uint64_t UlpTolerance = 4;47};48 49template <> struct FunctionConfig<sincosCos> {50  static constexpr llvm::StringRef Name = "sincos (cos part)";51  static constexpr llvm::StringRef KernelName = "sincosCosKernel";52 53  // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,54  //         Table 68, Khronos Registry [July 10, 2025].55  static constexpr uint64_t UlpTolerance = 4;56};57} // namespace mathtest58 59int main(int argc, const char **argv) {60  llvm::cl::ParseCommandLineOptions(argc, argv,61                                    "Conformance test of the sincos function");62 63  using namespace mathtest;64 65  uint64_t Seed = 42;66  uint64_t Size = 1ULL << 32;67  IndexedRange<double> Range;68  RandomGenerator<double> Generator(SeedTy{Seed}, Size, Range);69 70  const auto Configs = cl::getTestConfigs();71  const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;72  const bool IsVerbose = cl::IsVerbose;73 74  bool SinPartPassed =75      runTests<sincosSin>(Generator, Configs, DeviceBinaryDir, IsVerbose);76  bool CosPartPassed =77      runTests<sincosCos>(Generator, Configs, DeviceBinaryDir, IsVerbose);78 79  return (SinPartPassed && CosPartPassed) ? EXIT_SUCCESS : EXIT_FAILURE;80}81