Skip to content

Commit

Permalink
fix a bug of issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lyciumlee committed Feb 10, 2022
1 parent 77b97b9 commit 3aa9479
Show file tree
Hide file tree
Showing 36 changed files with 686 additions and 143 deletions.
14 changes: 7 additions & 7 deletions yafu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# code to the public domain.
# [email protected] 7/28/09
# ----------------------------------------------------------------------*/
COMPILER = gcc

CC = gcc
CFLAGS = -g -m64 -DUSE_SSE2
#CFLAGS += -march=core2 -mtune=core2
Expand All @@ -40,11 +40,11 @@ LIBS = -L.
INC += -I../ysieve -I../ytools
LIBS += -L../ysieve -L../ytools

INC += -I../gmp-6.2.1/
LIBS += -L../gmp-6.2.1/
INC += -I../gmp_install/gmp-6.2.0/include
LIBS += -L../gmp_install/gmp-6.2.0/lib

INC += -I../avx-ecm/
LIBS += -L../avx-ecm/
INC += -I../ecm_install/include/
LIBS += -L../ecm_install/lib/

INC += -I../msieve/zlib
LIBS += -L../msieve/
Expand Down Expand Up @@ -145,7 +145,7 @@ ifeq ($(FORCE_GENERIC),1)
endif

# make sure we get the correct libgmp linked by using an absolute path
LIBS += -lecm ../gmp-6.2.1/.libs/libgmp.a -lytools -lysieve
LIBS += -lecm /users/buhrow/src/c/gmp_install/gmp-6.2.0/lib/libgmp.a -lytools -lysieve
#LIBS += -lecm -lgmp -lytools -lysieve

ifeq ($(SKYLAKEX),1)
Expand Down Expand Up @@ -173,7 +173,7 @@ ifeq ($(COMPILER),icc)
LIBS += -lsvml
endif

CFLAGS += -static $(OPT_FLAGS) $(WARN_FLAGS) $(INC)
CFLAGS += $(OPT_FLAGS) $(WARN_FLAGS) $(INC)

x86: CFLAGS += -m32

Expand Down
Binary file added yafu/bin/x64/Release/yafu-x64.exe
Binary file not shown.
15 changes: 9 additions & 6 deletions yafu/factor/autofactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,10 @@ int check_if_done(fact_obj_t *fobj, mpz_t N)
// load the new fobj with this number
fobj_refactor = (fact_obj_t *)malloc(sizeof(fact_obj_t));
init_factobj(fobj_refactor);
copy_factobj(fobj_refactor, fobj);

mpz_set(fobj_refactor->N, fobj->factors->factors[i].factor);
fobj_refactor->refactor_depth = fobj->refactor_depth;

// recurse on factor
factor(fobj_refactor);
Expand Down Expand Up @@ -1823,12 +1826,12 @@ void factor(fact_obj_t *fobj)
if (fobj->VFLAG > 0)
printf("fac: found siqs savefile, resuming siqs\n");

// remove any common factor so the input exactly matches
// the file
// mpz_tdiv_q(b, b, g);
// mpz_set(fobj->N, b);
// mpz_set(origN, b);
// mpz_set(copyN, b);
// if the inputs don't match exactly, resume siqs on the exact
// number in the savefile and put the cofactor (prime or composite)
// into the factor list. If composite it will get refactored.
add_to_factor_list(fobj->factors, g, fobj->VFLAG, fobj->NUM_WITNESSES);

mpz_set(b, tmpz);

//override default choice
fact_state = state_qs;
Expand Down
16 changes: 11 additions & 5 deletions yafu/factor/avx-ecm/avx_ecm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,14 @@ void vec_ecm_main(fact_obj_t* fobj, uint32_t numcurves, uint64_t B1,
mpz_init(r);
mpz_init(N);

mpz_set(N, fobj->ecm_obj.gmp_n);
// set N equal to the original input, so we can
// detect Mersenne inputs correctly.
mpz_set(N, fobj->N);

// check for Mersenne inputs
size_n = mpz_sizeinbase(N, 2);

for (i = size_n; i < 2048; i++)
for (i = 31; i <= size_n; i++)
{
mpz_set_ui(r, 1);
mpz_mul_2exp(r, r, i);
Expand Down Expand Up @@ -197,13 +199,18 @@ void vec_ecm_main(fact_obj_t* fobj, uint32_t numcurves, uint64_t B1,
mpz_set_ui(r, 1);
mpz_mul_2exp(r, r, i);
mpz_mod(g, r, N);
if (mpz_sizeinbase(g, 2) < DIGITBITS)
if (mpz_sizeinbase(g, 2) < (DIGITBITS/2))
{
size_n = i;
isMersenne = mpz_get_ui(g);
break;
}
}
//printf("found isMersenne = 2^%d %d\n", size_n, isMersenne);

// now set N equal to the actual input, which may have had factors removed
// by previous factoring routines.
mpz_set(N, fobj->ecm_obj.gmp_n);

// if the input is Mersenne and still contains algebraic factors, remove them.
if (abs(isMersenne) == 1)
Expand Down Expand Up @@ -293,7 +300,7 @@ void vec_ecm_main(fact_obj_t* fobj, uint32_t numcurves, uint64_t B1,
gmp_printf("commencing parallel ecm on %Zd with %d threads\n", N, threads);
}

if ((double)nwords / ((double)maxbits / (double)DIGITBITS) < 0.7)
if ((isMersenne != 0) && ((double)nwords / ((double)maxbits / (double)DIGITBITS) < 0.7))
{
if (verbose > 1)
{
Expand Down Expand Up @@ -615,7 +622,6 @@ void vec_ecm_main(fact_obj_t* fobj, uint32_t numcurves, uint64_t B1,
}
vecaddmod_ptr = &vecaddmod52;
vecsubmod_ptr = &vecsubmod52;

}
}
else
Expand Down
Loading

0 comments on commit 3aa9479

Please sign in to comment.