Fix tux regressions (#1018)
Fix allocation issue with hypre_CreateBinaryTree
This commit is contained in:
parent
a544782335
commit
c662999d58
@ -1661,7 +1661,7 @@ typedef struct
|
||||
|
||||
} hypre_DataExchangeResponse;
|
||||
|
||||
HYPRE_Int hypre_CreateBinaryTree(HYPRE_Int, HYPRE_Int, hypre_BinaryTree*);
|
||||
HYPRE_Int hypre_CreateBinaryTree(HYPRE_Int, HYPRE_Int, hypre_BinaryTree**);
|
||||
HYPRE_Int hypre_DestroyBinaryTree(hypre_BinaryTree*);
|
||||
HYPRE_Int hypre_DataExchangeList(HYPRE_Int num_contacts, HYPRE_Int *contact_proc_list,
|
||||
void *contact_send_buf, HYPRE_Int *contact_send_buf_starts, HYPRE_Int contact_obj_size,
|
||||
@ -1669,7 +1669,6 @@ HYPRE_Int hypre_DataExchangeList(HYPRE_Int num_contacts, HYPRE_Int *contact_proc
|
||||
HYPRE_Int rnum, MPI_Comm comm, void **p_response_recv_buf, HYPRE_Int **p_response_recv_buf_starts);
|
||||
|
||||
#endif /* end of header */
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright (c) 1998 Lawrence Livermore National Security, LLC and other
|
||||
* HYPRE Project Developers. See the top-level COPYRIGHT file for details.
|
||||
|
||||
@ -15,19 +15,25 @@
|
||||
#include "_hypre_utilities.h"
|
||||
|
||||
/*---------------------------------------------------
|
||||
* hypre_CreateBinaryTree()
|
||||
* hypre_CreateBinaryTree
|
||||
*
|
||||
* Get the processors position in the binary tree (i.e.,
|
||||
* its children and parent processor ids)
|
||||
*----------------------------------------------------*/
|
||||
|
||||
HYPRE_Int hypre_CreateBinaryTree(HYPRE_Int myid, HYPRE_Int num_procs,
|
||||
hypre_BinaryTree *tree)
|
||||
HYPRE_Int
|
||||
hypre_CreateBinaryTree(HYPRE_Int myid,
|
||||
HYPRE_Int num_procs,
|
||||
hypre_BinaryTree **tree_ptr)
|
||||
{
|
||||
hypre_BinaryTree *tree;
|
||||
HYPRE_Int i, proc, size = 0;
|
||||
HYPRE_Int *tmp_child_id;
|
||||
HYPRE_Int num = 0, parent = 0;
|
||||
|
||||
/* initialize*/
|
||||
tree = hypre_CTAlloc(hypre_BinaryTree, 1, HYPRE_MEMORY_HOST);
|
||||
|
||||
/* initialize */
|
||||
proc = myid;
|
||||
|
||||
/*how many children can a processor have?*/
|
||||
@ -56,30 +62,38 @@ HYPRE_Int hypre_CreateBinaryTree(HYPRE_Int myid, HYPRE_Int num_procs,
|
||||
parent = myid - i;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hypre_BinaryTreeParentId(tree) = parent;
|
||||
hypre_BinaryTreeNumChild(tree) = num;
|
||||
hypre_BinaryTreeChildIds(tree) = tmp_child_id;
|
||||
|
||||
*tree_ptr = tree;
|
||||
|
||||
return hypre_error_flag;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------
|
||||
* hypre_DestroyBinaryTree()
|
||||
* Destroy storage created by createBinaryTree
|
||||
*
|
||||
* Destroy storage created by hypre_CreateBinaryTree
|
||||
*----------------------------------------------------*/
|
||||
HYPRE_Int hypre_DestroyBinaryTree(hypre_BinaryTree *tree)
|
||||
{
|
||||
|
||||
HYPRE_Int
|
||||
hypre_DestroyBinaryTree(hypre_BinaryTree *tree)
|
||||
{
|
||||
if (tree)
|
||||
{
|
||||
hypre_TFree(hypre_BinaryTreeChildIds(tree), HYPRE_MEMORY_HOST);
|
||||
hypre_TFree(tree, HYPRE_MEMORY_HOST);
|
||||
}
|
||||
|
||||
return hypre_error_flag;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------
|
||||
* hypre_DataExchangeList()
|
||||
*
|
||||
* This function is for sending a list of messages ("contacts" to
|
||||
* a list of processors. The receiving processors
|
||||
* do not know how many messages they are getting. The
|
||||
@ -90,7 +104,8 @@ HYPRE_Int hypre_DestroyBinaryTree(hypre_BinaryTree *tree)
|
||||
/* should change to where the buffers for sending and receiving are voids
|
||||
instead of ints - then cast accordingly */
|
||||
|
||||
HYPRE_Int hypre_DataExchangeList(HYPRE_Int num_contacts,
|
||||
HYPRE_Int
|
||||
hypre_DataExchangeList(HYPRE_Int num_contacts,
|
||||
HYPRE_Int *contact_proc_list,
|
||||
void *contact_send_buf,
|
||||
HYPRE_Int *contact_send_buf_starts,
|
||||
@ -98,7 +113,8 @@ HYPRE_Int hypre_DataExchangeList(HYPRE_Int num_contacts,
|
||||
HYPRE_Int response_obj_size,
|
||||
hypre_DataExchangeResponse *response_obj,
|
||||
HYPRE_Int max_response_size,
|
||||
HYPRE_Int rnum, MPI_Comm comm,
|
||||
HYPRE_Int rnum,
|
||||
MPI_Comm comm,
|
||||
void **p_response_recv_buf,
|
||||
HYPRE_Int **p_response_recv_buf_starts)
|
||||
{
|
||||
@ -275,7 +291,7 @@ HYPRE_Int hypre_DataExchangeList(HYPRE_Int num_contacts,
|
||||
|
||||
if (num_procs > 1)
|
||||
{
|
||||
hypre_CreateBinaryTree(myid, num_procs, tree);
|
||||
hypre_CreateBinaryTree(myid, num_procs, &tree);
|
||||
|
||||
/* we will get a message from all of our children when they
|
||||
have received responses for all of their contacts.
|
||||
|
||||
@ -41,7 +41,7 @@ typedef struct
|
||||
|
||||
} hypre_DataExchangeResponse;
|
||||
|
||||
HYPRE_Int hypre_CreateBinaryTree(HYPRE_Int, HYPRE_Int, hypre_BinaryTree*);
|
||||
HYPRE_Int hypre_CreateBinaryTree(HYPRE_Int, HYPRE_Int, hypre_BinaryTree**);
|
||||
HYPRE_Int hypre_DestroyBinaryTree(hypre_BinaryTree*);
|
||||
HYPRE_Int hypre_DataExchangeList(HYPRE_Int num_contacts, HYPRE_Int *contact_proc_list,
|
||||
void *contact_send_buf, HYPRE_Int *contact_send_buf_starts, HYPRE_Int contact_obj_size,
|
||||
@ -49,4 +49,3 @@ HYPRE_Int hypre_DataExchangeList(HYPRE_Int num_contacts, HYPRE_Int *contact_proc
|
||||
HYPRE_Int rnum, MPI_Comm comm, void **p_response_recv_buf, HYPRE_Int **p_response_recv_buf_starts);
|
||||
|
||||
#endif /* end of header */
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user