Debian Codegraph @

offload/unittests/Conformance/lib/TestConfig.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 implementation for the functions that define the set
11 /// of all and default test configurations.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #include "mathtest/TestConfig.hpp"
16
17 #include "mathtest/DeviceContext.hpp"
18
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/SmallVectorExtras.h"
21
22 using namespace mathtest;
23
24 [[nodiscard]] const llvm::SmallVector<TestConfig, 4> &
25 mathtest::getAllTestConfigs() {
26 // Thread-safe initialization of a static local variable
27 static auto AllTestConfigs = []() -> llvm::SmallVector<TestConfig, 4> {
28 return {
29 {"llvm-libm", "amdgpu"},
30 {"llvm-libm", "cuda"},
31 {"cuda-math", "cuda"},
32 {"hip-math", "amdgpu"},
33 };
34 }();
35
36 return AllTestConfigs;
37 };
38
39 [[nodiscard]] const llvm::SmallVector<TestConfig, 4> &
40 mathtest::getDefaultTestConfigs() {
41 // Thread-safe initialization of a static local variable
42 static auto DefaultTestConfigs = []() -> llvm::SmallVector<TestConfig, 4> {
43 const auto Platforms = getPlatforms();
44 const auto AllTestConfigs = getAllTestConfigs();
45 llvm::StringRef Provider = "llvm-libm";
46
47 return llvm::filter_to_vector(AllTestConfigs, [&](const auto &Config) {
48 return Provider.equals_insensitive(Config.Provider) &&
49 llvm::any_of(Platforms, [&](llvm::StringRef Platform) {
50 return Platform.equals_insensitive(Config.Platform);
51 });
52 });
53 }();
54
55 return DefaultTestConfigs;
56 };