Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix circular dependencies #175

Merged
merged 2 commits into from
Oct 14, 2024
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spcl/sdfv",
"version": "1.3.0",
"version": "1.3.1",
"description": "A standalone viewer for SDFGs",
"homepage": "https://github.com/spcl/dace-webclient",
"main": "out/index.js",
Expand Down
96 changes: 1 addition & 95 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { SDFGElement } from './renderer/renderer_elements';

export * from './overlays/memory_volume_overlay';
export * from './overlays/runtime_micro_seconds_overlay';
export * from './overlays/memory_location_overlay';
Expand All @@ -26,96 +24,4 @@ export * from './utils/utils';
export * from './overlay_manager';
export * from './sdfv';
export * from './sdfv_ui';

export type SymbolMap = {
[symbol: string]: number | undefined,
};

export type DagreGraph = dagre.graphlib.Graph<SDFGElement>;

export type InvalidSDFGError = {
message: string | undefined,
sdfg_id: number | undefined,
state_id: number | undefined,
node_id: number | undefined,
edge_id: number | undefined,
isedge_id: number | undefined,
};

export interface JsonSDFGElement {
attributes?: any,
type: string,
}

export interface JsonSDFGEdge extends JsonSDFGElement {
dst: string,
dst_connector: string | null,
src: string,
src_connector: string | null,
height: number,
width: number,
x?: number,
y?: number,
}

export interface JsonSDFGNode extends JsonSDFGElement {
id: number,
label: string,
scope_entry: string | null,
scope_exit: string | null,
}

export interface JsonSDFGBlock extends JsonSDFGElement {
collapsed?: boolean,
edges?: JsonSDFGEdge[],
nodes?: (JsonSDFGBlock | JsonSDFGNode)[],
id: number,
label: string,
}

type CodeBlock = {
string_data: string,
language: string,
};

export interface JsonSDFGConditionalBlock extends JsonSDFGBlock {
branches: ([CodeBlock | null, JsonSDFGControlFlowRegion])[];
}

export interface JsonSDFGControlFlowRegion extends JsonSDFGBlock {
nodes: JsonSDFGBlock[],
edges: JsonSDFGEdge[],
start_block: number,
cfg_list_id: number,
}

export interface JsonSDFGState extends JsonSDFGBlock {
scope_dict: any,
nodes: JsonSDFGNode[],
edges: JsonSDFGEdge[],
}

export interface JsonSDFG extends JsonSDFGControlFlowRegion {
error: InvalidSDFGError | undefined,
}

export type ModeButtons = {
pan: HTMLElement | null,
move: HTMLElement | null,
select: HTMLElement | null,
add_btns: HTMLElement[],
};

export type SDFVTooltipFunc = (container: HTMLElement) => void;

export type Point2D = {
x: number,
y: number,
};

export type Size2D = {
w: number,
h: number,
};

export type SimpleRect = Point2D & Size2D;
export * from './types';
48 changes: 26 additions & 22 deletions src/layouter/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,45 @@

import dagre from 'dagre';

import { SDFVSettings } from '../utils/sdfv_settings';
import { SMLayouter } from './state_machine/sm_layouter';
import {
AccessNode,
calculateBoundingBox,
calculateEdgeBoundingBox,
CFGListType,
check_and_redirect_edge,
ConditionalBlock,
Connector,
ControlFlowRegion,
DagreGraph,
deepCopy,
findExitForEntry,
intersectRect,
InterstateEdge,
JsonSDFG,
JsonSDFGBlock,
JsonSDFGConditionalBlock,
JsonSDFGControlFlowRegion,
JsonSDFGEdge,
JsonSDFGNode,
Point2D,
Size2D,
} from '../types';
import {
AccessNode,
ConditionalBlock,
Connector,
ControlFlowRegion,
InterstateEdge,
LoopRegion,
Memlet,
NestedSDFG,
Point2D,
ScopeNode,
SDFG,
sdfg_property_to_string,
SDFGElements,
SDFGElementType,
SDFGNode,
SDFV,
Size2D,
State,
} from '..';
import { SDFVSettings } from '../utils/sdfv_settings';
import { SMLayouter } from './state_machine/sm_layouter';
} from '../renderer/renderer_elements';
import { sdfg_property_to_string } from '../utils/sdfg/display';
import { SDFV } from '../sdfv';
import type { CFGListType, DagreGraph } from '../renderer/renderer';
import {
check_and_redirect_edge,
findExitForEntry,
} from '../utils/sdfg/sdfg_utils';
import {
calculateBoundingBox,
calculateEdgeBoundingBox,
} from '../utils/bounding_box';
import { deepCopy, intersectRect } from '../utils/utils';

type CFGBlockInfoT = {
label?: string,
Expand Down Expand Up @@ -270,8 +273,9 @@ function layoutDFNode(
node.type === SDFGElementType.ExternalNestedSDFG) {
if (node.attributes.sdfg &&
node.attributes.sdfg.type !== 'SDFGShell') {
const nsdfg = new SDFG(node.attributes.sdfg);
nestedGraph = layoutControlFlowRegion(
node.attributes.sdfg, state, ctx, cfgList, stateParentList,
node.attributes.sdfg, nsdfg, ctx, cfgList, stateParentList,
omitAccessNodes
);
const sdfgInfo = calculateBoundingBox(nestedGraph);
Expand Down
2 changes: 1 addition & 1 deletion src/layouter/state_machine/sm_layouter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { DagreGraph } from '../..';
import * as dagre from 'dagre';
import { allBackedges } from '../graphlib/algorithms/cycles';
import {
dominatorTree,
immediateDominators,
} from '../graphlib/algorithms/dominance';
import { DiGraph } from '../graphlib/di_graph';
import type { DagreGraph } from '../../renderer/renderer';

/* eslint-disable @typescript-eslint/no-var-requires */
const dagreOrder = require('dagre/lib/order');
Expand Down
3 changes: 2 additions & 1 deletion src/local_view/lview_parser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import $ from 'jquery';
import { DagreGraph, JsonSDFG } from '..';
import {
AccessNode,
Edge,
Expand All @@ -28,6 +27,8 @@ import { MemoryNode } from './elements/memory_node';
import { Element } from './elements/element';
import { LViewRenderer } from './lview_renderer';
import { evaluate } from 'mathjs';
import type { DagreGraph } from '../renderer/renderer';
import { JsonSDFG } from '../types';

export class LViewGraphParseError extends Error {}

Expand Down
8 changes: 4 additions & 4 deletions src/overlay_manager.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { MathNode, parse, SymbolNode } from 'mathjs';
import { Point2D, SymbolMap } from './index';
import { GenericSdfgOverlay } from './overlays/generic_sdfg_overlay';
import {
import type { GenericSdfgOverlay } from './overlays/generic_sdfg_overlay';
import type {
GraphElementInfo,
SDFGElementGroup,
SDFGRenderer,
} from './renderer/renderer';
import { SDFGElement } from './renderer/renderer_elements';
import type { SDFGElement } from './renderer/renderer_elements';
import { createElement } from './utils/utils';
import { Point2D, SymbolMap } from './types';

export class SymbolResolver {

Expand Down
9 changes: 3 additions & 6 deletions src/overlays/avg_parallelism_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import {
import type {
DagreGraph,
Point2D,
SymbolMap,
getGraphElementUUID,
} from '../index';
import {
GraphElementInfo,
SDFGElementGroup,
SDFGRenderer,
Expand All @@ -19,6 +14,8 @@ import {
SDFGElement,
SDFGNode,
} from '../renderer/renderer_elements';
import { Point2D, SymbolMap } from '../types';
import { getGraphElementUUID } from '../utils/sdfg/sdfg_utils';
import { getTempColorHslString } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

Expand Down
9 changes: 3 additions & 6 deletions src/overlays/depth_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import {
import type {
DagreGraph,
Point2D,
SymbolMap,
getGraphElementUUID,
} from '../index';
import {
GraphElementInfo,
SDFGElementGroup,
SDFGRenderer,
Expand All @@ -19,6 +14,8 @@ import {
SDFGElement,
SDFGNode,
} from '../renderer/renderer_elements';
import { Point2D, SymbolMap } from '../types';
import { getGraphElementUUID } from '../utils/sdfg/sdfg_utils';
import { getTempColorHslString } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

Expand Down
4 changes: 2 additions & 2 deletions src/overlays/diff_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { Point2D } from '../index';
import {
import type {
GraphElementInfo,
SDFGElementGroup,
SDFGRenderer,
Expand All @@ -13,6 +12,7 @@ import {
ControlFlowBlock,
} from '../renderer/renderer_elements';
import { DiffMap } from '../sdfg_diff_viewer';
import { Point2D } from '../types';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

export class DiffOverlay extends GenericSdfgOverlay {
Expand Down
7 changes: 5 additions & 2 deletions src/overlays/generic_sdfg_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { log, mean, median } from 'mathjs';
import { DagreGraph, OverlayManager, Point2D, SDFVSettings, SimpleRect, SymbolResolver } from '../index';
import {
import type {
DagreGraph,
GraphElementInfo,
SDFGElementGroup,
SDFGRenderer,
} from '../renderer/renderer';
import { OverlayManager, SymbolResolver } from '../overlay_manager';
import { SDFVSettings } from '../utils/sdfv_settings';
import {
ConditionalBlock,
ControlFlowBlock,
Expand All @@ -17,6 +19,7 @@ import {
SDFGNode,
State,
} from '../renderer/renderer_elements';
import { Point2D, SimpleRect } from '../types';

declare const vscode: any;

Expand Down
4 changes: 2 additions & 2 deletions src/overlays/logical_group_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { Point2D } from '../index';
import {
import type {
GraphElementInfo,
SDFGElementGroup,
SDFGRenderer,
Expand All @@ -13,6 +12,7 @@ import {
ControlFlowBlock,
Edge,
} from '../renderer/renderer_elements';
import { Point2D } from '../types';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

export type LogicalGroup = {
Expand Down
4 changes: 2 additions & 2 deletions src/overlays/memory_location_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { Point2D } from '../index';
import {
import type {
GraphElementInfo,
SDFGElementGroup,
SDFGRenderer,
Expand All @@ -11,6 +10,7 @@ import {
SDFGElement,
SDFGNode,
} from '../renderer/renderer_elements';
import { Point2D } from '../types';
import { KELLY_COLORS } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

Expand Down
5 changes: 3 additions & 2 deletions src/overlays/memory_volume_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { DagreGraph, Point2D, SymbolMap } from '../index';
import {
import type {
DagreGraph,
GraphElementInfo,
SDFGElementGroup,
SDFGRenderer,
Expand All @@ -15,6 +15,7 @@ import {
SDFGElement,
State,
} from '../renderer/renderer_elements';
import { Point2D, SymbolMap } from '../types';
import { getTempColorHslString } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

Expand Down
Loading
Loading