Skip to content

[Libomptarget] Explicitly pass the OpenMP device libraries to tests #68225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2023
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
10 changes: 10 additions & 0 deletions openmp/libomptarget/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ if("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND (LIBC_GPU_BUILD OR
LIBC_GPU_ARCHITECTURES))
set(LIBC_GPU_SUPPORT TRUE)
endif()

# Find the path of the GPU libc static library.
find_library(GPU_LIBC_PATH NAMES cgpu
PATHS ${LIBOMPTARGET_LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
if((NOT GPU_LIBC_PATH) OR (NOT LIBC_GPU_SUPPORT))
set(GPU_LIBC_PATH "")
endif()

set(LIBOMPTARGET_GPU_LIBC_PATH ${GPU_LIBC_PATH} CACHE STRING
"Location of the 'libcgpu.a' library ")
set(LIBOMPTARGET_GPU_LIBC_SUPPORT ${LIBC_GPU_SUPPORT} CACHE BOOL
"Libomptarget support for the GPU libc")
pythonize_bool(LIBOMPTARGET_GPU_LIBC_SUPPORT)
Expand Down
17 changes: 9 additions & 8 deletions openmp/libomptarget/test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ elif config.operating_system == 'Darwin':
config.test_flags += " -Wl,-rpath," + config.library_dir
config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
else: # Unices
config.test_flags += " -nogpulib"
config.test_flags += " -Wl,-rpath," + config.library_dir
config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
config.test_flags += " -Wl,-rpath," + config.llvm_lib_directory
Expand All @@ -151,6 +152,10 @@ def remove_suffix_if_present(name):
else:
return name

def add_libraries(source):
return source + " " + config.libomptarget_libc_path + " " + \
config.library_dir + "/libomptarget.devicertl.a"

# substitutions
# - for targets that exist in the system create the actual command.
# - for valid targets that do not exist in the system, return false, so that the
Expand Down Expand Up @@ -229,12 +234,10 @@ for libomptarget_target in config.libomptarget_all_targets:
"%libomptarget-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compilexx-" + \
libomptarget_target, \
"%clangxx-" + libomptarget_target + " %s -o %t" + \
(" -lcgpu" if config.libomptarget_has_libc else "")))
"%clangxx-" + libomptarget_target + add_libraries(" %s -o %t")))
config.substitutions.append(("%libomptarget-compile-" + \
libomptarget_target, \
"%clang-" + libomptarget_target + " %s -o %t" +
(" -lcgpu" if config.libomptarget_has_libc else "")))
"%clang-" + libomptarget_target + add_libraries(" %s -o %t")))
config.substitutions.append(("%libomptarget-compile-fortran-" + \
libomptarget_target, \
"%flang-" + libomptarget_target + " %s -o %t"))
Expand All @@ -256,12 +259,10 @@ for libomptarget_target in config.libomptarget_all_targets:
"%libomptarget-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileoptxx-" + \
libomptarget_target, \
"%clangxx-" + libomptarget_target + " -O3 %s -o %t" +
(" -lcgpu" if config.libomptarget_has_libc else "")))
"%clangxx-" + libomptarget_target + add_libraries(" -O3 %s -o %t")))
config.substitutions.append(("%libomptarget-compileopt-" + \
libomptarget_target, \
"%clang-" + libomptarget_target + " -O3 %s -o %t" +
(" -lcgpu" if config.libomptarget_has_libc else "")))
"%clang-" + libomptarget_target + add_libraries(" -O3 %s -o %t")))
config.substitutions.append(("%libomptarget-run-" + \
libomptarget_target, \
"%t"))
Expand Down
1 change: 1 addition & 0 deletions openmp/libomptarget/test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@"
config.libomptarget_debug = @LIBOMPTARGET_DEBUG@
config.has_libomptarget_ompt = @LIBOMPTARGET_OMPT_SUPPORT@
config.libomptarget_has_libc = @LIBOMPTARGET_GPU_LIBC_SUPPORT@
config.libomptarget_libc_path = "@LIBOMPTARGET_GPU_LIBC_PATH@"

# Let the main config do the real work.
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")