57 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 implementation for the functions that define the set11/// 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 22using namespace mathtest;23 24[[nodiscard]] const llvm::SmallVector<TestConfig, 4> &25mathtest::getAllTestConfigs() {26 // Thread-safe initialization of a static local variable27 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> &40mathtest::getDefaultTestConfigs() {41 // Thread-safe initialization of a static local variable42 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};57