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

Graph Visualization: Added a 'Label' structure, debug marks , order of commandBuffer and reestructuration of the code. #2541

Merged
merged 1 commit into from
Jan 16, 2019

Conversation

ecapia
Copy link
Contributor

@ecapia ecapia commented Jan 14, 2019

No description provided.

UNUSED = "UNUSED"
)

func (g *graph) traverseGraph(currentNode *node, visitTime, minVisitTime, idInStronglyConnectedComponents, visitedNodesId *[]int, currentId, currentTime *int) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are large enough functions, it would be good to get comments on exactly what the parameters are supposed to be.

Copy link
Contributor Author

@ecapia ecapia Jan 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I abstracted the parameters used to compute the Strongly Connected Components in a directed graph based on Tarjan algorithm. Thank you.

LevelsID []int
}

func (label *Label) GetSize() int {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Godocs needed for all public methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I added the Godocs for all public methods.

"bytes"
"fmt"
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Godocs here as well.

Copy link
Contributor Author

@ecapia ecapia Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the Godocs here as well. Thanks.

Copy link
Contributor

@bjoeris bjoeris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, modulo adding the godocs, our offline discussion about debug markers, and a few nits.

level := builder.labelsInsideDebugMarkers[len(builder.labelsInsideDebugMarkers)-1].GetSize() - 1
builder.numberOfDebugMarker++
for i := from; i <= to; i++ {
builder.labelsInsideDebugMarkers[i].Insert(level, VK_CMD_DEBUG_MARKER, builder.numberOfDebugMarker)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why adding a debug marker affects multiple entries in labelsInsideDebugMarkers.

Copy link
Contributor Author

@ecapia ecapia Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact some labels could be affected by more than one debug marker (nested debug markers), in that case the algorithm add more than one time the debug marker level. All commands between debug_marker_begin and debug_marker_end are affected.


} else if len(builder.positionOfDebugMarkersBegin) > 0 {
if labelOfLastDebugMarkerBegin.GetSize() != currentLabel.GetSize() {
builder.positionOfDebugMarkersBegin = builder.positionOfDebugMarkersBegin[:0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this aborts ALL open debug markers as soon as ONE doesn't nest correctly with the non-debug markers. Is that a correct understanding?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a ton of code in vulkan.go to handle nesting of debug markers and similar, (as used for displaying groups in the UI) It handles some of these cases (bad nestings etc).

Is there a chance we can leverage that?
It may be a follow-up, but it may save some time in handling some of these cases.

Copy link
Contributor Author

@ecapia ecapia Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I am adding debug markers as long as it does not destroy any level of hierarchy defined in commands. So, if exists some command between debug_marker_begin and debug_marker_end which has smaller Label size , adding the debug marker here will destroy the levels of hierarchy and for this case I just ignore the debug marker. It means I am preserving Labels with no-decreasing size. I have tested with several captures and it is working very nice. In addition to this, I am analyzing the possibility to include code from vulkan.go to address this problem as well, but if it is the case , I will add this in the last commit. Thank you.

}
}
}
if _, ok := builder.labelToHierarchy[label]; !ok {
builder.labelToHierarchy[label] = &api.Hierarchy{}
temporalLabelAsAString := label.GetLabelAsAString()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the name "temporal" intentional? Or was it meant to be "temporary"?

Copy link
Contributor Author

@ecapia ecapia Jan 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is intentional, but I figured out that 'temporal' is not the correct word to describe something provisional , thank you. I changed it to temporary.

}
hierarchy := builder.labelToHierarchy[label]
hierarchy := builder.labelAsAStringToHierarchy[temporalLabelAsAString]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this pattern of inserting a default value into the map when the key is missing can be re-expressed as

hierarchy, ok := builder.labelAsAStringToHierarchy[temporalLabelAsAString]
if !ok {
	hierarchy = &api.Hierarchy{}
	builder.labelAsAStringToHierarchy[temporalLabelAsAString] = hierarchy
}		

This removes one of the map lookups.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Yes , using this I am removing one look up in the map. I changed it for the two cases.

@@ -197,122 +189,6 @@ func (input nodeSorter) Less(i, j int) bool {
return input[i].id < input[j].id
}

func (g *graph) traverseGraph(currentNode *node, visitTime, minVisitTime, idInStronglyConnectedComponents, visitedNodesId *[]int, currentId, currentTime *int) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When moving big chunks of code like this, it's usually preferred to do the move in a separate commit, since it is hard to see what changed. Just a comment, no need to change this.

Copy link
Contributor Author

@ecapia ecapia Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have abstracted this part of code to simplify the understanding, because it is essentially the Tarjan algorithm to compute Strongly Connected Components in a directed graph. I will remove this in a later commit.

Copy link
Contributor

@bjoeris bjoeris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

}

func (builder *labelForVulkanCommands) GetCommandLabel(command api.Cmd, commandNodeId uint64) string {
func (builder *labelForVulkanCommands) GetCommandLabel(command api.Cmd, cmdId uint64) *api.Label {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions that implement the interfaces are also public, and should also have godocs. Those godocs are usually exactly the same as the godocs from the interface method they are implementing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I will add the Godocs here as well.

@ecapia ecapia force-pushed the graph_visualization_5 branch 2 times, most recently from 10bdf15 to c895efd Compare January 16, 2019 02:37
commandBuffer and reestructuration of the code.

'Label' Structure: It improves the time and space complexity for algorithms
on the graph and the output format.

Debug markers: They are added whenever do not break any previous hierarchy
already defined. It follows the idea of balance parenthesis.

Reestructuration of the code: This is divided in graph_algorithms,
graph_structure, graph_output and graph_visualization for better understanding
and future work.
@ecapia ecapia force-pushed the graph_visualization_5 branch from c895efd to 54a9bbc Compare January 16, 2019 02:43
@bjoeris bjoeris merged commit fdfbfbc into google:master Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants