From 633cf86ae92184f1844e2878aff07faa4e742a89 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Fri, 3 May 2002 19:29:11 +0000 Subject: [PATCH] Convert job priority from float to int. --- src/api/allocate.c | 2 +- src/api/job_info.c | 6 +++--- src/api/submit.c | 2 +- src/common/slurm.h | 25 ++++++++++++------------- src/common/slurmlib.h | 4 ++-- src/slurmctld/controller.c | 2 +- src/slurmctld/job_mgr.c | 27 +++++++++++++-------------- src/slurmctld/job_scheduler.c | 4 ++-- 8 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/api/allocate.c b/src/api/allocate.c index ccb585c1ad9..c40a9ce8d81 100644 --- a/src/api/allocate.c +++ b/src/api/allocate.c @@ -85,7 +85,7 @@ main (int argc, char *argv[]) { * Distribution=<BLOCK|CYCLE> Features=<features> Groups=<groups> * JobId=<id> JobName=<name> Key=<credential> MinProcs=<count> * MinRealMemory=<MB> MinTmpDisk=<MB> Partition=<part_name> - * Priority=<float> ProcsPerTask=<count> ReqNodes=<node_list> + * Priority=<integer> ProcsPerTask=<count> ReqNodes=<node_list> * Shared=<YES|NO> TimeLimit=<minutes> TotalNodes=<count> * TotalProcs=<count> * NOTE: the calling function must free the allocated storage at node_list[0] diff --git a/src/api/job_info.c b/src/api/job_info.c index 4c4088baa2d..300e010e6e4 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -37,7 +37,7 @@ main (int argc, char *argv[]) { char job_state[MAX_NAME_LEN], node_list[FEATURE_SIZE]; int time_limit, user_id; time_t start_time, end_time; - float priority; + int priority; error_code = load_job (&last_update_time); if (error_code) @@ -60,7 +60,7 @@ main (int argc, char *argv[]) { req_name, job_name, partition); printf ("user_id=%d job_state=%s node_list=%s ", user_id, job_state, node_list); - printf ("time_limit=%d priority=%f ", + printf ("time_limit=%d priority=%d ", time_limit, priority); printf ("start_time=%lx end_time=%lx\n", (long)start_time, (long)end_time); @@ -212,7 +212,7 @@ int load_job_config (char *req_name, char *next_name, char *job_name, char *partition, int *user_id, char *job_state, char *node_list, int *time_limit, time_t *start_time, - time_t *end_time, float *priority) + time_t *end_time, int *priority) { int i, error_code, version, buffer_offset, my_user_id; diff --git a/src/api/submit.c b/src/api/submit.c index 7abbd8e98ca..b0fff704cc7 100644 --- a/src/api/submit.c +++ b/src/api/submit.c @@ -67,7 +67,7 @@ main (int argc, char *argv[]) { * Distribution=<BLOCK|CYCLE> Features=<features> Groups=<groups> * JobId=<id> JobName=<name> Key=<key> MinProcs=<count> * MinRealMemory=<MB> MinTmpDisk=<MB> Partition=<part_name> - * Priority=<float> ProcsPerTask=<count> ReqNodes=<node_list> + * Priority=<integer> ProcsPerTask=<count> ReqNodes=<node_list> * Shared=<YES|NO> TimeLimit=<minutes> TotalNodes=<count> * TotalProcs=<count> */ diff --git a/src/common/slurm.h b/src/common/slurm.h index 2cce9fea09b..651a2dd86ae 100644 --- a/src/common/slurm.h +++ b/src/common/slurm.h @@ -79,9 +79,8 @@ enum node_states { STATE_DOWN, /* node is not responding */ STATE_UNKNOWN, /* node's initial state, unknown */ STATE_IDLE, /* node idle and available for use */ - STATE_STAGE_IN, /* node has been allocated to a job, which has not yet begun execution */ - STATE_BUSY, /* node allocated to a job and that job is actively running */ - STATE_STAGE_OUT, /* node has been allocated to a job, which has completed execution */ + STATE_STAGE_IN, /* node has been allocated, job not yet running */ + STATE_BUSY, /* node has been allocated, job currently */ STATE_DRAINED, /* node idle and not to be allocated future work */ STATE_DRAINING, /* node in use, but not to be allocated future work */ STATE_END /* last entry in table */ @@ -118,15 +117,15 @@ extern time_t last_part_update; /* time of last update to part records */ struct part_record { unsigned magic; /* magic cookie to test data integrity */ char name[MAX_NAME_LEN];/* name of the partition */ - int max_time; /* -1 if unlimited */ - int max_nodes; /* -1 if unlimited */ + int max_time; /* minutes, -1 if unlimited */ + int max_nodes; /* per job, -1 if unlimited */ int total_nodes; /* total number of nodes in the partition */ int total_cpus; /* total number of cpus in the partition */ unsigned key:1; /* 1 if slurm distributed key is required for use of partition */ unsigned shared:2; /* 1 if more than one job can execute on a node, 2 if required */ unsigned state_up:1; /* 1 if state is up, 0 if down */ - char *nodes; /* names of nodes in partition */ - char *allow_groups; /* null indicates all */ + char *nodes; /* comma delimited list names of nodes in partition */ + char *allow_groups; /* comma delimited list of groups, null indicates all */ bitstr_t *node_bitmap; /* bitmap of nodes in partition */ }; extern List part_list; /* list of part_record entries */ @@ -136,8 +135,8 @@ extern struct part_record *default_part_loc; /* location of default partition */ /* NOTE: change JOB_STRUCT_VERSION value whenever the contents of JOB_STRUCT_FORMAT change */ #define JOB_STRUCT_VERSION 1 -#define JOB_STRUCT_FORMAT1 "JobId=%s Partition=%s JobName=%s UID=%d Nodes=%s State=%s TimeLimit=%d StartTime=%lx EndTime=%lx Priority=%f\n" -#define JOB_STRUCT_FORMAT2 "JobId=%s Partition=%s JobName=%s UID=%d Nodes=%s State=%s TimeLimit=%d StartTime=%lx EndTime=%lx Priority=%f TotalProcs=%d TotalNodes=%d ReqNodes=%s Features=%s Shared=%d Contiguous=%d MinProcs=%d MinMemory=%d MinTmpDisk=%d Distribution=%d Script=%s ProcsPerTask=%d TotalProcs=%d\n" +#define JOB_STRUCT_FORMAT1 "JobId=%s Partition=%s JobName=%s UID=%d Nodes=%s State=%s TimeLimit=%d StartTime=%lx EndTime=%lx Priority=%d\n" +#define JOB_STRUCT_FORMAT2 "JobId=%s Partition=%s JobName=%s UID=%d Nodes=%s State=%s TimeLimit=%d StartTime=%lx EndTime=%lx Priority=%d TotalProcs=%d TotalNodes=%d ReqNodes=%s Features=%s Shared=%d Contiguous=%d MinProcs=%d MinMemory=%d MinTmpDisk=%d Distribution=%d Script=%s ProcsPerTask=%d TotalProcs=%d\n" extern time_t last_job_update; /* time of last update to part records */ enum job_states { JOB_PENDING, /* queued waiting for initiation */ @@ -191,11 +190,11 @@ struct job_record { char partition[MAX_NAME_LEN]; /* name of the partition */ uid_t user_id; /* user the job runs as */ enum job_states job_state; /* state of the job */ - char *nodes; /* list of nodes allocated to the job */ - int time_limit; /* maximum run time in minutes */ + char *nodes; /* comma delimited list of nodes allocated to job */ + int time_limit; /* maximum run time in minutes, -1 if unlimited */ time_t start_time; /* time execution begins, actual or expected*/ time_t end_time; /* time of termination, actual or expected */ - float priority; /* relative priority of the job */ + int priority; /* relative priority of the job */ struct job_details *details; /* job details (set until job terminates) */ }; @@ -620,7 +619,7 @@ extern int parse_job_specs (char *job_specs, char **req_features, char **req_nod int *contiguous, int *req_cpus, int *req_nodes, int *min_cpus, int *min_memory, int *min_tmp_disk, int *key, int *shared, int *dist, char **script, int *time_limit, - int *procs_per_task, char **job_id, float *priority, + int *procs_per_task, char **job_id, int *priority, int *user_id); /* part_lock - lock the partition information */ diff --git a/src/common/slurmlib.h b/src/common/slurmlib.h index ca3c7b2bc5e..e7769030ddc 100644 --- a/src/common/slurmlib.h +++ b/src/common/slurmlib.h @@ -24,7 +24,7 @@ * Distribution=<BLOCK|CYCLE> Features=<features> Groups=<groups> * JobId=<id> JobName=<name> Key=<credential> MinProcs=<count> * MinRealMemory=<MB> MinTmpDisk=<MB> Partition=<part_name> - * Priority=<float> ProcsPerTask=<count> ReqNodes=<node_list> + * Priority=<integer> ProcsPerTask=<count> ReqNodes=<node_list> * Shared=<YES|NO> TimeLimit=<minutes> TotalNodes=<count> * TotalProcs=<count> * NOTE: the calling function must free the allocated storage at node_list[0] @@ -127,7 +127,7 @@ extern int load_node (time_t * last_update_time); extern int load_job_config (char *req_name, char *next_name, char *job_name, char *partition, int *user_id, char *job_state, char *node_list, int *time_limit, time_t *start_time, - time_t *end_time, float *priority); + time_t *end_time, int *priority); /* * load_node_config - load the state information about the named node diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index 1c7c8c4a987..f13d6d02781 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -148,7 +148,7 @@ dump_build (char **buffer_ptr, int *buffer_size) (&buffer, &buffer_offset, &buffer_allocated, out_line)) goto cleanup; - sprintf (out_line, BUILD_STRUCT_FORMAT, "FAST_SCHEDULE", FAST_SCHEDULE); + sprintf (out_line, BUILD_STRUCT2_FORMAT, "FAST_SCHEDULE", FAST_SCHEDULE); if (write_buffer (&buffer, &buffer_offset, &buffer_allocated, out_line)) goto cleanup; diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c index 09d37ca6b10..fddd854ba73 100644 --- a/src/slurmctld/job_mgr.c +++ b/src/slurmctld/job_mgr.c @@ -43,7 +43,7 @@ main (int argc, char *argv[]) struct job_record * job_rec; log_options_t opts = LOG_OPTS_STDERR_ONLY; char *dump, tmp_id[50]; - char update_spec[] = "TimeLimit=1234 Priority=123.45"; + char update_spec[] = "TimeLimit=1234 Priority=123"; printf("initialize the database and create a few jobs\n"); log_init(argv[0], opts, SYSLOG_FACILITY_DAEMON, NULL); @@ -543,7 +543,7 @@ job_create (char *job_specs, char **new_job_id) struct part_record *part_ptr; struct job_record *job_ptr; struct job_details *detail_ptr; - float priority; + int priority; bitstr_t *req_bitmap; new_job_id[0] = NULL; @@ -553,7 +553,7 @@ job_create (char *job_specs, char **new_job_id) contiguous = dist = req_cpus = req_nodes = min_cpus = NO_VAL; min_memory = min_tmp_disk = time_limit = procs_per_task = NO_VAL; key = shared = user_id = NO_VAL; - priority = (float) NO_VAL; + priority = NO_VAL; /* setup and basic parsing */ error_code = @@ -726,7 +726,7 @@ job_create (char *job_specs, char **new_job_id) job_ptr->user_id = (uid_t) user_id; job_ptr->job_state = JOB_PENDING; job_ptr->time_limit = time_limit; - if (key && is_key_valid (key) && ((priority - NO_VAL) > 0.01)) + if (key && is_key_valid (key) && (priority != NO_VAL)) job_ptr->priority = priority; else set_job_prio (job_ptr); @@ -893,7 +893,7 @@ parse_job_specs (char *job_specs, char **req_features, char **req_node_list, int *contiguous, int *req_cpus, int *req_nodes, int *min_cpus, int *min_memory, int *min_tmp_disk, int *key, int *shared, int *dist, char **script, int *time_limit, - int *procs_per_task, char **job_id, float *priority, + int *procs_per_task, char **job_id, int *priority, int *user_id) { int bad_index, error_code, i; char *temp_specs, *contiguous_str, *dist_str, *shared_str; @@ -904,7 +904,7 @@ parse_job_specs (char *job_specs, char **req_features, char **req_node_list, *contiguous = *req_cpus = *req_nodes = *min_cpus = NO_VAL; *min_memory = *min_tmp_disk = *time_limit = NO_VAL; *dist = *key = *shared = *procs_per_task = *user_id = NO_VAL; - *priority = (float) NO_VAL; + *priority = NO_VAL; temp_specs = xmalloc (strlen (job_specs) + 1); strcpy (temp_specs, job_specs); @@ -921,7 +921,7 @@ parse_job_specs (char *job_specs, char **req_features, char **req_node_list, "MinRealMemory=", 'd', min_memory, "MinTmpDisk=", 'd', min_tmp_disk, "Partition=", 's', req_partition, - "Priority=", 'f', priority, + "Priority=", 'd', priority, "ProcsPerTask=", 'd', procs_per_task, "ReqNodes=", 's', req_node_list, "Script=", 's', script, @@ -1071,13 +1071,12 @@ set_job_id (struct job_record *job_ptr) void set_job_prio (struct job_record *job_ptr) { - static float default_prio = 1.000; + static int default_prio = 100000; if ((job_ptr == NULL) || (job_ptr->magic != JOB_MAGIC)) fatal ("set_job_prio: invalid job_ptr"); - job_ptr->priority = default_prio; - default_prio -= 0.00001; + job_ptr->priority = default_prio--; } @@ -1095,7 +1094,7 @@ int update_job (char *job_id, char *spec) { int bad_index, error_code, i, time_limit; - float prio; + int prio; struct job_record *job_ptr; if (strlen (job_id) >= MAX_ID_LEN) { @@ -1114,8 +1113,8 @@ update_job (char *job_id, char *spec) if (error_code) return error_code; - prio = (float) NO_VAL; - error_code = load_float (&prio, "Priority=", spec); + prio = NO_VAL; + error_code = load_integer (&prio, "Priority=", spec); if (error_code) return error_code; @@ -1141,7 +1140,7 @@ update_job (char *job_id, char *spec) time_limit, job_id); } - if ((prio - NO_VAL) > 0.01) { /* avoid reset from round-off */ + if (prio != NO_VAL) { job_ptr->priority = prio; info ("update_job: setting priority to %f for job_id %s", (double) prio, job_id); diff --git a/src/slurmctld/job_scheduler.c b/src/slurmctld/job_scheduler.c index 6255ddce03b..9003e76de2c 100644 --- a/src/slurmctld/job_scheduler.c +++ b/src/slurmctld/job_scheduler.c @@ -17,7 +17,7 @@ #include "slurm.h" struct job_queue { - float priority; + int priority; struct job_record *job_ptr; }; @@ -140,7 +140,7 @@ void sort_job_queue (struct job_queue *job_queue, int job_queue_size) { int i, j, top_prio_inx; - float tmp_prio, top_prio; + int tmp_prio, top_prio; struct job_record *tmp_job_ptr; for (i=0; i<job_queue_size; i++) { -- GitLab