Skip to content

Commit

Permalink
makes sht->bht conversion sequential, but parallelizes cols->mons con…
Browse files Browse the repository at this point in the history
…version
  • Loading branch information
ederc committed Sep 5, 2023
1 parent 73c1cfd commit 2f1b7c6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/neogb/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,9 @@ static void convert_sparse_matrix_rows_to_basis_elements(
len_t i, j, k;
deg_t deg;

const len_t bl = bs->ld;
const len_t np = mat->np;
const hi_t * const hcm = st->hcm;
const len_t bl = bs->ld;
const len_t np = mat->np;
hi_t *hcm = st->hcm;

/* timings */
double ct0, ct1, rt0, rt1;
Expand All @@ -611,11 +611,9 @@ static void convert_sparse_matrix_rows_to_basis_elements(

/* fix size of basis for entering new elements directly */
check_enlarge_basis(bs, mat->np, st);
while (bht->esz - bht->eld < mat->ncr) {
enlarge_hash_table(bht);
}

hm_t **rows = mat->tr;
switch_hcm_data_to_basis_hash_table(hcm, bht, mat, sht);
#pragma omp parallel for num_threads(st->nthrds) \
private(i, j, k)
for (k = 0; k < np; ++k) {
Expand All @@ -627,7 +625,10 @@ static void convert_sparse_matrix_rows_to_basis_elements(
} else {
i = k;
}
insert_in_basis_hash_table_pivots(rows[i], bht, sht, hcm, st);
const len_t len = rows[i][LENGTH]+OFFSET;
for (j = OFFSET; j < len; ++j) {
rows[i][j] = hcm[rows[i][j]];
}
deg = bht->hd[rows[i][OFFSET]].deg;
if (st->nev > 0) {
const len_t len = rows[i][LENGTH]+OFFSET;
Expand Down
20 changes: 20 additions & 0 deletions src/neogb/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,26 @@ static inline void insert_plcms_in_basis_hash_table(
psl->ld = m;
}

static inline void switch_hcm_data_to_basis_hash_table(
hi_t *hcm,
ht_t *bht,
const mat_t *mat,
const ht_t * const sht
)
{
const len_t start = mat->ncl;
const len_t end = mat->nc;

while (bht->esz - bht->eld < mat->ncr) {
enlarge_hash_table(bht);
}

for (len_t i = start; i < end; ++i) {
hcm[i] = check_insert_in_hash_table(
sht->ev[hcm[i]], sht->hd[hcm[i]].val, bht);
}
}

static inline void insert_in_basis_hash_table_pivots(
hm_t *row,
ht_t *bht,
Expand Down

0 comments on commit 2f1b7c6

Please sign in to comment.