qp.runtime_declare

runtime_declare(symbol, spec, library=None)

Declare the signature of a runtime symbol so it can be called by name.

spec lists parameter types in runtime order, followed by an optional result. An out parameter is declared in spec but omitted from the arguments to runtime_call().

Parameters:
  • symbol (str) – the C symbol name, as exported by the runtime library

  • spec (str) – the signature spec, e.g. "(ptr, buf, u64) -> i32". See CType for the available types.

  • library (str | None) – the shared library (.so / .dylib) exporting symbol, for a local in-process call. It is recorded on the compiled module so the driver links against it. Leave it None for a dispatched symbol, or one already loaded in the calling process.

Returns:

the declared signature, which runtime_call() also takes

directly

Return type:

CSignature

Example

import pennylane as qp

qp.runtime_declare("example_declared_rounds", "(ptr, u32) -> i32")

# ...and a local symbol, from a shared library the program is linked against:
qp.runtime_declare("example_local", "(i32, i32) -> i32", library="/path/liblocal.so")

def program(session, lhs, rhs):
    qp.runtime_call("example_declared_rounds", session, 1000, address="board:9000")
    return qp.runtime_call("example_local", lhs, rhs)

See also

runtime_call()