-
Notifications
You must be signed in to change notification settings - Fork 51
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
[fud] Add save_temps option to Xilinx synthesis #851
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2d61ed7
First attempt at save_temps
sampsyo 865133a
Fix abspath invocation
sampsyo d326e09
Document save_temps
sampsyo 6d8e7df
Fix read_file output function
sampsyo 1a4e9e6
Little docs fixes
sampsyo b5b0090
Fix close_and_get in SSH context
sampsyo 53940e5
Rename `keep` to `keep_tmpdir`
sampsyo a8d87c4
Comment about save_temps
sampsyo 7f5e10d
Merge branch 'master' into xilinx-save-temps
sampsyo 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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from fud.stages import Source, SourceType, Stage | ||
from fud.stages.remote_context import RemoteExecution | ||
from fud.stages.futil import FutilStage | ||
from fud.utils import TmpDir, shell | ||
from fud.utils import TmpDir, FreshDir, shell | ||
|
||
|
||
class XilinxStage(Stage): | ||
|
@@ -40,6 +40,10 @@ def __init__(self, config): | |
self.remote_exec = RemoteExecution(self) | ||
self.temp_location = self.config["stages", self.name, "temp_location"] | ||
|
||
# As a debugging aid, the pass can optionally preserve the | ||
# (local or remote) sandbox where the Xilinx commands ran. | ||
self.save_temps = bool(self.config["stages", self.name, "save_temps"]) | ||
|
||
self.mode = self.config["stages", self.name, "mode"] | ||
self.device = self.config["stages", self.name, "device"] | ||
|
||
|
@@ -75,7 +79,10 @@ def copy_file( | |
"""Copy an input file.""" | ||
shutil.copyfile(src_path, Path(tmpdir) / dest_path) | ||
|
||
tmpdir = Source(TmpDir(), SourceType.Directory) | ||
tmpdir = Source( | ||
FreshDir() if self.save_temps else TmpDir(), | ||
SourceType.Directory, | ||
) | ||
for src_path, dest_path in input_files.items(): | ||
if not isinstance(src_path, Source): | ||
src_path = Source(src_path, SourceType.Path) | ||
|
@@ -173,9 +180,9 @@ def compile_xclbin(client: SourceType.UnTyped, tmpdir: SourceType.String): | |
def read_file( | ||
tmpdir: SourceType.Directory, | ||
name: SourceType.String, | ||
) -> SourceType.Stream: | ||
) -> SourceType.Path: | ||
"""Read an output file.""" | ||
return Path(tmpdir.name) / name.data | ||
return Path(tmpdir.name) / name | ||
|
||
if self.remote_exec.use_ssh: | ||
self.remote_exec.import_libs() | ||
|
@@ -200,14 +207,14 @@ def read_file( | |
compile_xclbin(client, tmpdir) | ||
|
||
if self.remote_exec.use_ssh: | ||
xclbin = self.remote_exec.close_and_get( | ||
return self.remote_exec.close_and_get( | ||
client, | ||
tmpdir, | ||
"xclbin/kernel.xclbin", | ||
keep_tmpdir=self.save_temps, | ||
) | ||
else: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Super nit: |
||
xclbin = read_file( | ||
return read_file( | ||
tmpdir, | ||
Source("xclbin/kernel.xclbin", SourceType.String), | ||
) | ||
return xclbin |
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
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.
Maybe a comment explaining why this is added would prove useful for future readers. It wasn't obvious to me until I read your PR description.
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.
Good call; added a short comment.