Skip to content

Commit

Permalink
Fix 64-bit index bug found by compiler warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiangrimberg committed Jan 10, 2024
1 parent 5e2692b commit 7e7e643
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
40 changes: 40 additions & 0 deletions extern/patch/metis/patch_build.diff
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,43 @@ index 3fb0e6e..6e88b53 100644
return;

if (graph->nbnd > 0)
diff --git a/libmetis/parmetis.c b/libmetis/parmetis.c
index 631d811..418b606 100644
--- a/libmetis/parmetis.c
+++ b/libmetis/parmetis.c
@@ -308,7 +308,7 @@ void FM_2WayNodeRefine1SidedP(ctrl_t *ctrl, graph_t *graph,
* Get into the FM loop
*******************************************************/
mptr[0] = nmind = nbad = 0;
- mindiff = abs(pwgts[0]-pwgts[1]);
+ mindiff = iabs(pwgts[0]-pwgts[1]);
for (nswaps=0; nswaps<nvtxs; nswaps++) {
if ((higain = rpqGetTop(queue)) == -1)
break;
@@ -333,7 +333,7 @@ void FM_2WayNodeRefine1SidedP(ctrl_t *ctrl, graph_t *graph,

pwgts[2] -= (vwgt[higain]-rinfo[higain].edegrees[from]);

- newdiff = abs(pwgts[to]+vwgt[higain] - (pwgts[from]-rinfo[higain].edegrees[from]));
+ newdiff = iabs(pwgts[to]+vwgt[higain] - (pwgts[from]-rinfo[higain].edegrees[from]));
if (pwgts[2] < mincut || (pwgts[2] == mincut && newdiff < mindiff)) {
mincut = pwgts[2];
mincutorder = nswaps;
@@ -537,7 +537,7 @@ void FM_2WayNodeRefine2SidedP(ctrl_t *ctrl, graph_t *graph,
* Get into the FM loop
*******************************************************/
mptr[0] = nmind = 0;
- mindiff = abs(pwgts[0]-pwgts[1]);
+ mindiff = iabs(pwgts[0]-pwgts[1]);
to = (pwgts[0] < pwgts[1] ? 0 : 1);
for (nswaps=0; nswaps<nvtxs; nswaps++) {
u[0] = rpqSeeTopVal(queues[0]);
@@ -580,7 +580,7 @@ void FM_2WayNodeRefine2SidedP(ctrl_t *ctrl, graph_t *graph,

pwgts[2] -= (vwgt[higain]-rinfo[higain].edegrees[other]);

- newdiff = abs(pwgts[to]+vwgt[higain] - (pwgts[other]-rinfo[higain].edegrees[other]));
+ newdiff = iabs(pwgts[to]+vwgt[higain] - (pwgts[other]-rinfo[higain].edegrees[other]));
if (pwgts[2] < mincut || (pwgts[2] == mincut && newdiff < mindiff)) {
mincut = pwgts[2];
mincutorder = nswaps;
15 changes: 15 additions & 0 deletions extern/patch/mfem/patch_getnodalvalues_device_fix.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/fem/gridfunc.cpp b/fem/gridfunc.cpp
index 310d8d704..bd5504d63 100644
--- a/fem/gridfunc.cpp
+++ b/fem/gridfunc.cpp
@@ -1924,9 +1924,9 @@ void GridFunction::GetNodalValues(Vector &nval, int vdim) const
Array<double> values;
Array<int> overlap(fes->GetNV());
nval.SetSize(fes->GetNV());
-
nval = 0.0;
overlap = 0;
+ nval.HostReadWrite();
for (i = 0; i < fes->GetNE(); i++)
{
fes->GetElementVertices(i, vertices);

0 comments on commit 7e7e643

Please sign in to comment.