Debian Codegraph @

offload/unittests/Conformance/tests/SincosfTest.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 sincosf 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
20 #include "llvm/ADT/StringRef.h"
21
22 #include <cstdlib>
23 #include <math.h>
24
25 static inline float sincosfSin(float X) {
26 float SinX, CosX;
27 sincosf(X, &SinX, &CosX);
28 return SinX;
29 }
30
31 static inline float sincosfCos(float X) {
32 float SinX, CosX;
33 sincosf(X, &SinX, &CosX);
34 return CosX;
35 }
36
37 namespace mathtest {
38
39 template <> struct FunctionConfig<sincosfSin> {
40 static constexpr llvm::StringRef Name = "sincosf (sin part)";
41 static constexpr llvm::StringRef KernelName = "sincosfSinKernel";
42
43 // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
44 // Table 65, Khronos Registry [July 10, 2025].
45 static constexpr uint64_t UlpTolerance = 4;
46 };
47
48 template <> struct FunctionConfig<sincosfCos> {
49 static constexpr llvm::StringRef Name = "sincosf (cos part)";
50 static constexpr llvm::StringRef KernelName = "sincosfCosKernel";
51
52 // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
53 // Table 65, Khronos Registry [July 10, 2025].
54 static constexpr uint64_t UlpTolerance = 4;
55 };
56 } // namespace mathtest
57
58 int main(int argc, const char **argv) {
59 llvm::cl::ParseCommandLineOptions(argc, argv,
60 "Conformance test of the sincosf function");
61
62 using namespace mathtest;
63
64 IndexedRange<float> Range;
65 ExhaustiveGenerator<float> Generator(Range);
66
67 const auto Configs = cl::getTestConfigs();
68 const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
69 const bool IsVerbose = cl::IsVerbose;
70
71 bool SinPartPassed =
72 runTests<sincosfSin>(Generator, Configs, DeviceBinaryDir, IsVerbose);
73 bool CosPartPassed =
74 runTests<sincosfCos>(Generator, Configs, DeviceBinaryDir, IsVerbose);
75
76 return (SinPartPassed && CosPartPassed) ? EXIT_SUCCESS : EXIT_FAILURE;
77 }