Quantum Resource Management Interface (QRMI) C API
Loading...
Searching...
No Matches
QRMI Service

Functions

QrmiReturnCode qrmi_service_resources (QrmiQuantumResources *resources_out)
QrmiReturnCode qrmi_service_resources_free (QrmiQuantumResources *resources)

Detailed Description

Functions used to discover the QPU resources assigned to the current job from the QRMI C API.

Function Documentation

◆ qrmi_service_resources()

QrmiReturnCode qrmi_service_resources ( QrmiQuantumResources * resources_out)

Discovers the QPU resources assigned to the current job – read from the QRMI_JOB_QPU_RESOURCES / QRMI_JOB_QPU_TYPES environment variables, or their legacy SLURM_JOB_QPU_RESOURCES / SLURM_JOB_QPU_TYPES equivalents – and returns the ones that are currently accessible.

This is the C counterpart of qrmi.QRMIService (Python) and qrmi::QRMIService (Rust); all three share the same underlying discovery/filtering logic.

Unlike qrmi_provider_resources(), which is called against a persistent QrmiResourceProvider handle (and can be called repeatedly, e.g. with different filters), this function takes no arguments and is a one-shot operation: there is no separate "service" handle to create or free. Discovery happens inline, and each QrmiQuantumResource handle placed in resources_out is independently owned by the caller from that point on – usable with the same qrmi_resource_*() functions as a handle returned by qrmi_resource_new(), just not individually freed (see qrmi_service_resources_free() below).

The caller is responsible for freeing the returned struct with qrmi_service_resources_free(). Individual handles inside the struct must NOT be freed separately.

Safety

Example

QrmiQuantumResources resources = {0};
for (size_t i = 0; i < resources.length; i++) {
char *id = NULL;
qrmi_resource_id(resources.resources[i], &id);
printf("resource: %s\n", id);
}
} else {
const char *err = qrmi_get_last_error();
printf("error: %s\n", err);
}
QrmiReturnCode qrmi_resource_id(QrmiQuantumResource *qrmi, char **outp)
QrmiReturnCode qrmi_service_resources_free(QrmiQuantumResources *resources)
QrmiReturnCode qrmi_service_resources(QrmiQuantumResources *resources_out)
char * qrmi_get_last_error(void)
QrmiReturnCode qrmi_string_free(char *ptr)
QrmiReturnCode
Definition qrmi.h:55
@ QRMI_RETURN_CODE_SUCCESS
Definition qrmi.h:59
Definition qrmi.h:462
QrmiQuantumResource ** resources
Definition qrmi.h:466
size_t length
Definition qrmi.h:470
Parameters
(resources_out)[out] Pointer to a QrmiQuantumResources struct to populate
Returns
QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded.
Version
0.23.0

◆ qrmi_service_resources_free()

QrmiReturnCode qrmi_service_resources_free ( QrmiQuantumResources * resources)

Frees a QrmiQuantumResources struct populated by qrmi_service_resources().

This frees both the individual QrmiQuantumResource handles and the internal array. After calling this, the struct's fields are zeroed. Do NOT call qrmi_resource_free() on individual elements after calling this.

Safety

Example

Parameters
(resources)[in] Pointer to a QrmiQuantumResources struct to free
Returns
QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded.
Version
0.23.0