Skip to content

Commit 43c0fcf

Browse files
DrTimothyAldenDavisdperry17
authored andcommitted
fix padding of user-defined types. Use int32 in more places
1 parent 009022c commit 43c0fcf

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

experimental/algorithm/LAGr_MaxFlow.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,34 +123,35 @@ static GrB_Info LG_augment_maxflow
123123
JIT_STR(typedef struct{
124124
double flow;
125125
double capacity;
126-
} MF_flowEdge;, GRB_FLOWEDGE_STR)
126+
} MF_flowEdge;, GRB_FLOWEDGE_STR) // 16 bytes: OK
127127

128128
JIT_STR(typedef struct{
129129
double residual;
130130
int64_t j;
131131
int64_t d;
132-
} MF_resultTuple64;, GRB_RESULTTUPLE_STR64)
132+
} MF_resultTuple64;, GRB_RESULTTUPLE_STR64) // 24 bytes: OK
133133

134134
JIT_STR(typedef struct{
135135
double residual;
136-
int64_t j;
136+
int32_t j;
137137
int32_t d;
138-
} MF_resultTuple32;, GRB_RESULTTUPLE_STR32)
138+
} MF_resultTuple32;, GRB_RESULTTUPLE_STR32) // 16 bytes: OK
139139

140140

141141
JIT_STR(typedef struct{
142142
double residual;
143143
int64_t di;
144144
int64_t y_dmin;
145145
int64_t j;
146-
} MF_compareTuple64;, GRB_COMPARETUPLE_STR64)
146+
} MF_compareTuple64;, GRB_COMPARETUPLE_STR64) // 32 bytes: OK
147147

148148
JIT_STR(typedef struct{
149149
double residual;
150150
int32_t di;
151151
int32_t y_dmin;
152-
int64_t j;
153-
} MF_compareTuple32;, GRB_COMPARETUPLE_STR32)
152+
int32_t j;
153+
int32_t unused; /* to pad the struct to 24 bytes */
154+
} MF_compareTuple32;, GRB_COMPARETUPLE_STR32) // 24 bytes: padded
154155

155156

156157
JIT_STR(void MF_CreateResidualForward(MF_flowEdge *z, const double *y) {
@@ -322,7 +323,7 @@ JIT_STR(void MF_MxeMult64(MF_resultTuple64 * z, const MF_compareTuple64 * x,
322323
z->d = x->y_dmin;
323324
z->residual = x->residual;
324325
z->j = x->j;
325-
} //add else to populate with empty tuple, prune after.
326+
} /* add else to populate with empty tuple, prune after. */
326327
else{
327328
z->d = INT64_MAX;
328329
z->residual = 0;
@@ -355,7 +356,7 @@ JIT_STR(void MF_MxeMult32(MF_resultTuple32 * z, const MF_compareTuple32 * x,
355356
z->d = x->y_dmin;
356357
z->residual = x->residual;
357358
z->j = x->j;
358-
} //add else to populate with empty tuple, prune after.
359+
} /*add else to populate with empty tuple, prune after. */
359360
else{
360361
z->d = INT32_MAX;
361362
z->residual = 0;
@@ -415,6 +416,7 @@ JIT_STR(void MF_CreateCompareVec32(MF_compareTuple32 *comp,
415416
comp->j = res->j;
416417
comp->residual = res->residual;
417418
comp->y_dmin = res->d;
419+
comp->unused = 0 ;
418420
}, GRB_CREATECOMPVEC_STR32)
419421

420422

@@ -537,6 +539,11 @@ JIT_STR(void MF_getResidual(double * res, const MF_flowEdge * flow_edge){
537539

538540
int LAGr_MaxFlow(double* f, LAGraph_Graph G, GrB_Index src, GrB_Index sink, char *msg){
539541

542+
// printf ("sizeof (MF_flowEdge): %d\n", (int) sizeof (MF_flowEdge)) ;
543+
// printf ("sizeof (MF_resultTuple64): %d\n", (int) sizeof (MF_resultTuple64)) ;
544+
// printf ("sizeof (MF_resultTuple32): %d\n", (int) sizeof (MF_resultTuple32)) ;
545+
// printf ("sizeof (MF_compareTuple64): %d\n", (int) sizeof (MF_compareTuple64)) ;
546+
// printf ("sizeof (MF_compareTuple32): %d\n", (int) sizeof (MF_compareTuple32)) ;
540547

541548
//types
542549
GrB_Type GrB_FlowEdge = NULL ;
@@ -923,7 +930,7 @@ int LAGr_MaxFlow(double* f, LAGraph_Graph G, GrB_Index src, GrB_Index sink, char
923930
}
924931
}
925932

926-
printf("******iter: %ld\n\n", iter);
933+
printf("******iter: %ld\n\n", iter); // FIXME: remove this
927934

928935
GRB_TRY(GrB_mxv(y, e, NULL,
929936
GrB_RxdSemiring, R, d, GrB_DESC_RS));

experimental/test/test_MaxFlow.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ test_info tests[] = {
3535

3636
void test_MaxFlow(void) {
3737
LAGraph_Init(msg);
38-
OK(LG_SET_BURBLE(1));
38+
//OK(LG_SET_BURBLE(1));
39+
OK(LG_SET_BURBLE(0));
3940
OK(GxB_Global_Option_set(GxB_JIT_C_CONTROL, 4));
4041
for(uint8_t test = 0; test < NTESTS; test++){
4142
GrB_Matrix A=NULL;

0 commit comments

Comments
 (0)