diff --git a/include/cudaq/Optimizer/Dialect/CC/CCTypes.td b/include/cudaq/Optimizer/Dialect/CC/CCTypes.td index f85a8be11c..d8a5820abe 100644 --- a/include/cudaq/Optimizer/Dialect/CC/CCTypes.td +++ b/include/cudaq/Optimizer/Dialect/CC/CCTypes.td @@ -195,17 +195,16 @@ def cc_CallableType : CCType<"Callable", "callable"> { } def cc_IndirectCallableType : CCType<"IndirectCallable", "indirect_callable"> { - let summary = "Proxy for cudaq::qkernel_ref."; + let summary = "Proxy for cudaq::qkernel."; let description = [{ An entry-point kernel may take a reference to another kernel as an argument. The passed kernel may be entirely opaque at compile-time with its definition present in some other compilation module. - It is on the programmer to use the cudaq::qkernel_ref type. This wrapper - class is very much like std::function, but it extends that functionality - with some extra information for the runtime to be able to "link" the - distinct kernels on the device side and provide, for example, LTO at - JIT compile time. + It is on the programmer to use the cudaq::qkernel type. This wrapper class + is very much like std::function, but it extends that functionality with some + extra information for the runtime to be able to "link" the distinct kernels + on the device side and provide, for example, LTO at JIT compile time. }]; let parameters = (ins "mlir::FunctionType":$signature); diff --git a/lib/Frontend/nvqpp/ConvertDecl.cpp b/lib/Frontend/nvqpp/ConvertDecl.cpp index 39ef0ad8df..7d277197a8 100644 --- a/lib/Frontend/nvqpp/ConvertDecl.cpp +++ b/lib/Frontend/nvqpp/ConvertDecl.cpp @@ -177,7 +177,7 @@ bool QuakeBridgeVisitor::interceptRecordDecl(clang::RecordDecl *x) { return pushType(cc::StateType::get(ctx)); if (name.equals("pauli_word")) return pushType(cc::CharspanType::get(ctx)); - if (name.equals("qkernel_ref")) { + if (name.equals("qkernel")) { auto *cts = cast(x); // Traverse template argument 0 to get the function's signature. if (!TraverseType(cts->getTemplateArgs()[0].getAsType())) diff --git a/runtime/cudaq/cudaq.cpp b/runtime/cudaq/cudaq.cpp index 4e4b29cd73..9373d05139 100644 --- a/runtime/cudaq/cudaq.cpp +++ b/runtime/cudaq/cudaq.cpp @@ -14,7 +14,7 @@ #include "cuda_runtime_api.h" #endif #include "cudaq/platform.h" -#include "cudaq/qis/qkernel_ref.h" +#include "cudaq/qis/qkernel.h" #include "cudaq/utils/registry.h" #include "distributed/mpi_plugin.h" #include @@ -253,7 +253,7 @@ void cudaq::registry::__cudaq_registerLinkableKernel(void *hostSideFunc, std::intptr_t cudaq::registry::__cudaq_getLinkableKernelKey(void *p) { if (!p) throw std::runtime_error("cannot get kernel key, nullptr"); - const auto &qk = *reinterpret_cast *>(p); + const auto &qk = *reinterpret_cast *>(p); return reinterpret_cast(*qk.get_entry_kernel_from_holder()); } diff --git a/runtime/cudaq/qis/qkernel_ref.h b/runtime/cudaq/qis/qkernel.h similarity index 85% rename from runtime/cudaq/qis/qkernel_ref.h rename to runtime/cudaq/qis/qkernel.h index f7e50223f5..6f477110fe 100644 --- a/runtime/cudaq/qis/qkernel_ref.h +++ b/runtime/cudaq/qis/qkernel.h @@ -17,9 +17,9 @@ namespace cudaq { /// In library mode, the quake compiler is not involved. To streamline things, -/// just have qkernel_ref alias the std::function template class. +/// just have `qkernel` alias the std::function template class. template -using qkernel_ref = std::function; +using qkernel = std::function; } // namespace cudaq @@ -100,7 +100,7 @@ template using remove_cvref_t = std::remove_cv_t>; #endif -/// A qkernel_ref<> must be used to wrap `CUDA-Q` kernels (callables annotated +/// A `qkernel` must be used to wrap `CUDA-Q` kernels (callables annotated /// with the `__qpu__` attribute) when those kernels are \e referenced other /// than by a direct call in code outside of quantum kernels proper. Supports /// free functions, classes with call operators, and lambdas. @@ -110,18 +110,18 @@ using remove_cvref_t = std::remove_cv_t>; /// either stitch together execution in a simulation environment and/or JIT /// compile and re-link these kernels into a cohesive quantum circuit. template -class qkernel_ref; +class qkernel; template -class qkernel_ref { +class qkernel { public: - qkernel_ref() {} - qkernel_ref(std::nullptr_t) {} - qkernel_ref(const qkernel_ref &) = default; - qkernel_ref(qkernel_ref &&) = default; + qkernel() {} + qkernel(std::nullptr_t) {} + qkernel(const qkernel &) = default; + qkernel(qkernel &&) = default; template , qkernel_ref>> + bool SELF = std::is_same_v, qkernel>> using DecayType = typename std::enable_if_t>::type; template , @@ -131,7 +131,7 @@ class qkernel_ref { struct CallableType : RES {}; template ::value>> - qkernel_ref(S &&f) { + qkernel(S &&f) { using PS = remove_cvref_t; if constexpr (std::is_same_v || std::is_same_v) { @@ -162,31 +162,31 @@ class qkernel_ref { // Deduction guides for C++20. template -qkernel_ref(R (*)(As...)) -> qkernel_ref; +qkernel(R (*)(As...)) -> qkernel; template -struct qkernel_ref_deduction_guide_helper {}; +struct qkernel_deduction_guide_helper {}; template -struct qkernel_ref_deduction_guide_helper { +struct qkernel_deduction_guide_helper { using type = R(As...); }; template -struct qkernel_ref_deduction_guide_helper { +struct qkernel_deduction_guide_helper { using type = R(As...); }; template -struct qkernel_ref_deduction_guide_helper { +struct qkernel_deduction_guide_helper { using type = R(As...); }; template -struct qkernel_ref_deduction_guide_helper { +struct qkernel_deduction_guide_helper { using type = R(As...); }; -template ::type> -qkernel_ref(F) -> qkernel_ref; +qkernel(F) -> qkernel; #endif // CUDAQ_USE_STD20 diff --git a/runtime/cudaq/qis/qubit_qis.h b/runtime/cudaq/qis/qubit_qis.h index 5e09625d1c..c83dffe844 100644 --- a/runtime/cudaq/qis/qubit_qis.h +++ b/runtime/cudaq/qis/qubit_qis.h @@ -13,7 +13,7 @@ #include "cudaq/qis/modifiers.h" #include "cudaq/qis/pauli_word.h" #include "cudaq/qis/qarray.h" -#include "cudaq/qis/qkernel_ref.h" +#include "cudaq/qis/qkernel.h" #include "cudaq/qis/qreg.h" #include "cudaq/qis/qvector.h" #include "cudaq/spin_op.h" diff --git a/runtime/cudaq/utils/registry.h b/runtime/cudaq/utils/registry.h index a9b96bb3c0..3e339c196b 100644 --- a/runtime/cudaq/utils/registry.h +++ b/runtime/cudaq/utils/registry.h @@ -19,7 +19,7 @@ void cudaqRegisterLambdaName(const char *, const char *); /// Register a kernel with the runtime for kernel runtime stitching. void __cudaq_registerLinkableKernel(void *, const char *, void *); -/// Return the kernel key from a qkernel_ref object. If \p p is a `nullptr` this +/// Return the kernel key from a `qkernel` object. If \p p is a `nullptr` this /// will throw a runtime error. std::intptr_t __cudaq_getLinkableKernelKey(void *p); diff --git a/targettests/SeparateCompilation/basic.cpp b/targettests/SeparateCompilation/basic.cpp index 81f429a47c..eae9d13f3d 100644 --- a/targettests/SeparateCompilation/basic.cpp +++ b/targettests/SeparateCompilation/basic.cpp @@ -40,8 +40,7 @@ __qpu__ void dunkadee(cudaq::qvector<> &q) { #include "baselib.h" #include -__qpu__ void -userKernel(const cudaq::qkernel_ref &)> &init) { +__qpu__ void userKernel(const cudaq::qkernel &)> &init) { cudaq::qvector q(2); init(q); } diff --git a/targettests/SeparateCompilation/class.cpp b/targettests/SeparateCompilation/class.cpp index 87828bba20..eec15ccedd 100644 --- a/targettests/SeparateCompilation/class.cpp +++ b/targettests/SeparateCompilation/class.cpp @@ -42,8 +42,7 @@ void HereIsTheThing::operator()(cudaq::qvector<> &q) __qpu__ { #include "classlib.h" #include -__qpu__ void -userKernel(const cudaq::qkernel_ref &)> &init) { +__qpu__ void userKernel(const cudaq::qkernel &)> &init) { cudaq::qvector q(2); init(q); } diff --git a/targettests/SeparateCompilation/deduction_guide.cpp b/targettests/SeparateCompilation/deduction_guide.cpp index d585be56fa..9f64c5e5d6 100644 --- a/targettests/SeparateCompilation/deduction_guide.cpp +++ b/targettests/SeparateCompilation/deduction_guide.cpp @@ -34,8 +34,7 @@ __qpu__ void dunkadee(cudaq::qvector<> &q) { x(q[0]); } #include "udedgulib.h" #include -__qpu__ void -userKernel(const cudaq::qkernel_ref &)> &init) { +__qpu__ void userKernel(const cudaq::qkernel &)> &init) { cudaq::qvector q(2); init(q); } diff --git a/targettests/SeparateCompilation/emulate.cpp b/targettests/SeparateCompilation/emulate.cpp index 1b9def0bab..9128a93548 100644 --- a/targettests/SeparateCompilation/emulate.cpp +++ b/targettests/SeparateCompilation/emulate.cpp @@ -34,15 +34,14 @@ __qpu__ void dunkadee(cudaq::qvector<> &q) { x(q[0]); } #include "emulib.h" #include -__qpu__ void -userKernel(const cudaq::qkernel_ref &)> &init) { +__qpu__ void userKernel(const cudaq::qkernel &)> &init) { cudaq::qvector q(2); init(q); } int main() { cudaq::sample(10, userKernel, - cudaq::qkernel_ref &)>{dunkadee}); + cudaq::qkernel &)>{dunkadee}); std::cout << "Hello, World!\n"; return 0; } diff --git a/targettests/SeparateCompilation/lambda.cpp b/targettests/SeparateCompilation/lambda.cpp index 5fa3b301b1..724d81d804 100644 --- a/targettests/SeparateCompilation/lambda.cpp +++ b/targettests/SeparateCompilation/lambda.cpp @@ -21,14 +21,13 @@ #include "cudaq.h" -__qpu__ void userKernel(const cudaq::qkernel_ref &)> &); +__qpu__ void userKernel(const cudaq::qkernel &)> &); //--- anonlib.cpp #include "anonlib.h" -__qpu__ void -userKernel(const cudaq::qkernel_ref &)> &init) { +__qpu__ void userKernel(const cudaq::qkernel &)> &init) { cudaq::qvector q(2); init(q); } diff --git a/targettests/SeparateCompilation/multiple_callables.cpp b/targettests/SeparateCompilation/multiple_callables.cpp index 8ed4a02b65..2f8bc5e6a1 100644 --- a/targettests/SeparateCompilation/multiple_callables.cpp +++ b/targettests/SeparateCompilation/multiple_callables.cpp @@ -11,8 +11,8 @@ #include "cudaq.h" -__qpu__ void entry(const cudaq::qkernel_ref &)> &o, - const cudaq::qkernel_ref &, int)> &p) { +__qpu__ void entry(const cudaq::qkernel &)> &o, + const cudaq::qkernel &, int)> &p) { cudaq::qvector q(2); o(q); p(q, 1); @@ -25,4 +25,3 @@ int main() { entry(l, m); return 0; } - diff --git a/targettests/execution/cudaq_observe.cpp b/targettests/execution/cudaq_observe.cpp index c983ce36d2..daa10c1425 100644 --- a/targettests/execution/cudaq_observe.cpp +++ b/targettests/execution/cudaq_observe.cpp @@ -8,7 +8,6 @@ // REQUIRES: c++20 // clang-format off -// RUN: nvq++ --target anyon --emulate %s -o %t && %t | FileCheck %s // RUN: nvq++ --target ionq --emulate %s -o %t && %t | FileCheck %s // 2 different IQM machines for 2 different topologies // RUN: nvq++ --target iqm --iqm-machine Adonis --emulate %s -o %t && %t | FileCheck %s diff --git a/test/AST-Quake/indirect_callable.cpp b/test/AST-Quake/indirect_callable.cpp index 5fb4af1106..ba429e9782 100644 --- a/test/AST-Quake/indirect_callable.cpp +++ b/test/AST-Quake/indirect_callable.cpp @@ -12,19 +12,19 @@ __qpu__ int rando_qernel(double); -__qpu__ void superstar_qernel(const cudaq::qkernel_ref& bob, double dub) { +__qpu__ void superstar_qernel(const cudaq::qkernel& bob, double dub) { auto size = bob(dub); cudaq::qvector q(size); mz(q); } void meanwhile_on_safari() { - cudaq::qkernel_ref tiger{rando_qernel}; + cudaq::qkernel tiger{rando_qernel}; superstar_qernel(tiger, 11.0); } // clang-format off -// CHECK-LABEL: func.func @__nvqpp__mlirgen__function_superstar_qernel._Z16superstar_qernelRKN5cudaq11qkernel_refIFidEEEd( +// CHECK-LABEL: func.func @__nvqpp__mlirgen__function_superstar_qernel._Z16superstar_qernelRKN5cudaq7qkernelIFidEEEd( // CHECK-SAME: %[[VAL_0:.*]]: !cc.indirect_callable<(f64) -> i32>, // CHECK-SAME: %[[VAL_1:.*]]: f64) attributes {"cudaq-entrypoint", "cudaq-kernel", no_this} { // CHECK: %[[VAL_2:.*]] = cc.alloca f64 @@ -40,7 +40,7 @@ void meanwhile_on_safari() { // CHECK: return // CHECK: } -// CHECK-LABEL: func.func @_Z16superstar_qernelRKN5cudaq11qkernel_refIFidEEEd( +// CHECK-LABEL: func.func @_Z16superstar_qernelRKN5cudaq7qkernelIFidEEEd( // CHECK-SAME: %[[VAL_0:.*]]: !cc.ptr, // CHECK-SAME: %[[VAL_1:.*]]: f64) attributes {no_this} { // CHECK: return