Skip to content

Commit

Permalink
Fix element redistribution issue (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
thilinarmtb authored Mar 23, 2021
1 parent b2a77e4 commit b6d60ca
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 131 deletions.
9 changes: 6 additions & 3 deletions src/genmap-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/* rcb_element is used for rcb and rib */
struct rcb_element {
unsigned char type;
int type;
GenmapInt proc;
GenmapInt origin;
GenmapInt seq;
Expand All @@ -38,7 +38,7 @@ struct rcb_element {

/* rsb_element should be a superset of rcb_element */
struct rsb_element {
unsigned char type;
int type;
GenmapInt proc;
GenmapInt origin;
GenmapInt seq;
Expand Down Expand Up @@ -99,12 +99,15 @@ typedef enum {
FIEDLER,
NFIEDLER,
FIEDLERSORT,
BISECT,
BISECTANDREPAIR,
LANCZOS,
NLANCZOS,
WEIGHTEDLAPLACIAN,
TQLI,
LAPLACIANSETUP,
FINDNBRS,
CSRMATSETUP,
CSRTOPSETUP,
PRECONDSETUP,
RQI,
NRQI,
Expand Down
28 changes: 17 additions & 11 deletions src/genmap-laplacian.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#define min(a, b) ((b) < (a) ? (b) : (a))

static void GenmapFindNeighbors(struct array *nbrs, genmap_handle h,
struct comm *cc) {
static void genmap_find_neighbors(struct array *nbrs, genmap_handle h,
struct comm *cc) {
sint lelt = genmap_get_nel(h);
sint nv = genmap_get_nvertices(h);

Expand Down Expand Up @@ -38,9 +38,7 @@ static void GenmapFindNeighbors(struct array *nbrs, genmap_handle h,
size = vertices.n;
vertex *vPtr = vertices.ptr;

buffer buf;
buffer_init(&buf, 1024);
sarray_sort(vertex, vPtr, size, vertexId, 1, &buf);
sarray_sort(vertex, vPtr, size, vertexId, 1, &h->buf);

struct array a;
array_init(csr_entry, &a, 10);
Expand All @@ -67,14 +65,13 @@ static void GenmapFindNeighbors(struct array *nbrs, genmap_handle h,

sarray_transfer(csr_entry, &a, proc, 1, &cr);
// TODO: Check if the last line is redundant
sarray_sort_2(csr_entry, a.ptr, a.n, r, 1, c, 1, &buf);
sarray_sort(csr_entry, a.ptr, a.n, r, 1, &buf);
sarray_sort_2(csr_entry, a.ptr, a.n, r, 1, c, 1, &h->buf);
// sarray_sort(csr_entry, a.ptr, a.n, r, 1, &h->buf);

array_init(entry, nbrs, lelt);

if (a.n == 0) {
crystal_free(&cr);
buffer_free(&buf);
array_free(&vertices);
array_free(&a);
}
Expand All @@ -96,21 +93,30 @@ static void GenmapFindNeighbors(struct array *nbrs, genmap_handle h,
}
}

sarray_sort_2(entry, nbrs->ptr, nbrs->n, r, 1, c, 1, &buf);
sarray_sort_2(entry, nbrs->ptr, nbrs->n, r, 1, c, 1, &h->buf);

crystal_free(&cr);
buffer_free(&buf);
array_free(&vertices);
array_free(&a);
}

int GenmapInitLaplacian(genmap_handle h, struct comm *c) {
struct array entries;
GenmapFindNeighbors(&entries, h, c);

metric_tic(c, FINDNBRS);
genmap_find_neighbors(&entries, h, c);
metric_toc(c, FINDNBRS);

metric_tic(c, CSRMATSETUP);
csr_mat_setup(&entries, c, &h->M);
metric_toc(c, CSRMATSETUP);

array_free(&entries);

metric_toc(c, CSRTOPSETUP);
h->gsh = get_csr_top(h->M, c);
metric_toc(c, CSRTOPSETUP);

GenmapRealloc(h->M->row_off[h->M->rn], &h->b);

#if defined(GENMAP_DEBUG)
Expand Down
31 changes: 31 additions & 0 deletions src/genmap-load-balance.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,34 @@ void genmap_load_balance(struct array *eList, uint nel, int nv, double *coord,

free(element);
}

void genmap_restore_original(int *part, int *seq, struct crystal *cr,
struct array *eList, buffer *bfr) {
struct rcb_element *element = eList->ptr;
size_t unit_size;
if (element->type == GENMAP_RSB_ELEMENT) // RSB
unit_size = sizeof(struct rsb_element);
else
unit_size = sizeof(struct rcb_element);

sarray_transfer_(eList, unit_size, offsetof(struct rcb_element, origin), 1,
cr);

uint nel = eList->n;
if (element->type == GENMAP_RSB_ELEMENT) // RSB
sarray_sort(struct rsb_element, eList->ptr, nel, globalId, 1, bfr);
else
sarray_sort(struct rcb_element, eList->ptr, nel, globalId, 1, bfr);

int e;
for (e = 0; e < nel; e++) {
element = eList->ptr + e * unit_size;
part[e] = element->origin; // element[e].origin;
}

if (seq != NULL)
for (e = 0; e < nel; e++) {
element = eList->ptr + e * unit_size;
seq[e] = element->seq; // element[e].seq;
}
}
Loading

0 comments on commit b6d60ca

Please sign in to comment.