-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[Offload] Add MPI Plugin #90890
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
Closed
Closed
[Offload] Add MPI Plugin #90890
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
##===----------------------------------------------------------------------===## | ||
# | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
##===----------------------------------------------------------------------===## | ||
# | ||
# Build a plugin for a MPI machine if available. | ||
# | ||
##===----------------------------------------------------------------------===## | ||
|
||
# Looking for MPI... | ||
find_package(MPI QUIET) | ||
|
||
|
||
if(NOT(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux")) | ||
libomptarget_say("Not building MPI offloading plugin: only support MPI in Linux x86_64 or ppc64le hosts.") | ||
return() | ||
elseif(NOT LIBOMPTARGET_DEP_LIBFFI_FOUND) | ||
libomptarget_say("Not building MPI offloading plugin: libffi dependency not found.") | ||
return() | ||
elseif(NOT MPI_CXX_FOUND) | ||
libomptarget_say("Not building MPI offloading plugin: MPI not found in system.") | ||
return() | ||
endif() | ||
|
||
libomptarget_say("Building MPI NextGen offloading plugin.") | ||
|
||
# Create the library and add the default arguments. | ||
add_target_library(omptarget.rtl.mpi MPI) | ||
|
||
target_sources(omptarget.rtl.mpi PRIVATE | ||
src/EventSystem.cpp | ||
src/rtl.cpp | ||
) | ||
|
||
if(FFI_STATIC_LIBRARIES) | ||
target_link_libraries(omptarget.rtl.mpi PRIVATE FFI::ffi_static) | ||
else() | ||
target_link_libraries(omptarget.rtl.mpi PRIVATE FFI::ffi) | ||
endif() | ||
|
||
target_link_libraries(omptarget.rtl.mpi PRIVATE | ||
MPI::MPI_CXX | ||
) | ||
|
||
# Add include directories | ||
target_include_directories(omptarget.rtl.mpi PRIVATE | ||
${LIBOMPTARGET_INCLUDE_DIR}) | ||
|
||
# Set C++20 as the target standard for this plugin. | ||
set_target_properties(omptarget.rtl.mpi | ||
PROPERTIES | ||
CXX_STANDARD 20 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
||
# Configure testing for the MPI plugin. | ||
list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.mpi") | ||
# Report to the parent scope that we are building a plugin for MPI. | ||
set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE) | ||
|
||
# Define the target specific triples and ELF machine values. | ||
set(LIBOMPTARGET_SYSTEM_TARGETS | ||
"${LIBOMPTARGET_SYSTEM_TARGETS} x86_64-pc-linux-gnu-mpi" PARENT_SCOPE) | ||
|
||
# MPI Device Binary | ||
llvm_add_tool(OPENMP llvm-offload-mpi-device src/EventSystem.cpp src/MPIDeviceMain.cpp) | ||
|
||
llvm_update_compile_flags(llvm-offload-mpi-device) | ||
|
||
target_link_libraries(llvm-offload-mpi-device PRIVATE | ||
MPI::MPI_CXX | ||
LLVMSupport | ||
omp | ||
) | ||
|
||
if(FFI_STATIC_LIBRARIES) | ||
target_link_libraries(llvm-offload-mpi-device PRIVATE FFI::ffi_static) | ||
else() | ||
target_link_libraries(llvm-offload-mpi-device PRIVATE FFI::ffi) | ||
endif() | ||
|
||
target_include_directories(llvm-offload-mpi-device PRIVATE | ||
${LIBOMPTARGET_INCLUDE_DIR} | ||
) | ||
|
||
|
||
set_target_properties(llvm-offload-mpi-device | ||
PROPERTIES | ||
CXX_STANDARD 20 | ||
CXX_STANDARD_REQUIRED ON | ||
) | ||
|
||
target_compile_definitions(llvm-offload-mpi-device PRIVATE | ||
DEBUG_PREFIX="OFFLOAD MPI DEVICE") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really want to be rid of
libffi
#88738. I ran into a snag doing it but I think it's better to just hack around what I have and try to improve it later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even use
ffi
here anywhere?