Skip to content

Commit

Permalink
Fix missing refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Apr 23, 2024
1 parent 971ac0d commit 86b9265
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 73 deletions.
14 changes: 10 additions & 4 deletions src/overlays/avg_parallelism_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { DagreGraph, Point2D, SimpleRect, SymbolMap } from '../index';
import {
DagreGraph,
Point2D,
SimpleRect,
SymbolMap,
getGraphElementUUID,
} from '../index';
import { SDFGRenderer } from '../renderer/renderer';
import {
ControlFlowBlock,
Expand All @@ -12,7 +18,7 @@ import {
State,
} from '../renderer/renderer_elements';
import { SDFV } from '../sdfv';
import { getTempColorHslString, get_element_uuid } from '../utils/utils';
import { getTempColorHslString } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

export class AvgParallelismOverlay extends GenericSdfgOverlay {
Expand Down Expand Up @@ -45,7 +51,7 @@ export class AvgParallelismOverlay extends GenericSdfgOverlay {
node: SDFGNode, symbol_map: SymbolMap, avg_parallelism_values: number[]
): number | undefined {
const avg_parallelism_string = this.avg_parallelism_map[
get_element_uuid(node)
getGraphElementUUID(node)
];
let avg_parallelism = undefined;
if (avg_parallelism_string !== undefined) {
Expand Down Expand Up @@ -285,7 +291,7 @@ export class AvgParallelismOverlay extends GenericSdfgOverlay {
!(foreground_elem instanceof Edge)) {
if (foreground_elem.data.avg_parallelism === undefined) {
const avg_parallelism_string = this.avg_parallelism_map[
get_element_uuid(foreground_elem)
getGraphElementUUID(foreground_elem)
];
if (avg_parallelism_string) {
this.symbolResolver.parse_symbol_expression(
Expand Down
14 changes: 10 additions & 4 deletions src/overlays/depth_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { DagreGraph, Point2D, SimpleRect, SymbolMap } from '../index';
import {
DagreGraph,
Point2D,
SimpleRect,
SymbolMap,
getGraphElementUUID,
} from '../index';
import { SDFGRenderer } from '../renderer/renderer';
import {
Edge,
Expand All @@ -9,7 +15,7 @@ import {
SDFGNode,
} from '../renderer/renderer_elements';
import { SDFV } from '../sdfv';
import { getTempColorHslString, get_element_uuid } from '../utils/utils';
import { getTempColorHslString } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

export class DepthOverlay extends GenericSdfgOverlay {
Expand Down Expand Up @@ -41,7 +47,7 @@ export class DepthOverlay extends GenericSdfgOverlay {
public calculate_depth_node(
node: SDFGNode, symbol_map: SymbolMap, depth_values: number[]
): number | undefined {
const depth_string = this.depth_map[get_element_uuid(node)];
const depth_string = this.depth_map[getGraphElementUUID(node)];
let depth = undefined;
if (depth_string !== undefined) {
depth = this.symbolResolver.parse_symbol_expression(
Expand Down Expand Up @@ -266,7 +272,7 @@ export class DepthOverlay extends GenericSdfgOverlay {
!(foreground_elem instanceof Edge)) {
if (foreground_elem.data.depth === undefined) {
const depth_string = this.depth_map[
get_element_uuid(foreground_elem)
getGraphElementUUID(foreground_elem)
];
if (depth_string) {
this.symbolResolver.parse_symbol_expression(
Expand Down
14 changes: 10 additions & 4 deletions src/overlays/operational_intensity_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { DagreGraph, Point2D, SimpleRect, SymbolMap } from '../index';
import {
DagreGraph,
Point2D,
SimpleRect,
SymbolMap,
getGraphElementUUID,
} from '../index';
import { SDFGRenderer } from '../renderer/renderer';
import {
Edge,
Expand All @@ -9,7 +15,7 @@ import {
SDFGNode,
} from '../renderer/renderer_elements';
import { SDFV } from '../sdfv';
import { getTempColorHslString, get_element_uuid } from '../utils/utils';
import { getTempColorHslString } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

export class OperationalIntensityOverlay extends GenericSdfgOverlay {
Expand Down Expand Up @@ -49,7 +55,7 @@ export class OperationalIntensityOverlay extends GenericSdfgOverlay {
if (node.parent_id === undefined || node.parent_id === null)
return;

const flops_string = this.flops_map[get_element_uuid(node)];
const flops_string = this.flops_map[getGraphElementUUID(node)];
let flops = undefined;
if (flops_string !== undefined) {
flops = this.symbolResolver.parse_symbol_expression(
Expand Down Expand Up @@ -309,7 +315,7 @@ export class OperationalIntensityOverlay extends GenericSdfgOverlay {
!(foreground_elem instanceof Edge)) {
if (foreground_elem.data.flops === undefined) {
const flops_string = this.flops_map[
get_element_uuid(foreground_elem)
getGraphElementUUID(foreground_elem)
];
if (flops_string) {
this.symbolResolver.parse_symbol_expression(
Expand Down
6 changes: 3 additions & 3 deletions src/overlays/runtime_micro_seconds_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { Node } from 'dagre';
import { DagreGraph, SimpleRect } from '../index';
import { DagreGraph, SimpleRect, getGraphElementUUID } from '../index';
import { SDFGRenderer } from '../renderer/renderer';
import { NestedSDFG, SDFGNode } from '../renderer/renderer_elements';
import { SDFV } from '../sdfv';
import { getTempColorHslString, get_element_uuid } from '../utils/utils';
import { getTempColorHslString } from '../utils/utils';
import {
GenericSdfgOverlay,
OverlayType,
Expand Down Expand Up @@ -66,7 +66,7 @@ export class RuntimeMicroSecondsOverlay extends RuntimeReportOverlay {
}

public shade_node(node: SDFGNode, ctx: CanvasRenderingContext2D): void {
const rt_summary = this.runtime_map[get_element_uuid(node)];
const rt_summary = this.runtime_map[getGraphElementUUID(node)];

if (rt_summary === undefined)
return;
Expand Down
14 changes: 10 additions & 4 deletions src/overlays/simulated_operational_intensity_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { DagreGraph, Point2D, SimpleRect, SymbolMap } from '../index';
import {
DagreGraph,
Point2D,
SimpleRect,
SymbolMap,
getGraphElementUUID,
} from '../index';
import { SDFGRenderer } from '../renderer/renderer';
import {
Edge,
Expand All @@ -9,7 +15,7 @@ import {
SDFGNode,
} from '../renderer/renderer_elements';
import { SDFV } from '../sdfv';
import { getTempColorHslString, get_element_uuid } from '../utils/utils';
import { getTempColorHslString } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

export class SimulatedOperationalIntensityOverlay extends GenericSdfgOverlay {
Expand Down Expand Up @@ -43,7 +49,7 @@ export class SimulatedOperationalIntensityOverlay extends GenericSdfgOverlay {
public calculate_op_in_node(
node: SDFGNode, symbol_map: SymbolMap, op_in_values: number[]
): number | undefined {
const op_in_string = this.op_in_map[get_element_uuid(node)];
const op_in_string = this.op_in_map[getGraphElementUUID(node)];
let op_in = undefined;
if (op_in_string !== undefined) {
op_in = this.symbolResolver.parse_symbol_expression(
Expand Down Expand Up @@ -272,7 +278,7 @@ export class SimulatedOperationalIntensityOverlay extends GenericSdfgOverlay {
!(foreground_elem instanceof Edge)) {
if (foreground_elem.data.op_in === undefined) {
const op_in_string = this.op_in_map[
get_element_uuid(foreground_elem)
getGraphElementUUID(foreground_elem)
];
if (op_in_string) {
this.symbolResolver.parse_symbol_expression(
Expand Down
14 changes: 10 additions & 4 deletions src/overlays/static_flops_overlay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved.

import { DagreGraph, Point2D, SimpleRect, SymbolMap } from '../index';
import {
DagreGraph,
Point2D,
SimpleRect,
SymbolMap,
getGraphElementUUID,
} from '../index';
import { SDFGRenderer } from '../renderer/renderer';
import {
Edge,
Expand All @@ -9,7 +15,7 @@ import {
SDFGNode,
} from '../renderer/renderer_elements';
import { SDFV } from '../sdfv';
import { getTempColorHslString, get_element_uuid } from '../utils/utils';
import { getTempColorHslString } from '../utils/utils';
import { GenericSdfgOverlay, OverlayType } from './generic_sdfg_overlay';

export class StaticFlopsOverlay extends GenericSdfgOverlay {
Expand Down Expand Up @@ -41,7 +47,7 @@ export class StaticFlopsOverlay extends GenericSdfgOverlay {
public calculate_flops_node(
node: SDFGNode, symbol_map: SymbolMap, flops_values: number[]
): number | undefined {
const flops_string = this.flops_map[get_element_uuid(node)];
const flops_string = this.flops_map[getGraphElementUUID(node)];
let flops = undefined;
if (flops_string !== undefined) {
flops = this.symbolResolver.parse_symbol_expression(
Expand Down Expand Up @@ -266,7 +272,7 @@ export class StaticFlopsOverlay extends GenericSdfgOverlay {
!(foreground_elem instanceof Edge)) {
if (foreground_elem.data.flops === undefined) {
const flops_string = this.flops_map[
get_element_uuid(foreground_elem)
getGraphElementUUID(foreground_elem)
];
if (flops_string) {
this.symbolResolver.parse_symbol_expression(
Expand Down
9 changes: 7 additions & 2 deletions src/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ export class SDFGRenderer extends EventEmitter {
const uuid = getGraphElementUUID(this.selected_elements[0]);
if (this.graph) {
this.sdfv_instance.fill_info(
findGraphElementByUUID(this.cfgList, uuid)
findGraphElementByUUID(this.cfgList, this.cfgTree, uuid)
);
}
}
Expand Down Expand Up @@ -1920,7 +1920,8 @@ export class SDFGRenderer extends EventEmitter {
}
const sdfg_id = error.sdfg_id ?? 0;
const problemElem = findGraphElementByUUID(
this.cfgList, sdfg_id + '/' + state_id + '/' + el_id + '/-1'
this.cfgList, this.cfgTree,
sdfg_id + '/' + state_id + '/' + el_id + '/-1'
);
if (problemElem) {
if (problemElem && problemElem instanceof SDFGElement)
Expand Down Expand Up @@ -3578,6 +3579,10 @@ export class SDFGRenderer extends EventEmitter {
return this.cfgList;
}

public getCFGTree(): { [key: number]: number} {
return this.cfgTree;
}

public get_graph(): DagreGraph | null {
return this.graph;
}
Expand Down
17 changes: 11 additions & 6 deletions src/utils/sdfg/sdfg_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function getGraphElementUUID(element: SDFGElement | null): string {
);
}
return (
undefined_val + '/' +
cfgId + '/' +
undefined_val + '/' +
undefined_val + '/' +
undefined_val
Expand Down Expand Up @@ -107,8 +107,8 @@ export function check_and_redirect_edge(
}

export function findGraphElementByUUID(
cfgList: CFGListType, uuid: string
): SDFGElement | DagreGraph | null {
cfgList: CFGListType, cfgTree: { [key: number]: number }, uuid: string
): SDFGElement | null {
const uuidParts = uuid.split('/');

const cfgId = uuidParts[0];
Expand Down Expand Up @@ -139,9 +139,14 @@ export function findGraphElementByUUID(
return element;
if (state)
return state;
if (graph)
return graph;
return null;

const parentCfgId = cfgTree[Number(cfgId)];
if (parentCfgId === undefined || parentCfgId === null)
return null;
const parentCfg = cfgList[parentCfgId].graph;
if (!parentCfg)
return null;
return parentCfg.node(cfgList[cfgId].jsonObj.id.toString()) ?? null;
}

/**
Expand Down
42 changes: 0 additions & 42 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,48 +144,6 @@ export function intersectRect(
};
}

export function get_element_uuid(element: SDFGElement): string {
const undefined_val = -1;
if (element instanceof State) {
return (
element.sdfg.cfg_list_id + '/' +
element.id + '/' +
undefined_val + '/' +
undefined_val
);
} else if (element instanceof NestedSDFG) {
const sdfg_id = element.data.node.attributes.sdfg.cfg_list_id;
return (
sdfg_id + '/' +
undefined_val + '/' +
undefined_val + '/' +
undefined_val
);
} else if (element instanceof MapExit) {
// For MapExit nodes, we want to get the uuid of the corresponding
// entry node instead.
return (
element.sdfg.cfg_list_id + '/' +
element.parent_id + '/' +
element.data.node.scope_entry + '/' +
undefined_val
);
} else if (element instanceof SDFGNode) {
return (
element.sdfg.cfg_list_id + '/' +
element.parent_id + '/' +
element.id + '/' +
undefined_val
);
}
return (
undefined_val + '/' +
undefined_val + '/' +
undefined_val + '/' +
undefined_val
);
}

export function hsl2rgb(h: number, s: number, l: number): number[] {
const a = s * Math.min(l, 1 - l);
const f = (n: number, k = (n + h / 30) % 12): number => {
Expand Down

0 comments on commit 86b9265

Please sign in to comment.