Skip to content

Commit

Permalink
[fud] Fix environment variables for real-FPGA runs (#1728)
Browse files Browse the repository at this point in the history
This should probably fix #1724, superseding the `fix-pynq` branch
(apparently @nathanielnrn and I stumbled on the same issue). We were
setting the environment variables like `XCL_EMULATION_MODE=hw` in
hardware-execution mode, where what we should be doing is not setting
this at all in this mode.
  • Loading branch information
sampsyo authored Sep 24, 2023
1 parent f6bd3a0 commit ecb7900
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions fud/fud/stages/xilinx/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ def configure():

# Create the `emconfig.json` file that the simulator loudly (but
# perhaps unnecessarily?) complains about if it's missing.
platform = config["stages", "xclbin", "device"]
utilpath = os.path.join(vitis_path, 'bin', 'emconfigutil')
shell(
f'{utilpath} --platform {platform} --od {new_dir.name}',
capture_stdout=False,
stdout_as_debug=True,
)
if emu_mode != 'hw':
platform = config["stages", "xclbin", "device"]
utilpath = os.path.join(vitis_path, 'bin', 'emconfigutil')
shell(
f'{utilpath} --platform {platform} --od {new_dir.name}',
capture_stdout=False,
stdout_as_debug=True,
)

@builder.step()
def run(xclbin: SourceType.Path) -> SourceType.String:
Expand All @@ -110,10 +111,15 @@ def run(xclbin: SourceType.Path) -> SourceType.String:
f"{xclbin_abs} {data_abs}"
)
envs = {
"EMCONFIG_PATH": new_dir.name,
"XCL_EMULATION_MODE": emu_mode, # hw_emu or hw
"XRT_INI_PATH": xrt_ini_path,
}
if emu_mode != 'hw':
# `hw` denotes actual hardware execution. In other modes,
# configure emulation.
envs.update({
"EMCONFIG_PATH": new_dir.name,
"XCL_EMULATION_MODE": emu_mode, # hw_emu or hw
})

# Invoke xclrun.
start_time = time.time()
Expand All @@ -125,7 +131,7 @@ def run(xclbin: SourceType.Path) -> SourceType.String:
stdout_as_debug=True,
)
end_time = time.time()
log.debug(f"Emulation time: {end_time - start_time} sec")
log.debug(f"Execution time: {end_time - start_time} sec")

# Add xrt log output to our debug output.
if os.path.exists(self.xrt_output_logname):
Expand Down

0 comments on commit ecb7900

Please sign in to comment.