Skip to content

Commit

Permalink
Small changes to reduce maximum memory use
Browse files Browse the repository at this point in the history
  • Loading branch information
karypis committed Jan 7, 2022
1 parent 366bbbb commit aef54c5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
36 changes: 23 additions & 13 deletions libmetis/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,25 @@ void InitGraph(graph_t *graph)
}


/*************************************************************************/
/*! This function frees the memory storing the structure of the graph */
/*************************************************************************/
void FreeSData(graph_t *graph)
{
/* free graph structure */
if (graph->free_xadj)
gk_free((void **)&graph->xadj, LTERM);
if (graph->free_vwgt)
gk_free((void **)&graph->vwgt, LTERM);
if (graph->free_vsize)
gk_free((void **)&graph->vsize, LTERM);
if (graph->free_adjncy)
gk_free((void **)&graph->adjncy, LTERM);
if (graph->free_adjwgt)
gk_free((void **)&graph->adjwgt, LTERM);
}


/*************************************************************************/
/*! This function frees the refinement/partition memory stored in a graph */
/*************************************************************************/
Expand Down Expand Up @@ -252,19 +271,10 @@ void FreeGraph(graph_t **r_graph)

graph = *r_graph;

/* free graph structure */
if (graph->free_xadj)
gk_free((void **)&graph->xadj, LTERM);
if (graph->free_vwgt)
gk_free((void **)&graph->vwgt, LTERM);
if (graph->free_vsize)
gk_free((void **)&graph->vsize, LTERM);
if (graph->free_adjncy)
gk_free((void **)&graph->adjncy, LTERM);
if (graph->free_adjwgt)
gk_free((void **)&graph->adjwgt, LTERM);

/* free partition/refinement structure */
/* free the graph structure's fields */
FreeSData(graph);

/* free the partition/refinement fields */
FreeRData(graph);

gk_free((void **)&graph->tvwgt, &graph->invtvwgt, &graph->label,
Expand Down
3 changes: 3 additions & 0 deletions libmetis/kwayrefine.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ void ProjectKWayPartition(ctrl_t *ctrl, graph_t *graph)
cgraph = graph->coarser;
cwhere = cgraph->where;

/* free the coarse graph's structure (reduce maxmem) */
FreeSData(cgraph);

nvtxs = graph->nvtxs;
cmap = graph->cmap;
xadj = graph->xadj;
Expand Down
1 change: 1 addition & 0 deletions libmetis/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void SetupGraph_label(graph_t *graph);
graph_t *SetupSplitGraph(graph_t *graph, idx_t snvtxs, idx_t snedges);
graph_t *CreateGraph(void);
void InitGraph(graph_t *graph);
void FreeSData(graph_t *graph);
void FreeRData(graph_t *graph);
void FreeGraph(graph_t **graph);
void graph_WriteToDisk(ctrl_t *ctrl, graph_t *graph);
Expand Down
1 change: 1 addition & 0 deletions libmetis/rename.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
#define SetupSplitGraph libmetis__SetupSplitGraph
#define CreateGraph libmetis__CreateGraph
#define InitGraph libmetis__InitGraph
#define FreeSData libmetis__FreeSData
#define FreeRData libmetis__FreeRData
#define FreeGraph libmetis__FreeGraph
#define graph_WriteToDisk libmetis__graph_WriteToDisk
Expand Down
2 changes: 1 addition & 1 deletion programs/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void ComputePartitionInfo(params_t *params, graph_t *graph, idx_t *where)
}

gk_free((void **)&cptr, &cind, &cpwgts, LTERM);

}


0 comments on commit aef54c5

Please sign in to comment.