brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 9aa52b1 Raw
64 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 exp 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 26namespace {27 28// Disambiguate the overloaded 'exp' function to select the double version29constexpr auto expd // NOLINT(readability-identifier-naming)30    = static_cast<double (*)(double)>(exp);31} // namespace32 33namespace mathtest {34 35template <> struct FunctionConfig<expd> {36  static constexpr llvm::StringRef Name = "exp";37  static constexpr llvm::StringRef KernelName = "expKernel";38 39  // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,40  //         Table 68, Khronos Registry [July 10, 2025].41  static constexpr uint64_t UlpTolerance = 3;42};43} // namespace mathtest44 45int main(int argc, const char **argv) {46  llvm::cl::ParseCommandLineOptions(argc, argv,47                                    "Conformance test of the exp function");48 49  using namespace mathtest;50 51  uint64_t Seed = 42;52  uint64_t Size = 1ULL << 32;53  IndexedRange<double> Range;54  RandomGenerator<double> Generator(SeedTy{Seed}, Size, Range);55 56  const auto Configs = cl::getTestConfigs();57  const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;58  const bool IsVerbose = cl::IsVerbose;59 60  bool Passed = runTests<expd>(Generator, Configs, DeviceBinaryDir, IsVerbose);61 62  return Passed ? EXIT_SUCCESS : EXIT_FAILURE;63}64