Skip to content

Commit

Permalink
Change line width to 120 columns
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun committed Jan 3, 2022
1 parent fa22c46 commit 93efe94
Show file tree
Hide file tree
Showing 567 changed files with 12,364 additions and 27,147 deletions.
2 changes: 1 addition & 1 deletion .style.yapf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[style]
based_on_style = pep8
column_limit = 80
column_limit = 120
11 changes: 3 additions & 8 deletions dace/cli/dacelab.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,15 @@ def compile(inputfile):
# Clean isolated nodes
for state in sdfg.nodes():
for node in state.nodes():
if (isinstance(node, AccessNode)
and (state.in_degree(node) + state.out_degree(node) == 0)):
if (isinstance(node, AccessNode) and (state.in_degree(node) + state.out_degree(node) == 0)):
state.remove_node(node)

return sdfg


def main():
argparser = argparse.ArgumentParser(
description="dacelab: An Octave to SDFG compiler")
argparser.add_argument("infile",
metavar='infile',
type=argparse.FileType('r'),
help="Input file (Octave code)")
argparser = argparse.ArgumentParser(description="dacelab: An Octave to SDFG compiler")
argparser.add_argument("infile", metavar='infile', type=argparse.FileType('r'), help="Input file (Octave code)")
argparser.add_argument("-o",
"--outfile",
metavar='outfile',
Expand Down
15 changes: 6 additions & 9 deletions dace/cli/sdfgcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,17 @@

def main():
# Command line options parser
parser = argparse.ArgumentParser(
description='Simple SDFG command-line compiler.')
parser = argparse.ArgumentParser(description='Simple SDFG command-line compiler.')

# Required argument for SDFG file path
parser.add_argument('filepath', help='<PATH TO SDFG FILE>', type=str)

# Optional argument for output location
parser.add_argument(
'-o',
'--out',
type=str,
help=
'If provided, saves library as the given file or in the specified path, '
'together with a header file.')
parser.add_argument('-o',
'--out',
type=str,
help='If provided, saves library as the given file or in the specified path, '
'together with a header file.')

parser.add_argument('-O',
'--optimize',
Expand Down
3 changes: 1 addition & 2 deletions dace/cli/sdfv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def view(sdfg, filename=None):
sdfg = dace.serialize.dumps(sdfg.to_json())

basepath = os.path.dirname(os.path.realpath(diode.__file__))
template_loader = jinja2.FileSystemLoader(
searchpath=os.path.join(basepath, 'templates'))
template_loader = jinja2.FileSystemLoader(searchpath=os.path.join(basepath, 'templates'))
template_env = jinja2.Environment(loader=template_loader)
template = template_env.get_template('sdfv.html')

Expand Down
8 changes: 2 additions & 6 deletions dace/cli/sdprof.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
parser.add_argument('--sort',
'-s',
help='Sort by a specific criterion',
choices=('min', 'max', 'mean', 'median', 'counter',
'value'))
parser.add_argument('--ascending',
'-a',
help='Sort in ascending order',
action='store_true')
choices=('min', 'max', 'mean', 'median', 'counter', 'value'))
parser.add_argument('--ascending', '-a', help='Sort in ascending order', action='store_true')

args = parser.parse_args()

Expand Down
37 changes: 11 additions & 26 deletions dace/codegen/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ def generate_headers(sdfg: SDFG) -> str:
""" Generate a header file for the SDFG """
proto = ""
proto += "#include <dace/dace.h>\n"
init_params = (sdfg.name, sdfg.name,
sdfg.signature(with_types=True,
for_call=False,
with_arrays=False))
init_params = (sdfg.name, sdfg.name, sdfg.signature(with_types=True, for_call=False, with_arrays=False))
call_params = sdfg.signature(with_types=True, for_call=False)
if len(call_params) > 0:
call_params = ', ' + call_params
Expand All @@ -44,9 +41,7 @@ def generate_dummy(sdfg: SDFG) -> str:
the right types and and guess values for scalars.
"""
al = sdfg.arglist()
init_params = sdfg.signature(with_types=False,
for_call=True,
with_arrays=False)
init_params = sdfg.signature(with_types=False, for_call=True, with_arrays=False)
params = sdfg.signature(with_types=False, for_call=True)
if len(params) > 0:
params = ', ' + params
Expand All @@ -57,20 +52,15 @@ def generate_dummy(sdfg: SDFG) -> str:
# first find all scalars and set them to 42
for argname, arg in al.items():
if isinstance(arg, data.Scalar):
allocations += (" " +
str(arg.as_arg(name=argname, with_types=True)) +
" = 42;\n")
allocations += (" " + str(arg.as_arg(name=argname, with_types=True)) + " = 42;\n")

# allocate the array args using calloc
for argname, arg in al.items():
if isinstance(arg, data.Array):
dims_mul = cpp.sym2cpp(
functools.reduce(lambda a, b: a * b, arg.shape, 1))
dims_mul = cpp.sym2cpp(functools.reduce(lambda a, b: a * b, arg.shape, 1))
basetype = str(arg.dtype)
allocations += (" " +
str(arg.as_arg(name=argname, with_types=True)) +
" = (" + basetype + "*) calloc(" + dims_mul +
", sizeof(" + basetype + ")" + ");\n")
allocations += (" " + str(arg.as_arg(name=argname, with_types=True)) + " = (" + basetype + "*) calloc(" +
dims_mul + ", sizeof(" + basetype + ")" + ");\n")
deallocations += " free(" + argname + ");\n"

return f'''#include <cstdlib>
Expand Down Expand Up @@ -114,8 +104,7 @@ def generate_code(sdfg, validate=True) -> List[CodeObject]:
if not filecmp.cmp(f'{tmp_dir}/test.sdfg', f'{tmp_dir}/test2.sdfg'):
shutil.move(f"{tmp_dir}/test.sdfg", "test.sdfg")
shutil.move(f"{tmp_dir}/test2.sdfg", "test2.sdfg")
raise RuntimeError(
'SDFG serialization failed - files do not match')
raise RuntimeError('SDFG serialization failed - files do not match')

# Run with the deserialized version
# NOTE: This means that all subsequent modifications to `sdfg`
Expand Down Expand Up @@ -150,14 +139,12 @@ def generate_code(sdfg, validate=True) -> List[CodeObject]:
# Instantiate the rest of the targets
targets.update({
v['name']: k(frame, sdfg)
for k, v in target.TargetCodeGenerator.extensions().items()
if v['name'] not in targets
for k, v in target.TargetCodeGenerator.extensions().items() if v['name'] not in targets
})

# Instantiate all instrumentation providers in SDFG
provider_mapping = InstrumentationProvider.get_provider_mapping()
frame._dispatcher.instrumentation[
dtypes.InstrumentationType.No_Instrumentation] = None
frame._dispatcher.instrumentation[dtypes.InstrumentationType.No_Instrumentation] = None
for node, _ in sdfg.all_nodes_recursive():
if hasattr(node, 'instrument'):
frame._dispatcher.instrumentation[node.instrument] = \
Expand All @@ -177,8 +164,7 @@ def generate_code(sdfg, validate=True) -> List[CodeObject]:
}

# Generate frame code (and the rest of the code)
(global_code, frame_code, used_targets,
used_environments) = frame.generate_code(sdfg, None)
(global_code, frame_code, used_targets, used_environments) = frame.generate_code(sdfg, None)
target_objects = [
CodeObject(sdfg.name,
global_code + frame_code,
Expand All @@ -203,8 +189,7 @@ def generate_code(sdfg, validate=True) -> List[CodeObject]:
linkable=False)
target_objects.append(dummy)

for env in dace.library.get_environments_and_dependencies(
used_environments):
for env in dace.library.get_environments_and_dependencies(used_environments):
if hasattr(env, "codeobjects"):
target_objects.extend(env.codeobjects)

Expand Down
27 changes: 8 additions & 19 deletions dace/codegen/codeobject.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved.
import re
from dace import sourcemap
from dace.properties import (Property, DictProperty, SetProperty,
make_properties)
from dace.properties import (Property, DictProperty, SetProperty, make_properties)


@make_properties
class CodeObject(object):
name = Property(dtype=str, desc="Filename to use")
code = Property(dtype=str, desc="The code attached to this object")
language = Property(dtype=str,
desc="Language used for this code (same " +
"as its file extension)")
target = Property(dtype=type,
desc="Target to use for compilation",
allow_none=True)
target_type = Property(
dtype=str,
desc="Sub-target within target (e.g., host or device code)",
default="")
language = Property(dtype=str, desc="Language used for this code (same " + "as its file extension)")
target = Property(dtype=type, desc="Target to use for compilation", allow_none=True)
target_type = Property(dtype=str, desc="Sub-target within target (e.g., host or device code)", default="")
title = Property(dtype=str, desc="Title of code for GUI")
extra_compiler_kwargs = DictProperty(key_type=str,
value_type=str,
desc="Additional compiler argument "
"variables to add to template")
linkable = Property(dtype=bool,
desc='Should this file participate in '
'overall linkage?')
environments = SetProperty(
str,
desc="Environments required by CMake to build and run this code node.",
default=set())
linkable = Property(dtype=bool, desc='Should this file participate in ' 'overall linkage?')
environments = SetProperty(str,
desc="Environments required by CMake to build and run this code node.",
default=set())

def __init__(self,
name,
Expand Down
Loading

0 comments on commit 93efe94

Please sign in to comment.