Skip to content

Commit 2ef85d3

Browse files
committed
Compute AccountingStorageTRES
1 parent 3babb40 commit 2ef85d3

3 files changed

Lines changed: 20 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 }}"
3535
AccountingStorageUser: "{{ openhpc_slurm_accounting_storage_user }}"
36+
AccountingStorageTRES: "{{ ohpc_accounting_storage_tres | 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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,26 @@ ohpc_nodegroup_computed: >
3333
"first_host": {{ first_host | to_json }},
3434
"ram_mb": {{ ram_mb }},
3535
"def_mem_per_cpu": {{ (ram_mb / first_host_hv['ansible_processor_vcpus']) | int }},
36+
{% if 'gres' in nodegroup -%}
37+
"gres": {{ ','.join(nodegroup.gres | map(attribute='conf')) | to_json }},
38+
{% elif nodegroup.gres_autodetect | default(openhpc_gres_autodetect) == 'nvml' and first_host_hv['ohpc_node_gpu_gres'] != '' -%}
39+
"gres": {{ first_host_hv['ohpc_node_gpu_gres'] | to_json }},
40+
{% endif %}
3641
},
3742
{% endif %}
3843
{% endfor %}
3944
}
4045
46+
ohpc_accounting_storage_tres: >-
47+
{%- set tres =
48+
ohpc_nodegroup_computed.values()
49+
| selectattr('gres', 'defined') | map(attribute='gres')
50+
| map('regex_replace', ':[0-9]+(,|$)', '\\1')
51+
| map('split', ',')
52+
| flatten | sort | unique
53+
| map('regex_replace', '^', 'gres/')
54+
| join(',')
55+
-%}
56+
{{ ('gres/gpu:' in tres) | ternary('gres/gpu,' ~ tres, tres) }}
57+
4158
...

0 commit comments

Comments
 (0)