aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-09-24 15:45:46 +0200
committerThomas White <taw@physics.org>2024-09-24 15:46:03 +0200
commitcd0a321d11b2d8854e546fb0671f9cd50f8f4844 (patch)
tree3bb6e13a1aa8e257058cc847e0daa6e8d6b95e51
parentb568f3d4cc06fe96e072b988ed776d986fec4a1a (diff)
GUI: Add Slurm --exclusive option
Fixes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/103
-rw-r--r--src/gui_backend_slurm.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/gui_backend_slurm.c b/src/gui_backend_slurm.c
index 1c81dc55..b3e74fdd 100644
--- a/src/gui_backend_slurm.c
+++ b/src/gui_backend_slurm.c
@@ -49,6 +49,7 @@ struct slurm_common_opts
char *account;
char *constraint;
int time_limit;
+ int exclusive;
};
@@ -417,12 +418,21 @@ static gboolean timelimit_focus_sig(GtkEntry *entry, GdkEvent *event,
return FALSE;
}
+
+static void exclusive_toggle_sig(GtkToggleButton *toggle, gpointer data)
+{
+ struct slurm_common_opts *opts = data;
+ opts->exclusive = gtk_toggle_button_get_active(toggle);
+}
+
+
static void add_common_opts(GtkWidget *vbox,
struct slurm_common_opts *opts)
{
GtkWidget *hbox;
GtkWidget *entry;
GtkWidget *label;
+ GtkWidget *toggle;
char tmp[64];
/* Partition */
@@ -541,6 +551,16 @@ static void add_common_opts(GtkWidget *vbox,
G_CALLBACK(qos_activate_sig), opts);
g_signal_connect(G_OBJECT(entry), "focus-out-event",
G_CALLBACK(qos_focus_sig), opts);
+
+ /* Exclusive */
+ hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
+ gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), FALSE, FALSE, 0);
+ toggle = gtk_check_button_new_with_label("Request exclusive use of compute node(s)");
+ set_active(toggle, opts->exclusive);
+ gtk_widget_set_tooltip_text(toggle, "--exclusive");
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(toggle), FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(toggle), "toggled",
+ G_CALLBACK(exclusive_toggle_sig), opts);
}
@@ -580,6 +600,9 @@ static void write_common_opts(FILE *fh,
fprintf(fh, "%s.slurm.time_limit %i\n",
prefix, opts->time_limit);
+
+ fprintf(fh, "%s.slurm.exclusive %i\n",
+ prefix, opts->exclusive);
}
@@ -608,8 +631,10 @@ static char *add_bits(char *old, const char *new1, const char *new2)
strcpy(nn, old);
strcat(nn, "\n#SBATCH ");
strcat(nn, new1);
- strcat(nn, " ");
- strcat(nn, new2);
+ if ( strlen(new2) > 0 ) {
+ strcat(nn, " ");
+ strcat(nn, new2);
+ }
free(old);
return nn;
}
@@ -650,6 +675,9 @@ static char *sbatch_bits(struct slurm_common_opts *opts,
if ( !empty(opts->qos) ) {
str = add_bits(str, "--qos", opts->qos);
}
+ if ( opts->exclusive ) {
+ str = add_bits(str, "--exclusive", "");
+ }
str = add_bits(str, "--nodes", "1");
str = add_bits(str, "--mail-type", "FAIL\n\n");
@@ -950,6 +978,7 @@ static void set_default_common_opts(struct slurm_common_opts *opts)
opts->constraint = NULL;
opts->time_limit = 60;
opts->qos = NULL;
+ opts->exclusive = 1;
opts->reservation = NULL;
}
@@ -1024,6 +1053,10 @@ static void read_indexing_opt(void *opts_priv,
if ( strcmp(key, "indexing.slurm.time_limit") == 0 ) {
opts->common.time_limit = atoi(val);
}
+
+ if ( strcmp(key, "indexing.slurm.exclusive") == 0 ) {
+ opts->common.exclusive = atoi(val);
+ }
}
@@ -1218,6 +1251,10 @@ static void read_merging_opt(void *opts_priv,
if ( strcmp(key, "merging.slurm.time_limit") == 0 ) {
opts->common.time_limit = atoi(val);
}
+
+ if ( strcmp(key, "merging.slurm.exclusive") == 0 ) {
+ opts->common.exclusive = atoi(val);
+ }
}
@@ -1280,6 +1317,10 @@ static void read_ambi_opt(void *opts_priv,
if ( strcmp(key, "ambi.slurm.time_limit") == 0 ) {
opts->common.time_limit = atoi(val);
}
+
+ if ( strcmp(key, "ambi.slurm.exclusive") == 0 ) {
+ opts->common.exclusive = atoi(val);
+ }
}