Skip to content

Commit be3ef77

Browse files
author
Ralph Castain
committed
Improve packing efficiency by raising the initial buffer size and modifying the extension code. Flag if a job map has had its nodes added so we don't have to loop repeatedly to check it.
Signed-off-by: Ralph Castain <[email protected]>
1 parent 466cbd4 commit be3ef77

File tree

7 files changed

+36
-43
lines changed

7 files changed

+36
-43
lines changed

opal/dss/dss_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2012 Los Alamos National Security, Inc. All rights reserved.
14-
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
14+
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
1515
* Copyright (c) 2014 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
@@ -47,12 +47,12 @@ BEGIN_C_DECLS
4747
/*
4848
* The default starting chunk size
4949
*/
50-
#define OPAL_DSS_DEFAULT_INITIAL_SIZE 128
50+
#define OPAL_DSS_DEFAULT_INITIAL_SIZE 2048
5151
/*
5252
* The default threshold size when we switch from doubling the
5353
* buffer size to addatively increasing it
5454
*/
55-
#define OPAL_DSS_DEFAULT_THRESHOLD_SIZE 1024
55+
#define OPAL_DSS_DEFAULT_THRESHOLD_SIZE 4096
5656

5757
/*
5858
* Internal type corresponding to size_t. Do not use this in

opal/dss/dss_internal_functions.c

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2017 Intel, Inc. All rights reserved.
1213
* $COPYRIGHT$
1314
*
1415
* Additional copyrights may follow
@@ -35,6 +36,7 @@ char* opal_dss_buffer_extend(opal_buffer_t *buffer, size_t bytes_to_add)
3536
{
3637
size_t required, to_alloc;
3738
size_t pack_offset, unpack_offset;
39+
char *tmp;
3840

3941
/* Check to see if we have enough space already */
4042

@@ -43,34 +45,19 @@ char* opal_dss_buffer_extend(opal_buffer_t *buffer, size_t bytes_to_add)
4345
}
4446

4547
required = buffer->bytes_used + bytes_to_add;
46-
if(required >= (size_t)opal_dss_threshold_size) {
47-
to_alloc = ((required + opal_dss_threshold_size - 1)
48-
/ opal_dss_threshold_size) * opal_dss_threshold_size;
48+
if (required >= (size_t)opal_dss_threshold_size) {
49+
to_alloc = (required + opal_dss_threshold_size - 1) & ~(opal_dss_threshold_size - 1);
4950
} else {
50-
to_alloc = buffer->bytes_allocated;
51-
if(0 == to_alloc) {
52-
to_alloc = opal_dss_initial_size;
53-
}
54-
while(to_alloc < required) {
55-
to_alloc <<= 1;
56-
}
51+
to_alloc = buffer->bytes_allocated ? buffer->bytes_allocated : (size_t)opal_dss_initial_size;
5752
}
5853

59-
if (NULL != buffer->base_ptr) {
60-
pack_offset = ((char*) buffer->pack_ptr) - ((char*) buffer->base_ptr);
61-
unpack_offset = ((char*) buffer->unpack_ptr) -
62-
((char*) buffer->base_ptr);
63-
buffer->base_ptr = (char*)realloc(buffer->base_ptr, to_alloc);
64-
} else {
65-
pack_offset = 0;
66-
unpack_offset = 0;
67-
buffer->bytes_used = 0;
68-
buffer->base_ptr = (char*)malloc(to_alloc);
69-
}
70-
71-
if (NULL == buffer->base_ptr) {
54+
pack_offset = ((char*) buffer->pack_ptr) - ((char*) buffer->base_ptr);
55+
unpack_offset = ((char*) buffer->unpack_ptr) - ((char*) buffer->base_ptr);
56+
tmp = (char*)realloc(buffer->base_ptr, to_alloc);
57+
if (NULL == tmp) {
7258
return NULL;
7359
}
60+
buffer->base_ptr = tmp;
7461
buffer->pack_ptr = ((char*) buffer->base_ptr) + pack_offset;
7562
buffer->unpack_ptr = ((char*) buffer->base_ptr) + unpack_offset;
7663
buffer->bytes_allocated = to_alloc;

orte/mca/odls/base/odls_base_default_fns.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *buffer,
261261
orte_proc_t *pptr, *dmn;
262262
opal_buffer_t *bptr;
263263
orte_app_context_t *app;
264-
bool found;
265264
orte_node_t *node;
266265
bool newmap = false;
267266

@@ -409,6 +408,13 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *buffer,
409408
if (NULL == jdata->map) {
410409
jdata->map = OBJ_NEW(orte_job_map_t);
411410
newmap = true;
411+
} else if (ORTE_FLAG_TEST(jdata, ORTE_JOB_FLAG_MAP_INITIALIZED)) {
412+
/* zero all the node map flags */
413+
for (n=0; n < jdata->map->nodes->size; n++) {
414+
if (NULL != (node = (orte_node_t*)opal_pointer_array_get_item(jdata->map->nodes, n))) {
415+
ORTE_FLAG_UNSET(node, ORTE_NODE_FLAG_MAPPED);
416+
}
417+
}
412418
}
413419

414420
/* if we have a file map, then we need to load it */
@@ -454,17 +460,7 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *buffer,
454460
opal_pointer_array_add(dmn->node->procs, pptr);
455461

456462
/* add the node to the map, if not already there */
457-
found = false;
458-
for (k=0; k < jdata->map->nodes->size; k++) {
459-
if (NULL == (node = (orte_node_t*)opal_pointer_array_get_item(jdata->map->nodes, k))) {
460-
continue;
461-
}
462-
if (node->daemon == dmn) {
463-
found = true;
464-
break;
465-
}
466-
}
467-
if (!found) {
463+
if (!ORTE_FLAG_TEST(dmn->node, ORTE_NODE_FLAG_MAPPED)) {
468464
OBJ_RETAIN(dmn->node);
469465
opal_pointer_array_add(jdata->map->nodes, dmn->node);
470466
if (newmap) {
@@ -497,6 +493,7 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *buffer,
497493
app = (orte_app_context_t*)opal_pointer_array_get_item(jdata->apps, pptr->app_idx);
498494
ORTE_FLAG_SET(app, ORTE_APP_FLAG_USED_ON_NODE);
499495
}
496+
ORTE_FLAG_SET(jdata, ORTE_JOB_FLAG_MAP_INITIALIZED);
500497
}
501498

502499
COMPLETE:

orte/mca/rmaps/base/rmaps_base_map_job.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
389389
OBJ_RELEASE(caddy);
390390
return;
391391
}
392+
/* mark that nodes were assigned to this job */
393+
ORTE_FLAG_SET(jdata, ORTE_JOB_FLAG_MAP_INITIALIZED);
392394

393395
/* if any node is oversubscribed, then check to see if a binding
394396
* directive was given - if not, then we want to clear the default

orte/orted/pmix/pmix_server_register_fns.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ int orte_pmix_server_register_nspace(orte_job_t *jdata)
7474
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
7575
ORTE_JOBID_PRINT(jdata->jobid));
7676

77+
/* if this job has no local procs, then no need to register them */
78+
if (0 == jdata->num_local_procs) {
79+
return ORTE_SUCCESS;
80+
}
81+
7782
/* setup the info list */
7883
info = OBJ_NEW(opal_list_t);
7984
uid = geteuid();

orte/runtime/data_type_support/orte_dt_unpacking_fns.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
1414
* All rights reserved.
15-
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
1616
* $COPYRIGHT$
1717
*
1818
* Additional copyrights may follow
@@ -168,9 +168,9 @@ int orte_dt_unpack_job(opal_buffer_t *buffer, void *dest,
168168
return rc;
169169
}
170170

171-
/* if the map is NULL, then we din't pack it as there was
171+
/* if the map is NULL, then we didn't pack it as there was
172172
* nothing to pack. Instead, we packed a flag to indicate whether or not
173-
* the map is included */
173+
* the map is included */
174174
n = 1;
175175
if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
176176
&j, &n, ORTE_STD_CNTR))) {
@@ -204,6 +204,8 @@ int orte_dt_unpack_job(opal_buffer_t *buffer, void *dest,
204204
ORTE_ERROR_LOG(rc);
205205
return rc;
206206
}
207+
/* mark the map as uninitialized as we don't pack the node map */
208+
ORTE_FLAG_UNSET(jobs[i], ORTE_JOB_FLAG_MAP_INITIALIZED);
207209

208210
/* unpack the attributes */
209211
n=1;

orte/util/attr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved
2+
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
33
* Copyright (c) 2016 Research Organization for Information Science
44
* and Technology (RIST). All rights reserved.
55
* $COPYRIGHT$
@@ -89,7 +89,7 @@ typedef uint16_t orte_job_flags_t;
8989
#define ORTE_JOB_FLAG_RESTART 0x0200 //
9090
#define ORTE_JOB_FLAG_PROCS_MIGRATING 0x0400 // some procs in job are migrating from one node to another
9191
#define ORTE_JOB_FLAG_OVERSUBSCRIBED 0x0800 // at least one node in the job is oversubscribed
92-
92+
#define ORTE_JOB_FLAG_MAP_INITIALIZED 0x1000 // nodes have been assigned to this job map
9393

9494
/*** JOB ATTRIBUTE KEYS ***/
9595
#define ORTE_JOB_START_KEY ORTE_NODE_MAX_KEY

0 commit comments

Comments
 (0)