-
Notifications
You must be signed in to change notification settings - Fork 9
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
Setup: add option to build pykokkos-base for multiple GPUs #48
Open
NaderAlAwar
wants to merge
5
commits into
kokkos:main
Choose a base branch
from
NaderAlAwar:multi_gpu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
deef9e6
Setup: add option to build pykokkos-base for multiple GPUs
NaderAlAwar 2a1e5ff
multi_gpu: rename libkokkos copies with and fix dependencies with pat…
NaderAlAwar 1539ae1
multi_gpu: fix issue with library SONAME containing a newline
NaderAlAwar aed4237
Merge branch 'main' into multi_gpu
NaderAlAwar a3a76af
multi_gpu: mark execution spaces as module_local and fix cmake check …
NaderAlAwar 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 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 |
---|---|---|
|
@@ -61,3 +61,6 @@ timing_report* | |
|
||
# stashed source tree | ||
/.stash | ||
|
||
# multi gpu directories | ||
/gpu* |
This file contains 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 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 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 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 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 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,87 @@ | ||
# This should only be run after kokkos is installed | ||
|
||
import glob | ||
from pathlib import Path | ||
import shutil | ||
import subprocess | ||
import sys | ||
|
||
import kokkos | ||
|
||
if shutil.which("patchelf") is None: | ||
sys.exit("ERROR: Cannot run multi_gpu_copy.py without 'patchelf'") | ||
|
||
kokkos_path = kokkos.__path__[0] | ||
base_path = Path(kokkos_path).parent | ||
|
||
lib_path = None | ||
if (base_path / "lib").is_dir(): | ||
lib_path = base_path / "lib" | ||
elif (base_path / "lib64").is_dir(): | ||
lib_path = base_path / "lib64" | ||
|
||
assert(lib_path is not None) | ||
package_paths = [kokkos_path] + glob.glob(f"{str(base_path)}/gpu*") | ||
|
||
for package in package_paths: | ||
package_path = Path(package) | ||
package_lib_path = package_path / "lib" | ||
shutil.copytree(lib_path, package_lib_path, dirs_exist_ok=True) | ||
|
||
if package.endswith("kokkos"): | ||
continue | ||
|
||
package_id = package[-1] | ||
|
||
libkokkoscore_remove = None | ||
libkokkoscore_add = None | ||
libkokkoscontainers_remove = None | ||
libkokkoscontainers_add = None | ||
|
||
for lib in package_lib_path.iterdir(): | ||
if lib.name == "cmake": | ||
continue | ||
|
||
# Add the suffix to the end of each copy | ||
suffix = lib.name.split(".") | ||
lib_name = suffix[0] | ||
suffix = suffix[1:] | ||
suffix = ".".join(suffix) | ||
|
||
new_name = f"{lib_name}_{package_id}.{suffix}" | ||
|
||
if new_name.count(".") == 3: # this is the library that's listed as a dependency | ||
if "libkokkoscore" in new_name: | ||
libkokkoscore_remove = lib.name | ||
libkokkoscore_add = new_name | ||
elif "libkokkoscontainers" in new_name: | ||
libkokkoscontainers_remove = lib.name | ||
libkokkoscontainers_add = new_name | ||
|
||
new_lib_path = Path(lib.parent) / new_name | ||
lib.rename(new_lib_path) | ||
|
||
# Add the suffix to the end of the SONAME | ||
so_name = subprocess.run(["patchelf", "--print-soname", new_lib_path], capture_output=True).stdout.decode("utf-8") | ||
so_name = so_name.split(".") | ||
lib_name = so_name[0] | ||
suffix = so_name[1:] | ||
suffix = [s.strip() for s in suffix] | ||
suffix = ".".join(suffix) | ||
|
||
new_so_name = f"{lib_name}_{package_id}.{suffix}" | ||
subprocess.run(["patchelf", "--set-soname", new_so_name, new_lib_path]) | ||
|
||
for file in package_path.iterdir(): | ||
if "libpykokkos" in file.name: | ||
libpykokkos_path = file | ||
break | ||
|
||
assert(libkokkoscore_remove is not None) | ||
assert(libkokkoscore_add is not None) | ||
assert(libkokkoscontainers_remove is not None) | ||
assert(libkokkoscontainers_add is not None) | ||
|
||
subprocess.run(["patchelf", "--replace-needed", libkokkoscore_remove, libkokkoscore_add, libpykokkos_path]) | ||
subprocess.run(["patchelf", "--replace-needed", libkokkoscontainers_remove, libkokkoscontainers_add, libpykokkos_path]) | ||
subprocess.run(["patchelf", "--set-rpath", package_lib_path, libpykokkos_path]) |
This file contains 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 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 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 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
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.
@jrmadsen Should I be adding this option somewhere else?