Skip to content
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 9 commits into from
Jan 5, 2022
Merged

Conversation

sampsyo
Copy link
Contributor

@sampsyo sampsyo commented Jan 3, 2022

This change builds on #850 (and depends on it, which is why this is a draft for now and is not worth reviewing until that's merged).

It's a pretty small additional feature: it adds support for the save_temps config option in the Xilinx bitstream compilation stage, which is called xclbin. This option works in both SSH and local mode, and it just keeps around the temporary directory that would otherwise be deleted at the end of the fud execution. This should make it super easy to check things out manually when something goes wrong.

I added a simple utility class, FreshDir, that creates a new empty directory in cwd. I hope this will be useful for other vendor-toolchain-related fud stages that need sandbox directories.

There is new documentation in the synthesis.md chapter for how to use the new flag.

* 2 minutes turns out to be what it takes to crash in synthesis. 5
  minutes is about what it takes to successfully produce an `xclbin`.
* The fud invocation should use `-o` instead of `--to` because the
  output file is binary. (fud will crash when trying to decode it to a
  printable string.)
@sampsyo sampsyo force-pushed the xilinx-save-temps branch from 47a1cb4 to b5b0090 Compare January 4, 2022 16:44
@sampsyo sampsyo marked this pull request as ready for review January 4, 2022 16:45
@sampsyo
Copy link
Contributor Author

sampsyo commented Jan 4, 2022

Rebased and ready to look at!

@@ -120,18 +120,20 @@ def run_remote(client: SourceType.UnTyped, tmpdir: SourceType.String):

run_remote(client, tmpdir)

def _close(self, client, remote_tmpdir):
def _close(self, client, remote_tmpdir, keep=False):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: prefer a more verbose name, e.g. keep_tmpdir or keep_remote_tmpdir.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good; changed!

client,
tmpdir,
"xclbin/kernel.xclbin",
keep=self.save_temps,
)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nit: else not really needed here, but understand some people like the symmetry.

@@ -40,6 +40,8 @@ def __init__(self, config):
self.remote_exec = RemoteExecution(self)
self.temp_location = self.config["stages", self.name, "temp_location"]

self.save_temps = bool(self.config["stages", self.name, "save_temps"])
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@rachitnigam
Copy link
Contributor

LGTM! Chris's nits are a superset of mine so address and merge!

@sampsyo
Copy link
Contributor Author

sampsyo commented Jan 5, 2022

Thanks, y'all! Merging now.

@sampsyo sampsyo merged commit 6b701db into master Jan 5, 2022
@sampsyo sampsyo deleted the xilinx-save-temps branch January 5, 2022 17:44
sampsyo added a commit that referenced this pull request Jan 5, 2022
sampsyo added a commit that referenced this pull request Jan 6, 2022
* Start refactoring generic sandbox utility

LocalSandbox is a new alternative to RemoteExecution for running
commands locally. It's not a drop-in replacement (maybe that should come
in the future), but it offers morally equivalent functionality.

* Fix some configuration stuff

* Improve an error message

I don't know why "provide an input file" was suggested, so I took that
out. Also, properly interpolate the variable into the example flag.

* Document what we know so far

* Black formatting

* Simplify emulation command execution

And also make them work locally, with a utility.

* Avoid some hard-coding

* Document wdb stage configuration

* Fix for name change from #851
@sampsyo sampsyo mentioned this pull request Jan 15, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants