From 17a0f3ecb6fbde409d5c6c2b6f694c64a19bd144 Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Mon, 15 Mar 2021 21:39:03 -0700 Subject: [PATCH 1/7] Turn on QirRuntime build/validation by default --- build/build.ps1 | 2 +- build/ci.yml | 1 - build/test.ps1 | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build/build.ps1 b/build/build.ps1 index 9ff2e82b758..d1afe280967 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -45,7 +45,7 @@ Build-One 'publish' '../src/Simulation/CSharpGeneration.App' Build-One 'build' '../Simulation.sln' -if ($Env:ENABLE_QIRRUNTIME -eq "true") { +if ($Env:ENABLE_QIRRUNTIME -ne "false") { $qirRuntime = (Join-Path $PSScriptRoot "../src/QirRuntime") & "$qirRuntime/build-qir-runtime.ps1" if ($LastExitCode -ne 0) { diff --git a/build/ci.yml b/build/ci.yml index 111b68c0595..34383b7c24f 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -22,7 +22,6 @@ variables: Drops.Dir: $(Build.ArtifactStagingDirectory)/drops Drop.Native: $(System.DefaultWorkingDirectory)/xplat CI: "true" - ENABLE_QIRRUNTIME: "false" jobs: - job: build diff --git a/build/test.ps1 b/build/test.ps1 index cc2e0507a28..0e03830a36e 100644 --- a/build/test.ps1 +++ b/build/test.ps1 @@ -37,7 +37,7 @@ function Test-One { Test-One '../Simulation.sln' -if (($Env:ENABLE_NATIVE -ne "false") -and ($Env:ENABLE_QIRRUNTIME -eq "true")) { +if (($Env:ENABLE_NATIVE -ne "false") -and ($Env:ENABLE_QIRRUNTIME -ne "false")) { $qirRuntime = (Join-Path $PSScriptRoot "../src/QirRuntime") & "$qirRuntime/test-qir-runtime.ps1" if ($LastExitCode -ne 0) { From 45a1e470b7c408df90c2150e62433368bf394c69 Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Mon, 15 Mar 2021 21:57:12 -0700 Subject: [PATCH 2/7] Update package versions, remove redundant main --- AdvantageBenchmark/privateBuild/host.csproj | 2 +- .../releasedBuild/quantum/quantum.csproj | 2 +- .../qsharp/qir-standalone-input-reference.csproj | 2 +- src/QirRuntime/test/QIR-static/qsharp/main.cs | 13 ------------- .../test/QIR-static/qsharp/qir-gen.csproj | 3 +-- .../Microsoft.Quantum.CSharpGeneration.fsproj | 2 +- ...uantum.Simulation.QCTraceSimulatorRuntime.csproj | 2 +- .../QSharpCore/Microsoft.Quantum.QSharp.Core.csproj | 2 +- .../Microsoft.Quantum.QSharp.Foundation.csproj | 2 +- .../TestProjects/HoneywellExe/HoneywellExe.csproj | 2 +- .../IntrinsicTests/IntrinsicTests.csproj | 2 +- .../TestProjects/IonQExe/IonQExe.csproj | 2 +- .../Library with Spaces/Library with Spaces.csproj | 2 +- .../TestProjects/Library1/Library1.csproj | 2 +- .../TestProjects/Library2/Library2.csproj | 2 +- .../TestProjects/QCIExe/QCIExe.csproj | 2 +- .../TestProjects/QSharpExe/QSharpExe.csproj | 2 +- .../TestProjects/TargetedExe/TargetedExe.csproj | 2 +- .../TestProjects/UnitTests/UnitTests.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.Type1.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.Type2.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.Type3.csproj | 2 +- .../Simulators/Microsoft.Quantum.Simulators.csproj | 2 +- .../Type1Core/Microsoft.Quantum.Type1.Core.csproj | 2 +- .../Type2Core/Microsoft.Quantum.Type2.Core.csproj | 2 +- .../Type3Core/Microsoft.Quantum.Type3.Core.csproj | 2 +- 27 files changed, 26 insertions(+), 40 deletions(-) delete mode 100644 src/QirRuntime/test/QIR-static/qsharp/main.cs diff --git a/AdvantageBenchmark/privateBuild/host.csproj b/AdvantageBenchmark/privateBuild/host.csproj index 422cd590f67..945a912657b 100644 --- a/AdvantageBenchmark/privateBuild/host.csproj +++ b/AdvantageBenchmark/privateBuild/host.csproj @@ -1,4 +1,4 @@ - + diff --git a/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj b/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj index 50c82fa9032..edc2bedc0fb 100644 --- a/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj +++ b/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj b/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj index dc30ec6b33f..5878e9774c3 100644 --- a/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj +++ b/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/QirRuntime/test/QIR-static/qsharp/main.cs b/src/QirRuntime/test/QIR-static/qsharp/main.cs deleted file mode 100644 index 3e0cec7acae..00000000000 --- a/src/QirRuntime/test/QIR-static/qsharp/main.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -// Currently, compiling to QIR has to suppress C# generation but then we need to provide Main function ourselves. -namespace CompilerWorkaround -{ - class Program - { - static void Main(string[] args) - { - } - } -} \ No newline at end of file diff --git a/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj b/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj index 75a033a2193..071e4daa6d5 100644 --- a/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj +++ b/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj @@ -1,10 +1,9 @@ - + Exe netcoreapp3.1 True - false false diff --git a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj index 2b666f6ee5d..dbcade9d0a4 100644 --- a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj +++ b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj @@ -22,7 +22,7 @@ - + diff --git a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj index 4ddaacb5478..b9a9f23a05e 100644 --- a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj +++ b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj index 5a3259aaefe..55f5296116c 100644 --- a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj +++ b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj index 6e2ebc85e7f..5f2739dc51b 100644 --- a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj +++ b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj index 41d13f419bd..8d6648d99bd 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj index 1a751162446..5df0333fbfd 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj index 9dca549e624..155c413dd90 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj index 9ffe7425982..967fdc57f93 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 false diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj index 8d99e867492..3be0a69493f 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj index 8d99e867492..3be0a69493f 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj index 8befb110c86..10e31d76d29 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj index d807ca12f3d..46fffc1465e 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj index 926e3a698b3..efc6191b015 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj index f9bb1941fb3..6e8e0d10e34 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 diff --git a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj index 74861b061e7..281a717746a 100644 --- a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj index e0e3f72e741..48eae1fd4aa 100644 --- a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj +++ b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj index a48ce4a0e54..4ecc2f5d180 100644 --- a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj +++ b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj b/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj index a667973bb0f..4de9084ec8b 100644 --- a/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj +++ b/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj index e16bde73d07..2704eb6a47c 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj index 5987caf0baa..f75c9ba8145 100644 --- a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj +++ b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj index 3cd88162088..804ad9d7054 100644 --- a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj +++ b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj b/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj index 9e4252461a8..bfd3eee533e 100644 --- a/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj +++ b/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj @@ -1,4 +1,4 @@ - + From e79dd52d2146067e7871e9f80e2b21c49ee0c21e Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Mon, 15 Mar 2021 22:09:18 -0700 Subject: [PATCH 3/7] install prereqs by default too --- build/prerequisites.ps1 | 12 +++--------- src/QirRuntime/prerequisites.ps1 | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/build/prerequisites.ps1 b/build/prerequisites.ps1 index 2d745543ecf..32259ba09ce 100644 --- a/build/prerequisites.ps1 +++ b/build/prerequisites.ps1 @@ -21,12 +21,6 @@ if ($Env:ENABLE_NATIVE -ne "false") { Write-Host "Skipping installing prerequisites for native simulator because ENABLE_NATIVE variable set to: $Env:ENABLE_NATIVE" } -# At the moment the QIR Runtime build isn't enabled locally by default. -if ($Env:ENABLE_QIRRUNTIME -eq "true") { - Push-Location (Join-Path $PSScriptRoot "../src/QirRuntime") - .\prerequisites.ps1 - Pop-Location -} else { - Write-Host "Skipping installing prerequisites for qir runtime because ENABLE_QIRRUNTIME variable set to: $Env:ENABLE_QIRRUNTIME" -} - +Push-Location (Join-Path $PSScriptRoot "../src/QirRuntime") + .\prerequisites.ps1 +Pop-Location diff --git a/src/QirRuntime/prerequisites.ps1 b/src/QirRuntime/prerequisites.ps1 index 17b9b0633ca..43a7337012f 100644 --- a/src/QirRuntime/prerequisites.ps1 +++ b/src/QirRuntime/prerequisites.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -if ($Env:ENABLE_QIRRUNTIME -eq "true") { +if ($Env:ENABLE_QIRRUNTIME -ne "false") { if (($IsWindows) -or ((Test-Path Env:AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Win"))) -and !(Get-Command clang -ErrorAction SilentlyContinue)) { choco install llvm From deda0aca8db853151ba50520efae7f5225747b3f Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Mon, 15 Mar 2021 23:00:14 -0700 Subject: [PATCH 4/7] Correctly throw when QIR build/test fails. --- src/QirRuntime/build-qir-runtime.ps1 | 19 ++++++++++++++----- src/QirRuntime/test-qir-runtime.ps1 | 6 ++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/QirRuntime/build-qir-runtime.ps1 b/src/QirRuntime/build-qir-runtime.ps1 index f7e4388b884..f0be99bd107 100644 --- a/src/QirRuntime/build-qir-runtime.ps1 +++ b/src/QirRuntime/build-qir-runtime.ps1 @@ -7,7 +7,7 @@ $qirStaticPath = Join-Path $PSScriptRoot test QIR-static qsharp dotnet build $qirStaticPath -c $Env:BUILD_CONFIGURATION -v $Env:BUILD_VERBOSITY if ($LastExitCode -ne 0) { Write-Host "##vso[task.logissue type=error;]Failed to compile Q# project at '$qirStaticPath' into QIR." - return + throw "Failed to compile Q# project at '$qirStaticPath' into QIR." } Copy-Item -Path (Join-Path $qirStaticPath qir *.ll) -Destination (Split-Path $qirStaticPath -Parent) # Also copy to drops so it ends up in build artifacts, for easier post-build debugging. @@ -59,15 +59,20 @@ if (-not (Test-Path $qirRuntimeBuildFolder)) { New-Item -Path $qirRuntimeBuildFolder -ItemType "directory" } +$all_ok = $true + Push-Location $qirRuntimeBuildFolder cmake -G Ninja $clangTidy -D CMAKE_BUILD_TYPE="$Env:BUILD_CONFIGURATION" ../.. if ($LastExitCode -ne 0) { Write-Host "##vso[task.logissue type=error;]Failed to generate QIR Runtime." -} -cmake --build . --target install -if ($LastExitCode -ne 0) { - Write-Host "##vso[task.logissue type=error;]Failed to build QIR Runtime." + $all_ok = $false +} else { + cmake --build . --target install + if ($LastExitCode -ne 0) { + Write-Host "##vso[task.logissue type=error;]Failed to build QIR Runtime." + $all_ok = $false + } } $os = "win" @@ -90,3 +95,7 @@ Pop-Location $env:CC = $oldCC $env:CXX = $oldCXX $env:RC = $oldRC + +if (-not $all_ok) { + throw "At least one project failed to compile. Check the logs." +} \ No newline at end of file diff --git a/src/QirRuntime/test-qir-runtime.ps1 b/src/QirRuntime/test-qir-runtime.ps1 index 0b0094e1054..ecf02e60823 100644 --- a/src/QirRuntime/test-qir-runtime.ps1 +++ b/src/QirRuntime/test-qir-runtime.ps1 @@ -1,6 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +$all_ok = $true + Write-Host "##[info]Test QIR Runtime" Push-Location (Join-Path $PSScriptRoot build $Env:BUILD_CONFIGURATION test) @@ -26,3 +28,7 @@ if ($LastExitCode -ne 0) { } Pop-Location + +if (-not $all_ok) { + throw "At least one project failed testing. Check the logs." +} From 9be24a48218547e1b44f210053beba143223a1ab Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Tue, 16 Mar 2021 17:15:43 +0000 Subject: [PATCH 5/7] Update tests for latest QIR compiler features --- src/QirRuntime/test/QIR-static/qir-driver.cpp | 14 +++++++++----- .../test/QIR-tracer/qir-tracer-driver.cpp | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/QirRuntime/test/QIR-static/qir-driver.cpp b/src/QirRuntime/test/QIR-static/qir-driver.cpp index f0c34c84d5a..db166dba9e5 100644 --- a/src/QirRuntime/test/QIR-static/qir-driver.cpp +++ b/src/QirRuntime/test/QIR-static/qir-driver.cpp @@ -49,24 +49,28 @@ To update the *.ll files to a newer version: - the generated file name.ll will be placed into `s` folder */ +struct Array { + int64_t itemSize; + void* buffer; +}; + // The function replaces array[index] with value, then creates a new array that consists of every other element up to // index (starting from index backwards) and every element from index to the end. It returns the sum of elements in this // new array extern "C" int64_t Microsoft__Quantum__Testing__QIR__Test_Arrays( // NOLINT - int64_t count, - int64_t* array, + Array* array, int64_t index, int64_t val, bool compilerDecoy); TEST_CASE("QIR: Using 1D arrays", "[qir][qir.arr1d]") { - // re-enable tracking when https://github.com/microsoft/qsharp-compiler/issues/844 is fixed - QirContextScope qirctx(nullptr, false /*trackAllocatedObjects*/); + QirContextScope qirctx(nullptr, true /*trackAllocatedObjects*/); constexpr int64_t n = 5; int64_t values[n] = {0, 1, 2, 3, 4}; + auto array = Array{5, values}; - int64_t res = Microsoft__Quantum__Testing__QIR__Test_Arrays(n, values, 2, 42, false); + int64_t res = Microsoft__Quantum__Testing__QIR__Test_Arrays(&array, 2, 42, false); REQUIRE(res == (0 + 42) + (42 + 3 + 4)); } diff --git a/src/QirRuntime/test/QIR-tracer/qir-tracer-driver.cpp b/src/QirRuntime/test/QIR-tracer/qir-tracer-driver.cpp index 09199fe5782..8d386eb976b 100644 --- a/src/QirRuntime/test/QIR-tracer/qir-tracer-driver.cpp +++ b/src/QirRuntime/test/QIR-tracer/qir-tracer-driver.cpp @@ -20,7 +20,7 @@ namespace TracerUser TEST_CASE("Invoke each intrinsic from Q# core once", "[qir-tracer]") { shared_ptr tr = CreateTracer(1 /*layer duration*/, g_operationNames); - QirContextScope qirctx(tr.get(), false /*trackAllocatedObjects*/); + QirContextScope qirctx(tr.get(), true /*trackAllocatedObjects*/); REQUIRE_NOTHROW(Microsoft__Quantum__Testing__Tracer__TestCoreIntrinsics__body()); const vector& layers = tr->UseLayers(); @@ -37,7 +37,7 @@ TEST_CASE("Invoke each intrinsic from Q# core once", "[qir-tracer]") TEST_CASE("Conditional execution on measurement result", "[qir-tracer]") { shared_ptr tr = CreateTracer(1 /*layer duration*/, g_operationNames); - QirContextScope qirctx(tr.get(), false /*trackAllocatedObjects*/); + QirContextScope qirctx(tr.get(), true /*trackAllocatedObjects*/); REQUIRE_NOTHROW(Microsoft__Quantum__Testing__Tracer__TestMeasurements__body()); From e11820c7c1435e9ee7ae5a3b583525188a4d6c13 Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Tue, 16 Mar 2021 11:55:15 -0700 Subject: [PATCH 6/7] Dont gate QIR tests on fullstate simulator flag --- build/test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/test.ps1 b/build/test.ps1 index 0e03830a36e..0de3665976e 100644 --- a/build/test.ps1 +++ b/build/test.ps1 @@ -37,7 +37,7 @@ function Test-One { Test-One '../Simulation.sln' -if (($Env:ENABLE_NATIVE -ne "false") -and ($Env:ENABLE_QIRRUNTIME -ne "false")) { +if ($Env:ENABLE_QIRRUNTIME -ne "false") { $qirRuntime = (Join-Path $PSScriptRoot "../src/QirRuntime") & "$qirRuntime/test-qir-runtime.ps1" if ($LastExitCode -ne 0) { From 5f9801fd91094d36acd7640d6d609f6b028fad6d Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Tue, 16 Mar 2021 13:22:52 -0700 Subject: [PATCH 7/7] Use solution build to generate QIR --- Simulation.sln | 32 +++++++++++++++++++++++++++- src/QirRuntime/build-qir-runtime.ps1 | 11 ++++++---- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Simulation.sln b/Simulation.sln index b13975b999a..d141c8b46c7 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -85,6 +85,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Type3.Cor EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulators.Type3", "src\Simulation\Simulators.Type3.Tests\Tests.Microsoft.Quantum.Simulators.Type3.csproj", "{7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A6394A39-9862-4D5C-8FA1-81B61B424EE6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "QirRuntime", "QirRuntime", "{223F1FAE-5551-4237-AE8A-73502B007003}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "QIR-static", "QIR-static", "{9BED35A6-3FBF-4A55-8424-C801BEB64D68}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "qir-gen", "src\QirRuntime\test\QIR-static\qsharp\qir-gen.csproj", "{DC69B7C8-7B25-4C12-878A-DF59722C306E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -641,6 +651,22 @@ Global {7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU {7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU {7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Debug|x64.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Debug|x64.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Release|Any CPU.Build.0 = Release|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Release|x64.ActiveCfg = Release|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Release|x64.Build.0 = Release|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -681,8 +707,12 @@ Global {789C86D9-CE77-40DA-BDDD-979436952512} = {93409CC3-8DF9-45FA-AE21-16A19FDEF650} {7E24885B-D86D-477E-A840-06FA53C33FE1} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} {7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} + {223F1FAE-5551-4237-AE8A-73502B007003} = {A6394A39-9862-4D5C-8FA1-81B61B424EE6} + {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} = {223F1FAE-5551-4237-AE8A-73502B007003} + {9BED35A6-3FBF-4A55-8424-C801BEB64D68} = {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} + {DC69B7C8-7B25-4C12-878A-DF59722C306E} = {9BED35A6-3FBF-4A55-8424-C801BEB64D68} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821} EndGlobalSection -EndGlobal \ No newline at end of file +EndGlobal diff --git a/src/QirRuntime/build-qir-runtime.ps1 b/src/QirRuntime/build-qir-runtime.ps1 index f0be99bd107..e10c3dde683 100644 --- a/src/QirRuntime/build-qir-runtime.ps1 +++ b/src/QirRuntime/build-qir-runtime.ps1 @@ -4,10 +4,13 @@ & (Join-Path $PSScriptRoot .. .. build set-env.ps1) Write-Host "##[info]Compile Q# Projects into QIR" $qirStaticPath = Join-Path $PSScriptRoot test QIR-static qsharp -dotnet build $qirStaticPath -c $Env:BUILD_CONFIGURATION -v $Env:BUILD_VERBOSITY -if ($LastExitCode -ne 0) { - Write-Host "##vso[task.logissue type=error;]Failed to compile Q# project at '$qirStaticPath' into QIR." - throw "Failed to compile Q# project at '$qirStaticPath' into QIR." +if (!(Test-Path (Join-Path $qirStaticPath qir *.ll))) { + Write-Host "##[info]Build Q# project for QIR tests" + dotnet build $qirStaticPath -c $Env:BUILD_CONFIGURATION -v $Env:BUILD_VERBOSITY + if ($LastExitCode -ne 0) { + Write-Host "##vso[task.logissue type=error;]Failed to compile Q# project at '$qirStaticPath' into QIR." + throw "Failed to compile Q# project at '$qirStaticPath' into QIR." + } } Copy-Item -Path (Join-Path $qirStaticPath qir *.ll) -Destination (Split-Path $qirStaticPath -Parent) # Also copy to drops so it ends up in build artifacts, for easier post-build debugging.