From 1a44fd71a156dcf138cbd146e2e5a7e0a25a7214 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 5 Nov 2021 19:08:54 -0700 Subject: [PATCH 1/8] Changes to support Qir processors --- .../DefaultItems.props.v.template | 1 + .../DefaultItems/DefaultItems.targets | 27 ++++++++++++++----- src/QuantumSdk/Sdk/Sdk.props | 23 ++++++++-------- src/QuantumSdk/Sdk/Sdk.targets | 11 +++----- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/QuantumSdk/DefaultItems/DefaultItems.props.v.template b/src/QuantumSdk/DefaultItems/DefaultItems.props.v.template index 5a5c8b4209..195f63598b 100644 --- a/src/QuantumSdk/DefaultItems/DefaultItems.props.v.template +++ b/src/QuantumSdk/DefaultItems/DefaultItems.props.v.template @@ -31,6 +31,7 @@ Normal true + false true true true diff --git a/src/QuantumSdk/DefaultItems/DefaultItems.targets b/src/QuantumSdk/DefaultItems/DefaultItems.targets index ba34b7f008..9465ba4020 100644 --- a/src/QuantumSdk/DefaultItems/DefaultItems.targets +++ b/src/QuantumSdk/DefaultItems/DefaultItems.targets @@ -30,6 +30,7 @@ + HoneywellProcessor IonQProcessor QCIProcessor @@ -38,13 +39,19 @@ Possible values must match 'ionq*', 'honeywell*', 'qci*', 'microsoft.simulator*', or 'Any'. The execution target for a Q# library needs to be 'Any'. + + HoneywellQirProcessor + QCIQirProcessor - Type1 + Type1 Type2 - Type3 + Type3 Default Default @@ -71,6 +78,7 @@ true false false + true $([System.String]::Copy('$(AssemblyName)').Replace(' ','')) @@ -96,7 +104,7 @@ - + @@ -107,17 +115,24 @@ <_ResolvedTargetPackageReference Include="$(%(_TargetPackageReferencePathProperty.Identity))" /> - - + + + + + + + + + diff --git a/src/QuantumSdk/Sdk/Sdk.props b/src/QuantumSdk/Sdk/Sdk.props index 69d01b573b..78870b3ea6 100644 --- a/src/QuantumSdk/Sdk/Sdk.props +++ b/src/QuantumSdk/Sdk/Sdk.props @@ -25,16 +25,15 @@ - - + + - + + + + @@ -43,23 +42,23 @@ Include="Microsoft.Quantum.DocumentationGenerator" Version="0.18.2107151063-beta" IsImplicitlyDefined="true" IsQscReference="true" ExecutionTarget="Any" Priority="-1" PrivateAssets="All" /> - - - - - diff --git a/src/QuantumSdk/Sdk/Sdk.targets b/src/QuantumSdk/Sdk/Sdk.targets index 2ccfa9e219..0d30ea7b49 100644 --- a/src/QuantumSdk/Sdk/Sdk.targets +++ b/src/QuantumSdk/Sdk/Sdk.targets @@ -43,7 +43,7 @@ @@ -67,7 +67,6 @@ - @@ -78,9 +77,7 @@ - + <_NewLine>%0D%0A <_NewLineIndent>$(_NewLine)%20%20%20%20 <_QscCommandProjFlag>--proj$(_NewLineIndent)"$([System.IO.Path]::GetFullPath('$(PathCompatibleAssemblyName)'))" @@ -94,7 +91,7 @@ <_QscCommandReferencesFlag Condition="@(ResolvedQSharpReferences->Count()) > 0">$(_NewLine)--references$(_NewLineIndent)"@(ResolvedQSharpReferences,'"$(_NewLineIndent)"')" <_QscCommandLoadFlag Condition="@(_PrioritizedResolvedQscReferences->Count()) > 0">$(_NewLine)--load$(_NewLineIndent)"@(_PrioritizedResolvedQscReferences,'"$(_NewLineIndent)"')" <_QscCommandRuntimeFlag>$(_NewLine)--runtime$(_NewLineIndent)$(ResolvedRuntimeCapabilities) - <_QscCommandSkipMonomorphization Condition="'$(ResolvedRuntimeCapabilities)' == 'FullComputation' And $(CSharpGeneration) And '$(ResolvedProcessorArchitecture)' != 'MicrosoftSimulator'">$(_NewLine)--skip-monomorphization + <_QscCommandSkipMonomorphization Condition="'$(ResolvedRuntimeCapabilities)' == 'FullComputation' And $(CSharpGeneration) And !$(EnableQirSubmission)">$(_NewLine)--skip-monomorphization <_QscCommandPerfDataGenerationFlag Condition="$(PerfDataGeneration)">$(_NewLine)--perf$(_NewLineIndent)$(PerfDataOutputPath) <_QscCommandTargetDecompositionsFlag Condition="@(ResolvedTargetSpecificDecompositions->Count()) > 0">$(_NewLine)--target-specific-decompositions$(_NewLineIndent)"@(ResolvedTargetSpecificDecompositions,'"$(_NewLineIndent)"')" <_QscPackageLoadFallbackFoldersFlag Condition="@(ResolvedPackageLoadFallbackFolders->Count()) > 0">$(_NewLine)--package-load-fallback-folders$(_NewLineIndent)"@(ResolvedPackageLoadFallbackFolders,'"$(_NewLineIndent)"')" @@ -166,7 +163,7 @@ - + From a36107810eb852fd1edd42baf5803d3f208b9b03 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 5 Nov 2021 19:43:04 -0700 Subject: [PATCH 2/8] updating package numbers --- examples/QIR/Development/Development.csproj | 6 ++-- examples/QIR/Emission/Emission.csproj | 2 +- src/QsCompiler/QirGeneration/README.md | 2 +- .../Simulation/Example/Example.csproj | 2 +- src/QuantumSdk/Sdk/Sdk.props | 28 +++++++++---------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/QIR/Development/Development.csproj b/examples/QIR/Development/Development.csproj index 477f3f323a..86e5368623 100644 --- a/examples/QIR/Development/Development.csproj +++ b/examples/QIR/Development/Development.csproj @@ -1,4 +1,4 @@ - + Exe @@ -20,8 +20,8 @@ - - + + diff --git a/examples/QIR/Emission/Emission.csproj b/examples/QIR/Emission/Emission.csproj index 7f8829fd9a..14d6240359 100644 --- a/examples/QIR/Emission/Emission.csproj +++ b/examples/QIR/Emission/Emission.csproj @@ -1,4 +1,4 @@ - + Detailed diff --git a/src/QsCompiler/QirGeneration/README.md b/src/QsCompiler/QirGeneration/README.md index 6e105b176f..e5c1565458 100644 --- a/src/QsCompiler/QirGeneration/README.md +++ b/src/QsCompiler/QirGeneration/README.md @@ -13,7 +13,7 @@ To enable QIR emission, open the project file in a text editor and add the follo ``` If the project builds successfully, the .ll file containing QIR can be found in `qir` folder in the project folder. Alternatively, the folder path can be specified via the `QirOutputPath` project property. The project file should look similar to this: ``` - + Exe netcoreapp3.1 diff --git a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj index 8b32800176..a290a4cb20 100644 --- a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj +++ b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj @@ -1,4 +1,4 @@ - + Detailed Exe diff --git a/src/QuantumSdk/Sdk/Sdk.props b/src/QuantumSdk/Sdk/Sdk.props index 78870b3ea6..fb5c96b619 100644 --- a/src/QuantumSdk/Sdk/Sdk.props +++ b/src/QuantumSdk/Sdk/Sdk.props @@ -23,27 +23,27 @@ - - + + - - - - + + + + - - - + + + + Include="Microsoft.Quantum.Runtime.Core" Version="0.20.2110171573" IsImplicitlyDefined="true" /> + Include="Microsoft.Quantum.EntryPointDriver" Version="0.20.2110171573" IsImplicitlyDefined="true" /> From 15e25ed270fe747e53b333520c7121e81deadc9b Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 5 Nov 2021 19:47:09 -0700 Subject: [PATCH 3/8] missed a file --- examples/QIR/Emission/Emission.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/QIR/Emission/Emission.csproj b/examples/QIR/Emission/Emission.csproj index 14d6240359..7e1c497226 100644 --- a/examples/QIR/Emission/Emission.csproj +++ b/examples/QIR/Emission/Emission.csproj @@ -1,4 +1,4 @@ - + Detailed From f62026d1eed20b1a00cf92518d733870ec56ec2a Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 5 Nov 2021 19:52:47 -0700 Subject: [PATCH 4/8] ... and some more --- src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj | 2 +- src/QsCompiler/TestTargets/Libraries/Library2/Library2.csproj | 2 +- .../TestTargets/Simulation/Target/Simulation.csproj | 4 ++-- src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj b/src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj index 9e09c64f53..6af260881f 100644 --- a/src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj +++ b/src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/QsCompiler/TestTargets/Libraries/Library2/Library2.csproj b/src/QsCompiler/TestTargets/Libraries/Library2/Library2.csproj index 9e09c64f53..6af260881f 100644 --- a/src/QsCompiler/TestTargets/Libraries/Library2/Library2.csproj +++ b/src/QsCompiler/TestTargets/Libraries/Library2/Library2.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj b/src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj index 074993f0fc..3c9e7ad084 100644 --- a/src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj +++ b/src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj @@ -21,8 +21,8 @@ - - + + diff --git a/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj b/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj index 78b3f12f13..2ae76ed453 100644 --- a/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj +++ b/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj @@ -563,8 +563,8 @@ - - + + From ea9750e927eb64ed55a6a603858a70edeb92644f Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 5 Nov 2021 20:01:03 -0700 Subject: [PATCH 5/8] updating code to reflect runtime changes --- src/QsCompiler/TestTargets/Simulation/Target/QirExecution.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QsCompiler/TestTargets/Simulation/Target/QirExecution.cs b/src/QsCompiler/TestTargets/Simulation/Target/QirExecution.cs index 639c27612f..3b9ede2fbd 100644 --- a/src/QsCompiler/TestTargets/Simulation/Target/QirExecution.cs +++ b/src/QsCompiler/TestTargets/Simulation/Target/QirExecution.cs @@ -13,7 +13,7 @@ namespace Microsoft.Quantum.QsCompiler.Testing.Qir public static class JitCompilation { [DllImport("Microsoft.Quantum.Qir.QSharp.Core", ExactSpelling = true, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] - public static extern IntPtr CreateFullstateSimulator(long seed); + public static extern IntPtr CreateFullstateSimulatorC(long seed); [DllImport("Microsoft.Quantum.Qir.Runtime", ExactSpelling = true, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern void InitializeQirContext(IntPtr driver, bool trackAllocatedObjects); @@ -33,7 +33,7 @@ public static void BuildAndRun(string pathToBitcode, params string[] functionNam // To get this line to work, I had to change the CreateFullstateSimulator API to use raw pointers instead of shared pointers, // and I had to update both calls to be "extern 'C'" otherwise name mangling makes then impossible to call here. // This should be revised more broadly as we move the runtime to a C-style API for ABI compatibility across langauges. - InitializeQirContext(CreateFullstateSimulator(0), true); + InitializeQirContext(CreateFullstateSimulatorC(0), true); if (!File.Exists(pathToBitcode)) { From 46a2d2db296fb98211b5471d43af4d6b3c6ef969 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Fri, 5 Nov 2021 20:29:45 -0700 Subject: [PATCH 6/8] also need to copy C headers --- examples/QIR/Development/Development.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/QIR/Development/Development.csproj b/examples/QIR/Development/Development.csproj index 86e5368623..74493b8648 100644 --- a/examples/QIR/Development/Development.csproj +++ b/examples/QIR/Development/Development.csproj @@ -136,6 +136,7 @@ <_QirRuntimeLibFiles Include="$(QirRuntimeLibs)/**/*.*" Exclude="$(QirRuntimeLibs)/**/*.exe" /> <_QirRuntimeHeaderFiles Include="$(QirRuntimeHeaders)/**/*.hpp" /> + <_QirRuntimeHeaderFiles Include="$(QirRuntimeHeaders)/**/*.h" /> From 018073dffca6a347cff0cfae81489453ea972efd Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Mon, 8 Nov 2021 15:49:34 -0800 Subject: [PATCH 7/8] Exclude cannot be used on its own --- src/QuantumSdk/DefaultItems/DefaultItems.targets | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/QuantumSdk/DefaultItems/DefaultItems.targets b/src/QuantumSdk/DefaultItems/DefaultItems.targets index 9465ba4020..8dadc79de8 100644 --- a/src/QuantumSdk/DefaultItems/DefaultItems.targets +++ b/src/QuantumSdk/DefaultItems/DefaultItems.targets @@ -127,8 +127,10 @@ - - + From 7241b450c588e0e26f239c3404339c871223c5d7 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Mon, 8 Nov 2021 15:57:09 -0800 Subject: [PATCH 8/8] minor edit --- src/QuantumSdk/Sdk/Sdk.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QuantumSdk/Sdk/Sdk.targets b/src/QuantumSdk/Sdk/Sdk.targets index 0d30ea7b49..0230516a19 100644 --- a/src/QuantumSdk/Sdk/Sdk.targets +++ b/src/QuantumSdk/Sdk/Sdk.targets @@ -157,7 +157,7 @@ - <_DefaultEntryPoint Condition="$(QirGeneration) And '$(CSharpGeneration)' != 'true' And @(Compile->Count()) == 0">$(GeneratedFilesOutputPath)Main.cs + <_DefaultEntryPoint Condition="$(QirGeneration) And !$(CSharpGeneration) And @(Compile->Count()) == 0">$(GeneratedFilesOutputPath)Main.cs <_GeneratedBinary>$(GeneratedFilesOutputPath)$(PathCompatibleAssemblyName)