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