# SLURM Generic Resource (GRES) Plugin API

## Overview

This document describes SLURM generic resource plugins and the API that defines them. It is intended as a resource to programmers wishing to write their own SLURM job submit plugins.

SLURM generic resource plugins must conform to the SLURM Plugin API with the following specifications:

const char gres_name[]="gres_name"

The gres_name should matc minor in plugin_version described below.

const char plugin_name[]="full text name"

A free-formatted ASCII text string that identifies the plugin.

const char plugin_type[]="major/minor"

The major type must be "gres." The minor type can be any suitable name for the type of accounting package.

const uint32_t plugin_version="version_number"

The version number should be 120.

We include samples in the SLURM distribution for

- gpu—Manage GPUs (Graphics Processing Units).
- nic—Manage NICs (Network Interface Cards, this plugin does nothing today).

## API Functions

All of the following functions are required. Functions which are not implemented must be stubbed.

int node_config_load(List gres_conf_list)

Description:
This function is called by the slurmd daemon after the slurm.conf and gres.conf files have been read. It can be used to validate the configuration by testing the actual hardware resources available or just confirm that an entry for the resource was included in the gres.conf file.

Arguments:
gres_conf_list (input/output) a list of configuration records generated by reading the slurm.conf and gres.conf files

Returns:
SLURM_SUCCESS on success, or
SLURM_ERROR on failure.

void job_set_env(char ***job_env_ptr, void *gres_ptr)

Description:
This function is called by the slurmd daemon after the getting a job credential and can be used to set environment variables for the job based upon GRES state information in that credential.

Arguments:
job_env_ptr (input/output) pointer to the job's environment variable structure.
gres_ptr (input) pointer to the job's GRES allocation information.

void step_set_env(char ***job_env_ptr, void *gres_ptr)

Description:
This function is called by the slurmd daemon after the getting a job step credential and can be used to set environment variables for the job step based upon GRES state information in that credential.

Arguments:
job_env_ptr (input/output) pointer to the job step's environment variable structure.
gres_ptr (input) pointer to the step's GRES allocation information.

extern void send_stepd(int fd)

Description:
This function is called by the slurmd daemon to send any needed information to the slurmstepd step shepherd.

Arguments:
fd (input) file descriptor to write information to.

extern void recv_stepd(int fd)

Description:
This function is called by the slurmstepd step shepherd to read any needed information from the slurmd daemon.

Arguments:
fd (input) file descriptor to read information from.

extern int job_info(gres_job_state_t *job_gres_data, uint32_t node_inx, enum gres_job_data_type data_type, void *data)

Description:
This function is used to extract plugin specific data from the job's GRES data structure. Note that data types GRES_JOB_DATA_COUNT and GRES_JOB_DATA_BITMAP are processed in common code rather than within the plugin and return data types of uint32_t* and bitstr_t** respectively.

Arguments:
job_gres_data (input) Information about the job's GRES resources.
(input) Zero origin index within the job's resource allocation for which data is desired.
gres_job_data_type data_type (input) Type of information to be gathered from the data structure.
data (output) Pointer to data within job_gres_data. No data is copied or needs to be freed. Data type depends upon the value of gres_job_data_type data_type.

Returns:
SLURM_SUCCESS on success, or
SLURM_ERROR on failure.

extern int step_info(gres_step_state_t *step_gres_data, uint32_t node_inx, enum gres_step_data_type data_type, void *data)

Description:
This function is used to extract plugin specific data from the step's GRES data structure. Note that data types GRES_STEP_DATA_COUNT and GRES_STEP_DATA_BITMAP are processed in common code rather than within the plugin and return data types of uint32_t* and bitstr_t** respectively.

Arguments:
step_gres_data (input) Information about the step's GRES resources.
node_inx (input) Zero origin index within the job's resource allocation for which data is desired.
gres_step_data_type data_type (input) Type of information to be gathered from the data structure.
data (output) Pointer to data within step_gres_data. No data is copied or needs to be freed. Data type depends upon the value of gres_step_data_type data_type.

Returns:
SLURM_SUCCESS on success, or
SLURM_ERROR on failure.

## Versioning

This document describes version 120 of the SLURM Generic Resource API. Future releases of SLURM may revise this API.

Last modified 6 August 2013