Skip to content

Commit a8e6bc5

Browse files
committed
[libcxx] Add testing configuration for GPU targets
Summary: The GPU runs these tests using the files built from the `libc` project. These will be placed in `include/<triple>` and `lib/<triple>`. We use the `amdhsa-loader` and `nvptx-loader` tools, which are also provided by `libc`. These launch a kernel called `_start` which calls `main` so we can pretend like GPU programs are normal terminal applications. We force serial exeuction here, because `llvm-lit` runs way too many processes in parallel, which has a bad habit of making the GPU drivers hang or run out of resources. This allows the compilation to be run in parallel while the jobs themselves are serialized via a file lock. In the future this can likely be refined to accept user specified architectures, or better handle including the root directory by exposing that instead of just `include/<triple>/c++/v1/`. This currently fails ~1% of the tests on AMDGPU and ~3% of the tests on NVPTX. This will hopefully be reduced further, and later patches can XFAIL a lot of them once it's down to a reasonable number. Future support will likely want to allow passing in a custom architecture instead of simply relying on `-mcpu=native`.
1 parent 1c9d8a6 commit a8e6bc5

File tree

6 files changed

+76
-0
lines changed

6 files changed

+76
-0
lines changed

libcxx/cmake/caches/AMDGPU.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
2828
set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
2929
set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
3030

31+
# Test configuration.
32+
set(LIBCXX_TEST_CONFIG "amdgpu-libc++-shared.cfg.in" CACHE STRING "")
33+
set(LIBCXX_TEST_PARAMS "long_tests=False;executor=amdhsa-loader" CACHE STRING "")
34+
3135
# Necessary compile flags for AMDGPU.
3236
set(LIBCXX_ADDITIONAL_COMPILE_FLAGS
3337
"-nogpulib;-flto;-fconvergent-functions;-Xclang;-mcode-object-version=none" CACHE STRING "")

libcxx/cmake/caches/NVPTX.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
2828
set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
2929
set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
3030

31+
# Test configuration.
32+
set(LIBCXX_TEST_CONFIG "nvptx-libc++-shared.cfg.in" CACHE STRING "")
33+
set(LIBCXX_TEST_PARAMS "long_tests=False;executor=nvptx-loader" CACHE STRING "")
34+
3135
# Necessary compile flags for NVPTX.
3236
set(LIBCXX_ADDITIONAL_COMPILE_FLAGS
3337
"-nogpulib;-flto;-fconvergent-functions;--cuda-feature=+ptx63" CACHE STRING "")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
2+
3+
config.substitutions.append(('%{flags}',
4+
f'--target={config.target_triple} -Wno-multi-gpu -flto -mcpu=native'))
5+
config.substitutions.append(('%{compile_flags}',
6+
'-nogpulib -fno-builtin-printf -nogpuinc -nostdlibinc '
7+
'-I %{include-dir} -I %{target-include-dir}/../../ '
8+
'-I %{target-include-dir} -I %{libcxx-dir}/test/support'
9+
))
10+
config.substitutions.append(('%{link_flags}',
11+
'-O1 -nostdinc++ -nostdlib++ %{lib-dir}/crt1.o '
12+
'-L %{lib-dir} -lc++ -lc++abi -lclang_rt.builtins '
13+
))
14+
15+
config.substitutions.append(('%{exec}',
16+
'%{executor} --no-parallelism'
17+
))
18+
19+
config.stdlib = 'llvm-libc++'
20+
21+
import os, site
22+
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
23+
import libcxx.test.params, libcxx.test.config
24+
libcxx.test.config.configure(
25+
libcxx.test.params.DEFAULT_PARAMETERS,
26+
libcxx.test.features.DEFAULT_FEATURES,
27+
config,
28+
lit_config
29+
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
2+
3+
config.substitutions.append(('%{flags}',
4+
f'--target={config.target_triple} -Wno-multi-gpu -flto -march=native'))
5+
config.substitutions.append(('%{compile_flags}',
6+
'-nogpulib -fno-builtin-printf -nogpuinc -nostdlibinc '
7+
'-I %{include-dir} -I %{target-include-dir}/../../ '
8+
'-I %{target-include-dir} -I %{libcxx-dir}/test/support'
9+
))
10+
config.substitutions.append(('%{link_flags}',
11+
'-nostdinc++ -nostdlib++ %{lib-dir}/crt1.o '
12+
'-L %{lib-dir} -lc++ -lc++abi -lclang_rt.builtins '
13+
'-Wl,--suppress-stack-size-warning '
14+
'-Wl,-mllvm,-nvptx-lower-global-ctor-dtor=1 '
15+
'-Wl,-mllvm,-nvptx-emit-init-fini-kernel'
16+
))
17+
config.substitutions.append(('%{exec}',
18+
'%{executor} --no-parallelism'
19+
))
20+
21+
config.stdlib = 'llvm-libc++'
22+
23+
import os, site
24+
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
25+
import libcxx.test.params, libcxx.test.config
26+
libcxx.test.config.configure(
27+
libcxx.test.params.DEFAULT_PARAMETERS,
28+
libcxx.test.features.DEFAULT_FEATURES,
29+
config,
30+
lit_config
31+
)

libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_range.pass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// FIXME: This takes over an hour to compile, disable for now.
10+
// UNSUPPORTED: target=amdgcn-amd-amdhsa
11+
// UNSUPPORTED: target=nvptx64-nvidia-cuda
12+
913
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1014
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
1115

libcxx/test/std/strings/basic.string/string.modifiers/string_replace/replace_with_range.pass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// FIXME: This takes over an hour to compile, disable for now.
10+
// UNSUPPORTED: target=amdgcn-amd-amdhsa
11+
// UNSUPPORTED: target=nvptx64-nvidia-cuda
12+
913
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1014
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=10000000
1115
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=70000000

0 commit comments

Comments
 (0)