Resource requirement strings

Most LSF commands accept a -R res_req argument to specify resource requirements. A resource requirement string describes the resources that a job needs. The exact behavior depends on the command. LSF uses resource requirements to select hosts for remote execution and job execution. Resource requirement strings can be simple (applying to the entire job) or compound (applying to the specified number of slots).

For example, specifying a resource requirement for the lsload command displays the load levels for all hosts that have the requested resources. Specifying resource requirements for the lsrun command causes LSF to select the best host out of the set of hosts that have the requested resources.

Resource requirement string sections

The section names for resource requirement strings are select, order, rusage, span, same, cu, and affinity. Sections that do not apply for a command are ignored.

  • A selection section (select). The selection section specifies the criteria for selecting hosts from the system.
  • An ordering section (order). The ordering section indicates how the hosts that meet the selection criteria is sorted.
  • A resource usage section (rusage). The resource usage section specifies the expected resource consumption of the task.
  • A job spanning section (span). The job spanning section indicates whether a parallel batch job can span across multiple hosts.
  • A same resource section (same). The same section indicates that all processes of a parallel job must run on the same type of host.
  • A compute unit resource section (cu). The cu section specifies how a job is placed compared to the underlying network architecture.
  • An affinity resource section (affinity). The affinity section specifies how a job is be placed compared to CPU and memory affinity on NUMA hosts.

Which sections apply

Depending on the command, one or more of the resource requirement string sections might apply.
  • The bsub command uses all sections.
  • The brsvadd command uses the information in the select and same sections to select an appropriate host for an advance reservation.
  • The lshosts command selects hosts, but does not order them.
  • The lsload command selects and orders hosts.
  • The lsloadadj command uses the rusage section to determine how the load information is adjusted on a host.
  • The lsplace command uses the information in the select, order, and rusage sections to select an appropriate host for a task.

Simple syntax

select[selection_string] order[order_string] rusage[usage_string [, usage_string]
[|| usage_string] ...] span[span_string] same[same_string] cu[cu_string] affinity[affinity_string]

With the bsub and bmod commands, and only with these commands, you can specify multiple -R order, same, rusage, and select sections. The bmod command does not support the use of the || operator.

The section names are select, order, rusage, span, same, cu, and affinity. Sections that do not apply for a command are ignored.

The square brackets must be typed as shown for each section. A blank space must separate each resource requirement section.

You can omit the select[] section, but if you include it, the selection section must be the first string in the resource requirement string. If you do not use a section keyword (select, order, rusage, span, same, cu, and affinity), the first resource requirement string is treated as a selection string (select[selection_string]).

Each section has a different syntax.

By default, memory (mem) and swap (swp) limits in select[] and rusage[] sections are specified in MB. Use the LSF_UNIT_FOR_LIMITS parameter in the lsf.conf file to specify a larger unit for these limits.

For the bsub, bmod, and brestart commands, you can use the following units for resource requirements and limits:
  • KB or K (kilobytes)
  • MB or M (megabytes)
  • GB or G (gigabytes)
  • TB or T (terabytes)
  • PB or P (petabytes)
  • EB or E (exabytes)
  • ZB or Z (zettabytes)

The specified unit is converted to the appropriate value specified by the LSF_UNIT_FOR_LIMITS parameter. The converted limit values round up to a positive integer. For resource requirements, you can specify unit for mem, swp, and tmp in the select and rusage sections.

By default, the tmp resource is not supported by the LSF_UNIT_FOR_LIMITS parameter. Use the parameter LSF_ENABLE_TMP_UNIT=Y to enable the LSF_UNIT_FOR_LIMITS parameter to support limits on the tmp resource.

If the LSF_ENABLE_TMP_UNIT=Y and LSF_UNIT_FOR_LIMIT=GB parameters are set, the following conversion happens.

bsub -C 500MB -M 1G -S 1TB -F 1GB -R "rusage[mem=512MB:swp=1GB:tmp=1TB]" sleep 100 
The units in this job submission are converted to the following units:
 bsub -C 1 -M 1 -S 1024 -F 1 -R "rusage[mem=0.5:swp=1:tmp=1024]" sleep 100 

Compound syntax

num1*{simple_string1} + num2*{simple_string2} + ...

where numx is the number of slots that are affected and simple_stringx is a simple resource requirement string with the syntax:

select[selection_string] order[order_string] rusage[usage_string [, usage_string]...] span[span_string]

Resource requirements that apply to the first execution host (if used) appear in the first compound term num1*{simple_string1}.

Place specific (harder to fill) requirements before general (easier to fill) requirements since compound resource requirement terms are considered in the order they appear. Resource allocation for parallel jobs that use compound resources is done for each compound resource term independently instead of considering all possible combinations.

Note: A host that is rejected for not satisfying one resource requirement term is not reconsidered for subsequent resource requirement terms.
For jobs without the number of total slots that are specified by using the bsub -n option, you can omit the final numx. The final resource requirement is then applied to the zero or more slots that are not yet accounted for using the default slot setting of the parameter TASKLIMIT as follows:
  • (final res_req number of slots) = MAX(0,(default number of job slots from TASKLIMIT)-(num1+num2+...))
For jobs with the total number of slots that are specified with the bsub -n num_slots option, the total number of slots must match the number of slots in the resource requirement:
  • num_slots=(num1+num2+num3+...)
You can omit the final numx.
For jobs with compound resource requirements and first execution host candidates that are specified by using the bsub -m option, the host that is allocated first must satisfy the simple resource requirement string that appears first in the compound resource requirement. The first execution host must satisfy the requirements in simple_string1 for the following compound resource requirement:
num1*{simple_string1} + 
num2*{simple_string2} + 
num3*{simple_string3}

Compound resource requirements do not support use of the || operator within the component rusage simple resource requirements, or use of the cu section.

How simple multi-level resource requirements are resolved

Simple resource requirements can be specified at the job, application, and queue levels.

When none of the resource requirements are compound, requirements that are defined at different levels are resolved in the following ways:
  • In a select string, a host must satisfy all queue-level, application-level, and job-level requirements for the job to be dispatched.
  • In a same string, all queue-level, application-level, and job-level requirements are combined before the job is dispatched.
  • The order, span, and cu sections that are defined at the job level overwrite the sections that are defined at the application level or queue level. The order, span, and cu sections that are defined at the application level overwrite the sections that are defined at the queue level. The default order string is r15s:pg.
  • For usage strings, the rusage section that is defined for the job overrides the rusage section that is defined in the application. The two rusage definitions are merged. The job-level rusage takes precedence. Similarly, rusage strings that are defined for the job or application are merged with queue-level strings, with the job and then application definitions taking precedence over the queue if there is any overlap.

Section Simple resource requirement multilevel behavior
select All levels are satisfied
same All levels are combined
order

span

cu

Job-level section overwrites application-level section, which overwrites queue-level section (if a level is present)
rusage All levels merge

If conflicts occur the job-level section overwrites the application-level section, which overwrites the queue-level section.


For internal load indices and duration, jobs are rejected if the merged job-level and application-level resource reservation requirements exceed the requirements that are specified at the queue level.

Note: If a compound resource requirement is used at one or more levels (job, application, or queue) the compound rules apply.

How compound and multi-level resource requirements are resolved

Compound resource requirements can be specified at the job, application, and queue levels. When one or more of the resource requirements is compound or alternative, requirements at different levels are resolved depending on where the compound resource requirement appears.

During the first stage, LSF decides between the job and application level resource requirement:

  1. If a resource requirement is not defined at the job level, LSF takes the application level resource requirement, if any.
  2. If any level defines an alternative resource requirement, the job level overrides the application level resource requirement as a whole. There is no merge.
  3. If both levels have simple resource requirements, the job level merges with the application level resource requirement.
During the second stage, LSF decides between the job/application merged result and the queue level resource requirement:
  1. If the merged result does not define any resource requirement, LSF takes the queue-level resource requirement.
  2. If the merged result or queue-level is an alternative resource requirement, LSF takes the merged result.
  3. If the queue-level is a simple resource requirement and the merged result is a simple resource requirement, LSF merges the merged result with the queue-level resource requirement.
  4. If the queue-level resource requirement is simple and the merged result is an alternative resource requirement, each sub expression in the alternative resource requirement merges with the queue-level resource requirement, following these rules:
    1. The select[] clause must be satisfied for all of them.
    2. The merged order[] clause overrides the queue-level clause.
    3. The merged rusage[] clause merges with the queue-level rusage. If the queue-level rusage defines a job-level resource, this rusage subterm is merged only into the left most atomic resource requirement term.
    4. The merged span[] clause overrides the queue-level span[] clause.
    5. Queue-level same[] and cu[] clauses are ignored.

For internal load indices and duration, jobs are rejected if they specify resource reservation requirements that exceed the requirements that are specified at the application level or queue level.

Note: If a compound resource requirement is used at one or more levels (job, application, or queue) the compound rules apply.

Compound queue level

When a compound resource requirement is set for a queue, it is ignored unless it is the only resource requirement specified (no resource requirements are set at the job level or application level).

Compound application level

When a compound resource requirement is set at the application level, it is ignored if any job-level resource requirements (simple or compound) are defined.

If no job-level resource requirements are set, the compound application-level requirements interact with queue-level resource requirement strings in the following ways:

  • If no queue-level resource requirement is defined or a compound queue-level resource requirement is defined, the compound application-level requirement is used.
  • If a simple queue-level requirement is defined, the application-level and queue-level requirements combine as follows:
    Section Compound application and simple queue behavior
    select Both levels are satisfied. Queue requirement applies to all compound terms.
    same Queue level is ignored.
    order and span Application-level section overwrites queue-level section (if a level is present). Queue requirement (if used) applies to all compound terms.
    rusage
    • Both levels merge.
    • Queue requirement if a job-based resource is applied to the first compound term, otherwise applies to all compound terms.
    • If conflicts occur, the application-level section overwrites the queue-level section.

    For example, if the application-level requirement is num1*{rusage[R1]} + num2*{rusage[R2]} and the queue-level requirement is rusage[RQ] where RQ is a job-based resource, the merged requirement is num1*{rusage[merge(R1,RQ)]} + num2*{rusage[R2]}


Compound job level

When a compound resource requirement is set at the job level, any simple or compound application-level resource requirements are ignored, and any compound queue-level resource requirements are ignored.

If a simple queue-level requirement appears with a compound job-level requirement, the requirements interact as follows:


Section Compound job and simple queue behavior
select Both levels are satisfied; queue requirement applies to all compound terms.
same Queue level section is ignored.
order and span Job-level section overwrites queue-level section (if a level is present). Queue requirement (if used) applies to all compound terms.
rusage
  • Both levels merge.
  • Queue requirement if a job-based resource is applied to the first compound term, otherwise applies to all compound terms.
  • If conflicts occur, the job-level section overwrites the queue-level section.

For example, if the job-level requirement is num1*{rusage[R1]} + num2*{rusage[R2]} and the queue-level requirement is rusage[RQ] where RQ is a job resource, the merged requirement is num1*{rusage[merge(R1,RQ)]} + num2*{rusage[R2]}


Example 1

A compound job requirement and simple queue requirement are specified.
Job level
2*{select[type==X86_64] rusage[licA=1] span[hosts=1]} + 8*{select[type==any]}
Application level
Not defined.
Queue level
rusage[perslot=1]

The final job scheduling resource requirement merges the simple queue-level rusage section into each term of the compound job-level requirement, resulting in the following resource requirement: 2*{select[type==X86_64] rusage[licA=1:perslot=1] span[hosts=1]} + 8*{select[type==any] rusage[perslot=1]}

Example 2

A compound job requirement and compound queue requirement are specified.
Job level
2*{select[type==X86_64 && tmp>10000] rusage[mem=1000] span[hosts=1]} + 8*{select[type==X86_64]}
Application level
Not defined.
Queue level
2*{select[type==X86_64] rusage[mem=1000] span[hosts=1]} +8*{select[type==X86_64]}

The final job scheduling resource requirement ignores the compound queue-level requirement, resulting in the following resource requirement: 2*{select[type==X86_64 && tmp>10000] rusage[mem=1000] span[hosts=1]} + 8*{select[type==X86_64]}

Example 3

A compound job requirement and simple queue requirement where the queue requirement is a job-based resource.
Job level
2*{select[type==X86_64]} + 2*{select[mem>1000]}
Application level
Not defined.
Queue level
rusage[licA=1]. The resource licA=1 is job-based.

The queue-level requirement is added to the first term of the compound job-level requirement, resulting in the following resource requirement: 2*{select[type==X86_64] rusage[licA=1]} + 2*{select[mem>1000]}

Example 4

Compound multi-phase job requirements and simple multi-phase queue requirements.
Job level
2*{rusage[mem=(400 350):duration=(10 15):decay=(0 1)]} + 2*{rusage[mem=300:duration=10:decay=1]}
Application level
Not defined.
Queue level
rusage[mem=(500 300):duration=(20 10):decay=(0 1)]

The queue-level requirement is overridden by the first term of the compound job-level requirement, resulting in the following resource requirement: 2*{rusage[mem=(400 350):duration=(10 15):decay=(0 1)]} + 2*{rusage[mem=300:duration=10:decay=1]}

How alternative resource requirements are resolved

Alternative resource requirements are resolved in two stages. During the first stage, LSF decides between the job and application level resource requirement. During the second stage, LSF decides between the job/application merged result and the queue level resource requirement.

LSF makes the following decisions in the first stage:
  1. If a resource requirement is not defined at the job level, LSF takes the application-level resource requirement, if any.
  2. If any level defines an alternative resource requirement, the job-level overrides the application level resource requirement as a whole. There is no merge.
  3. If both levels have simple resource requirements, the job level merges with the application level resource requirement.
LSF makes the following decisions in the second stage:
  1. If the merged result does not define any resource requirement, LSF takes the queue-level resource requirement.
  2. If the merged result and queue-level resource requirement is an alternative resource requirement, LSF takes the merged result.
  3. If the queue-level is a simple resource requirement and the merged result is a simple resource requirement, LSF merges the merged result with the queue-level resource requirement.
  4. If the queue-level resource requirement is simple and the merged result is an alternative resource requirement, each sub expression in the alternative resource requirement merges with the queue-level resource requirement, following these rules:
    1. The select[] clause must be satisfied for all of them.
    2. The merged order[] clause overrides the queue-level clause.
    3. The merged rusage[] clause is merged with the queue-level rusage. When the subterm of the alternative resource requirement is a compound resource requirement, and the queue-level defines a job-level resource, this rusage section is merged only into the left-most atomic resource requirement term of this subterm. Otherwise, it is merged into all the terms for this subterm.
    4. The merged span[] clause overrides the queue-level span[] clause.
    5. The queue-level same[] and cu[] clauses are ignored.

After the job is submitted, the pending reason that is given applies only to the first alternative even though LSF is trying the other applicable alternatives.

Combined resource requirements

The combined resource requirement is the result of the mbatchd daemon merging job, application, and queue level resource requirements for a job.

Effective resource requirements

The effective resource requirement always represents the job's allocation. The effective resource requirement string for scheduled jobs represents the resource requirement that is used by the scheduler to make a dispatch decision. When a job is dispatched, the mbschd daemon generates the effective resource requirement for the job from the combined resource requirement according to the job's real allocation.

After the job starts, you can use the bmod -R command to modify the job's effective resource requirement along with the job allocation. The rusage section of the effective resource is updated with the rusage in the newly combined resource requirement. The other sections in the resource requirement string such as select, order, and span are kept the same during job run time because they are still used for the job by the scheduler.

For started jobs, you can modify only simple effective resource requirements with another simple requirement. Any request to change effective resource requirements to compound or alternative resource requirements are rejected. Attempting to modify the resource requirement of a running job to use rusage with or (||) branches are also rejected.

By default, LSF does not modify effective resource requirements and job resource usage when it runs the bswitch command. However, you can set the BSWITCH_MODIFY_RUSAGE parameter to Y to make the bswitch command update job resource usage according to the resource requirements in the new queue.

When a job finishes, the effective resource requirement last used by the job is saved in the JOB_FINISH event record of the lsb.acct file and the JOB_FINISH2 record of the lsb.stream file. The bjobs -l command always displays the effective resource requirement that is used by the job in the resource requirement details.