From 9cbbf9a27afb97e22a76db3999b4b5fbba3cba1c Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <pedro.gonnet@durham.ac.uk> Date: Fri, 23 Aug 2013 09:39:16 +0000 Subject: [PATCH] small bug on proxies init. Former-commit-id: cbee9e70b44163d624dd13a9e96ce587edc1b555 --- src/engine.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/engine.c b/src/engine.c index 1f6a7acf5b..36b0e481f3 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1557,14 +1557,17 @@ void engine_makeproxies ( struct engine *e ) { struct proxy *proxies = e->proxies; /* Prepare the proxies and the proxy index. */ - if ( e->proxy_ind != NULL ) - free( e->proxy_ind ); - if ( ( e->proxy_ind = (int *)malloc( sizeof(int) * e->nr_nodes ) ) == NULL ) - error( "Failed to allocate proxy index." ); + if ( e->proxy_ind == NULL ) + if ( ( e->proxy_ind = (int *)malloc( sizeof(int) * e->nr_nodes ) ) == NULL ) + error( "Failed to allocate proxy index." ); for ( k = 0 ; k < e->nr_nodes ; k++ ) e->proxy_ind[k] = -1; e->nr_proxies = 0; + /* The following loop is super-clunky, but it's necessary + to ensure that the order of the send and recv cells in + the proxies is identical for all nodes! */ + /* Loop over each cell in the space. */ for ( ind[0] = 0 ; ind[0] < cdim[0] ; ind[0]++ ) for ( ind[1] = 0 ; ind[1] < cdim[1] ; ind[1]++ ) @@ -1750,7 +1753,7 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread e->policy |= engine_policy_mpi; if ( ( e->proxies = (struct proxy *)malloc( sizeof(struct proxy) * engine_maxproxies ) ) == NULL ) error( "Failed to allocate memory for proxies." ); - bzero( e->proxies , sizeof(struct proxy) * 26 ); + bzero( e->proxies , sizeof(struct proxy) * engine_maxproxies ); e->nr_proxies = 0; #endif } -- GitLab