Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,4 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
/src/Simulation/Simulators.Tests/TestProjects/QsharpExe/built
/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/built
19 changes: 19 additions & 0 deletions Simulation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IonQExe", "src\Simulation\S
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QCIExe", "src\Simulation\Simulators.Tests\TestProjects\QCIExe\QCIExe.csproj", "{C015FF41-9A51-4AF0-AEFC-2547D596B10A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TargetedExe", "src\Simulation\Simulators.Tests\TestProjects\TargetedExe\TargetedExe.csproj", "{D292BF18-3956-4827-820E-254C3F81EF09}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -459,6 +461,22 @@ Global
{C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{C015FF41-9A51-4AF0-AEFC-2547D596B10A}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.Debug|x64.ActiveCfg = Debug|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.Debug|x64.Build.0 = Debug|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.Release|Any CPU.Build.0 = Release|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.Release|x64.ActiveCfg = Release|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.Release|x64.Build.0 = Release|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{D292BF18-3956-4827-820E-254C3F81EF09}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -489,6 +507,7 @@ Global
{1448512E-132F-4DA8-BCBA-D98F16B31600} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820}
{55833C6C-6E91-4413-9F77-96B3A09666B8} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820}
{C015FF41-9A51-4AF0-AEFC-2547D596B10A} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820}
{D292BF18-3956-4827-820E-254C3F81EF09} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,7 @@ namespace N1
let testOneClass (_,op : QsCallable) executionTarget (expected : string) =
let expected = expected.Replace("%%%", HttpUtility.JavaScriptStringEncode op.SourceFile.Value)
let assemblyConstants =
new System.Collections.Generic.KeyValuePair<_,_> (AssemblyConstants.ExecutionTarget, executionTarget)
new Collections.Generic.KeyValuePair<_,_> (AssemblyConstants.ProcessorArchitecture, executionTarget)
|> Seq.singleton
|> ImmutableDictionary.CreateRange
let compilation = {Namespaces = syntaxTree; EntryPoints = ImmutableArray.Create op.FullName}
Expand Down
7 changes: 6 additions & 1 deletion src/Simulation/CsharpGeneration/Context.fs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ type CodegenContext = {
static member public Create (syntaxTree : ImmutableArray<QsNamespace>) =
CodegenContext.Create(syntaxTree, ImmutableDictionary.Empty)

member public this.ProcessorArchitecture =
match this.assemblyConstants.TryGetValue AssemblyConstants.ProcessorArchitecture with
| true, name -> name
| false, _ -> null

member public this.ExecutionTarget =
match this.assemblyConstants.TryGetValue AssemblyConstants.ExecutionTarget with
| true, name -> name
Expand All @@ -116,7 +121,7 @@ type CodegenContext = {

member internal this.GenerateCodeForSource (fileName : NonNullable<string>) =
let targetsQuantumProcessor =
match this.assemblyConstants.TryGetValue AssemblyConstants.ExecutionTarget with
match this.assemblyConstants.TryGetValue AssemblyConstants.ProcessorArchitecture with
| true, target -> target = AssemblyConstants.HoneywellProcessor || target = AssemblyConstants.IonQProcessor || target = AssemblyConstants.QCIProcessor
| _ -> false
not (fileName.Value.EndsWith ".dll") || targetsQuantumProcessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.7.0" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.11.2006.3017-alpha" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.12.20072031" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Simulation/CsharpGeneration/SimulationCode.fs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ module SimulationCode =
/// Returns a static property of type OperationInfo using the operation's input and output types.
let buildOperationInfoProperty (globalContext:CodegenContext) operationInput operationOutput operationName =
let propertyType =
match globalContext.ExecutionTarget with
match globalContext.ProcessorArchitecture with
| target when target = AssemblyConstants.HoneywellProcessor -> sprintf "HoneywellEntryPointInfo<%s, %s>" operationInput operationOutput
| target when target = AssemblyConstants.IonQProcessor -> sprintf "IonQEntryPointInfo<%s, %s>" operationInput operationOutput
| target when target = AssemblyConstants.QCIProcessor -> sprintf "QCIEntryPointInfo<%s, %s>" operationInput operationOutput
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\Simulators.Dev.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand Down
14 changes: 14 additions & 0 deletions src/Simulation/Simulators.Tests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ public void BasicExecution()
Assert.Empty(error.ToString().Trim());
}

[Fact]
public void BasicExecutionTargetedExe()
{
var asmPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var exe = Path.Combine(asmPath, "TestTargetedExe", "TargetedExe.dll");

ProcessRunner.Run("dotnet", exe, out StringBuilder output, out StringBuilder error, out int exitCode, out Exception ex);

Assert.Null(ex);
Assert.Equal(0, exitCode);
Assert.Empty(error.ToString().Trim());
Assert.Equal("TargetedExe", output.ToString().Trim());
}

[Fact]
public void Borrowing()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<PropertyGroup>
<OutputType>Library</OutputType>
Expand Down
48 changes: 24 additions & 24 deletions src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- we will provide our own -->
<CsharpGeneration>false</CsharpGeneration>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages>
<IncludeProviderPackages>false</IncludeProviderPackages>
<NoEntryPoint>true</NoEntryPoint>
<ExecutionTarget>ionq.qpu</ExecutionTarget>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
<ProjectReference Include="..\..\..\QsharpCore\Microsoft.Quantum.QSharp.Core.csproj" />
</ItemGroup>
<Target Name="BeforeCsharpCompile">
<ItemGroup>
<Compile Include="$(GeneratedFilesOutputPath)**/*.g.cs" Exclude="@(Compile)" AutoGen="true" />
</ItemGroup>
</Target>
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- we will provide our own -->
<CsharpGeneration>false</CsharpGeneration>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages>
<IncludeProviderPackages>false</IncludeProviderPackages>
<NoEntryPoint>true</NoEntryPoint>
<ExecutionTarget>ionq.qpu</ExecutionTarget>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
<ProjectReference Include="..\..\..\QsharpCore\Microsoft.Quantum.QSharp.Core.csproj" />
</ItemGroup>

<Target Name="BeforeCsharpCompile">
<ItemGroup>
<Compile Include="$(GeneratedFilesOutputPath)**/*.g.cs" Exclude="@(Compile)" AutoGen="true" />
</ItemGroup>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<CsharpGeneration>false</CsharpGeneration>
Expand All @@ -12,9 +12,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\QsharpCore\Microsoft.Quantum.QSharp.Core.csproj" />
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj"
PrivateAssets="All"
IsQscReference="true" />
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
</ItemGroup>

<Target Name="BeforeCsharpCompile">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
48 changes: 24 additions & 24 deletions src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- we will provide our own -->
<CsharpGeneration>false</CsharpGeneration>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages>
<IncludeProviderPackages>false</IncludeProviderPackages>
<NoEntryPoint>true</NoEntryPoint>
<ExecutionTarget>qci.qpu</ExecutionTarget>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
<ProjectReference Include="..\..\..\QsharpCore\Microsoft.Quantum.QSharp.Core.csproj" />
</ItemGroup>
<Target Name="BeforeCsharpCompile">
<ItemGroup>
<Compile Include="$(GeneratedFilesOutputPath)**/*.g.cs" Exclude="@(Compile)" AutoGen="true" />
</ItemGroup>
</Target>
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- we will provide our own -->
<CsharpGeneration>false</CsharpGeneration>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages>
<IncludeProviderPackages>false</IncludeProviderPackages>
<NoEntryPoint>true</NoEntryPoint>
<ExecutionTarget>qci.qpu</ExecutionTarget>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
<ProjectReference Include="..\..\..\QsharpCore\Microsoft.Quantum.QSharp.Core.csproj" />
</ItemGroup>

<Target Name="BeforeCsharpCompile">
<ItemGroup>
<Compile Include="$(GeneratedFilesOutputPath)**/*.g.cs" Exclude="@(Compile)" AutoGen="true" />
</ItemGroup>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Microsoft.Quantum.Testing.Honeywell.Monomorphization {

open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Measurement;
open Microsoft.Quantum.Canon;

@EntryPoint()
operation CallGenerics() : String {

let arr = Default<Qubit[]>();
using (qs = Qubit[2]) {
Ignore(Measure([PauliX, PauliX], qs));
return "TargetedExe";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- we will provide our own -->
<CsharpGeneration>false</CsharpGeneration>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages>
<IncludeProviderPackages>false</IncludeProviderPackages>
<ExecutionTarget>honeywell.qpu</ExecutionTarget>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj" PrivateAssets="All" IsQscReference="true" />
<ProjectReference Include="..\..\..\EntryPointDriver\Microsoft.Quantum.EntryPointDriver.csproj" />
<ProjectReference Include="..\..\..\QsharpCore\Microsoft.Quantum.QSharp.Core.csproj" />
</ItemGroup>

<Target Name="BeforeCsharpCompile">
<ItemGroup>
<Compile Include="$(GeneratedFilesOutputPath)**/*.g.cs" Exclude="@(Compile)" AutoGen="true" />
</ItemGroup>
</Target>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<PropertyGroup>
<_ExeDir>$(MSBuildThisFileDirectory)built</_ExeDir>
</PropertyGroup>
<ItemGroup>
<FilesToRemove Include="$(_ExeDir)**" />
</ItemGroup>
<Delete Files="@(_ExeDir)" />
<MakeDir Directories="$(_ExeDir)" />
<ItemGroup>
<_ExeFiles Include="$(OutputPath)*" />
</ItemGroup>
<Copy SourceFiles="@(_ExeFiles)" DestinationFolder="$(_ExeDir)" ContinueOnError="false" />
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand All @@ -23,6 +23,9 @@
<ProjectReference Include="TestProjects\QsharpExe\QsharpExe.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="TestProjects\TargetedExe\TargetedExe.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>

<ItemGroup>
Expand All @@ -38,12 +41,16 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<PropertyGroup>
<_ExeDir>$(MSBuildThisFileDirectory)TestProjects\QsharpExe\built\</_ExeDir>
<_TargetedExeDir>$(MSBuildThisFileDirectory)TestProjects\TargetedExe\built\</_TargetedExeDir>
</PropertyGroup>
<ItemGroup>
<_ExeFiles Include="$(_ExeDir)*" />
<_TargetedExeFiles Include="$(_TargetedExeDir)*" />
</ItemGroup>
<MakeDir Directories="$(OutputPath)TestExe" />
<MakeDir Directories="$(OutputPath)TestTargetedExe" />
<Copy SourceFiles="@(_ExeFiles)" DestinationFolder="$(OutputPath)TestExe" ContinueOnError="false" />
<Copy SourceFiles="@(_TargetedExeFiles)" DestinationFolder="$(OutputPath)TestTargetedExe" ContinueOnError="false" />
</Target>

</Project>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20072031">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand Down