Ejemplo n.º 1
0
def synthesis_module(tmpdir, kernel_files, module_name, device_info):
    """Synthesis a module in kernel files.

  Returns:
    (returncode, stdout, stderr) results of the subprocess.
  """
    job_server = util.acquire_job_slot()
    with tempfile.TemporaryFile(mode='w+b') as tarfileobj:
        with backend.RunHls(tarfileobj,
                            kernel_files,
                            module_name,
                            device_info['clock_period'],
                            device_info['part_num'],
                            reset_low=False) as proc:
            stdout, stderr = proc.communicate()
        if proc.returncode == 0:
            tarfileobj.seek(0)
            with tarfile.open(mode='r', fileobj=tarfileobj) as tar:
                tar.extractall(
                    tmpdir,
                    (f for f in tar.getmembers()
                     if f.name.startswith('hdl') or f.name.startswith('report')
                     ))
    util.release_job_slot(job_server)
    return proc.returncode, stdout, stderr
Ejemplo n.º 2
0
 def worker(task: Task, idx: int) -> None:
     os.nice(idx % 19)
     with open(self.get_tar(task.name), 'wb') as tarfileobj:
         with hls.RunHls(
                 tarfileobj,
                 kernel_files=[(self.get_cpp(task.name), self.cflags)],
                 top_name=task.name,
                 clock_period=clock_period,
                 part_num=part_num,
                 auto_prefix=True,
                 hls='vitis_hls',
                 std='c++17',
         ) as proc:
             stdout, stderr = proc.communicate()
     if proc.returncode != 0:
         if b'Pre-synthesis failed.' in stdout and b'\nERROR:' not in stdout:
             _logger.error(
                 'HLS failed for %s, but the failure may be flaky; retrying',
                 task.name,
             )
             worker(task, 0)
             return
         sys.stdout.write(stdout.decode('utf-8'))
         sys.stderr.write(stderr.decode('utf-8'))
         raise RuntimeError('HLS failed for {}'.format(task.name))
Ejemplo n.º 3
0
Archivo: core.py Proyecto: mfkiwl/tapa
 def worker(task: Task) -> None:
     with open(self.get_tar(task.name), 'wb') as tarfileobj:
         with hls.RunHls(
                 tarfileobj,
                 kernel_files=[(self.get_cpp(task.name), self.cflags)],
                 top_name=task.name,
                 clock_period=clock_period,
                 part_num=part_num,
                 auto_prefix=True,
                 hls='vitis_hls',
         ) as proc:
             stdout, stderr = proc.communicate()
         if proc.returncode != 0:
             sys.stdout.write(stdout.decode('utf-8'))
             sys.stderr.write(stderr.decode('utf-8'))
             raise RuntimeError('HLS failed for {}'.format(task.name))
Ejemplo n.º 4
0
def synthesis_module(tmpdir, kernel_files, module_name, device_info):
  """Synthesis a module in kernel files.

  Returns:
    (returncode, stdout, stderr) results of the subprocess.
  """
  with tempfile.TemporaryFile(mode='w+b') as tarfileobj:
    with backend.RunHls(
        tarfileobj, kernel_files, module_name, device_info['clock_period'],
        device_info['part_num']) as proc:
      stdout, stderr = proc.communicate()
    if proc.returncode == 0:
      tarfileobj.seek(0)
      with tarfile.open(mode='r', fileobj=tarfileobj) as tar:
        tar.extractall(tmpdir, filter(lambda _: _.name.startswith('hdl'),
                                      tar.getmembers()))
  return proc.returncode, stdout, stderr