Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Pulldown from llvm/llvm-test-suite #13

Merged
merged 12 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TEST_SUITE_EXTRA_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} ${TEST_SUITE_EXTRA_EXE_LINKER_FLAGS}")

# Use X/OPEN compatibility flag on AIX for C tests to avoid problems
# with some versions of the system headers.
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700")
endif()

# This is either directly the C++ ABI library or the full C++ library
# which pulls in the ABI transitively.
set(TEST_SUITE_CXX_ABI "default" CACHE STRING "Specify C++ ABI library to use.")
Expand Down
2 changes: 2 additions & 0 deletions External/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ macro(create_cuda_tests)
if(EXISTS ${_path_to_libcxx})
add_library(libcxx SHARED IMPORTED)
set_property(TARGET libcxx PROPERTY IMPORTED_LOCATION ${_path_to_libcxx})
get_filename_component(_libcxx_dir ${_path_to_libcxx} DIRECTORY)
target_link_options(libcxx INTERFACE "-Wl,-rpath,${_libcxx_dir}")
set(HAVE_LIBCXX 1)
else()
message(WARNING "Can't find libcxx location.")
Expand Down
6 changes: 1 addition & 5 deletions External/CUDA/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cuda_env_vars = [
'CUDA_CACHE_PATH',
'CUDA_FORCE_PTX_JIT',
'CUDA_VISIBLE_DEVICES',
'LD_LIBRARY_PATH',
]

# We need to propagate cuda environment vars to tests so we can
Expand All @@ -17,8 +18,3 @@ for var in cuda_env_vars:
config.environment[var] = os.environ[var]

config.traditional_output = True

# "compiletime" wants to traverse whole build directory after each test which
# takes a lot of time if we have config with split thrust tests. Disable it
# until it has smaller overhead.
config.test_modules.remove("compiletime")
2 changes: 1 addition & 1 deletion HashProgramOutput.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi

mv $1 $1.bak
if [ $is_md5sum = "0" ]; then
$md5cmd < $1.bak > $1
$md5cmd -q < $1.bak > $1
else
$md5cmd < $1.bak | cut -d' ' -f 1 > $1
fi
Expand Down
1 change: 1 addition & 0 deletions MicroBenchmarks/Builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(Int128)
8 changes: 8 additions & 0 deletions MicroBenchmarks/Builtins/Int128/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})

llvm_test_executable(Builtins main.cpp)

target_link_libraries(Builtins benchmark)
117 changes: 117 additions & 0 deletions MicroBenchmarks/Builtins/Int128/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#include <algorithm>
#include <cstdint>
#include <limits>
#include <random>
#include <type_traits>
#include <vector>

#include "benchmark/benchmark.h"

#if defined(__SIZEOF_INT128__)

namespace {

constexpr size_t kSampleSize = 1 << 20;

// Some implementations of <random> do not support __int128_t when it is
// available, so we make our own uniform_int_distribution-like type.
template <typename T>
class UniformIntDistribution128 {
public:
T operator()(std::mt19937& generator) {
return (static_cast<T>(dist64_(generator)) << 64) | dist64_(generator);
}

private:
using H = typename std::conditional<
std::is_same<T, __int128_t>::value, int64_t, uint64_t>::type;
std::uniform_int_distribution<H> dist64_;
};

// Generates uniformly pairs (a, b) of 128-bit integers such as a >= b.
template <typename T>
std::vector<std::pair<T, T>> GetRandomIntrinsic128SampleUniformDivisor() {
std::vector<std::pair<T, T>> values;
std::mt19937 random;
UniformIntDistribution128<T> uniform_128;
values.reserve(kSampleSize);
for (size_t i = 0; i < kSampleSize; ++i) {
T a = uniform_128(random);
T b = uniform_128(random);
values.emplace_back(std::max(static_cast<T>(2), std::max(a, b)),
std::max(static_cast<T>(2), std::min(a, b)));
}
return values;
}

template <typename T>
void BM_DivideIntrinsic128UniformDivisor(benchmark::State& state) {
auto values = GetRandomIntrinsic128SampleUniformDivisor<T>();
size_t i = 0;
for (const auto _ : state) {
benchmark::DoNotOptimize(values[i].first / values[i].second);
i = (i + 1) % kSampleSize;
}
}
BENCHMARK_TEMPLATE(BM_DivideIntrinsic128UniformDivisor, __uint128_t);
BENCHMARK_TEMPLATE(BM_DivideIntrinsic128UniformDivisor, __int128_t);

template <typename T>
void BM_RemainderIntrinsic128UniformDivisor(benchmark::State& state) {
auto values = GetRandomIntrinsic128SampleUniformDivisor<T>();
size_t i = 0;
for (const auto _ : state) {
benchmark::DoNotOptimize(values[i].first % values[i].second);
i = (i + 1) % kSampleSize;
}
}
BENCHMARK_TEMPLATE(BM_RemainderIntrinsic128UniformDivisor, __uint128_t);
BENCHMARK_TEMPLATE(BM_RemainderIntrinsic128UniformDivisor, __int128_t);

// Generates random pairs of (a, b) where a >= b, a is 128-bit and
// b is 64-bit.
template <typename T, typename H = typename std::conditional<
std::is_same<T, __int128_t>::value, int64_t, uint64_t>::type>
std::vector<std::pair<T, H>> GetRandomIntrinsic128SampleSmallDivisor() {
std::vector<std::pair<T, H>> values;
std::mt19937 random;
UniformIntDistribution128<T> uniform_int128;
std::uniform_int_distribution<H> uniform_int64;
values.reserve(kSampleSize);
for (size_t i = 0; i < kSampleSize; ++i) {
T a = uniform_int128(random);
H b = std::max(H{2}, uniform_int64(random));
values.emplace_back(std::max(a, static_cast<T>(b)), b);
}
return values;
}

template <typename T>
void BM_DivideIntrinsic128SmallDivisor(benchmark::State& state) {
auto values = GetRandomIntrinsic128SampleSmallDivisor<T>();
size_t i = 0;
for (const auto _ : state) {
benchmark::DoNotOptimize(values[i].first / values[i].second);
i = (i + 1) % kSampleSize;
}
}
BENCHMARK_TEMPLATE(BM_DivideIntrinsic128SmallDivisor, __uint128_t);
BENCHMARK_TEMPLATE(BM_DivideIntrinsic128SmallDivisor, __int128_t);

template <typename T>
void BM_RemainderIntrinsic128SmallDivisor(benchmark::State& state) {
auto values = GetRandomIntrinsic128SampleSmallDivisor<T>();
size_t i = 0;
for (const auto _ : state) {
benchmark::DoNotOptimize(values[i].first % values[i].second);
i = (i + 1) % kSampleSize;
}
}
BENCHMARK_TEMPLATE(BM_RemainderIntrinsic128SmallDivisor, __uint128_t);
BENCHMARK_TEMPLATE(BM_RemainderIntrinsic128SmallDivisor, __int128_t);

} // namespace

#endif

BENCHMARK_MAIN();
1 change: 1 addition & 0 deletions MicroBenchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
file(COPY lit.local.cfg DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

add_subdirectory(Builtins)
add_subdirectory(libs)
add_subdirectory(XRay)
add_subdirectory(LCALS)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
list(APPEND CXXFLAGS -I. -DMINIFE_SCALAR=double -DMINIFE_LOCAL_ORDINAL=int -DMINIFE_GLOBAL_ORDINAL=int -DMINIFE_CSR_MATRIX -DREDSTORM) # -DREDSTORM for mkdir
# Use X/OPEN compatibility flag on AIX to avoid problems with some
# versions of the system headers. Define "UseTimes" to avoid usages of
# "struct timezone" in some source files because it's not available on
# AIX when the compatibility flag is set.
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
list(APPEND CXXFLAGS -D_XOPEN_SOURCE=700 -DUseTimes)
endif()
list(APPEND LDFLAGS -lm)
set(RUN_OPTIONS -nx 64 -ny 64 -nz 64)
llvm_multisource(miniFE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ file(GLOB UnsupportedTests CONFIGURE_DEPENDS
# UB: Creates two `restrict` pointers that alias in the same scope.
pr38212.c

# UB: Each comparisons in (cyx != cyy || mpn_cmp (dx, dy, size + 1) != 0 ||
# dx[size] != 0x12345678) is UB on its own.
921202-1.c

# The following all expect very specific optimiser behavior from the compiler

# __builtin_return_address(n) with n > 0 not guaranteed to give expected result
Expand Down
11 changes: 11 additions & 0 deletions SingleSource/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(CheckCCompilerFlag)

add_subdirectory(C++11)
add_subdirectory(SignlessTypes)
add_subdirectory(Threads)
Expand Down Expand Up @@ -45,4 +47,13 @@ if(NOT ARCH STREQUAL "x86")
ms_struct_pack_layout-1.c
)
endif()

# Enable matrix types extension tests for compilers supporting -fenable-matrix.
check_c_compiler_flag(-fenable-matrix COMPILER_HAS_MATRIX_FLAG)
if (COMPILER_HAS_MATRIX_FLAG)
set_property(SOURCE matrix-types-spec.cpp PROPERTY COMPILE_FLAGS -fenable-matrix)
else()
list(REMOVE_ITEM Source matrix-types-spec.cpp)
endif()

llvm_singlesource()
Loading