-
Notifications
You must be signed in to change notification settings - Fork 356
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
192 lines (176 loc) · 7.37 KB
/
CMakeLists.txt
File metadata and controls
192 lines (176 loc) · 7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# ============================================================================ #
# Copyright (c) 2022 - 2026 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
set(CMAKE_BUILD_TYPE "Debug")
endif()
include(HandleLLVMOptions)
include(AddMLIRPython)
# Specifies that all MLIR packages are co-located under the cudaq
# top level package (the API has been embedded in a relocatable way).
add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=cudaq.mlir.")
################################################################################
# Sources
################################################################################
declare_mlir_python_sources(CUDAQuantumPythonSources)
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CUDAQuantumPythonSources
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../cudaq/mlir"
TD_FILE dialects/QuakeOps.td
SOURCES
dialects/quake.py
DIALECT_NAME quake)
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT CUDAQuantumPythonSources
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../cudaq/mlir"
TD_FILE dialects/CCOps.td
SOURCES
dialects/cc.py
DIALECT_NAME cc)
declare_mlir_python_extension(CUDAQuantumPythonSources.Extension
MODULE_NAME _quakeDialects
ADD_TO_PARENT CUDAQuantumPythonSources
SOURCES
CUDAQuantumExtension.cpp
../runtime/common/py_ExecutionContext.cpp
../runtime/common/py_NoiseModel.cpp
../runtime/common/py_EvolveResult.cpp
../runtime/common/py_ObserveResult.cpp
../runtime/common/py_SampleResult.cpp
../runtime/common/py_Resources.cpp
../runtime/common/py_CustomOpRegistry.cpp
../runtime/common/py_AnalogHamiltonian.cpp
../runtime/cudaq/algorithms/py_draw.cpp
../runtime/cudaq/algorithms/py_evolve.cpp
../runtime/cudaq/algorithms/py_observe_async.cpp
../runtime/cudaq/algorithms/py_optimizer.cpp
../runtime/cudaq/algorithms/py_sample_async.cpp
../runtime/cudaq/algorithms/py_sample_ptsbe.cpp
../runtime/cudaq/algorithms/py_resource_count.cpp
../runtime/cudaq/algorithms/py_run.cpp
../../runtime/cudaq/algorithms/run.cpp # Common Python and C++ implementation of run
../runtime/cudaq/algorithms/py_state.cpp
../runtime/cudaq/algorithms/py_translate.cpp
../runtime/cudaq/algorithms/py_unitary.cpp
../runtime/cudaq/algorithms/py_utils.cpp
../runtime/cudaq/platform/JITExecutionCache.cpp
../runtime/cudaq/platform/py_alt_launch_kernel.cpp
../runtime/cudaq/qis/py_execution_manager.cpp
../runtime/cudaq/qis/py_pauli_word.cpp
../runtime/cudaq/operators/py_helpers.cpp
../runtime/cudaq/operators/py_matrix.cpp
../runtime/cudaq/operators/py_scalar_op.cpp
../runtime/cudaq/operators/py_spin_op.cpp
../runtime/cudaq/operators/py_fermion_op.cpp
../runtime/cudaq/operators/py_boson_op.cpp
../runtime/cudaq/operators/py_matrix_op.cpp
../runtime/cudaq/operators/py_super_op.cpp
../runtime/cudaq/operators/py_handlers.cpp
../runtime/cudaq/target/py_runtime_target.cpp
../runtime/cudaq/target/py_testing_utils.cpp
../runtime/mlir/py_register_dialects.cpp
../runtime/utils/PyRemoteSimulatorQPU.cpp
../runtime/utils/PyRestRemoteClient.cpp
../utils/LinkedLibraryHolder.cpp
../../runtime/common/ArgumentConversion.cpp
../../runtime/common/CodeGenConfig.cpp
../../runtime/common/LayoutInfo.cpp
../../runtime/common/RuntimeMLIR.cpp
../../runtime/common/RuntimePyMLIR.cpp
../../runtime/common/JIT.cpp
../../runtime/common/Compiler.cpp
../../runtime/common/PassPipelineLogging.cpp
../../runtime/cudaq/platform/default/rest_server/RemoteRuntimeClient.cpp
../../runtime/cudaq/platform/orca/OrcaExecutor.cpp
../../runtime/cudaq/platform/orca/OrcaQPU.cpp
../../runtime/cudaq/platform/orca/OrcaRemoteRESTQPU.cpp
../../runtime/cudaq/platform/orca/OrcaServerHelper.cpp
../../runtime/cudaq/platform/pasqal/PasqalRemoteRESTQPU.cpp
../../runtime/cudaq/platform/pasqal/PasqalServerHelper.cpp
../../runtime/cudaq/platform/quera/QuEraRemoteRESTQPU.cpp
../../runtime/cudaq/platform/fermioniq/FermioniqQPU.cpp
../../runtime/cudaq/platform/default/rest/RemoteRESTQPU.cpp
../../runtime/cudaq/platform/default/python/QPU.cpp
EMBED_CAPI_LINK_LIBS
CUDAQuantumMLIRCAPI
MLIRCAPIExecutionEngine
PRIVATE_LINK_LIBS
OptCodeGen
OptTransforms
MLIRPass
MLIRSupport
CUDAQTargetConfigUtil
cudaq-python-interop
cudaq-platform-default
cudaq-qir-verifier
)
set_source_files_properties(
../../runtime/common/PassPipelineLogging.cpp
PROPERTIES COMPILE_OPTIONS "-fno-rtti"
)
target_include_directories(CUDAQuantumPythonSources.Extension INTERFACE
${CMAKE_SOURCE_DIR}/python
${CMAKE_SOURCE_DIR}/python/utils
${CMAKE_SOURCE_DIR}/runtime
)
target_link_libraries(CUDAQuantumPythonSources.Extension INTERFACE
cudaq
cudaq-logger
cudaq-common
cudaq-em-default
cudaq-em-photonics
fmt::fmt-header-only
unzip_util
)
################################################################################
# Common CAPI
################################################################################
add_mlir_python_common_capi_library(CUDAQuantumPythonCAPI
INSTALL_COMPONENT CUDAQuantumPythonModules
INSTALL_DESTINATION cudaq/mlir/_mlir_libs
OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/python/cudaq/mlir/_mlir_libs"
RELATIVE_INSTALL_ROOT "../.."
DECLARED_SOURCES
CUDAQuantumPythonSources
# TODO: Remove this in favor of showing fine grained registration once
# available.
MLIRPythonExtension.RegisterEverything
MLIRPythonSources.Core
)
################################################################################
# Instantiation of Python module
################################################################################
add_mlir_python_modules(CUDAQuantumPythonModules
ROOT_PREFIX "${MLIR_BINARY_DIR}/python/cudaq/mlir"
INSTALL_PREFIX "cudaq/mlir"
DECLARED_SOURCES
CUDAQuantumPythonSources
# TODO: Remove this in favor of showing fine grained registration once
# available.
MLIRPythonExtension.RegisterEverything
MLIRPythonSources
COMMON_CAPI_LINK_LIBS
CUDAQuantumPythonCAPI
)
## The Python bindings module for Quake dialect depends on CUDAQ libraries
## which it can't locate since they are in "../../lib" and the 'rpath' is set
## to '$ORIGIN' by default.
## macOS uses @loader_path instead of $ORIGIN for RPATH.
if(APPLE)
set(_origin_prefix "@loader_path")
else()
set(_origin_prefix "$ORIGIN")
endif()
if (NOT SKBUILD)
list(APPEND CMAKE_INSTALL_RPATH "${_origin_prefix}/../../lib" "${_origin_prefix}/../../lib/plugins")
set_property(TARGET CUDAQuantumPythonModules.extension._quakeDialects.dso
APPEND PROPERTY INSTALL_RPATH "${_origin_prefix}/../../../lib" "${_origin_prefix}/../../../lib/plugins")
else()
list(APPEND CMAKE_INSTALL_RPATH "${_origin_prefix}/../cuda_quantum.libs")
set_property(TARGET CUDAQuantumPythonModules.extension._quakeDialects.dso
APPEND PROPERTY INSTALL_RPATH "${_origin_prefix}/../../../lib" "${_origin_prefix}/../../../cuda_quantum.libs")
endif()