Skip to content

Commit 5468dd1

Browse files
committed
Compute AccountingStorageTRES
1 parent da6d88c commit 5468dd1

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ openhpc_default_config:
3333
AccountingStoragePort: "{{ openhpc_slurm_accounting_storage_port }}"
3434
AccountingStorageType: "{{ openhpc_slurm_accounting_storage_type | default('omit') }}"
3535
AccountingStorageUser: "{{ openhpc_slurm_accounting_storage_user }}"
36+
AccountingStorageTRES: "{{ ohpc_accounting_storage_tres | trim | default('omit', true) }}"
3637
JobCompLoc: "{{ openhpc_slurm_job_comp_loc }}"
3738
JobCompType: "{{ openhpc_slurm_job_comp_type }}"
3839
JobAcctGatherFrequency: "{{ openhpc_slurm_job_acct_gather_frequency }}"

templates/slurm.conf.j2

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ NodeName={{ hostlists | join(',') }} {{ '' -}}
3636
CoresPerSocket={{ first_host_hv['ansible_processor_cores'] }} {{ '' -}}
3737
ThreadsPerCore={{ first_host_hv['ansible_processor_threads_per_core'] }} {{ '' -}}
3838
{{ nodegroup.node_params | default({}) | dict2parameters }} {{ '' -}}
39-
{% if 'gres' in nodegroup -%}
40-
Gres={{ ','.join(nodegroup.gres | map(attribute='conf')) -}}
41-
{% elif nodegroup.gres_autodetect | default(openhpc_gres_autodetect) == 'nvml' and first_host_hv['ohpc_node_gpu_gres'] != '' -%}
42-
Gres={{ first_host_hv['ohpc_node_gpu_gres'] -}}
39+
{% if 'gres' in nodegroup_computed -%}
40+
Gres={{ nodegroup_computed.gres -}}
4341
{% endif %}
4442

4543
{% endif %}{# 1 or more hosts in inventory #}

vars/main.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,27 @@ ohpc_nodegroups_computed: >
3535
"first_host": {{ first_host | to_json }},
3636
"ram_mb": {{ ram_mb }},
3737
"def_mem_per_cpu": {{ (ram_mb / first_host_hv['ansible_processor_vcpus']) | int }},
38+
{% if 'gres' in nodegroup -%}
39+
"gres": {{ ','.join(nodegroup.gres | map(attribute='conf')) | to_json }},
40+
{% elif nodegroup.gres_autodetect | default(openhpc_gres_autodetect) == 'nvml' and first_host_hv['ohpc_node_gpu_gres'] != '' -%}
41+
"gres": {{ first_host_hv['ohpc_node_gpu_gres'] | to_json }},
42+
{% endif %}
3843
},
3944
{% endif %}
4045
{% endfor %}
4146
}
4247
48+
ohpc_accounting_storage_tres: >-
49+
{%- set tres =
50+
ohpc_nodegroups_computed.values()
51+
| selectattr('gres', 'defined') | map(attribute='gres')
52+
| map('regex_replace', ':[0-9]+(,|$)', '\\1')
53+
| map('split', ',')
54+
| flatten | sort | unique
55+
| map('regex_replace', '^', 'gres/')
56+
| join(',')
57+
-%}
58+
{# add the generic gres/gpu otherwise a job requesting `--gpus 1` or `--gres=gpu:1` will be assigned to a "random" gpu model #}
59+
{{ ('gres/gpu:' in tres and not tres is search('gres/gpu(,|$)')) | ternary('gres/gpu,' ~ tres, tres) }}
60+
4361
...

0 commit comments

Comments
 (0)