Skip to content

Commit

Permalink
Merge branch 'main' into users/phschaad/adapt_passes
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Nov 5, 2024
2 parents ca00134 + d7abf06 commit 8d03dc5
Show file tree
Hide file tree
Showing 57 changed files with 784 additions and 398 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fpga-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-ci') }}
runs-on: [self-hosted, linux, intel-fpga, xilinx-fpga]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/general-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
simplify: [0,1,autoopt]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gpu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
if: "!contains(github.event.pull_request.labels.*.name, 'no-ci')"
runs-on: [self-hosted, gpu]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hardware_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test-rtl:
runs-on: [self-hosted, linux, xilinx-fpga]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/heterogeneous-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
if: "!contains(github.event.pull_request.labels.*.name, 'no-ci')"
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pyFV3-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ jobs:
python-version: [3.11.7]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
repository: 'NOAA-GFDL/PyFV3'
ref: 'ci/DaCe'
submodules: 'recursive'
path: 'pyFV3'
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: 'dace'
submodules: 'recursive'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install library dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verilator_compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ jobs:
steps:
- name: trigger reason
run: echo "Trigger Reason:" ${{ github.event.inputs.reason }}
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: checkout submodules
run: git submodule update --init --recursive
- name: install apt packages
run: sudo apt-get update && sudo apt-get -y install git make autoconf g++ flex bison libfl2 libfl-dev
- name: compile verilator
run: git clone https://github.com/verilator/verilator.git && cd verilator && git fetch origin && if [ ! "${{ matrix.verilator_version }}" == "master" ]; then git checkout v${{ matrix.verilator_version }}; fi && autoconf && ./configure && make -j2 && sudo make install
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: '3.8'
architecture: 'x64'
Expand Down
5 changes: 0 additions & 5 deletions dace/cli/dacelab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved.

import argparse
import numpy
import pickle
import json

import dace
from dace.frontend.octave import parse
from dace.sdfg.nodes import AccessNode

Expand Down
6 changes: 5 additions & 1 deletion dace/cli/sdfg_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import tempfile
from typing import Dict, Literal, Set, Tuple, Union

import jinja2
import dace
from dace import memlet as mlt
from dace.sdfg import nodes as nd
Expand Down Expand Up @@ -179,6 +178,11 @@ def main():
diff_sets = _sdfg_diff(sdfg_A, sdfg_B, eq_strategy)

if args.graphical:
try:
import jinja2
except (ImportError, ModuleNotFoundError):
raise ImportError('Graphical SDFG diff requires jinja2, please install by running `pip install jinja2`')

basepath = os.path.join(os.path.dirname(os.path.realpath(dace.__file__)), 'viewer')
template_loader = jinja2.FileSystemLoader(searchpath=os.path.join(basepath, 'templates'))
template_env = jinja2.Environment(loader=template_loader)
Expand Down
2 changes: 1 addition & 1 deletion dace/cli/sdfgcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main():
sdfg = SDFGOptimizer(sdfg).optimize()

# Compile SDFG
sdfg.compile(outpath)
sdfg.compile(outpath, return_program_handle=False)

# Copying header file to optional path
if outpath is not None:
Expand Down
12 changes: 10 additions & 2 deletions dace/cli/sdfv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import dace
import tempfile
import jinja2


def partialclass(cls, *args, **kwds):
Expand Down Expand Up @@ -44,10 +43,19 @@ def view(sdfg: dace.SDFG, filename: Optional[Union[str, int]] = None, verbose: b
):
fd, filename = tempfile.mkstemp(suffix='.sdfg')
sdfg.save(filename)
os.system(f'code {filename}')
if platform.system() == 'Darwin':
# Special case for MacOS
os.system(f'open {filename}')
else:
os.system(f'code {filename}')
os.close(fd)
return

try:
import jinja2
except (ImportError, ModuleNotFoundError):
raise ImportError('SDFG.view() requires jinja2, please install by running `pip install jinja2`')

if type(sdfg) is dace.SDFG:
sdfg = dace.serialize.dumps(sdfg.to_json())

Expand Down
5 changes: 5 additions & 0 deletions dace/codegen/compiled_sdfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ def _construct_args(self, kwargs) -> Tuple[Tuple[Any], Tuple[Any]]:
# Otherwise, None values are passed as null pointers below
elif isinstance(arg, ctypes._Pointer):
pass
elif isinstance(arg, str):
# Cast to bytes
arglist[i] = ctypes.c_char_p(arg.encode('utf-8'))
else:
raise TypeError(f'Passing an object (type {type(arg).__name__}) to an array in argument "{a}"')
elif is_array and not is_dtArray:
Expand Down Expand Up @@ -550,6 +553,8 @@ def _construct_args(self, kwargs) -> Tuple[Tuple[Any], Tuple[Any]]:
pass
elif isinstance(arg, float) and atype.dtype.type == np.float64:
pass
elif isinstance(arg, bool) and atype.dtype.type == np.bool_:
pass
elif (isinstance(arg, str) or arg is None) and atype.dtype == dtypes.string:
if arg is None:
arglist[i] = ctypes.c_char_p(None)
Expand Down
2 changes: 1 addition & 1 deletion dace/codegen/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def configure_and_compile(program_folder, program_name=None, output_stream=None)
# Clean CMake directory and try once more
if Config.get_bool('debugprint'):
print('Cleaning CMake build folder and retrying...')
shutil.rmtree(build_folder)
shutil.rmtree(build_folder, ignore_errors=True)
os.makedirs(build_folder)
try:
_run_liveoutput(cmake_command, shell=True, cwd=build_folder, output_stream=output_stream)
Expand Down
8 changes: 7 additions & 1 deletion dace/codegen/cppunparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,11 @@ def _write_constant(self, value):
if result.find("b'") >= 0:
self.write(result)
else:
self.write(result.replace('\'', '\"'))
towrite = result
if result.startswith("'"):
towrite = result[1:-1].replace('"', '\\"')
towrite = f'"{towrite}"'
self.write(towrite)

def _Constant(self, t):
value = t.value
Expand Down Expand Up @@ -1187,6 +1191,8 @@ def py2cpp(code, expr_semicolon=True, defined_symbols=None):
return cppunparse(ast.parse(symbolic.symstr(code, cpp_mode=True)),
expr_semicolon,
defined_symbols=defined_symbols)
elif isinstance(code, int):
return str(code)
elif code.__class__.__name__ == 'function':
try:
code_str = inspect.getsource(code)
Expand Down
2 changes: 2 additions & 0 deletions dace/codegen/tools/type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ def _Compare(t, symbols, inferred_symbols):
for o, e in zip(t.ops, t.comparators):
if o.__class__.__name__ not in cppunparse.CPPUnparser.cmpops:
continue
if isinstance(e, ast.Constant) and e.value is None:
continue
inf_type = _dispatch(e, symbols, inferred_symbols)
if isinstance(inf_type, dtypes.vector):
# Make sure all occuring vectors are of same size
Expand Down
2 changes: 2 additions & 0 deletions dace/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ def __init__(self, wrapped_type, typename=None):
wrapped_type = numpy.bool_
elif getattr(wrapped_type, '__name__', '') == 'bool_' and typename is None:
typename = 'bool'
elif wrapped_type is type(None):
wrapped_type = None

self.type = wrapped_type # Type in Python
self.ctype = _CTYPES[wrapped_type] # Type in C
Expand Down
4 changes: 2 additions & 2 deletions dace/memlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,9 @@ def used_symbols(self, all_symbols: bool, edge=None) -> Set[str]:
from dace.sdfg import nodes
if isinstance(edge.dst, nodes.CodeNode) or isinstance(edge.src, nodes.CodeNode):
view_edge = True
elif edge.dst_conn == 'views' and isinstance(edge.dst, nodes.AccessNode):
elif edge.dst_conn and isinstance(edge.dst, nodes.AccessNode):
view_edge = True
elif edge.src_conn == 'views' and isinstance(edge.src, nodes.AccessNode):
elif edge.src_conn and isinstance(edge.src, nodes.AccessNode):
view_edge = True

if not view_edge:
Expand Down
2 changes: 1 addition & 1 deletion dace/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def initialize_properties(obj, *args, **kwargs):
for name, prop in own_properties.items():
# Only assign our own properties, so we don't overwrite what's been
# set by the base class
if hasattr(obj, name):
if hasattr(obj, '_' + name):
raise PropertyError("Property {} already assigned in {}".format(name, type(obj).__name__))
if not prop.indirected:
if prop.allow_none or prop.default is not None:
Expand Down
8 changes: 4 additions & 4 deletions dace/runtime/include/dace/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ namespace dace {

template <int CHUNKSIZE>
struct Consume {
template <template <typename, bool> typename StreamT, typename T, bool ALIGNED,
template <template <typename, bool> class StreamT, typename T, bool ALIGNED,
typename Functor>
static void consume(StreamT<T, ALIGNED>& stream, unsigned num_threads,
Functor&& contents) {
Expand All @@ -359,7 +359,7 @@ namespace dace {
for (auto& t : threads) t.join();
}

template <template <typename, bool> typename StreamT, typename T, bool ALIGNED,
template <template <typename, bool> class StreamT, typename T, bool ALIGNED,
typename CondFunctor, typename Functor>
static void consume_cond(StreamT<T, ALIGNED>& stream, unsigned num_threads,
CondFunctor&& quiescence, Functor&& contents) {
Expand All @@ -384,7 +384,7 @@ namespace dace {
// Specialization for consumption of 1 element
template<>
struct Consume<1> {
template <template <typename, bool> typename StreamT, typename T, bool ALIGNED,
template <template <typename, bool> class StreamT, typename T, bool ALIGNED,
typename Functor>
static void consume(StreamT<T, ALIGNED>& stream, unsigned num_threads,
Functor&& contents) {
Expand All @@ -404,7 +404,7 @@ namespace dace {
for (auto& t : threads) t.join();
}

template <template <typename, bool> typename StreamT, typename T, bool ALIGNED,
template <template <typename, bool> class StreamT, typename T, bool ALIGNED,
typename CondFunctor, typename Functor>
static void consume_cond(StreamT<T, ALIGNED>& stream, unsigned num_threads,
CondFunctor&& quiescence, Functor&& contents) {
Expand Down
Loading

0 comments on commit 8d03dc5

Please sign in to comment.