Skip to content

Commit

Permalink
Merge pull request #1509 from dongahn/drop_jsc_keys
Browse files Browse the repository at this point in the history
libjsc: drop unused jsc rdl_alloc JSC keys
  • Loading branch information
grondo committed May 8, 2018
2 parents 090556f + 89ae9af commit 6939f86
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 163 deletions.
16 changes: 0 additions & 16 deletions src/common/libjsc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ service.
| state-pair | JSC_STATE\_PAIR| dictionary | A dictionary containing this old and new states of the job. See Table 3-2. |
| rdesc | JSC_RDESC | dictionary | Information on the resources owned by this job. See Table 3-3. |
| rdl | JSC_RDL | string | RDL binary string allocated to the job |
| rdl_alloc | JSC_RDL\_ALLOC | array of per-broker resources | Resource descriptor array (Resources allocated per broker - rank order). See Table 3-4.|
| R_lite | JSC_R\_LITE | string | R\_lite serialized JSON string allocated to the job |
| pdesc | JSC_PDESC | dictionary | Information on the processes spawned by this job. See Table 3-5. |

Expand All @@ -99,21 +98,6 @@ service.
**Table 3-3** Keys and values of *rdesc* attribute


| Key | Macro | Value Type | Comment |
|------------|------------------------------|----------------|---------------------------------|
| contained | JSC_RDL\_ALLOC\_CONTAINED | dictionary | Per cmdb resource containment See Table 3-4-1 |

**Table 3-4** Keys and values of *rdl\_alloc* attribute


| Key | Macro | Value Type | Comment |
|------------|-----------------------------------|----------------|-----------------------------------|
| cmbdrank | JSC_RDL\_ALLOC\_CONTAINING\_RANK | 64-bit integer | broker rank that manages the cores|
| cmbdncores | JSC_RDL\_ALLOC\_CONTAINED\_NCORES | 64-bit integer | Core count to use for this broker |
| cmbdngpus | JSC_RDL\_ALLOC\_CONTAINED\_NGPUS | 64-bit integer | GPU count to use for this broker |

**Table 3-4-1** Keys and values of *rsarray* attribute


| Key | Macro | Value Type | Comment |
|------------|----------------------|-----------------------------|---------------------------------------------------------------------|
Expand Down
131 changes: 0 additions & 131 deletions src/common/libjsc/jstatctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,35 +537,6 @@ static int extract_raw_pdescs (flux_t *h, int64_t j, int64_t n, json_object *jcb
return rc;
}

static int extract_raw_rdl_alloc (flux_t *h, int64_t j, json_object *jcb)
{
int i;
json_object *ra = Jnew_ar ();
bool processing = true;

for (i=0; processing; ++i) {
char *key = lwj_key (h, j, ".rank.%d.cores", i);
flux_future_t *f = NULL;
int64_t cores = 0;
if (!key || !(f = flux_kvs_lookup (h, 0, key))
|| flux_kvs_lookup_get_unpack (f, "I", &cores) < 0) {
if (errno != EINVAL)
flux_log_error (h, "extract %s", key);
processing = false;
} else {
json_object *elem = Jnew ();
json_object *o = Jnew ();
Jadd_int64 (o, JSC_RDL_ALLOC_CONTAINED_NCORES, cores);
json_object_object_add (elem, JSC_RDL_ALLOC_CONTAINED, o);
json_object_array_add (ra, elem);
}
free (key);
flux_future_destroy (f);
}
json_object_object_add (jcb, JSC_RDL_ALLOC, ra);
return 0;
}

static int query_jobid (flux_t *h, int64_t j, json_object **jcb)
{
int rc = 0;
Expand Down Expand Up @@ -675,12 +646,6 @@ static int query_r_lite (flux_t *h, int64_t j, json_object **jcb)
return 0;
}

static int query_rdl_alloc (flux_t *h, int64_t j, json_object **jcb)
{
*jcb = Jnew ();
return extract_raw_rdl_alloc (h, j, *jcb);
}

static int query_pdesc (flux_t *h, int64_t j, json_object **jcb)
{
int64_t ntasks = 0;
Expand Down Expand Up @@ -885,96 +850,6 @@ static int update_r_lite (flux_t *h, int64_t j, const char *rs)
return rc;
}

static int update_hash_1ra (flux_t *h, int64_t j, json_object *o, zhash_t *rtab)
{
int rc = 0;
int64_t ncores = 0;
int64_t ngpus = 0;
int64_t rank = 0;
int64_t *curcnt;
char *key;
json_object *c = NULL;

if (!Jget_obj (o, JSC_RDL_ALLOC_CONTAINED, &c)) return -1;
if (!Jget_int64 (c, JSC_RDL_ALLOC_CONTAINING_RANK, &rank)) return -1;
if (!Jget_int64 (c, JSC_RDL_ALLOC_CONTAINED_NCORES, &ncores)) return -1;
if (!Jget_int64 (c, JSC_RDL_ALLOC_CONTAINED_NGPUS, &ngpus)) return -1;

key = lwj_key (h, j, ".rank.%ju.cores", rank);
if (!(curcnt = zhash_lookup (rtab, key))) {
curcnt = xzmalloc (sizeof (*curcnt));
*curcnt = ncores;
zhash_insert (rtab, key, curcnt);
zhash_freefn (rtab, key, free);
} else
*curcnt = *curcnt + ncores;
free (key);

key = lwj_key (h, j, ".rank.%ju.gpus", rank);
if (!(curcnt = zhash_lookup (rtab, key))) {
curcnt = xzmalloc (sizeof (*curcnt));
*curcnt = ngpus;
zhash_insert (rtab, key, curcnt);
zhash_freefn (rtab, key, free);
} else
*curcnt = *curcnt + ngpus;
free (key);

return rc;
}

static int update_rdl_alloc (flux_t *h, int64_t j, json_object *o)
{
int i = 0;
int rc = -1;
int size = 0;
json_object *ra_e = NULL;
const char *key = NULL;
zhash_t *rtab = NULL;
int64_t *rcount = NULL;
flux_kvs_txn_t *txn = NULL;
flux_future_t *f = NULL;

if (!(rtab = zhash_new ()))
oom ();
if (!Jget_ar_len (o, &size))
goto done;

for (i=0; i < (int) size; ++i) {
if (!Jget_ar_obj (o, i, &ra_e))
goto done;
/* 'o' represents an array of per-node core and gpu count to use.
* However, because the same rank can appear multiple times
* in this array in emulation mode, update_hash_1ra is
* used to determine the total core count per rank.
*/
if ( (rc = update_hash_1ra (h, j, ra_e, rtab)) < 0)
goto done;
}

if (!(txn = flux_kvs_txn_create ())) {
flux_log_error (h, "txn_create");
goto done;
}
FOREACH_ZHASH (rtab, key, rcount) {
if ( (rc = flux_kvs_txn_pack (txn, 0, key, "I", *rcount)) < 0) {
flux_log_error (h, "put %s", key);
goto done;
}
}
if (!(f = flux_kvs_commit (h, 0, txn)) || flux_future_get (f, NULL) < 0) {
flux_log (h, LOG_ERR, "update_pdesc commit failed");
goto done;
}
rc = 0;

done:
flux_future_destroy (f);
flux_kvs_txn_destroy (txn);
zhash_destroy (&rtab);
return rc;
}

static int update_1pdesc (flux_t *h, flux_kvs_txn_t *txn,
int r, int64_t j, json_object *o,
json_object *ha, json_object *ea)
Expand Down Expand Up @@ -1328,9 +1203,6 @@ int jsc_query_jcb (flux_t *h, int64_t jobid, const char *key, char **jcb_str)
} else if (!strcmp (key, JSC_R_LITE)) {
if ( (rc = query_r_lite (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_r_lite failed");
} else if (!strcmp (key, JSC_RDL_ALLOC)) {
if ( (rc = query_rdl_alloc (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_rdl_alloc failed");
} else if (!strcmp(key, JSC_PDESC)) {
if ( (rc = query_pdesc (h, jobid, &jcb)) < 0)
flux_log (h, LOG_ERR, "query_pdesc failed");
Expand Down Expand Up @@ -1374,9 +1246,6 @@ int jsc_update_jcb (flux_t *h, int64_t jobid, const char *key,
const char *s = NULL;
if (Jget_str (jcb, JSC_R_LITE, &s))
rc = update_r_lite (h, jobid, s);
} else if (!strcmp (key, JSC_RDL_ALLOC)) {
if (Jget_obj (jcb, JSC_RDL_ALLOC, &o))
rc = update_rdl_alloc (h, jobid, o);
} else if (!strcmp (key, JSC_PDESC)) {
if (Jget_obj (jcb, JSC_PDESC, &o))
rc = update_pdesc (h, jobid, o);
Expand Down
5 changes: 0 additions & 5 deletions src/common/libjsc/jstatctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ typedef int (*jsc_handler_f)(const char *base_jcb, void *arg, int errnum);
# define JSC_RDESC_WALLTIME "walltime"
#define JSC_RDL "rdl"
#define JSC_R_LITE "R_lite"
#define JSC_RDL_ALLOC "rdl_alloc"
# define JSC_RDL_ALLOC_CONTAINED "contained"
# define JSC_RDL_ALLOC_CONTAINING_RANK "cmbdrank"
# define JSC_RDL_ALLOC_CONTAINED_NCORES "cmbdncores"
# define JSC_RDL_ALLOC_CONTAINED_NGPUS "cmbdngpus"
#define JSC_PDESC "pdesc"
# define JSC_PDESC_SIZE "procsize"
# define JSC_PDESC_HOSTNAMES "hostnames"
Expand Down
11 changes: 0 additions & 11 deletions t/t2001-jsc.t
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,6 @@ EOF
test_cmp expected.12.1 output.12.1
"

test_expect_success 'jstat 13.1: update rdl_alloc' "
flux jstat update 1 rdl_alloc '{\"rdl_alloc\": [{\"contained\": {\"cmbdrank\": 0, \"cmbdncores\": 102, \"cmbdngpus\": 4}}]}' &&
flux kvs get --json $(flux wreck kvs-path 1).rank.0.cores > output.13.1 &&
flux kvs get --json $(flux wreck kvs-path 1).rank.0.gpus >> output.13.1 &&
cat > expected.13.1 <<-EOF &&
102
4
EOF
test_cmp expected.13.1 output.13.1
"

test_expect_success 'jstat 13.2: update r_lite' "
flux jstat update 1 R_lite '{\"R_lite\": [{\"children\": {\"core\": \"0\"}, \"rank\": 0}]}' &&
flux kvs get --json $(flux wreck kvs-path 1).R_lite > output.13.2 &&
Expand Down

0 comments on commit 6939f86

Please sign in to comment.