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

Functions

QrmiConfig * qrmi_config_load (const char *filename)
QrmiReturnCode qrmi_config_free (QrmiConfig *ptr)
QrmiResourceDef * qrmi_config_resource_def_get (QrmiConfig *config, const char *resource_id)
const char * qrmi_config_resource_type_to_str (QrmiResourceType type)
QrmiReturnCode qrmi_config_resource_type_from_str (const char *type_str, QrmiResourceType *outp)
QrmiReturnCode qrmi_config_resource_def_free (QrmiResourceDef *ptr)
QrmiReturnCode qrmi_config_resource_names_get (QrmiConfig *config, size_t *num_names, char **names[])

Detailed Description

Functions used when accessing configuration file data from the QRMI C API.

Function Documentation

◆ qrmi_config_free()

QrmiReturnCode qrmi_config_free ( QrmiConfig * ptr)

Frees the memory space pointed to by ptr, which must have been returned by a previous call to qrmi_config_load() or related functions. Otherwise, or if ptr has already been freed, segmentation fault occurs. If ptr is NULL, no operation is performed.

Safety

Example

QrmiConfig *cnf = qrmi_config_load("/etc/slurm/qrmi_config.json");
QrmiConfig * qrmi_config_load(const char *filename)
QrmiReturnCode qrmi_config_free(QrmiConfig *ptr)
struct QrmiConfig QrmiConfig
Definition qrmi.h:222
Parameters
(ptr)a pointer to Config to be free
Returns
QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded.
Version
0.6.0

◆ qrmi_config_load()

QrmiConfig * qrmi_config_load ( const char * filename)

Loads qrmi_config.json and returns it as Config.

Safety

  • The memory pointed to by filename must contain a valid nul terminator.
  • The nul terminator must be within isize::MAX from filename

Example

QrmiConfig *cnf = qrmi_config_load("/etc/slurm/qrmi_config.json");
Parameters
(filename)[in] qrmi_config.json file path
Returns
A QrmiConfig if succeeded, otherwise NULL. Must call qrmi_config_free() to free if no longer used.
Version
0.6.0

◆ qrmi_config_resource_def_free()

QrmiReturnCode qrmi_config_resource_def_free ( QrmiResourceDef * ptr)

Frees the memory space pointed to by ptr, which must have been returned by a previous call to qrmi_config_get_resource_def() or related functions. Otherwise, or if ptr has already been freed, segmentation fault occurs. If ptr is NULL, no operation is performed.

Safety

Example

QrmiConfig *cnf = qrmi_config_load(argv[1]);
if (!cnf) {
QrmiResourceDef* res = qrmi_config_resource_def_get(cnf, "your_resource_id");
if (res != NULL) {
printf("%s %d\n", res->name, res->type);
}
}
QrmiResourceDef * qrmi_config_resource_def_get(QrmiConfig *config, const char *resource_id)
QrmiReturnCode qrmi_config_resource_def_free(QrmiResourceDef *ptr)
Definition qrmi.h:283
QrmiResourceType type
Definition qrmi.h:291
char * name
Definition qrmi.h:287
Parameters
(ptr)a pointer to ResourceDef to be free
Returns
QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded.
Version
0.6.0

◆ qrmi_config_resource_def_get()

QrmiResourceDef * qrmi_config_resource_def_get ( QrmiConfig * config,
const char * resource_id )

Returns the resource definition for the specified resource.

Safety

  • The memory pointed to by resource_id must contain a valid nul terminator.
  • The nul terminator must be within isize::MAX from resource_id

Example

QrmiConfig *cnf = qrmi_config_load(argv[1]);
if (!cnf) {
QrmiResourceDef* res = qrmi_config_resource_def_get(cnf, "your_resource_id");
if (res != NULL) {
printf("%s %d\n", res->name, res->type);
for (int j = 0; j < envvars.length; j++) {
QrmiKeyValue envvar = envvars.variables[j];
printf("%s = %s\n", envvar.key, envvar.value);
}
}
}
Definition qrmi.h:269
QrmiKeyValue * variables
Definition qrmi.h:273
size_t length
Definition qrmi.h:277
Definition qrmi.h:255
char * value
Definition qrmi.h:263
char * key
Definition qrmi.h:259
QrmiEnvironmentVariables environments
Definition qrmi.h:299
Parameters
(config)[in] a Config handle
(resource_id)[in] resource identifier
Returns
A QrmiResourceDef if succeeded, otherwise NULL. Must call qrmi_config_resource_def_free() to free if no longer used.
Version
0.6.0

◆ qrmi_config_resource_names_get()

QrmiReturnCode qrmi_config_resource_names_get ( QrmiConfig * config,
size_t * num_names,
char ** names[] )

Returns a list of the resource names

Safety

  • config must have been returned by a previous call to qrmi_config_load().
  • The memory pointed to by outlen must have enough room to store size_t value.
  • names must be non-null.

Example

size_t num_names = 0;
char **names = NULL;
QrmiReturnCode rc = qrmi_config_resource_names_get(cnf, &num_names, &names);
for (int i = 0; i < num_names; i++) {
printf("[%s]\n", names[i]);
}
qrmi_string_array_free(num_names, names);
}
QrmiReturnCode qrmi_config_resource_names_get(QrmiConfig *config, size_t *num_names, char **names[])
QrmiReturnCode qrmi_string_array_free(size_t size, char *array[])
QrmiReturnCode
Definition qrmi.h:55
@ QRMI_RETURN_CODE_SUCCESS
Definition qrmi.h:59
Parameters
(config)[in] A Config handle
(num_names)[out] number of resource names in the list
(names)[out] A list of the resource names if succeeded. Must call qrmi_string_array_free() to free if no longer used.
Returns
QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded.
Version
0.6.0

◆ qrmi_config_resource_type_from_str()

QrmiReturnCode qrmi_config_resource_type_from_str ( const char * type_str,
QrmiResourceType * outp )

Parses the string representation used in qrmi_config.json and QRMI_JOB_QPU_TYPES, e.g. pasqal-local to QrmiResourceType::QRMI_RESOURCE_TYPE_PASQAL_LOCAL.

Safety

  • The memory pointed to by type_str must contain a valid nul terminator.
  • outp must be non-null.

Example

QrmiQuantumResource *qrmi = qrmi_resource_new("your_resource_name", type);
}
QrmiReturnCode qrmi_config_resource_type_from_str(const char *type_str, QrmiResourceType *outp)
QrmiQuantumResource * qrmi_resource_new(const char *resource_id, QrmiResourceType resource_type)
QrmiResourceType
Definition qrmi.h:125
struct QrmiQuantumResource QrmiQuantumResource
Definition qrmi.h:227
Parameters
(type_str)[in] string representation of ResourceType
(outp)[out] ResourceType variant if succeeded
Returns
QrmiReturnCode::QRMI_RETURN_CODE_SUCCESS if succeeded, QrmiReturnCode::QRMI_RETURN_CODE_INVALID_INPUT_ERROR for an unknown string.
Version
0.27.0

◆ qrmi_config_resource_type_to_str()

const char * qrmi_config_resource_type_to_str ( QrmiResourceType type)

Converts ResourceType to string representation used in qrmi_config.json, e.g. QrmiResourceType::QRMI_RESOURCE_TYPE_IBM_QUANTUM_COMPUTE_SERVICE to ibm-quantum-compute-service.

Safety

Example

printf("%s\n", type_as_str);
qrmi_string_free(type_as_str);
const char * qrmi_config_resource_type_to_str(QrmiResourceType type)
QrmiReturnCode qrmi_string_free(char *ptr)
@ QRMI_RESOURCE_TYPE_IBM_QUANTUM_COMPUTE_SERVICE
Definition qrmi.h:137
Parameters
type(QrmiResourceType) ResourceType variant
Returns
string representation of ResourceType.
Version
0.6.0