- save tmp works
- save works
This commit is contained in:
parent
cd4f3953b2
commit
12dcc2a60d
14 changed files with 386 additions and 110 deletions
|
|
@ -6,7 +6,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "kvmgr.h"
|
||||||
#include "xlist.h"
|
#include "xlist.h"
|
||||||
|
#include "xvec.h"
|
||||||
|
|
||||||
typedef struct xce_resreq_select_ xce_select_t;
|
typedef struct xce_resreq_select_ xce_select_t;
|
||||||
typedef struct xce_resreq_rusages_ xce_rusages_t;
|
typedef struct xce_resreq_rusages_ xce_rusages_t;
|
||||||
|
|
@ -35,7 +37,8 @@ typedef struct {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PER_TASK = 0,
|
PER_TASK = 0,
|
||||||
PER_JOB,
|
PER_JOB,
|
||||||
PER_HOST
|
PER_HOST,
|
||||||
|
PER_DEFAULT
|
||||||
} rusage_per_type_t;
|
} rusage_per_type_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -124,5 +127,9 @@ extern int parse_resreq_primary(xce_primary_resreq_t*, char*, char**);
|
||||||
extern int parse_resreq(xce_resreq_t*, char*, char**);
|
extern int parse_resreq(xce_resreq_t*, char*, char**);
|
||||||
extern void kill_resreq(xce_resreq_t*);
|
extern void kill_resreq(xce_resreq_t*);
|
||||||
extern int format_resreq(char**, xce_resreq_t*);
|
extern int format_resreq(char**, xce_resreq_t*);
|
||||||
|
extern int calc_wanted_global_resvals(xvec_idval_t*, resmgr_t*, xlist_t*,
|
||||||
|
rusage_per_type_t, int, int);
|
||||||
|
extern int calc_wanted_host_resvals(xvec_idval_t*, resmgr_t*, xlist_t*,
|
||||||
|
rusage_per_type_t, int, int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
107
src/lib/resreq.c
107
src/lib/resreq.c
|
|
@ -3,12 +3,15 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "kvmgr.h"
|
||||||
|
#include "objmgr.h"
|
||||||
#include "resreq.h"
|
#include "resreq.h"
|
||||||
#include "rusage.h"
|
#include "rusage.h"
|
||||||
#include "section.h"
|
#include "section.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "xce_resreq.h"
|
#include "xce_resreq.h"
|
||||||
#include "xlist.h"
|
#include "xlist.h"
|
||||||
|
#include "xvec.h"
|
||||||
|
|
||||||
static int get_parse_errmsg(char** errmsg, const char* data, int pos)
|
static int get_parse_errmsg(char** errmsg, const char* data, int pos)
|
||||||
{
|
{
|
||||||
|
|
@ -431,3 +434,107 @@ int format_resreq(char** buf, xce_resreq_t* resreq)
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int calc_wanted_global_resvals(xvec_idval_t* resvals, resmgr_t* resmgr,
|
||||||
|
xlist_t* rusages, rusage_per_type_t perflag,
|
||||||
|
int nhosts, int nslots)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < rusages->count; i++) {
|
||||||
|
rusage_value_t* v = (rusage_value_t*)xlist_get(rusages, i);
|
||||||
|
xce_resource_t* r = NULL;
|
||||||
|
float val;
|
||||||
|
rusage_per_type_t perflag1;
|
||||||
|
|
||||||
|
if (v == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = resmgr_lockres(resmgr, v->res, OBJREF_NOP);
|
||||||
|
if (r == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((r->flags & XCE_RESF_GLOBAL) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
perflag1 = v->per_flag;
|
||||||
|
if (perflag1 == PER_DEFAULT) {
|
||||||
|
perflag1 = perflag;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (perflag1) {
|
||||||
|
case PER_TASK:
|
||||||
|
val = v->value * nslots;
|
||||||
|
break;
|
||||||
|
case PER_JOB:
|
||||||
|
val = v->value;
|
||||||
|
break;
|
||||||
|
case PER_HOST:
|
||||||
|
val = v->value * nhosts;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* something wrong */
|
||||||
|
val = 0.0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
xvec_idval_store(resvals, r->idx, val);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int calc_wanted_host_resvals(xvec_idval_t* resvals, resmgr_t* resmgr,
|
||||||
|
xlist_t* rusages, rusage_per_type_t perfflag,
|
||||||
|
int nhosts, int nslots)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < rusages->count; i++) {
|
||||||
|
rusage_value_t* v = (rusage_value_t*)xlist_get(rusages, i);
|
||||||
|
xce_resource_t* r = NULL;
|
||||||
|
float val;
|
||||||
|
rusage_per_type_t perflag1;
|
||||||
|
|
||||||
|
if (v == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = resmgr_lockres(resmgr, v->res, OBJREF_NOP);
|
||||||
|
if (r == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((r->flags & XCE_RESF_GLOBAL) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
perflag1 = v->per_flag;
|
||||||
|
if (perflag1 == PER_DEFAULT) {
|
||||||
|
perflag1 = perflag;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (perflag1 == PER_JOB) {
|
||||||
|
/* FIXME: PER_JOB should be global? */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (perflag1) {
|
||||||
|
case PER_TASK:
|
||||||
|
val = v->value * nslots;
|
||||||
|
break;
|
||||||
|
case PER_HOST:
|
||||||
|
val = v->value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* something wrong */
|
||||||
|
val = 0.0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
xvec_idval_store(resvals, r->idx, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ empty_decay <- { } { auxil->decay_flag = 0; }
|
||||||
identifier <- [a-zA-Z_][a-zA-Z_0-9]* { auxil->resname = strdup($0); }
|
identifier <- [a-zA-Z_][a-zA-Z_0-9]* { auxil->resname = strdup($0); }
|
||||||
|
|
||||||
resvalue <- number '/' per_type { auxil->resvalue = auxil->tmp_value; }
|
resvalue <- number '/' per_type { auxil->resvalue = auxil->tmp_value; }
|
||||||
/ number { auxil->resvalue = auxil->tmp_value; auxil->per_flag = PER_TASK; }
|
/ number { auxil->resvalue = auxil->tmp_value; auxil->per_flag = PER_DEFAULT; }
|
||||||
|
|
||||||
per_type <- 'task' { auxil->per_flag = PER_TASK; }
|
per_type <- 'task' { auxil->per_flag = PER_TASK; }
|
||||||
/ 'job' { auxil->per_flag = PER_JOB; }
|
/ 'job' { auxil->per_flag = PER_JOB; }
|
||||||
|
|
|
||||||
|
|
@ -91,14 +91,14 @@ void test_parse_rusage1(void)
|
||||||
TEST_ASSERT_TRUE(strcmp(v->res, "mem") == 0);
|
TEST_ASSERT_TRUE(strcmp(v->res, "mem") == 0);
|
||||||
TEST_ASSERT_TRUE(fabs(v->value - 20.0) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->value - 20.0) < 0.001);
|
||||||
TEST_ASSERT_TRUE(fabs(v->duration - 18000) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->duration - 18000) < 0.001);
|
||||||
TEST_ASSERT_TRUE(v->per_flag == 0);
|
TEST_ASSERT_TRUE(v->per_flag == PER_DEFAULT);
|
||||||
TEST_ASSERT_TRUE(v->decay_flag == 1);
|
TEST_ASSERT_TRUE(v->decay_flag == 1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
TEST_ASSERT_TRUE(strcmp(v->res, "lic") == 0);
|
TEST_ASSERT_TRUE(strcmp(v->res, "lic") == 0);
|
||||||
TEST_ASSERT_TRUE(fabs(v->value - 55.0) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->value - 55.0) < 0.001);
|
||||||
TEST_ASSERT_TRUE(fabs(v->duration - 1200) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->duration - 1200) < 0.001);
|
||||||
TEST_ASSERT_TRUE(v->per_flag == 0);
|
TEST_ASSERT_TRUE(v->per_flag == PER_DEFAULT);
|
||||||
TEST_ASSERT_TRUE(v->decay_flag == 0);
|
TEST_ASSERT_TRUE(v->decay_flag == 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -140,14 +140,14 @@ void test_parse_rusage2(void)
|
||||||
TEST_ASSERT_TRUE(strcmp(v->res, "mem") == 0);
|
TEST_ASSERT_TRUE(strcmp(v->res, "mem") == 0);
|
||||||
TEST_ASSERT_TRUE(fabs(v->value - 20.0) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->value - 20.0) < 0.001);
|
||||||
TEST_ASSERT_TRUE(fabs(v->duration - 18000) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->duration - 18000) < 0.001);
|
||||||
TEST_ASSERT_TRUE(v->per_flag == 2);
|
TEST_ASSERT_TRUE(v->per_flag == PER_HOST);
|
||||||
TEST_ASSERT_TRUE(v->decay_flag == 1);
|
TEST_ASSERT_TRUE(v->decay_flag == 1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
TEST_ASSERT_TRUE(strcmp(v->res, "lic") == 0);
|
TEST_ASSERT_TRUE(strcmp(v->res, "lic") == 0);
|
||||||
TEST_ASSERT_TRUE(fabs(v->value - 55.0) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->value - 55.0) < 0.001);
|
||||||
TEST_ASSERT_TRUE(fabs(v->duration - 1200) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->duration - 1200) < 0.001);
|
||||||
TEST_ASSERT_TRUE(v->per_flag == 1);
|
TEST_ASSERT_TRUE(v->per_flag == PER_JOB);
|
||||||
TEST_ASSERT_TRUE(v->decay_flag == 0);
|
TEST_ASSERT_TRUE(v->decay_flag == 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -188,14 +188,14 @@ void test_resreq_primary(void)
|
||||||
TEST_ASSERT_TRUE(strcmp(v->res, "mem") == 0);
|
TEST_ASSERT_TRUE(strcmp(v->res, "mem") == 0);
|
||||||
TEST_ASSERT_TRUE(fabs(v->value - 20.0) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->value - 20.0) < 0.001);
|
||||||
TEST_ASSERT_TRUE(fabs(v->duration - 18000) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->duration - 18000) < 0.001);
|
||||||
TEST_ASSERT_TRUE(v->per_flag == 0);
|
TEST_ASSERT_TRUE(v->per_flag == PER_DEFAULT);
|
||||||
TEST_ASSERT_TRUE(v->decay_flag == 1);
|
TEST_ASSERT_TRUE(v->decay_flag == 1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
TEST_ASSERT_TRUE(strcmp(v->res, "lic") == 0);
|
TEST_ASSERT_TRUE(strcmp(v->res, "lic") == 0);
|
||||||
TEST_ASSERT_TRUE(fabs(v->value - 55.0) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->value - 55.0) < 0.001);
|
||||||
TEST_ASSERT_TRUE(fabs(v->duration - 1200) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->duration - 1200) < 0.001);
|
||||||
TEST_ASSERT_TRUE(v->per_flag == 0);
|
TEST_ASSERT_TRUE(v->per_flag == PER_DEFAULT);
|
||||||
TEST_ASSERT_TRUE(v->decay_flag == 0);
|
TEST_ASSERT_TRUE(v->decay_flag == 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -241,14 +241,14 @@ void test_resreq1(void)
|
||||||
TEST_ASSERT_TRUE(strcmp(v->res, "mem") == 0);
|
TEST_ASSERT_TRUE(strcmp(v->res, "mem") == 0);
|
||||||
TEST_ASSERT_TRUE(fabs(v->value - 20.0) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->value - 20.0) < 0.001);
|
||||||
TEST_ASSERT_TRUE(fabs(v->duration - 18000) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->duration - 18000) < 0.001);
|
||||||
TEST_ASSERT_TRUE(v->per_flag == 0);
|
TEST_ASSERT_TRUE(v->per_flag == PER_DEFAULT);
|
||||||
TEST_ASSERT_TRUE(v->decay_flag == 1);
|
TEST_ASSERT_TRUE(v->decay_flag == 1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
TEST_ASSERT_TRUE(strcmp(v->res, "lic") == 0);
|
TEST_ASSERT_TRUE(strcmp(v->res, "lic") == 0);
|
||||||
TEST_ASSERT_TRUE(fabs(v->value - 55.0) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->value - 55.0) < 0.001);
|
||||||
TEST_ASSERT_TRUE(fabs(v->duration - 1200) < 0.001);
|
TEST_ASSERT_TRUE(fabs(v->duration - 1200) < 0.001);
|
||||||
TEST_ASSERT_TRUE(v->per_flag == 0);
|
TEST_ASSERT_TRUE(v->per_flag == PER_DEFAULT);
|
||||||
TEST_ASSERT_TRUE(v->decay_flag == 0);
|
TEST_ASSERT_TRUE(v->decay_flag == 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,6 @@ extern int plugin_prepare_allocation(void*, xce_sched_ctx_t*);
|
||||||
extern int plugin_job_election(void*, xce_sched_ctx_t*);
|
extern int plugin_job_election(void*, xce_sched_ctx_t*);
|
||||||
extern int register_fcfs(void*);
|
extern int register_fcfs(void*);
|
||||||
extern int register_limit(void*);
|
extern int register_limit(void*);
|
||||||
extern int register_simple_allocator(void*);
|
extern int register_seqjob_allocator(void*);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "kvmgr.h"
|
#include "kvmgr.h"
|
||||||
|
#include "resreq.h"
|
||||||
#include "typemap.h"
|
#include "typemap.h"
|
||||||
#include "xce/types.h"
|
#include "xce/types.h"
|
||||||
#include "xlist.h"
|
#include "xlist.h"
|
||||||
|
|
@ -14,23 +15,12 @@
|
||||||
#include "zarray.h"
|
#include "zarray.h"
|
||||||
|
|
||||||
/* FIXME: improve later */
|
/* FIXME: improve later */
|
||||||
typedef void* host_selection_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
xvec_idval_t shared;
|
xvec_idval_t shared;
|
||||||
xvec_idval_t host;
|
xvec_idval_t host;
|
||||||
} xce_sched_alloc_req_t;
|
} xce_sched_alloc_req_t;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
RESREQ_OP_SIMPLE
|
|
||||||
= 0, /* simple just a list of resources and require values */
|
|
||||||
RESREQ_OP_AFFINITY, /* with affinity allocation */
|
|
||||||
RESREQ_OP_GPU, /* with GPU allocation */
|
|
||||||
RESREQ_OP_PARALL, /* parall job nhosts, ptile and other constraints */
|
|
||||||
RESREQ_OP_AND, /* success for all */
|
|
||||||
RESREQ_OP_OR /* success for any */
|
|
||||||
} resreq_op_t;
|
|
||||||
|
|
||||||
/* simple resource allocation just have numeric resource values */
|
/* simple resource allocation just have numeric resource values */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* res;
|
char* res;
|
||||||
|
|
@ -38,17 +28,8 @@ typedef struct {
|
||||||
} request_res_t;
|
} request_res_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
host_selection_t selection;
|
xce_resreq_t* resreq;
|
||||||
xlist_t res_shared;
|
} xce_sched_resreq_t;
|
||||||
xlist_t res_host;
|
|
||||||
} resreq_simple_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
resreq_op_t op;
|
|
||||||
union {
|
|
||||||
resreq_simple_t simple;
|
|
||||||
} u;
|
|
||||||
} resreq_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* name;
|
char* name;
|
||||||
|
|
@ -78,7 +59,7 @@ typedef struct {
|
||||||
xce_sched_queue_t* queue;
|
xce_sched_queue_t* queue;
|
||||||
xce_sched_user_t* user;
|
xce_sched_user_t* user;
|
||||||
xce_sched_project_t* project;
|
xce_sched_project_t* project;
|
||||||
resreq_t* resreq;
|
xce_sched_resreq_t* resreq;
|
||||||
uint32_t mintasks;
|
uint32_t mintasks;
|
||||||
uint32_t maxtasks;
|
uint32_t maxtasks;
|
||||||
xce_job_alloc_t* allocs;
|
xce_job_alloc_t* allocs;
|
||||||
|
|
@ -96,7 +77,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
xce_sched_job_t* job;
|
xce_sched_job_t* job;
|
||||||
xce_sched_worker_t* worker;
|
xce_sched_worker_t* worker;
|
||||||
resreq_t* resreq;
|
xce_sched_resreq_t* resreq;
|
||||||
xce_job_alloc_t* alloc;
|
xce_job_alloc_t* alloc;
|
||||||
xce_pendreason_t* reason;
|
xce_pendreason_t* reason;
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,10 @@ typedef struct {
|
||||||
uint64_t nextid;
|
uint64_t nextid;
|
||||||
xce_conf4sched_t* config;
|
xce_conf4sched_t* config;
|
||||||
kvmgr_t plugins;
|
kvmgr_t plugins;
|
||||||
void* simple_allocator;
|
void* seqjob_allocator;
|
||||||
|
void* parjob_allocator;
|
||||||
void* affinity_allocator;
|
void* affinity_allocator;
|
||||||
void* gpu_allocator;
|
void* gpu_allocator;
|
||||||
void* parallel_allocator;
|
|
||||||
dataq_t* pend_updates[2];
|
dataq_t* pend_updates[2];
|
||||||
resmgr_t resmgr;
|
resmgr_t resmgr;
|
||||||
groupmgr_t ugmgr;
|
groupmgr_t ugmgr;
|
||||||
|
|
@ -107,7 +107,7 @@ extern int sched_commit_decision(xce_scheduler_t*, xce_decision_t*);
|
||||||
extern int sched_publish_pend_reason(xce_scheduler_t*, xce_preason_set_t*);
|
extern int sched_publish_pend_reason(xce_scheduler_t*, xce_preason_set_t*);
|
||||||
extern int sched_publish_dispatch(xce_scheduler_t*, xce_job_dispatch_t*);
|
extern int sched_publish_dispatch(xce_scheduler_t*, xce_job_dispatch_t*);
|
||||||
extern int sched_meet_host_selection(xce_scheduler_t*, xce_sched_worker_t*,
|
extern int sched_meet_host_selection(xce_scheduler_t*, xce_sched_worker_t*,
|
||||||
host_selection_t*);
|
xce_select_t*);
|
||||||
extern int sched_check_shared_satisfy(xce_scheduler_t*, xvec_t*, xvec_idval_t*,
|
extern int sched_check_shared_satisfy(xce_scheduler_t*, xvec_t*, xvec_idval_t*,
|
||||||
xvec_idval_t*);
|
xvec_idval_t*);
|
||||||
extern int sched_check_host_satisfy(xce_scheduler_t*, xce_sched_worker_t*,
|
extern int sched_check_host_satisfy(xce_scheduler_t*, xce_sched_worker_t*,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ scheduler_srcs = [
|
||||||
'src/plugin.c',
|
'src/plugin.c',
|
||||||
'src/resource.c',
|
'src/resource.c',
|
||||||
'src/plugins/fcfs.c',
|
'src/plugins/fcfs.c',
|
||||||
'src/plugins/simple_allocator.c',
|
'src/plugins/seqjob_allocator.c',
|
||||||
|
'src/plugins/parjob_allocator.c',
|
||||||
'src/plugins/limit.c',
|
'src/plugins/limit.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,10 @@ static int update_limit_res_value(zarray_t* array, xce_vres_t* vres)
|
||||||
|
|
||||||
static float get_vres_value(xce_sched_ctx_t* ctx, xce_vres_t* vres)
|
static float get_vres_value(xce_sched_ctx_t* ctx, xce_vres_t* vres)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
resreq_t* resreq = ctx->resreq;
|
xce_sched_resreq_t* resreq = ctx->resreq;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (resreq->op != RESREQ_OP_SIMPLE) {
|
if (resreq->op != RESREQ_OP_SIMPLE) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
@ -114,6 +115,7 @@ static float get_vres_value(xce_sched_ctx_t* ctx, xce_vres_t* vres)
|
||||||
return rq->value;
|
return rq->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
78
src/scheduler/src/plugins/parjob_allocator.c
Normal file
78
src/scheduler/src/plugins/parjob_allocator.c
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "decision.h"
|
||||||
|
#include "kvmgr.h"
|
||||||
|
#include "objmgr.h"
|
||||||
|
#include "plugin.h"
|
||||||
|
#include "preason.h"
|
||||||
|
#include "scheduler.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "xce/types.h"
|
||||||
|
#include "xcealloc.h"
|
||||||
|
#include "xlist.h"
|
||||||
|
#include "xvec.h"
|
||||||
|
|
||||||
|
static int parjob_allocator_init(xce_sched_plugin_t* plugin)
|
||||||
|
{
|
||||||
|
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
||||||
|
|
||||||
|
sched->parjob_allocator = plugin;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void parjob_allocator_fini(xce_sched_plugin_t* plugin)
|
||||||
|
{
|
||||||
|
if (plugin == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FREEUP(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int skip_bad_worker_(xce_sched_worker_t* w)
|
||||||
|
{
|
||||||
|
if (w == NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add more check here */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx)
|
||||||
|
{
|
||||||
|
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
||||||
|
xce_sched_job_t* job = ctx->job;
|
||||||
|
xce_sched_resreq_t* resreq = ctx->resreq;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int register_parjob_allocator(void* sched)
|
||||||
|
{
|
||||||
|
static xce_sched_plugin_t parjob_allocator_plugin = {
|
||||||
|
.name = "xce_sched_parjob_allocator",
|
||||||
|
.hooks = { .config_hook = NULL, .commit_hook = NULL },
|
||||||
|
.init_fn = (plugin_init_fn_t)parjob_allocator_init,
|
||||||
|
.fini_fn = (plugin_fini_fn_t)parjob_allocator_fini,
|
||||||
|
.begin_session_fn = NULL,
|
||||||
|
.end_session_fn = NULL,
|
||||||
|
.job_elect_fn = NULL,
|
||||||
|
.job_alloc_fn = (plugin_job_allocate_fn_t)my_alloc,
|
||||||
|
.data = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
xce_sched_plugin_t* plugin = NULL;
|
||||||
|
|
||||||
|
plugin = (xce_sched_plugin_t*)calloc(1, sizeof(*plugin));
|
||||||
|
if (plugin == NULL) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(plugin, &parjob_allocator_plugin, sizeof(*plugin));
|
||||||
|
|
||||||
|
return plugin_register(sched, plugin);
|
||||||
|
}
|
||||||
|
|
@ -16,15 +16,15 @@
|
||||||
#include "xlist.h"
|
#include "xlist.h"
|
||||||
#include "xvec.h"
|
#include "xvec.h"
|
||||||
|
|
||||||
static int simple_allocator_init(xce_sched_plugin_t* plugin)
|
static int seqjob_allocator_init(xce_sched_plugin_t* plugin)
|
||||||
{
|
{
|
||||||
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
||||||
|
|
||||||
sched->simple_allocator = plugin;
|
sched->seqjob_allocator = plugin;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void simple_allocator_fini(xce_sched_plugin_t* plugin)
|
static void seqjob_allocator_fini(xce_sched_plugin_t* plugin)
|
||||||
{
|
{
|
||||||
if (plugin == NULL) {
|
if (plugin == NULL) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -44,13 +44,13 @@ static int skip_bad_worker_(xce_sched_worker_t* w)
|
||||||
|
|
||||||
static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx)
|
static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx)
|
||||||
{
|
{
|
||||||
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
|
||||||
xce_sched_job_t* job = ctx->job;
|
xce_sched_job_t* job = ctx->job;
|
||||||
resreq_t* resreq = ctx->resreq;
|
xce_sched_resreq_t* resreq = ctx->resreq;
|
||||||
int rc;
|
int rc;
|
||||||
xlist_t workers;
|
xlist_t workers;
|
||||||
xce_pendreason_t* reason = NULL;
|
xce_pendreason_t* reason = NULL;
|
||||||
xvec_t* uncomit = NULL;
|
xvec_t* uncomit = NULL;
|
||||||
|
|
||||||
reason = make_pendreason(job->jobid);
|
reason = make_pendreason(job->jobid);
|
||||||
ctx->reason = reason;
|
ctx->reason = reason;
|
||||||
|
|
@ -117,13 +117,13 @@ static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int register_simple_allocator(void* sched)
|
int register_seqjob_allocator(void* sched)
|
||||||
{
|
{
|
||||||
static xce_sched_plugin_t simple_allocator_plugin = {
|
static xce_sched_plugin_t seqjob_allocator_plugin = {
|
||||||
.name = "xce_sched_simple_allocator",
|
.name = "xce_sched_seqjob_allocator",
|
||||||
.hooks = { .config_hook = NULL, .commit_hook = NULL },
|
.hooks = { .config_hook = NULL, .commit_hook = NULL },
|
||||||
.init_fn = (plugin_init_fn_t)simple_allocator_init,
|
.init_fn = (plugin_init_fn_t)seqjob_allocator_init,
|
||||||
.fini_fn = (plugin_fini_fn_t)simple_allocator_fini,
|
.fini_fn = (plugin_fini_fn_t)seqjob_allocator_fini,
|
||||||
.begin_session_fn = NULL,
|
.begin_session_fn = NULL,
|
||||||
.end_session_fn = NULL,
|
.end_session_fn = NULL,
|
||||||
.job_elect_fn = NULL,
|
.job_elect_fn = NULL,
|
||||||
|
|
@ -138,7 +138,7 @@ int register_simple_allocator(void* sched)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(plugin, &simple_allocator_plugin, sizeof(*plugin));
|
memcpy(plugin, &seqjob_allocator_plugin, sizeof(*plugin));
|
||||||
|
|
||||||
return plugin_register(sched, plugin);
|
return plugin_register(sched, plugin);
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +124,7 @@ static int unsatisfy_(int nres, int* idxs, float* total, float* inuse,
|
||||||
}
|
}
|
||||||
|
|
||||||
int sched_meet_host_selection(xce_scheduler_t* sched, xce_sched_worker_t* w,
|
int sched_meet_host_selection(xce_scheduler_t* sched, xce_sched_worker_t* w,
|
||||||
host_selection_t* s)
|
xce_select_t* s)
|
||||||
{
|
{
|
||||||
/* FIXME: add real work later */
|
/* FIXME: add real work later */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -259,9 +259,9 @@ int sched_check_host_satisfy(xce_scheduler_t* sched, xce_sched_worker_t* w,
|
||||||
xvec_t* uncomitted, xvec_idval_t* wanted,
|
xvec_t* uncomitted, xvec_idval_t* wanted,
|
||||||
xvec_idval_t* unmeet)
|
xvec_idval_t* unmeet)
|
||||||
{
|
{
|
||||||
xvec_t total;
|
xvec_t total;
|
||||||
xvec_t inuse;
|
xvec_t inuse;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (wanted->count == 0) {
|
if (wanted->count == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -343,16 +343,18 @@ static int sched_update_res_accounts(xce_scheduler_t* sched, zarray_t* array,
|
||||||
|
|
||||||
static int sched_try_alloc_on_host_(xce_sched_worker_t* w, va_list ap)
|
static int sched_try_alloc_on_host_(xce_sched_worker_t* w, va_list ap)
|
||||||
{
|
{
|
||||||
xce_scheduler_t* sched = va_arg(ap, xce_scheduler_t*);
|
xce_scheduler_t* sched = va_arg(ap, xce_scheduler_t*);
|
||||||
xce_sched_ctx_t* ctx = va_arg(ap, xce_sched_ctx_t*);
|
xce_sched_ctx_t* ctx = va_arg(ap, xce_sched_ctx_t*);
|
||||||
xce_sched_job_t* job = ctx->job;
|
xce_sched_job_t* job = ctx->job;
|
||||||
resreq_t* resreq = ctx->resreq;
|
xce_sched_resreq_t* resreq = ctx->resreq;
|
||||||
int rc;
|
int rc;
|
||||||
xce_host_alloc_t** hallocs = NULL;
|
xce_host_alloc_t** hallocs = NULL;
|
||||||
xce_host_alloc_t* halloc = NULL;
|
xce_host_alloc_t* halloc = NULL;
|
||||||
xce_alloc_t** allocs = NULL;
|
xce_alloc_t** allocs = NULL;
|
||||||
xvec_t* uncomit = NULL;
|
xvec_t* uncomit = NULL;
|
||||||
|
|
||||||
|
/* FIXME: */
|
||||||
|
#if 0
|
||||||
rc = sched_meet_host_selection(sched, w, resreq->u.simple.selection);
|
rc = sched_meet_host_selection(sched, w, resreq->u.simple.selection);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
add_job_preason(ctx->reason->reasons, PREASON_MATCH_FAIL, w->name,
|
add_job_preason(ctx->reason->reasons, PREASON_MATCH_FAIL, w->name,
|
||||||
|
|
@ -360,6 +362,7 @@ static int sched_try_alloc_on_host_(xce_sched_worker_t* w, va_list ap)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
rc = sched_ctx_get_uncomit_host(&uncomit, ctx, w->idx);
|
rc = sched_ctx_get_uncomit_host(&uncomit, ctx, w->idx);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
|
@ -514,7 +517,8 @@ static int fill_ctx_idval_vec_(xce_scheduler_t* sched, xvec_idval_t* v,
|
||||||
|
|
||||||
int sched_ctx_fill_shared_requests(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
int sched_ctx_fill_shared_requests(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
#if 0
|
||||||
xlist_t* lists[]
|
xlist_t* lists[]
|
||||||
= { &(ctx->resreq->u.simple.res_shared), &(ctx->extra_res_requests) };
|
= { &(ctx->resreq->u.simple.res_shared), &(ctx->extra_res_requests) };
|
||||||
|
|
||||||
|
|
@ -522,13 +526,15 @@ int sched_ctx_fill_shared_requests(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
xvec_idval_fini(&(ctx->alloc_req.shared));
|
xvec_idval_fini(&(ctx->alloc_req.shared));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sched_ctx_fill_host_requests(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
int sched_ctx_fill_host_requests(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc = 0;
|
||||||
|
#if 0
|
||||||
xlist_t* lists[] = { &(ctx->resreq->u.simple.res_host),
|
xlist_t* lists[] = { &(ctx->resreq->u.simple.res_host),
|
||||||
&(ctx->extra_host_res_requests) };
|
&(ctx->extra_host_res_requests) };
|
||||||
|
|
||||||
|
|
@ -536,6 +542,7 @@ int sched_ctx_fill_host_requests(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
xvec_idval_fini(&(ctx->alloc_req.host));
|
xvec_idval_fini(&(ctx->alloc_req.host));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <rtti.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <rtti.h>
|
|
||||||
|
|
||||||
#include "controller.capnp.h"
|
#include "controller.capnp.h"
|
||||||
#include "kvmgr.h"
|
#include "kvmgr.h"
|
||||||
|
|
@ -36,39 +36,37 @@ request_res_t* make_resource_request(char* res, float value)
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
static resreq_t* make_sched_resreq(xce_scheduler_t* sched, xce_job_t* j)
|
static int make_sched_resreq(xce_sched_resreq_t* resreq, xce_scheduler_t* sched,
|
||||||
|
xce_job_t* j)
|
||||||
{
|
{
|
||||||
resreq_t* resreq = NULL;
|
int rc;
|
||||||
request_res_t* req = NULL;
|
char* errmsg;
|
||||||
|
|
||||||
resreq = (resreq_t*)calloc(1, sizeof(*resreq));
|
memset(resreq, 0x0, sizeof(*resreq));
|
||||||
if (resreq == NULL) {
|
resreq->resreq = (xce_resreq_t*)calloc(1, sizeof(*(resreq->resreq)));
|
||||||
return NULL;
|
if (resreq->resreq == NULL) {
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
resreq->op = RESREQ_OP_SIMPLE;
|
rc = parse_resreq(resreq->resreq, j->submit->resreq, &errmsg);
|
||||||
resreq->u.simple.selection = NULL;
|
if (rc < 0) {
|
||||||
|
ERROR("%s parse_resreq with error code %d", __func__, rc);
|
||||||
|
if (errmsg != NULL) {
|
||||||
|
ERROR("%s", errmsg);
|
||||||
|
free(errmsg);
|
||||||
|
}
|
||||||
|
|
||||||
xlist_init(&(resreq->u.simple.res_shared), 4);
|
return rc;
|
||||||
xlist_init(&(resreq->u.simple.res_host), 4);
|
|
||||||
|
|
||||||
req = make_resource_request("slots", 1.0);
|
|
||||||
if (req != NULL) {
|
|
||||||
xlist_store(&(resreq->u.simple.res_host), (void*)req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req = make_resource_request("mem", 1024.0);
|
return 1;
|
||||||
if (req != NULL) {
|
|
||||||
xlist_store(&(resreq->u.simple.res_host), (void*)req);
|
|
||||||
}
|
|
||||||
|
|
||||||
return resreq;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xce_sched_job_t* make_sched_job(void* arg, xce_job_t* j)
|
xce_sched_job_t* make_sched_job(void* arg, xce_job_t* j)
|
||||||
{
|
{
|
||||||
xce_sched_job_t* job = (xce_sched_job_t*)calloc(1, sizeof(*job));
|
xce_sched_job_t* job = (xce_sched_job_t*)calloc(1, sizeof(*job));
|
||||||
xce_scheduler_t* sched = (xce_scheduler_t*)arg;
|
xce_scheduler_t* sched = (xce_scheduler_t*)arg;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
if ((sched == NULL) || (job == NULL)) {
|
if ((sched == NULL) || (job == NULL)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -85,9 +83,18 @@ xce_sched_job_t* make_sched_job(void* arg, xce_job_t* j)
|
||||||
job->mintasks = j->submit->mintasks;
|
job->mintasks = j->submit->mintasks;
|
||||||
job->maxtasks = j->submit->maxtasks;
|
job->maxtasks = j->submit->maxtasks;
|
||||||
job->priority = 0; /* FIXME: support job level priority */
|
job->priority = 0; /* FIXME: support job level priority */
|
||||||
job->resreq = make_sched_resreq(sched, j);
|
|
||||||
job->allocs = NULL;
|
job->resreq = (xce_sched_resreq_t*)calloc(1, sizeof(*(job->resreq)));
|
||||||
job->accounts = NULL;
|
if (job->resreq == NULL) {
|
||||||
|
/* FIXME: */
|
||||||
|
free(job);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
make_sched_resreq(job->resreq, sched, j);
|
||||||
|
job->allocs = NULL;
|
||||||
|
job->accounts = NULL;
|
||||||
if (j->allocs != NULL) {
|
if (j->allocs != NULL) {
|
||||||
MOVE_PTR(job->allocs, j->allocs);
|
MOVE_PTR(job->allocs, j->allocs);
|
||||||
job->accounts = make_job_account(job->allocs);
|
job->accounts = make_job_account(job->allocs);
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ static void* sched_job_picker(void* arg)
|
||||||
return job_picker->job_elect_fn(job_picker);
|
return job_picker->job_elect_fn(job_picker);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sched_make_simple_allocation(xce_scheduler_t* sched,
|
static int sched_make_seqjob_allocation(xce_scheduler_t* sched,
|
||||||
xce_sched_ctx_t* ctx)
|
xce_sched_ctx_t* ctx)
|
||||||
{
|
{
|
||||||
xce_sched_plugin_t* plugin = NULL;
|
xce_sched_plugin_t* plugin = NULL;
|
||||||
|
|
||||||
plugin = sched->simple_allocator;
|
plugin = sched->seqjob_allocator;
|
||||||
if (plugin->job_alloc_fn == NULL) {
|
if (plugin->job_alloc_fn == NULL) {
|
||||||
ERROR("%s plugin %s has no allocation function", __func__,
|
ERROR("%s plugin %s has no allocation function", __func__,
|
||||||
plugin->name);
|
plugin->name);
|
||||||
|
|
@ -51,10 +51,90 @@ static int sched_make_simple_allocation(xce_scheduler_t* sched,
|
||||||
return plugin->job_alloc_fn(plugin, ctx);
|
return plugin->job_alloc_fn(plugin, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sched_make_parjob_allocation(xce_scheduler_t* sched,
|
||||||
|
xce_sched_ctx_t* ctx)
|
||||||
|
{
|
||||||
|
xce_sched_plugin_t* plugin = NULL;
|
||||||
|
|
||||||
|
plugin = sched->parjob_allocator;
|
||||||
|
if (plugin->job_alloc_fn == NULL) {
|
||||||
|
ERROR("%s plugin %s has no allocation function", __func__,
|
||||||
|
plugin->name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin_prepare_allocation(sched, ctx);
|
||||||
|
|
||||||
|
sched_ctx_fill_shared_requests(sched, ctx);
|
||||||
|
|
||||||
|
return plugin->job_alloc_fn(plugin, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sched_make_primary_allocation(xce_scheduler_t* sched,
|
||||||
|
xce_sched_ctx_t* ctx)
|
||||||
|
{
|
||||||
|
xce_primary_resreq_t *primary = ctx->resreq->resreq->u.primary;
|
||||||
|
|
||||||
|
if (primary->maxTasks == 1) {
|
||||||
|
return sched_make_seqjob_allocation(sched, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sched_make_parjob_allocation(sched, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sched_make_compound_allocation(xce_scheduler_t* sched,
|
||||||
|
xce_sched_ctx_t* ctx)
|
||||||
|
{
|
||||||
|
xce_compound_resreq_t *resreq = ctx->resreq->resreq->u.compound;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < resreq->primaries.count; i ++) {
|
||||||
|
xce_primary_resreq_t *resreq1 = (xce_primary_resreq_t *)xlist_get(&(resreq->primaries), i);
|
||||||
|
int rc;
|
||||||
|
xce_sched_ctx_t ctx1 = {0};
|
||||||
|
|
||||||
|
/* FIXME: initialize ctx1 */
|
||||||
|
|
||||||
|
rc = sched_make_primary_allocation(sched, &ctx1);
|
||||||
|
if (rc <= 0) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sched_make_alter_allocation(xce_scheduler_t* sched,
|
||||||
|
xce_sched_ctx_t* ctx)
|
||||||
|
{
|
||||||
|
xce_alter_resreq_t *resreq = ctx->resreq->resreq->u.alter;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < resreq->compounds.count; i ++) {
|
||||||
|
xce_compound_resreq_t *resreq1 = (xce_compound_resreq_t *)xlist_get(&(resreq->compounds), i);
|
||||||
|
int rc;
|
||||||
|
xce_sched_ctx_t ctx1 = {0};
|
||||||
|
|
||||||
|
if (resreq1 == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: we need to initialize ctx1 */
|
||||||
|
|
||||||
|
rc = sched_make_compound_allocation(sched, &ctx1);
|
||||||
|
if (rc > 0) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int sched_make_allocation(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
static int sched_make_allocation(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
xce_sched_job_t* job = ctx->job;
|
xce_sched_job_t* job = ctx->job;
|
||||||
|
xce_resreq_t* resreq = job->resreq->resreq;
|
||||||
|
|
||||||
if (job->resreq == NULL) {
|
if (job->resreq == NULL) {
|
||||||
xce_pendreason_t* reason = NULL;
|
xce_pendreason_t* reason = NULL;
|
||||||
|
|
@ -70,13 +150,19 @@ static int sched_make_allocation(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (job->resreq->op) {
|
ctx->resreq = job->resreq;
|
||||||
case RESREQ_OP_SIMPLE:
|
switch (resreq->tag) {
|
||||||
ctx->resreq = job->resreq;
|
case XCE_RESREQ_PRIMARY:
|
||||||
rc = sched_make_simple_allocation(sched, ctx);
|
rc = sched_make_primary_allocation(sched, ctx);
|
||||||
|
break;
|
||||||
|
case XCE_RESREQ_COMPOUND:
|
||||||
|
rc = sched_make_compound_allocation(sched, ctx);
|
||||||
|
break;
|
||||||
|
case XCE_RESREQ_ALTER:
|
||||||
|
rc = sched_make_alter_allocation(sched, ctx);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rc = 0;
|
rc = -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
|
@ -189,7 +275,7 @@ static int sched_register_plugins(xce_scheduler_t* sched)
|
||||||
{
|
{
|
||||||
register_fcfs(sched);
|
register_fcfs(sched);
|
||||||
register_limit(sched);
|
register_limit(sched);
|
||||||
register_simple_allocator(sched);
|
register_seqjob_allocator(sched);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue