66 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 hypot 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 'hypot' function to select the double version29constexpr auto hypotd // NOLINT(readability-identifier-naming)30 = static_cast<double (*)(double, double)>(hypot);31} // namespace32 33namespace mathtest {34 35template <> struct FunctionConfig<hypotd> {36 static constexpr llvm::StringRef Name = "hypot";37 static constexpr llvm::StringRef KernelName = "hypotKernel";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 = 4;42};43} // namespace mathtest44 45int main(int argc, const char **argv) {46 llvm::cl::ParseCommandLineOptions(argc, argv,47 "Conformance test of the hypot function");48 49 using namespace mathtest;50 51 uint64_t Seed = 42;52 uint64_t Size = 1ULL << 32;53 IndexedRange<double> RangeX;54 IndexedRange<double> RangeY;55 RandomGenerator<double, double> Generator(SeedTy{Seed}, Size, RangeX, RangeY);56 57 const auto Configs = cl::getTestConfigs();58 const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;59 const bool IsVerbose = cl::IsVerbose;60 61 bool Passed =62 runTests<hypotd>(Generator, Configs, DeviceBinaryDir, IsVerbose);63 64 return Passed ? EXIT_SUCCESS : EXIT_FAILURE;65}66