save works
This commit is contained in:
parent
d0174f2f30
commit
4db6b039c5
8 changed files with 140 additions and 34 deletions
|
|
@ -133,4 +133,8 @@ extern uint64_t array_idx(uint64_t);
|
|||
extern void unblock_sig(int);
|
||||
extern void block_sig(int);
|
||||
|
||||
extern uint32_t hash(uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
extern uint32_t hash64(uint64_t);
|
||||
extern uint32_t hash_string(const char*);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -416,7 +416,6 @@ typedef struct {
|
|||
typedef struct {
|
||||
uint64_t jobid;
|
||||
job_submit_data_t* submit;
|
||||
int64_t idx;
|
||||
time_t sub_time;
|
||||
time_t queue_time;
|
||||
time_t start_time;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "utils.h"
|
||||
|
||||
#define HASH_KEY_HASH(t, key) \
|
||||
(((t)->fn.hash != NULL) ? ((t)->fn.hash)(key) : (unsigned long)key)
|
||||
(((t)->fn.hash != NULL) ? ((t)->fn.hash)(key) : hash64((uint64_t)key))
|
||||
|
||||
#define HASH_KEY_CMP(t, k1, k2) \
|
||||
(((t)->fn.cmp != NULL) ? ((t)->fn.cmp)((k1), (k2)) : ((k1) != (k2)))
|
||||
|
|
@ -21,21 +21,9 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
static unsigned int hash_code(const char* key)
|
||||
{
|
||||
unsigned int hc = 5381;
|
||||
int c;
|
||||
|
||||
while ((c = *key++)) {
|
||||
hc = ((hc << 5) + hc) + c;
|
||||
}
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
||||
static unsigned int string_hash(void* data)
|
||||
{
|
||||
return hash_code((const char*)data);
|
||||
return hash_string((const char*)data);
|
||||
}
|
||||
|
||||
static int string_cmp(void* d1, void* d2)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#if defined(__GLIBC__) && (__GLIBC__ == 2 && __GLIBC_MINOR__ < 28)
|
||||
#include <pthread.h>
|
||||
#else
|
||||
|
|
@ -587,3 +588,74 @@ void block_sig(int signo)
|
|||
sigaddset(&mask, signo);
|
||||
sigprocmask(SIG_BLOCK, &mask, NULL);
|
||||
}
|
||||
|
||||
#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
|
||||
#define mix(a, b, c) \
|
||||
{ \
|
||||
a -= c; \
|
||||
a ^= rot(c, 4); \
|
||||
c += b; \
|
||||
b -= a; \
|
||||
b ^= rot(a, 6); \
|
||||
a += c; \
|
||||
c -= b; \
|
||||
c ^= rot(b, 8); \
|
||||
b += a; \
|
||||
a -= c; \
|
||||
a ^= rot(c, 16); \
|
||||
c += b; \
|
||||
b -= a; \
|
||||
b ^= rot(a, 19); \
|
||||
a += c; \
|
||||
c -= b; \
|
||||
c ^= rot(b, 4); \
|
||||
b += a; \
|
||||
}
|
||||
#define final(a, b, c) \
|
||||
{ \
|
||||
c ^= b; \
|
||||
c -= rot(b, 14); \
|
||||
a ^= c; \
|
||||
a -= rot(c, 11); \
|
||||
b ^= a; \
|
||||
b -= rot(a, 25); \
|
||||
c ^= b; \
|
||||
c -= rot(b, 16); \
|
||||
a ^= c; \
|
||||
a -= rot(c, 4); \
|
||||
b ^= a; \
|
||||
b -= rot(a, 14); \
|
||||
c ^= b; \
|
||||
c -= rot(b, 24); \
|
||||
}
|
||||
|
||||
uint32_t hash(uint32_t a, uint32_t b,uint32_t c, uint32_t d) {
|
||||
uint32_t i1 = a, i2 = b, i3 = c, i4 = d;
|
||||
|
||||
mix(i1,i2,i3);
|
||||
mix(i2,i3,i4);
|
||||
mix(i3,i4,i1);
|
||||
final(i4,i1,i2);
|
||||
|
||||
return i2;
|
||||
}
|
||||
|
||||
uint32_t hash64(uint64_t x) {
|
||||
uint32_t a = (uint32_t)(x & UMAX_BITS(32));
|
||||
uint32_t b = (uint32_t)(rot(x, 16) & UMAX_BITS(32));
|
||||
uint32_t c = (uint32_t)(rot(x,32) & UMAX_BITS(32));
|
||||
uint32_t d = (uint32_t)(rot(x, 48) & UMAX_BITS(32));
|
||||
|
||||
return hash(a,b,c,d);
|
||||
}
|
||||
|
||||
uint32_t hash_string(const char *key) {
|
||||
uint32_t hc = 5381;
|
||||
int c;
|
||||
|
||||
while ((c = *key ++)) {
|
||||
hc = ((hc << 5) + hc) + c;
|
||||
}
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@
|
|||
#define _SCHEDULER_H_ 1
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "decision.h"
|
||||
#include "client.h"
|
||||
#include "dataq.h"
|
||||
#include "decision.h"
|
||||
#include "mylock.h"
|
||||
#include "xce/types.h"
|
||||
#include "xlist.h"
|
||||
|
|
@ -39,6 +41,45 @@ typedef struct {
|
|||
- offsetof(xce_sched_update_request_t, \
|
||||
link)))
|
||||
|
||||
typedef void* host_selection_t;
|
||||
|
||||
typedef struct {
|
||||
host_selection_t* select;
|
||||
int nres;
|
||||
uint32_t* resources;
|
||||
float* amount;
|
||||
} rank_req_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t jobid;
|
||||
time_t sub_time;
|
||||
time_t queue_time;
|
||||
time_t start_time;
|
||||
unsigned int state;
|
||||
char* queue;
|
||||
char* user;
|
||||
char* project;
|
||||
uint32_t mintasks;
|
||||
uint32_t maxtasks;
|
||||
xce_job_alloc_t* allocs;
|
||||
} xce_sched_job_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
uint32_t attrs;
|
||||
uint32_t status;
|
||||
int32_t priority;
|
||||
int32_t accept_interval;
|
||||
int32_t sched_delay;
|
||||
char* resreq;
|
||||
} xce_sched_queue_t;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
xce_val_t* res_avail; /* resources in worker */
|
||||
xce_val_t* res_in_use; /* used resources in worker */
|
||||
} xce_sched_worker_t;
|
||||
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
int stop;
|
||||
|
|
|
|||
|
|
@ -136,6 +136,9 @@ int scheduler_req_handler(xce_request_t* request, void* args)
|
|||
/* configuration arriving */
|
||||
rc = sched_handle_config(
|
||||
sched, request->body.configpushmsg->data.conf4sched);
|
||||
if (rc >= 0) {
|
||||
request->body.configpushmsg->data.conf4sched = NULL;
|
||||
}
|
||||
break;
|
||||
case Request_body_pushmsg:
|
||||
/* data arriving */
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ static void sched_pend_update_killer(data_item_t* it)
|
|||
req = ITPTR_TO_UPDATE_REQ(it);
|
||||
switch (req->op) {
|
||||
case XCE_SCHED_OP_UPDATE_CONFIG:
|
||||
free_Conf4Sched_ptr(&(req->u.config));
|
||||
break;
|
||||
case XCE_SCHED_OP_UPDATE_JOB:
|
||||
for (i = 0; i < req->u.jobupdate.njobs; i++) {
|
||||
|
|
|
|||
|
|
@ -252,29 +252,27 @@ struct JobStartInfo $C.mapname("job_startinfo_t"){
|
|||
struct Job $C.mapname("xce_job_t"){
|
||||
jobid @0: UInt64;
|
||||
submitData @1: JobSubmitData $C.mapname("submit");
|
||||
idx @2: UInt64;
|
||||
subtime @3: UInt64 $C.mapname("sub_time");
|
||||
queuetime @4: UInt64 $C.mapname("queue_time");
|
||||
starttime @5: UInt64 $C.mapname("start_time");
|
||||
finishtime @6: UInt64 $C.mapname("finish_time");
|
||||
state @7: UInt32;
|
||||
allocs @8: JobAlloc $C.mapname("allocs");
|
||||
runtime @9: UInt32 $C.mapname("run_time");
|
||||
pidinfo @10: JobPIDInfo;
|
||||
pendreason @11: JobPendReason $C.mapname("pend_reasons");
|
||||
subtime @2: UInt64 $C.mapname("sub_time");
|
||||
queuetime @3: UInt64 $C.mapname("queue_time");
|
||||
starttime @4: UInt64 $C.mapname("start_time");
|
||||
finishtime @5: UInt64 $C.mapname("finish_time");
|
||||
state @6: UInt32;
|
||||
allocs @7: JobAlloc $C.mapname("allocs");
|
||||
runtime @8: UInt32 $C.mapname("run_time");
|
||||
pidinfo @9: JobPIDInfo;
|
||||
pendreason @10: JobPendReason $C.mapname("pend_reasons");
|
||||
}
|
||||
|
||||
struct SchedJob $C.mapname("xce_job_t"){
|
||||
jobid @0: UInt64;
|
||||
submitData @1: JobSubmitData $C.mapname("submit");
|
||||
idx @2: UInt64;
|
||||
subtime @3: UInt64 $C.mapname("sub_time");
|
||||
queuetime @4: UInt64 $C.mapname("queue_time");
|
||||
starttime @5: UInt64 $C.mapname("start_time");
|
||||
finishtime @6: UInt64 $C.mapname("finish_time");
|
||||
state @7: UInt32;
|
||||
allocs @8: JobAlloc $C.mapname("allocs");
|
||||
runtime @9: UInt32 $C.mapname("run_time");
|
||||
subtime @2: UInt64 $C.mapname("sub_time");
|
||||
queuetime @3: UInt64 $C.mapname("queue_time");
|
||||
starttime @4: UInt64 $C.mapname("start_time");
|
||||
finishtime @5: UInt64 $C.mapname("finish_time");
|
||||
state @6: UInt32;
|
||||
allocs @7: JobAlloc $C.mapname("allocs");
|
||||
runtime @8: UInt32 $C.mapname("run_time");
|
||||
}
|
||||
|
||||
struct SchedJobRusages $C.mapname("xce_job_rusages_t") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue