Debian Codegraph @

offload/unittests/Conformance/tests/Atan2fTest.cpp

raw
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file contains the conformance test of the atan2f 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
26 namespace mathtest {
27
28 template <> struct FunctionConfig<atan2f> {
29 static constexpr llvm::StringRef Name = "atan2f";
30 static constexpr llvm::StringRef KernelName = "atan2fKernel";
31
32 // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
33 // Table 65, Khronos Registry [July 10, 2025].
34 static constexpr uint64_t UlpTolerance = 6;
35 };
36 } // namespace mathtest
37
38 int main(int argc, const char **argv) {
39 llvm::cl::ParseCommandLineOptions(argc, argv,
40 "Conformance test of the atan2f function");
41
42 using namespace mathtest;
43
44 uint64_t Seed = 42;
45 uint64_t Size = 1ULL << 32;
46 IndexedRange<float> RangeX;
47 IndexedRange<float> RangeY;
48 RandomGenerator<float, float> Generator(SeedTy{Seed}, Size, RangeX, RangeY);
49
50 const auto Configs = cl::getTestConfigs();
51 const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
52 const bool IsVerbose = cl::IsVerbose;
53
54 bool Passed =
55 runTests<atan2f>(Generator, Configs, DeviceBinaryDir, IsVerbose);
56
57 return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
58 }