Skip to content

Commit

Permalink
Fix work depth analysis dependency (#239)
Browse files Browse the repository at this point in the history
* Fix work depth analysis dependency

* Package updates

* Update version number
  • Loading branch information
phschaad authored Oct 10, 2023
1 parent bc7f459 commit 7a8906e
Show file tree
Hide file tree
Showing 5 changed files with 795 additions and 635 deletions.
52 changes: 45 additions & 7 deletions backend/dace_vscode/work_depth.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
# Copyright 2020-2023 ETH Zurich and the DaCe-VSCode authors.
# All rights reserved.

from typing import Any

import sympy as sp
from dace.sdfg.work_depth_analysis.work_depth import analyze_sdfg, get_tasklet_work, get_tasklet_work_depth, get_tasklet_avg_par
try:
from dace.sdfg.work_depth_analysis import work_depth
except ImportError:
work_depth = None

from dace_vscode.utils import (
load_sdfg_from_json,
get_exception_message,
)

def get_work(sdfg_json, assumptions):
def get_work(sdfg_json: Any, assumptions: str):
if not work_depth:
return {
'error': {
'message': 'DaCe version does not support work depth analysis',
'details': 'Please update DaCe to a newer version',
},
}

loaded = load_sdfg_from_json(sdfg_json)
if loaded['error'] is not None:
return loaded['error']
sdfg = loaded['sdfg']

try:
work_map = {}
analyze_sdfg(sdfg, work_map, get_tasklet_work, assumptions.split(), False)
work_depth.analyze_sdfg(
sdfg, work_map, work_depth.get_tasklet_work, assumptions.split(),
False
)
for k, v, in work_map.items():
work_map[k] = str(sp.simplify(v[0])) # only take work
return {
Expand All @@ -32,15 +48,26 @@ def get_work(sdfg_json, assumptions):
}


def get_depth(sdfg_json, assumptions):
def get_depth(sdfg_json: Any, assumptions: str):
if not work_depth:
return {
'error': {
'message': 'DaCe version does not support work depth analysis',
'details': 'Please update DaCe to a newer version',
},
}

loaded = load_sdfg_from_json(sdfg_json)
if loaded['error'] is not None:
return loaded['error']
sdfg = loaded['sdfg']

try:
depth_map = {}
analyze_sdfg(sdfg, depth_map, get_tasklet_work_depth, assumptions.split(), False)
work_depth.analyze_sdfg(
sdfg, depth_map, work_depth.get_tasklet_work_depth,
assumptions.split(), False
)
for k, v, in depth_map.items():
depth_map[k] = str(sp.simplify(v[1])) # only take depth
return {
Expand All @@ -55,15 +82,26 @@ def get_depth(sdfg_json, assumptions):
}


def get_avg_parallelism(sdfg_json, assumptions):
def get_avg_parallelism(sdfg_json: Any, assumptions: str):
if not work_depth:
return {
'error': {
'message': 'DaCe version does not support work depth analysis',
'details': 'Please update DaCe to a newer version',
},
}

loaded = load_sdfg_from_json(sdfg_json)
if loaded['error'] is not None:
return loaded['error']
sdfg = loaded['sdfg']

try:
avg_parallelism_map = {}
analyze_sdfg(sdfg, avg_parallelism_map, get_tasklet_avg_par, assumptions.split(), False)
work_depth.analyze_sdfg(
sdfg, avg_parallelism_map, work_depth.get_tasklet_avg_par,
assumptions.split(), False
)
for k, v, in avg_parallelism_map.items():
avg_parallelism_map[k] = str(
sp.simplify(v[0] / v[1])
Expand Down
Loading

0 comments on commit 7a8906e

Please sign in to comment.