Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@alan-geller
Copy link
Contributor

@alan-geller alan-geller commented Nov 6, 2019

Syntax tree walkers parallel syntax tree transformations, but effectively do iter instead of fold. In some cases they can be a bit more performant.

Alan Geller and others added 22 commits November 6, 2019 10:46
…s based on the code, which will require levels to be defined.
…en state (everything is wrapped in the top-level transformation). Still tests to add, as well as a few TODOs left in the code.
…ing walker.

The leveler could be a transform on top and a walker below; not clear how much this would gain.
…tation of specializations, rather than transforming them, avoiding a bunch of copying and allocation.
}

static member LevelAttribute = {
Name = "Level" |> NonNullable<string>.New
Copy link
Contributor

Choose a reason for hiding this comment

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

I might suggest something more verbose, especially since it in in the Core namespace, which is automatically opened if imported. I am open to what name exactly.

Suggested change
Name = "Level" |> NonNullable<string>.New
Name = "TargetCapabilityLevel" |> NonNullable<string>.New

Parent : QsQualifiedName
/// contains all attributes associated with the specialization
Attributes : ImmutableArray<QsDeclarationAttribute>
/// contains the minimum target capability level for this specialization's code, not including anything it calls
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// contains the minimum target capability level for this specialization's code, not including anything it calls
/// contains the minimum target capability level required for executing this specialization's code, not including anything it calls

</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Protocol" Version="16.0.2264" />
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the package needed for? Diagnostics?

next |> Seq.fold (fun (a : HashSet<SpecializationKey>) k -> if a.Add(k) then WalkDependencyTree k a else a) accum
| false, _ -> accum

member this.GetSpecializationLevel(spec) =
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this function have migrated to CapabilityLeveler.fs?
It shouldn't have anything to do with the callgraph building I think.

| true, level -> level
| false, _ -> CapabilityLevel.Unset

member this.SetSpecializationLevel(spec, level) =
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

/// assigned to a variable or passed as an argument to another callable,
// which means it could get a functor applied at some later time.
// We're conservative and add all 4 possible kinds.
graph.AddDependency(spec, name, QsBody, typeArgs)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a finer point here unfortunately, that I think I should actually should fix on the expression resolution side: right now these type arguments contain only what is explicitly given as type arguments in the source code, not what the type parameters are that are determined e.g. by the argument of the call. There is also a bit more detail to that that I should think about carefully related to how one would have to set it up to support treating type parameterized callables as first class objects. Let me get back to you on that.

@@ -0,0 +1,243 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

There seem to be a couple of todo's left here. I might hence be tempted to suggest to split the dependency walker and the capability leveler (and tests) into a separate PR, with the capability leveler possibly going against a feature branch. What do you think?

| Intrinsic -> CapabilityLevel.Minimal
| External -> CapabilityLevel.Unset
| Generated _ -> CapabilityLevel.Unset
// TODO: For generated specializations, we need to find the appropriate "body" declaration
Copy link
Contributor

Choose a reason for hiding this comment

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

You know, this specifically makes me wonder if we might instead want to track it as inferred information. Let's maybe quickly discuss that option.

@ScottCarda-MS ScottCarda-MS mentioned this pull request Nov 14, 2019
@ScottCarda-MS ScottCarda-MS changed the title Syntax tree walkers, and specific walkers for capability levels and call graph computation Syntax Tree Walkers Nov 14, 2019
Copy link
Contributor

@bettinaheim bettinaheim left a comment

Choose a reason for hiding this comment

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

Happy to take this in, since the transformation vs walker distinction makes sense from a perf perspective. I'll make it a weekend challenge to sit down and think about clever ways of unifying the two - or officially admit defeat. ;)

@bettinaheim bettinaheim merged commit add8a07 into master Nov 15, 2019
@alan-geller alan-geller deleted the ageller/targetValidation branch September 25, 2020 19:21
@alan-geller alan-geller restored the ageller/targetValidation branch September 25, 2020 19:21
@alan-geller alan-geller deleted the ageller/targetValidation branch November 18, 2020 22:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants