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
26 changes: 1 addition & 25 deletions src/QirRuntime/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
add_subdirectory(QIR)
add_subdirectory(Simulators)


#===============================================================================
# Produce the qdk dynamic library
#
add_library(qdk SHARED
$<TARGET_OBJECTS:qir-rt-support-obj>
$<TARGET_OBJECTS:qir-qis-support-obj>
$<TARGET_OBJECTS:simulators-obj>
)

target_link_libraries(qdk
${QIR_BRIDGE_UTILITY_LIB}
${QIR_BRIDGE_QIS_UTILITY_LIB}
${CMAKE_DL_LIBS}
)

set_property(TARGET qdk PROPERTY POSITION_INDEPENDENT_CODE ON)

install(TARGETS qdk
RUNTIME DESTINATION "${CMAKE_BINARY_DIR}/bin"
LIBRARY DESTINATION "${CMAKE_BINARY_DIR}/bin"
)


add_subdirectory(qdk)
8 changes: 4 additions & 4 deletions src/QirRuntime/lib/QIR/arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
// Licensed under the MIT License.

#include <algorithm>
#include <assert.h>
#include <cassert>
#include <cstring> // for memcpy
#include <memory>
#include <numeric>
#include <stdexcept>
#include <string.h> // for memcpy
#include <vector>

#include "CoreTypes.hpp"
#include "QirContext.hpp"
#include "QirTypes.hpp"
#include "allocationsTracker.hpp"
#include "context.hpp"
#include "qirTypes.hpp"
#include "quantum__rt.hpp"

using namespace Microsoft::Quantum;
Expand Down
8 changes: 4 additions & 4 deletions src/QirRuntime/lib/QIR/callables.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include <assert.h>
#include <cassert>
#include <cstring> // for memcpy
#include <limits>
#include <memory>
#include <stdexcept>
#include <string.h> // for memcpy
#include <vector>

#include "QirContext.hpp"
#include "QirTypes.hpp"
#include "allocationsTracker.hpp"
#include "context.hpp"
#include "qirTypes.hpp"
#include "quantum__rt.hpp"

using namespace Microsoft::Quantum;
Expand Down
4 changes: 2 additions & 2 deletions src/QirRuntime/lib/QIR/context.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include <assert.h>
#include <cassert>

#include "context.hpp"
#include "QirContext.hpp"

#include "CoreTypes.hpp"
#include "QuantumApi_I.hpp"
Expand Down
24 changes: 6 additions & 18 deletions src/QirRuntime/lib/QIR/delegated.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/*=============================================================================
QIR assumes a single global execution context.
To support the dispatch over the qir-bridge, the clients must implement
Microsoft::Quantum::IQuantumGateSet* g_qapi;
=============================================================================*/
#include <assert.h>
#include <cassert>
#include <unordered_map>

#include "quantum__rt.hpp"

#include "QuantumApi_I.hpp"
#include "SimFactory.hpp"
#include "context.hpp"
#include "qirTypes.hpp"
#include "QirContext.hpp"
#include "QirTypes.hpp"

#ifdef _WIN32
#define EXPORTAPI extern "C" __declspec(dllexport)
#else
#define EXPORTAPI extern "C"
#endif
EXPORTAPI void SetupQirToRunOnFullStateSimulator()
{
// Leak the simulator, because the QIR only creates one and it will exist for the duration of the session
InitializeQirContext(Microsoft::Quantum::CreateFullstateSimulator().release(), false /*trackAllocatedObjects*/);
}
/*=============================================================================
Note: QIR assumes a single global execution context!
=============================================================================*/

// QIR specification requires the Result type to be reference counted, even though Results are created by the target and
// qubits, created by the same target, aren't reference counted. To minimize the implementation burden on the target,
Expand Down
6 changes: 3 additions & 3 deletions src/QirRuntime/lib/QIR/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
To support the dispatch over the qir-bridge, the clients must register their
Microsoft::Quantum::ISimulator* first.
=============================================================================*/
#include <assert.h>
#include <cassert>
#include <vector>

#include "quantum__qis.hpp"

#include "QuantumApi_I.hpp"
#include "context.hpp"
#include "qirTypes.hpp"
#include "QirContext.hpp"
#include "QirTypes.hpp"

// Pauli consts are {i2} in QIR, likely stored as {i8} in arrays, but we are using the standard C++ enum type based on
// {i32} so cannot pass through the buffer and have to allocate a new one instead and copy.
Expand Down
2 changes: 1 addition & 1 deletion src/QirRuntime/lib/QIR/intrinsicsOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <iostream>

#include "qirTypes.hpp"
#include "QirTypes.hpp"
#include "quantum__qis.hpp"

// Forward declarations:
Expand Down
2 changes: 1 addition & 1 deletion src/QirRuntime/lib/QIR/quantum__rt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdarg.h> // for va_list

#include "CoreTypes.hpp"
#include "qirTypes.hpp"
#include "QirTypes.hpp"

struct QirArray;
struct QirCallable;
Expand Down
4 changes: 2 additions & 2 deletions src/QirRuntime/lib/QIR/strings.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include <assert.h>
#include <cassert>
#include <limits>
#include <sstream>
#include <string>
#include <unordered_map>

#include "qirTypes.hpp"
#include "QirTypes.hpp"
#include "quantum__rt.hpp"

std::unordered_map<std::string, QirString*>& AllocatedStrings()
Expand Down
4 changes: 2 additions & 2 deletions src/QirRuntime/lib/QIR/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include <assert.h>
#include <cassert>
#include <stdexcept>
#include <memory>
#include <unordered_set>
#include <iostream>

#include "quantum__rt.hpp"

#include "qirTypes.hpp"
#include "QirTypes.hpp"

std::unordered_set<char*>& UseMemoryTracker()
{
Expand Down
2 changes: 1 addition & 1 deletion src/QirRuntime/lib/Simulators/FullstateSimulator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include <assert.h>
#include <cassert>
#include <bitset>
#include <complex>
#include <exception>
Expand Down
2 changes: 1 addition & 1 deletion src/QirRuntime/lib/Simulators/ToffoliSimulator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include <assert.h>
#include <cassert>
#include <vector>

#include "QuantumApi_I.hpp"
Expand Down
28 changes: 28 additions & 0 deletions src/QirRuntime/lib/qdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#===============================================================================
# Produce the qdk dynamic library
#
add_library(qdk SHARED
qdk.cpp
$<TARGET_OBJECTS:qir-rt-support-obj>
$<TARGET_OBJECTS:qir-qis-support-obj>
$<TARGET_OBJECTS:simulators-obj>
)

target_link_libraries(qdk
${QIR_BRIDGE_UTILITY_LIB}
${QIR_BRIDGE_QIS_UTILITY_LIB}
${CMAKE_DL_LIBS}
)

target_include_directories(qdk PUBLIC
${public_includes}
)

set_property(TARGET qdk PROPERTY POSITION_INDEPENDENT_CODE ON)

install(TARGETS qdk
RUNTIME DESTINATION "${CMAKE_BINARY_DIR}/bin"
LIBRARY DESTINATION "${CMAKE_BINARY_DIR}/bin"
)


18 changes: 18 additions & 0 deletions src/QirRuntime/lib/qdk/qdk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "QuantumApi_I.hpp"
#include "SimFactory.hpp"
#include "QirContext.hpp"
#include "QirTypes.hpp"

#ifdef _WIN32
#define EXPORTAPI extern "C" __declspec(dllexport)
#else
#define EXPORTAPI extern "C"
#endif
EXPORTAPI void SetupQirToRunOnFullStateSimulator()
{
// Leak the simulator, because the QIR only creates one and it will exist for the duration of the session
InitializeQirContext(Microsoft::Quantum::CreateFullstateSimulator().release(), false /*trackAllocatedObjects*/);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "QuantumApi_I.hpp"
#include "SimFactory.hpp"
#include "context.hpp"
#include "QirContext.hpp"

using namespace Microsoft::Quantum;
using namespace std;
Expand Down
6 changes: 3 additions & 3 deletions src/QirRuntime/test/QIR-static/qir-driver.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include <assert.h>
#include <cassert>
#include <bitset>
#include <iostream>
#include <memory>
Expand All @@ -12,8 +12,8 @@
#include "QuantumApi_I.hpp"
#include "SimFactory.hpp"
#include "SimulatorStub.hpp"
#include "context.hpp"
#include "qirTypes.hpp"
#include "QirContext.hpp"
#include "QirTypes.hpp"
#include "quantum__rt.hpp"

#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
Expand Down
Loading