Skip to content

Commit

Permalink
Merge pull request #77 from ederc/write-back-to-basis
Browse files Browse the repository at this point in the history
Addition of new basis elements in f4
  • Loading branch information
ederc authored Sep 6, 2023
2 parents 22620d4 + 2f1b7c6 commit 0c38068
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
15 changes: 10 additions & 5 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 @@ -613,7 +613,9 @@ static void convert_sparse_matrix_rows_to_basis_elements(
check_enlarge_basis(bs, mat->np, st);

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) {
/* We first insert the highest leading monomial element to the basis
* for a better Gebauer-Moeller application when updating the pair
Expand All @@ -623,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
28 changes: 24 additions & 4 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 All @@ -1046,9 +1066,9 @@ static inline void insert_in_basis_hash_table_pivots(
{
len_t l;

while (bht->esz - bht->eld < row[LENGTH]) {
/* while (bht->esz - bht->eld < row[LENGTH]) {
enlarge_hash_table(bht);
}
} */

const len_t len = row[LENGTH]+OFFSET;
const len_t evl = bht->evl;
Expand All @@ -1058,10 +1078,10 @@ static inline void insert_in_basis_hash_table_pivots(

exp_t *evt = (exp_t *)malloc(
(unsigned long)(st->nthrds * evl) * sizeof(exp_t));
#if PARALLEL_HASHING
/* #if PARALLEL_HASHING
#pragma omp parallel for num_threads(st->nthrds) \
private(l)
#endif
#endif */
for (l = OFFSET; l < len; ++l) {
exp_t *evtl = evt + (omp_get_thread_num() * evl);
memcpy(evtl, evs[hcm[row[l]]],
Expand Down

0 comments on commit 0c38068

Please sign in to comment.