SLURM APIs
Overview
All of the SLURM commands utilize a collection of Application Programming Interfaces (APIs). User and system applications can directly use these APIs as desired to achieve tighter integration with SLURM. For example, SLURM data structures and error codes can be directly examined rather than executing SLURM commands and parsing their output. This document describes SLURM APIs. You should see the man pages for individual APIs to get more details.
Get Overall SLURM Information
- slurm_api_versionGet SLURM API version number.
- slurm_load_ctl_confLoad system-wide configuration specifications. Free with slurm_free_ctl_conf to avoid memory leak.
- slurm_print_ctl_confPrint system-wide configuration specifications.
- slurm_free_ctl_confFree storage allocated by slurm_load_ctl_conf.
Get Job Information
- slurm_pid2jobidFor a given process ID on a node get the corresponding SLURM job ID.
- slurm_get_end_timeFor a given SLURM job ID get the expected termination time.
- slurm_load_jobsLoad job information. Free with slurm_free_job_info_msg to avoid memory leak.
- slurm_print_job_info_msgPrint information about all jobs.
- slurm_print_job_infoPrint information about a specific job.
- slurm_get_select_jobinfoGet select plugin specific information associated with the job. The information available is will vary by select plugin type configured.
- slurm_free_job_info_msgFree storage allocated by slurm_load_jobs.
Get Job Step Information
- slurm_get_job_stepsLoad job step information. Free with slurm_free_job_step_info_response_msg to avoid memory leak.
- slurm_print_job_step_info_msgPrint information about all job steps.
- slurm_print_job_step_infoPrint information about a specific job step.
- slurm_free_job_step_info_response_msgFree storage allocated by slurm_get_job_steps.
Get Node Information
- slurm_load_nodeLoad node information. Free with slurm_free_node_info to avoid memory leak.
- slurm_print_node_info_msgPrint information about all nodes.
- slurm_print_node_tablePrint information about a specific node.
- slurm_free_node_infoFree storage allocated by slurm_load_node.
Get Partition Information
- slurm_load_partitionsLoad partition (queue) information. Free with slurm_free_partition_info to avoid memory leak.
- slurm_print_partition_info_msgPrint information about all partitions.
- slurm_print_partition_infoPrint information about a specific partition.
- slurm_free_partition_infoFree storage allocated by slurm_load_partitions.
Error Handling
- slurm_get_errnoReturn the error code set by the last SLURM API function executed.
- slurm_perrorPrint SLURM error information to standard output.
- slurm_strerrorReturn a string describing a specific SLURM error code.
Resource Allocation
- slurm_init_job_desc_msgInitialize the data structure used in resource allocation requests. You can then just set the fields of particular interest and let the others use default values.
- slurm_job_will_runDetermine if a job would be immediately initiated if submitted now.
- slurm_allocate_resourcesAllocate resources for a job. Response message must be freed using slurm_free_resource_allocation_response_msg to avoid a memory leak.
- slurm_free_resource_allocation_response_msg Frees memory allocated by slurm_allocate_resources.
- slurm_allocate_resources_and_runAllocate resources for a job and spawn a job step. Response message must be freed using slurm_free_resource_allocation_and_run_response_msg to avoid a memory leak.
- slurm_free_resource_allocation_and_run_response_msg Frees memory allocated by slurm_allocate_resources_and_run.
- slurm_submit_batch_jobSubmit a script for later execution. Response message must be freed using slurm_free_submit_response_response_msg to avoid a memory leak.
- slurm_free_submit_response_response_msg Frees memory allocated by slurm_submit_batch_job.
- slurm_confirm_allocationTest if a resource allocation has already been made for a given job id. Response message must be freed using slurm_free_resource_allocation_response_msg to avoid a memory leak. This can be used to confirm that an allocation is still active or for error recovery.
Job Step Creation
SLURM job steps involve numerous interactions with the slurmd daemon. The job step creation is only the first step in the process. We don't advise direct user creation of job steps, but include the information here for completeness.
- slurm_job_step_createInitiate a job step. Allocated memory must be freed by slurm_free_job_step_create_response_msg to avoid a memory leak.
- slurm_free_job_step_create_response_msgFree memory allocated by slurm_job_step_create.
- slurm_step_ctx_createCreate job step context. Destroy using slurm_step_ctx_destroy.
- slurm_step_ctx_destroyDestroy a job step context created by slurm_step_ctx_create.
- slurm_step_ctx_getGet values from job step context.
- slurm_step_ctx_setSet values in job step context.
- slurm_jobinfo_ctx_getGet values from a jobinfo field as returned by slurm_step_ctx_get.
- slurm_spawnSpawn tasks and establish communications.
- slurm_spawn_killSignal spawned tasks.
Job and Job Step Signaling and Cancelling
- slurm_kill_jobSignal or cancel a job.
- slurm_kill_job_stepSignal or cancel a job step.
Job Completion
- slurm_complete_jobNote completion of a job. Releases resource allocation for the job.
- slurm_complete_job_stepNote completion of a job step.
Checkpoint
- slurm_checkpoint_ableNote that a specific job or job step is eligible for checkpoint.
- slurm_checkpoint_completeNote that a requested checkpoint has completed.
- slurm_checkpoint_createRequest a checkpoint for a specific job step. Continue execution upon completion of the checkpoint.
- slurm_checkpoint_vacateRequest a checkpoint for a specific job step. Terminate execution upon completion of the checkpoint.
- slurm_checkpoint_disableMake the identified job step non-checkpointable.
- slurm_checkpoint_enableMake the identified job step checkpointable.
- slurm_checkpoint_errorGet error information for the last checkpoint operation on a given job step.
- slurm_checkpoint_restartRequest that a previously checkpointed job resume execution.
Administrative Functions
Most of these functions can only be executed by user root.
- slurm_reconfigureUpdate slurm daemons based upon current slurm.conf configuration file. Use this after updating the configuration file to insure that it takes effect.
- slurm_shutdownTerminate slurm daemons.
- slurm_update_jobUpdate state information associated with a given job.
- slurm_update_nodeUpdate state information associated with a given node. NOTE: Most of a node's characteristics can not be modified.
- slurm_init_part_desc_msgInitialize a partition update descriptor. Used this to initialize the data structure used in slurm_update_partition.
- slurm_update_partitionUpdate state information associated with a given partition.
- slurm_delete_partitionDestroy a partition.
SLURM Host List Support
SLURM uses a condensed format to express node names. For example linux[1-3,6] represents linux1, linux2, linux3, and linux6. These functions permit you to translate the SLURM expression into a list of individual node names.
- slurm_hostlist_createTranslate a SLURM node name expression into a record used for parsing. Use slurm_hostlist_destroy to free the allocated storage.
- slurm_hostlist_shiftGet the next node name.
- slurm_hostlist_destroyRelease storage allocated by slurm_hostlist_create.
Last modified 13 November 2005