Skip to content

Commit 834f01a

Browse files
authored
Merge pull request #282 from wegank/32-bit-fix-1
Fix definition of some constants when sizeof(mp_limb_t)==4
2 parents 35b7a7b + 462d3b4 commit 834f01a

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/fglm/fglm_core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include<stdio.h>
2626
#include<stdlib.h>
2727
#include<string.h>
28+
#include<stdint.h>
2829
#include<unistd.h>
2930
#include<time.h>
3031
/* for timing functions */
@@ -504,15 +505,15 @@ static inline void sparse_mat_fglm_mult_vec(CF_t *res, sp_matfglm_t *mat,
504505
nmod_t mod;
505506
uint64_t pow2_precomp;
506507
nmod_init(&mod, (uint64_t)prime);
507-
NMOD_RED(pow2_precomp, (UWORD(1) << __DOT_SPLIT_BITS), mod);
508+
NMOD_RED(pow2_precomp, (UINT64_C(1) << __DOT_SPLIT_BITS), mod);
508509

509510
_avx512_matrix_vector_product(vres, mat->dense_mat, vec, mat->dst,
510511
ncols, nrows, mod, pow2_precomp, st);
511512
#elif defined(HAVE_AVX2)
512513
nmod_t mod;
513514
uint64_t pow2_precomp;
514515
nmod_init(&mod, (uint64_t)prime);
515-
NMOD_RED(pow2_precomp, (UWORD(1) << __DOT_SPLIT_BITS), mod);
516+
NMOD_RED(pow2_precomp, (UINT64_C(1) << __DOT_SPLIT_BITS), mod);
516517

517518
_avx2_matrix_vector_product(vres, mat->dense_mat, vec, mat->dst,
518519
ncols, nrows, mod, pow2_precomp, st);
@@ -565,15 +566,15 @@ static inline void sparse_mat_fglm_colon_mult_vec(CF_t *res, sp_matfglmcol_t *ma
565566
nmod_t mod;
566567
uint64_t pow2_precomp;
567568
nmod_init(&mod, (uint64_t)prime);
568-
NMOD_RED(pow2_precomp, (UWORD(1) << __DOT_SPLIT_BITS), mod);
569+
NMOD_RED(pow2_precomp, (UINT64_C(1) << __DOT_SPLIT_BITS), mod);
569570

570571
_avx512_matrix_vector_product(vres, mat->dense_mat, vec, mat->dst,
571572
ncols, nrows, mod, pow2_precomp, st);
572573
#elif defined(HAVE_AVX2)
573574
nmod_t mod;
574575
uint64_t pow2_precomp;
575576
nmod_init(&mod, (uint64_t)prime);
576-
NMOD_RED(pow2_precomp, (UWORD(1) << __DOT_SPLIT_BITS), mod);
577+
NMOD_RED(pow2_precomp, (UINT64_C(1) << __DOT_SPLIT_BITS), mod);
577578

578579
_avx2_matrix_vector_product(vres, mat->dense_mat, vec, mat->dst,
579580
ncols, nrows, mod, pow2_precomp, st);
@@ -2208,4 +2209,3 @@ param_t *nmod_fglm_guess_colon(sp_matfglmcol_t *matrix,
22082209
return param;
22092210
}
22102211

2211-

src/fglm/linalg-fglm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
// parameters for splitting
4242
#define __DOT_SPLIT_BITS 56
43-
#define __DOT_SPLIT_MASK 72057594037927935UL // (1UL << __DOT_SPLIT_BITS) - 1
43+
#define __DOT_SPLIT_MASK UINT64_C(72057594037927935) // (UINT64_C(1) << __DOT_SPLIT_BITS) - 1
4444

4545
/*--------------------------------------*/
4646
/* non-vectorized matrix vector product */

src/msolve/msolve.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,12 +912,12 @@ static inline void normalize_nmod_param(param_t *nmod_param) {
912912

913913
for (long i = 1; i < nmod_param->elim->length; i++) {
914914
nmod_param->denom->coeffs[i - 1] =
915-
(i * nmod_param->elim->coeffs[i]) % prime;
915+
(uint64_t)i * (uint64_t)nmod_param->elim->coeffs[i] % (uint64_t)prime;
916916
}
917917

918918
for (long i = 0; i < nmod_param->elim->length - 1; i++) {
919919
nmod_param->denom->coeffs[i] =
920-
(inv * nmod_param->denom->coeffs[i]) % prime;
920+
(uint64_t)inv * (uint64_t)nmod_param->denom->coeffs[i] % (uint64_t)prime;
921921
}
922922

923923
for (int j = 0; j < nmod_param->nvars - 1; j++) {

0 commit comments

Comments
 (0)