1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
|
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <ctype.h>
#include <float.h>
#include "sge.h"
#include "uti/sge_rmon.h"
#include "uti/sge_parse_num_par.h"
#include "uti/sge_string.h"
#include "uti/sge_log.h"
#include "cull/cull.h"
#include "sgeobj/sge_schedd_conf.h"
#include "sgeobj/sge_job.h"
#include "sgeobj/sge_centry.h"
#include "sgeobj/sge_feature.h"
#include "sgeobj/sge_range.h"
#include "sgeobj/sge_pe.h"
#include "sge_ct_SCT_L.h"
#include "sge_ct_REF_L.h"
#include "sge_ct_CT_L.h"
#include "sge_ct_CCT_L.h"
#include "sge_ct_CTI_L.h"
#include "sge_eejob_SGEJ_L.h"
#include "sge_urgency.h"
#include "sge_sched_process_events.h"
static void sge_normalize_urgency(lList *job_list, double min_urgency,
double max_urgency);
static void sge_urgency(u_long32 now, double *min_urgency, double *max_urgency,
lList *job_list, const lList *centry_list, lList *pe_list);
/****** sge_urgency/sge_do_urgency() *****************************
* NAME
* sge_do_urgency() -- Compute normalized urgency
*
* SYNOPSIS
* void sge_do_urgency(u_long32 now, lList *running_jobs, lList
* *pending_jobs, sge_Sdescr_t *lists)
*
* FUNCTION
* Determine normalized urgency for all job lists passed:
* * for the pending jobs we need it for determine dispatch order
* * for the running jobs it is needed when running jobs priority must
* be compared with pending jobs (preemption only)
*
* INPUTS
* u_long32 now - Current time
* lList *running_jobs - The running jobs list
* lList *pending_jobs - The pending jobs list
* sge_Sdescr_t *lists - Additional config information
*
* NOTES
*******************************************************************************/
void sge_do_urgency(u_long32 now, lList *running_jobs, lList *pending_jobs,
scheduler_all_data_t *lists)
{
double min_urgency = DBL_MAX;
double max_urgency = DBL_MIN;
/* determine absolute static urgency and related min/max values */
sge_urgency(now, &min_urgency, &max_urgency, pending_jobs,
lists->centry_list, lists->pe_list);
sge_urgency(now, &min_urgency, &max_urgency, running_jobs,
lists->centry_list, lists->pe_list);
/* use min/max value to normalize static urgency */
if (pending_jobs) {
sge_normalize_urgency(pending_jobs, min_urgency, max_urgency);
}
if (running_jobs) {
sge_normalize_urgency(running_jobs, min_urgency, max_urgency);
}
}
/****** sge_urgency/sge_urgency() ********************************
* NAME
* sge_urgency() -- Determine urgency value for a list of jobs
*
* SYNOPSIS
* static void sge_urgency(u_long32 now, double *min_urgency,
* double *max_urgency, lList *job_list, const lList *centry_list,
* const lList *pe_list)
*
* FUNCTION
* The urgency value is determined for all jobs in job_list. The urgency
* value has two time dependent components (waiting time contribution and
* deadline contribution) and a resource request dependent component. Only
* resource requests that apply to the job irrespective what resources it
* gets assigned finally are considered. Default requests specified for
* consumable resources are not considered as they are placement dependent.
* For the same reason soft request do not contribute to the urgency value.
* The urgency value range is tracked via min/max urgency. Category-based
* caching is used for the resource request urgency contribution.
*
* INPUTS
* u_long32 now - Current time
* double *min_urgency - For tracking minimum urgency value
* double *max_urgency - For tracking minimum urgency value
* lList *job_list - The jobs.
* const lList *centry_list - Needed for per resource urgency setting.
* const lList *pe_list - Needed to determine urgency slot setting.
*
* NOTES
*******************************************************************************/
static void sge_urgency(u_long32 now, double *min_urgency, double *max_urgency,
lList *job_list, const lList *centry_list, lList *pe_list)
{
lListElem *jep;
double rrc, wtc, dtc, absolute_urgency;
int slots;
double weight_deadline = sconf_get_weight_deadline();
double weight_waiting_time = sconf_get_weight_waiting_time();
DENTER(TOP_LAYER, "sge_urgency");
for_each (jep, job_list) {
lListElem *cat;
u_long32 deadline;
rrc = dtc = 0.0;
/* waiting time dependent contribution */
wtc = weight_waiting_time * (now - lGetUlong(jep, JB_submission_time));
/* job deadline dependent contribution */
if ((deadline=lGetUlong(jep, JB_deadline))) {
int time_left = deadline - now;
/* DPRINTF(("free: %d now: "sge_u32" deadline: "sge_u32"\n", time_left, now, deadline)); */
/* might be too late for this job anyways we're optimistic and treat it high prior */
dtc = weight_deadline / MAX(time_left, 1);
}
/* we do category based caching when determining the resource request
dependent contribution */
if ((cat = lGetRef(jep, JB_category)) && lGetBool(cat, CT_rc_valid)) {
rrc = lGetDouble(cat, CT_resource_contribution);
/* DPRINTF((" resource contribution from category cache ---> %7f\n", rrc)); */
} else {
lListElem *centry, *rr;
double contribution;
slots = sge_job_slot_request(jep, pe_list);
/* contribution for implicit slot request */
if (!(centry = centry_list_locate(centry_list, SGE_ATTR_SLOTS))) {
continue;
}
contribution = centry_urgency_contribution(slots, SGE_ATTR_SLOTS, 1.0, centry);
rrc += contribution;
/* contribution for all explicit requests */
for_each (rr, lGetList(jep, JB_hard_resource_list)) {
if (!(centry = centry_list_locate(centry_list, lGetString(rr, CE_name)))) {
continue;
}
contribution = centry_urgency_contribution(slots, lGetString(rr, CE_name),
lGetDouble(rr, CE_doubleval), centry);
rrc += contribution;
}
/* cache in category */
if (cat) {
lSetBool(cat, CT_rc_valid, true);
lSetDouble(cat, CT_resource_contribution, rrc);
}
}
absolute_urgency = wtc + dtc + rrc;
/* store these values with the job */
lSetDouble(jep, JB_dlcontr, dtc);
lSetDouble(jep, JB_rrcontr, rrc);
lSetDouble(jep, JB_wtcontr, wtc);
lSetDouble(jep, JB_urg, absolute_urgency);
/* DPRINTF(("--- job "sge_U32CFormat" (dtc %7f + wtc %7f + rrc %7f) = asu %7f\n",
lGetUlong(jep, JB_job_number), dtc, wtc, rrc, absolute_urgency));
*/
/* track min/max values */
if (min_urgency) {
*min_urgency = MIN(*min_urgency, absolute_urgency);
}
if (max_urgency) {
*max_urgency = MAX(*max_urgency, absolute_urgency);
}
}
DEXIT;
return;
}
/****** sge_urgency/sge_normalize_urgency() **********************
* NAME
* sge_normalize_urgency() -- Computes normalized urgency for job list
*
* SYNOPSIS
* static void sge_normalize_urgency(lList *job_list, double
* min_urgency, double max_urgency)
*
* FUNCTION
* The normalized urgency is determined for a list of jobs based on the
* min/max urgency values passed and the JB_urg value of each job.
*
* INPUTS
* lList *job_list - The job list
* double min_urgency - minimum urgency value
* double max_urgency - maximum urgency value
*
* NOTES
* MT-NOTES: sge_normalize_urgency() is MT safe
*******************************************************************************/
static void sge_normalize_urgency(lList *job_list, double min_urgency,
double max_urgency)
{
double nsu;
lListElem *jep;
DENTER(TOP_LAYER, "sge_normalize_urgency");
DPRINTF(("ASU min = %13.11f, ASU max = %13.11f\n",
min_urgency, max_urgency));
for_each (jep, job_list) {
double asu = lGetDouble(jep, JB_urg);
nsu = sge_normalize_value(asu, min_urgency, max_urgency);
lSetDouble(jep, JB_nurg, nsu);
/* DPRINTF(("NSU(job " sge_u32 ") = %f from %f\n", lGetUlong(jep, JB_job_number), nsu, asu)); */
}
DEXIT;
}
/****** sge_job_schedd/sge_job_slot_request() **********************************
* NAME
* sge_job_slot_request() -- return static urgency jobs slot request
*
* SYNOPSIS
* int sge_job_slot_request(lListElem *job, lList *pe_list)
*
* FUNCTION
* For sequential jobs the static urgency job slot request is always 1.
* For parallel jobs the static urgency job slot request depends on
* static urgency slots as defined with sge_pe(5).
*
* INPUTS
* lListElem *job - the job (JB_Type)
* lList *pe_list - the PE list (PE_Type)
*
* RESULT
* int - Number of slots
*
* NOTES
* In case of a wildcard parallel environment request the setting of the
* first matching is used. Behaviour is undefined if multiple parallel
* environments specify different settings!
*******************************************************************************/
int sge_job_slot_request(const lListElem *job, const lList *pe_list)
{
const char *pe_name;
const char *urgency_slot_setting;
lList* range_list;
const lListElem *pep;
int n;
DENTER(TOP_LAYER, "sge_job_slot_request");
/* sequential job */
if (!(pe_name=lGetString(job, JB_pe))) {
DEXIT;
return 1;
}
/* parallel job with fixed slot request */
range_list = lGetList(job, JB_pe_range);
if (range_list_get_number_of_ids(range_list)==1) {
DEXIT;
return range_list_get_first_id(range_list, NULL);
}
/* parallel job with slot range request */
if (!sge_is_pattern(pe_name))
pep = pe_list_locate(pe_list, pe_name);
else {
/* use the first matching pe */
if ((pep=pe_list_find_matching(pe_list, pe_name))) {
DPRINTF(("use %s as first matching pe for %s to verify schedulability\n",
lGetString(pep, PE_name), pe_name));
}
}
if (!pep) {
ERROR((SGE_EVENT, "no matching parallel environment "
"for job's PE request \"%s\"\n", pe_name));
DEXIT;
return 1;
}
urgency_slot_setting = lGetString(pep, PE_urgency_slots);
n = pe_urgency_slots(pep, urgency_slot_setting, range_list);
{
char pe_range_str[1024];
dstring pe_range;
sge_dstring_init(&pe_range, pe_range_str, sizeof(pe_range_str));
range_list_print_to_string(range_list, &pe_range, true, false, false);
DPRINTF(("slot request assumed for static urgency is %d for %s PE range due to "
"PE's \"%s\" setting \"%s\"\n", n, pe_range_str, lGetString(pep, PE_name),
urgency_slot_setting));
}
DEXIT;
return n;
}
/****** sge_urgency/sge_normalize_value() *******************************
* NAME
* sge_normalize_value() -- Returns normalized value with passed value range
*
* SYNOPSIS
* double sge_normalize_value(double value, double range_min, double
* range_max)
*
* FUNCTION
* The value passed is normalized and resulting value (0.0-1.0) is returned
* The value range passed is assumed. In case there is no range because
* min/max are (nearly) equal 0.5 is returned.
*
* INPUTS
* double value - Value to be normalized.
* double range_min - Range minimum value.
* double range_max - Range maximum value.
*
* RESULT
* double - Normalized value (0.0-1.0)
*
* NOTES
* MT-NOTE: sge_normalize_value() is MT safe
*******************************************************************************/
double sge_normalize_value(double value, double range_min, double range_max)
{
double result;
if (range_max - range_min < SGE_EPSILON)
result = 0.5;
else
result = (value - range_min)/( range_max - range_min);
return result;
}
|