scheduling using real slots number
This commit is contained in:
parent
8db4458375
commit
780e9fb313
22 changed files with 980 additions and 105 deletions
|
|
@ -4,11 +4,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "xce/types.h"
|
||||
#include "xcealloc.h"
|
||||
|
||||
xce_alloc_t* make_alloc(char* resname, char* reserve, int instid, float value,
|
||||
int duration)
|
||||
xce_alloc_t* make_alloc(char* resname, char* reserve, uint64_t instid,
|
||||
float value, int duration)
|
||||
{
|
||||
xce_alloc_t* alloc = NULL;
|
||||
|
||||
|
|
@ -32,6 +33,24 @@ xce_alloc_t* make_alloc(char* resname, char* reserve, int instid, float value,
|
|||
return alloc;
|
||||
}
|
||||
|
||||
static xce_res_account_t* make_res_account(xce_alloc_t* alloc)
|
||||
{
|
||||
xce_res_account_t* account = NULL;
|
||||
|
||||
account = (xce_res_account_t*)calloc(1, sizeof(*account));
|
||||
if (account == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
account->instid = alloc->instid;
|
||||
account->resname = strdup(alloc->resname);
|
||||
account->residx = -1;
|
||||
account->used = 0.0;
|
||||
account->reserved = alloc->value;
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
xce_alloc_t** make_allocs(int nallocs, ...)
|
||||
{
|
||||
xce_alloc_t** allocs = NULL;
|
||||
|
|
@ -74,6 +93,33 @@ xce_host_alloc_t* make_host_alloc(char* host, int nalloc, xce_alloc_t** allocs)
|
|||
return halloc;
|
||||
}
|
||||
|
||||
static xce_host_account_t* make_host_account(xce_host_alloc_t* halloc)
|
||||
{
|
||||
xce_host_account_t* haccount = NULL;
|
||||
int i;
|
||||
|
||||
haccount = (xce_host_account_t*)calloc(1, sizeof(*haccount));
|
||||
if (haccount == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
haccount->accounts = (xce_res_account_t**)calloc(
|
||||
halloc->nallocs, sizeof(xce_res_account_t*));
|
||||
if (haccount->accounts == NULL) {
|
||||
FREEUP(haccount);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < halloc->nallocs; i++) {
|
||||
haccount->accounts[i] = make_res_account(halloc->allocs[i]);
|
||||
}
|
||||
|
||||
haccount->naccount = halloc->nallocs;
|
||||
haccount->host = strdup(halloc->host);
|
||||
|
||||
return haccount;
|
||||
}
|
||||
|
||||
xce_host_alloc_t** make_host_allocs(int nhosts, ...)
|
||||
{
|
||||
xce_host_alloc_t** hallocs = NULL;
|
||||
|
|
@ -111,9 +157,50 @@ xce_job_alloc_t* make_job_alloc(uint64_t jobid, int nhost,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
jalloc->jobid = jobid;
|
||||
jalloc->nhosts = nhost;
|
||||
jalloc->allocs = hallocs;
|
||||
jalloc->jobid = jobid;
|
||||
jalloc->nhosts = nhost;
|
||||
jalloc->allocs = hallocs;
|
||||
jalloc->nres_shared = 0;
|
||||
jalloc->allocs_shared = NULL;
|
||||
|
||||
return jalloc;
|
||||
}
|
||||
|
||||
xce_job_account_t* make_job_account(xce_job_alloc_t* jalloc)
|
||||
{
|
||||
xce_job_account_t* account = NULL;
|
||||
int i;
|
||||
|
||||
account = (xce_job_account_t*)calloc(1, sizeof(*account));
|
||||
if (account == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
account->accounts
|
||||
= (xce_host_account_t**)calloc(1, sizeof(xce_host_account_t*));
|
||||
if (account->accounts == NULL) {
|
||||
FREEUP(account);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < jalloc->nhosts; i++) {
|
||||
account->accounts[i] = make_host_account(jalloc->allocs[i]);
|
||||
}
|
||||
|
||||
account->nhosts = jalloc->nhosts;
|
||||
account->accounts_shared = NULL;
|
||||
|
||||
if (jalloc->nres_shared) {
|
||||
account->accounts_shared = (xce_res_account_t**)calloc(
|
||||
jalloc->nres_shared, sizeof(xce_res_account_t*));
|
||||
|
||||
for (i = 0; i < jalloc->nres_shared; i++) {
|
||||
account->accounts_shared[i]
|
||||
= make_res_account(jalloc->allocs_shared[i]);
|
||||
}
|
||||
|
||||
account->nres_shared = jalloc->nres_shared;
|
||||
}
|
||||
|
||||
return account;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue