Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/finn/core/rtlsim_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def rtlsim_exec_cppxsi(
# write compilation command to a file for easy re-running/debugging
with open(sim_base + "/compile_rtlsim.sh", "w") as f:
f.write(" ".join(build_cmd))
launch_process_helper(build_cmd, cwd=sim_base)
launch_process_helper(build_cmd, cwd=sim_base, check=True)
assert os.path.isfile(sim_base + "/rtlsim_xsi"), "Failed to compile rtlsim executable"

# launch the rtlsim executable
Expand All @@ -310,7 +310,7 @@ def rtlsim_exec_cppxsi(
" ./rtlsim_xsi > rtlsim_xsi_log.txt"
" 2> rtlsim_xsi_stderr.log"
)
launch_process_helper(runsim_cmd, cwd=sim_base)
launch_process_helper(runsim_cmd, cwd=sim_base, check=True)

# parse results file and return dict
results_filename = sim_base + "/results.txt"
Expand Down
6 changes: 2 additions & 4 deletions src/finn/custom_op/fpgadataflow/hlsbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
import numpy as np
import os
import re
import subprocess
import warnings
from abc import ABC, abstractmethod
from qonnx.core.datatype import DataType

from finn import xsi
from finn.custom_op.fpgadataflow import templates
from finn.util.basic import CppBuilder, make_build_dir
from finn.util.basic import CppBuilder, launch_process_helper, make_build_dir
from finn.util.data_packing import npy_to_rtlsim_input, rtlsim_output_to_npy
from finn.util.hls import CallHLS

Expand Down Expand Up @@ -303,8 +302,7 @@ def exec_precompiled_singlenode_model(self):
compilation transformations?
"""
)
process_execute = subprocess.Popen(executable_path, stdout=subprocess.PIPE)
process_execute.communicate()
launch_process_helper(executable_path, check=True)

def fold_input_for_npy(self, inp_val, ind):
"""Lay an input tensor out into the folded shape written to the npy that
Expand Down
6 changes: 2 additions & 4 deletions src/finn/custom_op/fpgadataflow/rtl/finn_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import numpy as np
import os
import shutil
import subprocess
from pathlib import Path
from qonnx.core.datatype import DataType
from qonnx.core.modelwrapper import ModelWrapper
Expand All @@ -45,7 +44,7 @@
from finn.custom_op.fpgadataflow.hwcustomop import HWCustomOp
from finn.custom_op.fpgadataflow.rtlbackend import RTLBackend
from finn.transformation.fpgadataflow.annotate_cycles import AnnotateCycles
from finn.util.basic import make_build_dir, resolve_xilinx_tool
from finn.util.basic import launch_process_helper, make_build_dir, resolve_xilinx_tool
from finn.util.create import adjacency_list
from finn.util.data_packing import npy_to_rtlsim_input, rtlsim_output_to_npy
from finn.util.rtlsim import dat_file_to_numpy_array, mlo_prehook_func_factory
Expand Down Expand Up @@ -1234,8 +1233,7 @@ def ipgen_singlenode_code(self, fpgapart=None):
f.write("{} -mode batch -source make_loop_ip.tcl\n".format(vivado_cmd))
f.write("cd {}\n".format(working_dir))
bash_command = ["bash", make_project_sh]
process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
process_compile.communicate()
launch_process_helper(bash_command, check=True)
assert os.path.isfile(wrapper_filename), "IPGen failed: %s not found" % (wrapper_filename)
self.set_nodeattr("ipgen_path", wrapper_filename)
self.set_nodeattr("ip_path", vivado_stitch_proj_dir + "/ip")
Expand Down
11 changes: 4 additions & 7 deletions src/finn/transformation/fpgadataflow/alveo_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from finn.transformation.fpgadataflow.insert_iodma import InsertIODMA
from finn.transformation.fpgadataflow.prepare_ip import PrepareIP
from finn.transformation.fpgadataflow.specialize_layers import SpecializeLayers
from finn.util.basic import make_build_dir, resolve_xilinx_tool
from finn.util.basic import launch_process_helper, make_build_dir, resolve_xilinx_tool

from . import templates

Expand Down Expand Up @@ -189,8 +189,7 @@ def apply(self, model):
f.write("{} -mode batch -source gen_xo.tcl\n".format(vivado_cmd))
f.write("cd {}\n".format(working_dir))
bash_command = ["bash", package_xo_sh]
process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
process_compile.communicate()
launch_process_helper(bash_command, check=True)
assert os.path.isfile(xo_path), (
"Vitis .xo file not created, check logs under %s" % vivado_proj_dir
)
Expand Down Expand Up @@ -438,8 +437,7 @@ def apply(self, model):
)
f.write("cd {}\n".format(working_dir))
bash_command = ["bash", script]
process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
process_compile.communicate()
launch_process_helper(bash_command, check=True)
# TODO rename xclbin appropriately here?
xclbin = link_dir + "/a.xclbin"
assert os.path.isfile(xclbin), (
Expand All @@ -457,8 +455,7 @@ def apply(self, model):
f.write("%s -mode batch -source %s\n" % (vivado_cmd, link_dir + "/gen_report_xml.tcl"))
f.write("cd {}\n".format(working_dir))
bash_command = ["bash", gen_rep_xml_sh]
process_genxml = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
process_genxml.communicate()
launch_process_helper(bash_command, check=True)
# filename for the synth utilization report
synth_report_filename = link_dir + "/synth_report.xml"
model.set_metadata_prop("vivado_synth_rpt", synth_report_filename)
Expand Down
6 changes: 2 additions & 4 deletions src/finn/transformation/fpgadataflow/create_stitched_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import json
import multiprocessing as mp
import os
import subprocess
import warnings
from qonnx.custom_op.registry import getCustomOp
from qonnx.transformation.base import Transformation
Expand All @@ -40,7 +39,7 @@
from finn.transformation.fpgadataflow.replace_verilog_relpaths import (
ReplaceVerilogRelPaths,
)
from finn.util.basic import make_build_dir, resolve_xilinx_tool
from finn.util.basic import launch_process_helper, make_build_dir, resolve_xilinx_tool
from finn.util.fpgadataflow import is_hls_node, is_rtl_node


Expand Down Expand Up @@ -776,8 +775,7 @@ def apply(self, model):
f.write("{} -mode batch -source make_project.tcl\n".format(vivado_cmd))
f.write("cd {}\n".format(working_dir))
bash_command = ["bash", make_project_sh]
process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
process_compile.communicate()
launch_process_helper(bash_command, check=True)
# wrapper may be created in different location depending on Vivado version
if not os.path.isfile(wrapper_filename):
# check in alternative location (.gen instead of .srcs)
Expand Down
5 changes: 2 additions & 3 deletions src/finn/transformation/fpgadataflow/make_zynq_proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import multiprocessing as mp
import os
import subprocess
from qonnx.core.modelwrapper import ModelWrapper
from qonnx.custom_op.registry import getCustomOp
from qonnx.transformation.base import Transformation
Expand All @@ -50,6 +49,7 @@
from finn.transformation.fpgadataflow.prepare_ip import PrepareIP
from finn.transformation.fpgadataflow.specialize_layers import SpecializeLayers
from finn.util.basic import (
launch_process_helper,
make_build_dir,
pynq_native_port_width,
pynq_part_map,
Expand Down Expand Up @@ -277,8 +277,7 @@ def apply(self, model):

# call the synthesis script
bash_command = ["bash", synth_project_sh]
process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
process_compile.communicate()
launch_process_helper(bash_command, check=True)
bitfile_name = vivado_pynq_proj_dir + "/finn_zynq_link.runs/impl_1/top_wrapper.bit"
if not os.path.isfile(bitfile_name):
raise Exception(
Expand Down
3 changes: 1 addition & 2 deletions src/finn/util/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ def build(self, code_gen_dir):
f.write("#!/bin/bash \n")
f.write(bash_compile + "\n")
bash_command = ["bash", self.compile_script]
process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
process_compile.communicate()
launch_process_helper(bash_command, check=True)


def launch_process_helper(args, proc_env=None, cwd=None, check=False):
Expand Down
6 changes: 2 additions & 4 deletions src/finn/util/hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@

import os
import re
import subprocess

from finn.util.basic import resolve_xilinx_tool
from finn.util.basic import launch_process_helper, resolve_xilinx_tool


class CallHLS:
Expand Down Expand Up @@ -75,5 +74,4 @@ def build(self, code_gen_dir):
f.write("cd {}\n".format(working_dir))
f.close()
bash_command = ["bash", self.ipgen_script]
process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
process_compile.communicate()
launch_process_helper(bash_command, check=True)