Skip to content

Commit 43901fa

Browse files
committed
Merge branch 'master' of github.com:open-mpi/ompi
2 parents fb44b03 + 48f7028 commit 43901fa

File tree

10 files changed

+128
-27
lines changed

10 files changed

+128
-27
lines changed

ompi/mca/dpm/orte/dpm_orte.c

+3
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,9 @@ static int connect_accept(ompi_communicator_t *comm, int root,
584584
if ( NULL != proc_list ) {
585585
free ( proc_list );
586586
}
587+
if ( NULL != new_proc_list ) {
588+
free ( new_proc_list );
589+
}
587590
if ( OMPI_SUCCESS != rc ) {
588591
if ( MPI_COMM_NULL != newcomp && NULL != newcomp ) {
589592
OBJ_RETAIN(newcomp);

ompi/mca/topo/base/topo_base_dist_graph_create.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int mca_topo_base_dist_graph_distribute(mca_topo_base_module_t* module,
5454
* In addition we compute 3 arrays (that are allocated in one go):
5555
* - cnt: the number of elements for a peer
5656
* - pos: the position of the first element for a peer
57-
* - idx: temporaru indexes and message count after the reduce.
57+
* - idx: temporary indexes and message count after the reduce.
5858
*/
5959
cnt = (mca_topo_base_dist_graph_elem_t*)calloc(3 * csize, sizeof(mca_topo_base_dist_graph_elem_t));
6060
if( NULL == cnt ) {
@@ -118,8 +118,8 @@ int mca_topo_base_dist_graph_distribute(mca_topo_base_module_t* module,
118118
comm->c_coll.coll_allreduce_module);
119119
/**
120120
* At this point in the indexes array we have:
121-
* - indexes[0] total number of in edges
122-
* - indexes[1] total number of out edges
121+
* - idx[0].in total number of IN edges
122+
* - idx[0].out total number of OUT edges
123123
*/
124124
topo = OBJ_NEW(mca_topo_base_comm_dist_graph_2_2_0_t);
125125
if( NULL == topo ) {
@@ -134,7 +134,7 @@ int mca_topo_base_dist_graph_distribute(mca_topo_base_module_t* module,
134134
if (NULL == topo->in) {
135135
err = OMPI_ERR_OUT_OF_RESOURCE;
136136
goto bail_out;
137-
}
137+
}
138138
if (MPI_UNWEIGHTED != weights) {
139139
topo->inw = (int*)malloc(sizeof(int) * topo->indegree);
140140
if (NULL == topo->inw) {
@@ -148,7 +148,7 @@ int mca_topo_base_dist_graph_distribute(mca_topo_base_module_t* module,
148148
if (NULL == topo->out) {
149149
err = OMPI_ERR_OUT_OF_RESOURCE;
150150
goto bail_out;
151-
}
151+
}
152152
if (MPI_UNWEIGHTED != weights) {
153153
topo->outw = (int*)malloc(sizeof(int) * topo->outdegree);
154154
if (NULL == topo->outw) {

orte/mca/grpcomm/direct/grpcomm_direct.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,14 @@ static void xcast_recv(int status, orte_process_name_t* sender,
312312
rly = OBJ_NEW(opal_buffer_t);
313313
opal_dss.copy_payload(rly, buffer);
314314

315-
/* get the signature */
315+
/* get the signature that we do not need */
316316
cnt=1;
317317
if (ORTE_SUCCESS != (ret = opal_dss.unpack(buffer, &sig, &cnt, ORTE_SIGNATURE))) {
318318
ORTE_ERROR_LOG(ret);
319319
ORTE_FORCED_TERMINATE(ret);
320320
return;
321321
}
322+
OBJ_RELEASE(sig);
322323

323324
/* get the target tag */
324325
cnt=1;

orte/mca/odls/base/odls_base_default_fns.c

+24-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* All rights reserved.
1616
* Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved.
1717
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
18+
* Copyright (c) 2014 Research Organization for Information Science
19+
* and Technology (RIST). All rights reserved.
1820
* $COPYRIGHT$
1921
*
2022
* Additional copyrights may follow
@@ -393,7 +395,16 @@ static int odls_base_default_setup_fork(orte_job_t *jdata,
393395
/* setup base environment: copy the current environ and merge
394396
in the app context environ */
395397
if (NULL != context->env) {
396-
*environ_copy = opal_environ_merge(orte_launch_environ, context->env);
398+
if (*environ_copy == context->env) {
399+
/* manually free original context->env to avoid a memory leak */
400+
char ** tmp = context->env;
401+
*environ_copy = opal_environ_merge(orte_launch_environ, context->env);
402+
if (NULL != tmp) {
403+
opal_argv_free(tmp);
404+
}
405+
} else {
406+
*environ_copy = opal_environ_merge(orte_launch_environ, context->env);
407+
}
397408
} else {
398409
*environ_copy = opal_argv_copy(orte_launch_environ);
399410
}
@@ -891,8 +902,8 @@ void orte_odls_base_default_launch_local(int fd, short sd, void *cbdata)
891902
orte_jobid_t job = caddy->job;
892903
orte_odls_base_fork_local_proc_fn_t fork_local = caddy->fork_local;
893904
char *num_app_ctx = NULL;
894-
char **nps, *npstring;
895-
char **firstranks, *firstrankstring;
905+
char **nps, *npstring = NULL;
906+
char **firstranks, *firstrankstring = NULL;
896907
bool index_argv;
897908

898909
/* establish our baseline working directory - we will be potentially
@@ -1385,6 +1396,16 @@ void orte_odls_base_default_launch_local(int fd, short sd, void *cbdata)
13851396
ERROR_OUT:
13861397
/* ensure we reset our working directory back to our default location */
13871398
chdir(basedir);
1399+
/* release allocated memory */
1400+
if (NULL != num_app_ctx) {
1401+
free(num_app_ctx);
1402+
}
1403+
if (NULL != npstring) {
1404+
free(npstring);
1405+
}
1406+
if (NULL != firstrankstring) {
1407+
free(firstrankstring);
1408+
}
13881409
/* release the event */
13891410
OBJ_RELEASE(caddy);
13901411
}

orte/mca/plm/base/plm_base_launch_support.c

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* et Automatique. All rights reserved.
1515
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
1616
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
17+
* Copyright (c) 2014 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -521,6 +523,7 @@ void orte_plm_base_launch_apps(int fd, short args, void *cbdata)
521523
OBJ_RELEASE(caddy);
522524
return;
523525
}
526+
OBJ_RELEASE(buffer);
524527
/* maintain accounting */
525528
OBJ_RELEASE(sig);
526529

orte/util/context_fns.c

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
1313
* Copyright (c) 2008-2010 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2014 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2014 Research Organization for Information Science
16+
* and Technology (RIST). All rights reserved.
1517
* $COPYRIGHT$
1618
*
1719
* Additional copyrights may follow
@@ -140,6 +142,7 @@ int orte_util_check_context_app(orte_app_context_t *context, char **env)
140142
if (NULL != context->app) free(context->app);
141143
context->app = tmp;
142144
} else {
145+
free(tmp);
143146
if (0 != access(context->app, X_OK)) {
144147
return ORTE_ERR_EXE_NOT_ACCESSIBLE;
145148
}

test/datatype/opal_datatype_test.c

+19-12
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ static int test_upper( unsigned int length )
5656
TIMER_DATA_TYPE start, end;
5757
long total_time;
5858

59-
printf( "test upper matrix\n" );
59+
/*printf( "test upper matrix\n" );*/
6060
pdt = upper_matrix( length );
61-
opal_datatype_dump( pdt );
61+
/*opal_datatype_dump( pdt );*/
6262

6363
mat1 = malloc( length * length * sizeof(double) );
6464
init_random_upper_matrix( length, mat1 );
@@ -346,54 +346,61 @@ int main( int argc, char* argv[] )
346346
* By default simulate homogeneous architectures.
347347
*/
348348
remote_arch = opal_local_arch;
349-
printf( "\n\n#\n * TEST CREATE CONTIGUOUS\n #\n\n" );
349+
printf( "\n\n#\n * TEST CREATE CONTIGUOUS\n#\n\n" );
350350
pdt = create_contiguous_type( &opal_datatype_int1, 10 );
351351
if( outputFlags & CHECK_PACK_UNPACK ) {
352352
local_copy_ddt_count(pdt, 100);
353353
local_copy_with_convertor(pdt, 100, 956);
354354
}
355-
356355
OBJ_RELEASE( pdt ); assert( pdt == NULL );
357-
printf( "\n\n#\n * TEST STRANGE DATATYPE\n #\n\n" );
356+
357+
printf( "\n\n#\n * TEST STRANGE DATATYPE\n#\n\n" );
358358
pdt = create_strange_dt();
359359
if( outputFlags & CHECK_PACK_UNPACK ) {
360360
local_copy_ddt_count(pdt, 1);
361361
local_copy_with_convertor(pdt, 1, 956);
362362
}
363363
OBJ_RELEASE( pdt ); assert( pdt == NULL );
364364

365-
366-
printf( "\n\n#\n * TEST UPPER TRIANGULAR MATRIX (size 100)\n #\n\n" );
365+
printf( "\n\n#\n * TEST UPPER TRIANGULAR MATRIX (size 100)\n#\n\n" );
367366
pdt = upper_matrix(100);
368367
if( outputFlags & CHECK_PACK_UNPACK ) {
369368
local_copy_ddt_count(pdt, 1);
370369
local_copy_with_convertor(pdt, 1, 48);
371370
}
372371
OBJ_RELEASE( pdt ); assert( pdt == NULL );
373-
372+
373+
printf( "\n\n#\n * TEST CREATE STRUCT CONSTANT GAP RESIZED\n#\n\n" );
374+
pdt = create_struct_constant_gap_resized_ddt();
375+
if( outputFlags & CHECK_PACK_UNPACK ) {
376+
local_copy_ddt_count(pdt, 10000);
377+
local_copy_with_convertor(pdt, 10000, 956);
378+
}
379+
OBJ_RELEASE( pdt ); assert( pdt == NULL );
380+
374381
mpich_typeub();
375382
mpich_typeub2();
376383
mpich_typeub3();
377384

378-
printf( "\n\n#\n * TEST UPPER MATRIX\n #\n\n" );
385+
printf( "\n\n#\n * TEST UPPER MATRIX\n#\n\n" );
379386
rc = test_upper( length );
380387
if( rc == 0 )
381388
printf( "decode [PASSED]\n" );
382389
else
383390
printf( "decode [NOT PASSED]\n" );
384391

385-
printf( "\n\n#\n * TEST MATRIX BORDERS\n #\n\n" );
392+
printf( "\n\n#\n * TEST MATRIX BORDERS\n#\n\n" );
386393
pdt = test_matrix_borders( length, 100 );
387394
if( outputFlags & DUMP_DATA_AFTER_COMMIT ) {
388395
opal_datatype_dump( pdt );
389396
}
390397
OBJ_RELEASE( pdt ); assert( pdt == NULL );
391398

392399

393-
printf( "\n\n#\n * TEST CONTIGUOUS\n #\n\n" );
400+
printf( "\n\n#\n * TEST CONTIGUOUS\n#\n\n" );
394401
pdt = test_contiguous();
395402
OBJ_RELEASE( pdt ); assert( pdt == NULL );
396-
printf( "\n\n#\n * TEST STRUCT\n #\n\n" );
403+
printf( "\n\n#\n * TEST STRUCT\n#\n\n" );
397404
pdt = test_struct();
398405
OBJ_RELEASE( pdt ); assert( pdt == NULL );
399406

test/datatype/opal_ddt_lib.c

+21
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,27 @@ opal_datatype_t* create_contiguous_type( const opal_datatype_t* type, int length
253253
return newtype;
254254
}
255255

256+
/* Create a non-contiguous resized datatype */
257+
struct structure {
258+
double not_transfered;
259+
double transfered_1;
260+
double transfered_2;
261+
};
262+
263+
opal_datatype_t* create_struct_constant_gap_resized_ddt( void )
264+
{
265+
opal_datatype_t *struct_type;
266+
267+
opal_datatype_create_contiguous(0, &opal_datatype_empty, &struct_type);
268+
opal_datatype_add( struct_type, &opal_datatype_float8, 1, 8, -1 );
269+
opal_datatype_add( struct_type, &opal_datatype_float8, 1, 16, -1 );
270+
271+
opal_datatype_resize(struct_type, 0, sizeof(struct structure));
272+
opal_datatype_commit(struct_type);
273+
274+
return struct_type;
275+
}
276+
256277

257278
/*****************************************************************************/
258279
/* Copied Function to get test to work */

test/datatype/opal_ddt_lib.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ extern int mpich_typeub( void );
4949
extern int mpich_typeub2( void );
5050
extern int mpich_typeub3( void );
5151

52+
extern opal_datatype_t* create_struct_constant_gap_resized_ddt( void );
53+
5254
#endif /* TEST_OPAL_DDT_LIB_H */

test/datatype/to_self.c

+46-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,37 @@ extern void ompi_datatype_dump( MPI_Datatype ddt );
2323
#define MPI_DDT_DUMP(ddt)
2424
#endif /* OPEN_MPI */
2525

26+
/* Create a non-contiguous resized datatype */
27+
struct structure {
28+
double not_transfered;
29+
double transfered_1;
30+
double transfered_2;
31+
};
32+
33+
static MPI_Datatype
34+
create_struct_constant_gap_resized_ddt( int number, /* number of repetitions */
35+
int contig_size, /* IGNORED: number of elements in a contiguous chunk */
36+
int gap_size ) /* IGNORED: number of elements in a gap */
37+
{
38+
struct structure *data;
39+
MPI_Datatype struct_type, temp_type;
40+
MPI_Datatype types[2] = {MPI_DOUBLE, MPI_DOUBLE};
41+
int blocklens[2] = {1, 1};
42+
MPI_Aint disps[3];
43+
44+
MPI_Get_address(&data[0].transfered_1, &disps[0]);
45+
MPI_Get_address(&data[0].transfered_2, &disps[1]);
46+
MPI_Get_address(&data[0], &disps[2]);
47+
disps[1] -= disps[2]; /* 8 */
48+
disps[0] -= disps[2]; /* 16 */
49+
50+
MPI_Type_create_struct(2, blocklens, disps, types, &temp_type);
51+
MPI_Type_create_resized(temp_type, 0, sizeof(data[0]), &struct_type);
52+
MPI_Type_commit(&struct_type);
53+
54+
return struct_type;
55+
}
56+
2657
/* Create a datatype similar to the one use by HPL */
2758
static MPI_Datatype
2859
create_indexed_constant_gap_ddt( int number, /* number of repetitions */
@@ -328,17 +359,18 @@ static int do_test_for_ddt( MPI_Datatype sddt, MPI_Datatype rddt, int length )
328359
return 0;
329360
}
330361

331-
#define DO_CONTIG 0x01
332-
#define DO_CONSTANT_GAP 0x02
333-
#define DO_INDEXED_GAP 0x04
334-
#define DO_OPTIMIZED_INDEXED_GAP 0x08
362+
#define DO_CONTIG 0x01
363+
#define DO_CONSTANT_GAP 0x02
364+
#define DO_INDEXED_GAP 0x04
365+
#define DO_OPTIMIZED_INDEXED_GAP 0x08
366+
#define DO_STRUCT_CONSTANT_GAP_RESIZED 0x10
335367

336368
int main( int argc, char* argv[] )
337369
{
338-
int length = 1024 * 1024;
370+
int length = 111;
339371
int rank, size;
340372
MPI_Datatype ddt;
341-
int run_tests = DO_CONTIG | DO_CONSTANT_GAP | DO_INDEXED_GAP | DO_OPTIMIZED_INDEXED_GAP;
373+
int run_tests = 0xffffffff; /* do all tests by default */
342374
/*int run_tests = DO_CONSTANT_GAP;*/
343375

344376
MPI_Init (&argc, &argv);
@@ -388,6 +420,14 @@ int main( int argc, char* argv[] )
388420
MPI_Type_free( &ddt );
389421
}
390422

423+
if( run_tests & DO_STRUCT_CONSTANT_GAP_RESIZED ) {
424+
printf( "\nstruct constant gap resized\n\n" );
425+
ddt = create_struct_constant_gap_resized_ddt( 80, 0 /* unused */, 0 /* unused */ );
426+
MPI_DDT_DUMP( ddt );
427+
do_test_for_ddt( ddt, ddt, length );
428+
MPI_Type_free( &ddt );
429+
}
430+
391431
MPI_Finalize ();
392432
exit(0);
393433
}

0 commit comments

Comments
 (0)