The package rpms/fes.git has added or updated architecture specific content in its
spec file (ExclusiveArch/ExcludeArch or %ifarch/%ifnarch) in commit(s):
https://src.fedoraproject.org/cgit/rpms/fes.git/commit/?id=530a3ded757e63....
Change:
+%ifnarch %{ix86} x86_64
Thanks.
Full change:
============
commit 530a3ded757e632320f36b1e1eeba786583e1f65
Author: Jerry James <loganjerry(a)gmail.com>
Date: Mon Feb 18 10:23:59 2019 -0700
New upstream version, fixes FTBFS (bz 1603963, 1674882).
Also:
- Correct license from GPLv3+ to GPLv2+.
- Drop upstreamed -dynamic patch.
- Add -configure patch to fix multiple configuration problems.
- Add -python3 patch due to python2 removal in Rawhide.
- Add -const patch to fix warnings.
- Add -undef patch to fix the build on non-x86_64 arches.
- Drop ExclusiveArch as the SSE2 code is now optional.
- Reduce texlive BRs.
diff --git a/.gitignore b/.gitignore
index e69de29..4f79e2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/fes-*.spkg
diff --git a/fes-0.1.spkg b/fes-0.1.spkg
deleted file mode 100644
index 0400ed3..0000000
Binary files a/fes-0.1.spkg and /dev/null differ
diff --git a/fes-configure.patch b/fes-configure.patch
new file mode 100644
index 0000000..4f78897
--- /dev/null
+++ b/fes-configure.patch
@@ -0,0 +1,146 @@
+--- src/configure.ac.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/configure.ac 2019-02-06 14:05:04.469165554 -0700
+@@ -4,7 +4,7 @@ AC_CANONICAL_HOST
+ AC_CONFIG_MACRO_DIR([m4])
+
+ AM_INIT_AUTOMAKE([1.8 gnu no-dependencies])
+-AC_CONFIG_HEADERS([config.h])
++AC_CONFIG_HEADERS([config.h src/config.h])
+ AM_MAINTAINER_MODE
+
+ # user-definable options
+@@ -25,7 +25,7 @@ AC_ARG_ENABLE([assembly],
+ # -O3 vs -O0 (for fast compilation)
+ AC_ARG_ENABLE([optimizations],
+ AS_HELP_STRING([--disable-optimizations], [compile (much) faster.]),
+- [OPT_FLAGS="-O0"], [OPT_FLAGS="-O3"])
++ [OPT_FLAGS="-O0"], [OPT_FLAGS="-O2"])
+
+
+
+@@ -34,9 +34,8 @@ AC_ARG_ENABLE([optimizations],
+ AC_PROG_CC
+ AC_PROG_CC_C99
+ AC_PROG_MAKE_SET
+-AC_PROG_LIBTOOL
++LT_INIT()
+ AM_PATH_PYTHON([2.7])
+-AC_PROG_RANLIB
+ AC_PROG_INSTALL
+ #AC_ARG_PROGRAM
+ if test "x$enable_assembly" != "xno"; then
+@@ -102,10 +101,10 @@ AC_TYPE_UINT32_T
+ AC_TYPE_UINT64_T
+ AC_FUNC_MALLOC
+
+-CFLAGS="$CFLAGS $SIMD_CFLAGS -Wall -Wextra -Werror -fPIC $OPT_FLAGS
$gcc_cflags_cpu"
++CFLAGS="$CFLAGS $SIMD_CFLAGS -Wall -Wextra -fPIC $OPT_FLAGS $gcc_cflags_cpu"
+
+ AC_SUBST(CFLAGS)
+ AC_SUBST(LDFLAGS)
+
+-AC_CONFIG_FILES([Makefile src/Makefile test/Makefile src/config.h])
++AC_CONFIG_FILES([Makefile src/Makefile test/Makefile])
+ AC_OUTPUT
+--- src/m4/ax_ext.m4.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/m4/ax_ext.m4 2019-02-06 12:57:43.995576097 -0700
+@@ -65,22 +65,6 @@ AC_DEFUN([AX_EXT],
+ fi
+ ])
+
+- AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
+- [
+- ax_cv_have_sse3_ext=no
+- if test "$((0x$ecx&0x01))" = 1; then
+- ax_cv_have_sse3_ext=yes
+- fi
+- ])
+-
+- AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
+- [
+- ax_cv_have_ssse3_ext=no
+- if test "$((0x$ecx>>9&0x01))" = 1; then
+- ax_cv_have_ssse3_ext=yes
+- fi
+- ])
+-
+ if test "$ax_cv_have_mmx_ext" = yes; then
+ AC_DEFINE(HAVE_MMX,,[Support mmx instructions])
+ AX_CHECK_COMPILER_FLAGS(-mmmx, SIMD_CFLAGS="$SIMD_CFLAGS -mmmx", [])
+@@ -96,14 +80,5 @@ AC_DEFUN([AX_EXT],
+ AX_CHECK_COMPILER_FLAGS(-msse2, SIMD_CFLAGS="$SIMD_CFLAGS -msse2", [])
+ fi
+
+- if test "$ax_cv_have_sse3_ext" = yes; then
+- AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) instructions])
+- AX_CHECK_COMPILER_FLAGS(-msse3, SIMD_CFLAGS="$SIMD_CFLAGS -msse3", [])
+- fi
+-
+- if test "$ax_cv_have_ssse3_ext" = yes; then
+- AC_DEFINE(HAVE_SSSE3,,[Support SSSE3 (Supplemental Streaming SIMD Extensions 3)
instructions])
+- fi
+-
+ AC_SUBST(SIMD_CFLAGS)
+ ])
+--- src/Makefile.am.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/Makefile.am 2019-02-07 08:16:24.818993837 -0700
+@@ -1,5 +1,4 @@
+ AUTOMAKE_OPTIONS = gnu
+ ACLOCAL_AMFLAGS = -I m4
+
+-EXTRA_DIST = configfsf.guess configfsf.sub
+ SUBDIRS = src test .
+--- src/src/config.h.in.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/src/config.h.in 2019-02-06 14:03:59.981926667 -0700
+@@ -2,11 +2,13 @@
+ #define FES_CONFIG_H
+
+ // Defines determined during configuration of fes .
+-#define HAVE_SSE2 @HAVE_SSE2@
+-#define HAVE_64_BITS @HAVE_64_BITS@
+-#define __HAVE_OPENMP @HAVE_OPENMP@
+-#define __CPU_L1_CACHE @CPU_L1_CACHE@
+-#define __CPU_L2_CACHE @CPU_L2_CACHE@
+-#define __DEBUG @DEBUG@
++/* Support SSE2 (Streaming SIMD Extensions 2) instructions */
++#undef HAVE_SSE2
++
++/* Define to 1 when building for a 64-bit machine */
++#undef HAVE_64_BITS
++
++/* Define to 1 when building with -fopenmp */
++#undef HAVE_OPENMP
+
+ #endif
+--- src/src/Makefile.am.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/src/Makefile.am 2019-02-07 08:18:14.864495884 -0700
+@@ -4,6 +4,7 @@ libfes_LTLIBRARIES = libfes.la
+ libfesdir = $(libdir)
+ libfes_la_SOURCES = idx_LUT.c idx_LUT.h common.c wrapper.c fes.h moebius_transform.c
+ include_HEADERS = fes_interface.h
++noinst_HEADERS = binomials.h
+
+ # built_sources.am is generated by... gen_built_sources.py
+ include $(srcdir)/built_sources.am
+@@ -12,7 +13,7 @@ BUILT_SOURCES = $(plain_c_sources)
+ BUILT_SOURCES += all_functions.h
+
+ all_functions.h: gen_built_sources.py
+- $(PYTHON) gen_built_sources.py $@ $(TAB_T) > $@
++ $(PYTHON) $< $@ $(TAB_T) > $@
+
+
+ if HAVE_SSE2
+@@ -28,7 +29,9 @@ nodist_libfes_la_SOURCES = $(BUILT_SOURC
+ CLEANFILES = $(nodist_libfes_la_SOURCES)
+
+ autogenerated_c%.c: boilerplate_generator.py
+- $(PYTHON) boilerplate_generator.py $@ > $@
++ $(PYTHON) $< $@ > $@
+
+-autogenerated_asm%.s : gen_qhasm_code.py
+- $(PYTHON) gen_qhasm_code.py $@ > $@
++autogenerated_asm%.s: gen_qhasm_code.py
++ $(PYTHON) $< $@ > $@
++
++EXTRA_DIST = boilerplate_generator.py gen_built_sources.py gen_qhasm_code.py
get_idx_list.py idx_LUT.py
diff --git a/fes-const.patch b/fes-const.patch
new file mode 100644
index 0000000..80bb344
--- /dev/null
+++ b/fes-const.patch
@@ -0,0 +1,11 @@
+--- src/src/idx_LUT.h.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/src/idx_LUT.h 2019-02-06 11:19:09.231044885 -0700
+@@ -79,7 +79,7 @@
+ typedef uint32_t LUT_int_t;
+
+ // Actual type of the lookup tables
+-typedef const LUT_int_t const * const * const LUT_t;
++typedef const LUT_int_t * const * const LUT_t;
+
+ // A "package" that wraps the actual lookup tables
+ // along with useful informations
diff --git a/fes-dynamic.patch b/fes-dynamic.patch
deleted file mode 100644
index 16129df..0000000
--- a/fes-dynamic.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-diff -up fes-0.1/src/configure.ac.orig fes-0.1/src/configure.ac
---- fes-0.1/src/configure.ac.orig 2013-06-05 21:43:24.883102870 -0300
-+++ fes-0.1/src/configure.ac 2013-06-05 21:43:29.215103036 -0300
-@@ -34,6 +34,7 @@ AC_ARG_ENABLE([optimizations],
- AC_PROG_CC
- AC_PROG_CC_C99
- AC_PROG_MAKE_SET
-+AC_PROG_LIBTOOL
- AM_PATH_PYTHON([2.7])
- AC_PROG_RANLIB
- AC_PROG_INSTALL
-diff -up fes-0.1/src/src/built_sources.am.orig fes-0.1/src/src/built_sources.am
---- fes-0.1/src/src/built_sources.am.orig 2013-06-05 21:43:24.885102870 -0300
-+++ fes-0.1/src/src/built_sources.am 2013-06-05 21:43:29.216103036 -0300
-@@ -55,7 +55,6 @@ asm_c_sources= autogenerated_c-simd-wit
- autogenerated_c-simd-with-asm_deg_2_el_30.c \
- autogenerated_c-simd-with-asm_deg_2_el_31.c \
- autogenerated_c-simd-with-asm_deg_2_el_32.c \
-- autogenerated_c-simd-with-asm_deg_2_el_0.c \
- autogenerated_c-simd-with-asm_deg_3_el_0.c \
- autogenerated_c-simd-with-asm_deg_4_el_0.c \
- autogenerated_c-simd-with-asm_deg_5_el_0.c \
-@@ -96,7 +95,6 @@ asm_sources = autogenerated_asm_deg_2_e
- autogenerated_asm_deg_2_el_30.s \
- autogenerated_asm_deg_2_el_31.s \
- autogenerated_asm_deg_2_el_32.s \
-- autogenerated_asm_deg_2_el_0.s \
- autogenerated_asm_deg_3_el_0.s \
- autogenerated_asm_deg_4_el_0.s \
- autogenerated_asm_deg_5_el_0.s \
-diff -up fes-0.1/src/src/Makefile.am.orig fes-0.1/src/src/Makefile.am
---- fes-0.1/src/src/Makefile.am.orig 2013-06-05 21:43:24.879102870 -0300
-+++ fes-0.1/src/src/Makefile.am 2013-06-05 21:43:29.216103036 -0300
-@@ -1,8 +1,8 @@
- AUTOMAKE_OPTIONS = gnu
-
--lib_LIBRARIES = libfes.a
--
--libfes_a_SOURCES = idx_LUT.c idx_LUT.h common.c wrapper.c fes.h moebius_transform.c
-+libfes_LTLIBRARIES = libfes.la
-+libfesdir = $(libdir)
-+libfes_la_SOURCES = idx_LUT.c idx_LUT.h common.c wrapper.c fes.h moebius_transform.c
- include_HEADERS = fes_interface.h
-
- # built_sources.am is generated by... gen_built_sources.py
-@@ -24,8 +24,8 @@ else
- endif
- endif
-
--nodist_libfes_a_SOURCES = $(BUILT_SOURCES)
--CLEANFILES = $(nodist_libfes_a_SOURCES)
-+nodist_libfes_la_SOURCES = $(BUILT_SOURCES)
-+CLEANFILES = $(nodist_libfes_la_SOURCES)
-
-
- autogenerated_c%.c: boilerplate_generator.py
-diff -up fes-0.1/src/test/Makefile.am.orig fes-0.1/src/test/Makefile.am
---- fes-0.1/src/test/Makefile.am.orig 2013-06-05 21:43:24.881102870 -0300
-+++ fes-0.1/src/test/Makefile.am 2013-06-05 21:43:55.933104059 -0300
-@@ -1,7 +1,6 @@
- AM_CPPFLAGS = -I$(top_srcdir)/src
--LDADD = $(top_builddir)/src/libfes.a rand.o
-+LDADD = $(top_builddir)/src/libfes.la rand.o
-
--TESTS_ENVIRONMENT = $(PYTHON)
- TESTS = test_suite.py
- check_PROGRAMS = semislow semislow_specialize fast moebius
-
-diff -up fes-0.1/src/test/test_suite.py.orig fes-0.1/src/test/test_suite.py
---- fes-0.1/src/test/test_suite.py.orig 2013-06-05 21:43:24.887102870 -0300
-+++ fes-0.1/src/test/test_suite.py 2013-06-05 21:43:37.205103342 -0300
-@@ -1,3 +1,5 @@
-+#!/usr/bin/python
-+
- from subprocess import check_output
-
- output = dict()
diff --git a/fes-python3.patch b/fes-python3.patch
new file mode 100644
index 0000000..aee7e07
--- /dev/null
+++ b/fes-python3.patch
@@ -0,0 +1,1117 @@
+--- src/src/boilerplate_generator.py.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/src/boilerplate_generator.py 2019-02-06 11:39:30.945568833 -0700
+@@ -16,40 +16,40 @@ def popcount(n):
+ def data_reference(array, indices):
+ if indices == []:
+ return array + "[ 0 ]"
+- return "{array}[ idx_{i}(LUT, {stuff}) ]".format(array=array,
i=len(indices), stuff=string.join( indices, ", "))
++ return "{array}[ idx_{i}(LUT, {stuff}) ]".format(array=array,
i=len(indices), stuff=", ".join( indices ))
+
+
+ # generates the initialisation of the derivatives
+ def gen_init_code(degree):
+ idx = [ "i{0}".format(j) for j in range(degree+1) ]
+- print " // computes the derivatives required by the enumeration kernel up to
degree {d}".format(d=degree)
+- print " // this is done in-place, meaning that if `F` described the
coefficients of the"
+- print " // polynomials before, then afterwards, they describe the
derivatives"
+- print ""
++ print(" // computes the derivatives required by the enumeration kernel up to
degree {d}".format(d=degree))
++ print(" // this is done in-place, meaning that if `F` described the
coefficients of the")
++ print(" // polynomials before, then afterwards, they describe the
derivatives")
++ print("")
+
+ for updatee_degree in range(1, degree):
+ for updater_degree in range(updatee_degree+1, min(degree,2*updatee_degree)+1):
+- print " // here, degree-{0} terms are affected by degree-{1}
terms".format(updatee_degree, updater_degree)
+- print ' for(int {idx}={start}; {idx}<n; {idx}++)
{{'.format(idx=idx[updatee_degree-1], start=updatee_degree)
++ print(" // here, degree-{0} terms are affected by degree-{1}
terms".format(updatee_degree, updater_degree))
++ print(' for(int {idx}={start}; {idx}<n; {idx}++)
{{'.format(idx=idx[updatee_degree-1], start=updatee_degree))
+ for i in range(updatee_degree-2, -1, -1):
+- print '{pad} for(int {idx}={start}; {idx}<{prev_idx}; {idx}++)
{{'.format(pad=' '*(updatee_degree-i), \
+-
idx=idx[i], start=i, prev_idx=idx[i+1])
++ print('{pad} for(int {idx}={start}; {idx}<{prev_idx}; {idx}++)
{{'.format(pad=' '*(updatee_degree-i), \
++
idx=idx[i], start=i, prev_idx=idx[i+1]))
+ updatee = data_reference('F', idx[:updatee_degree])
+- conditions = [ idx[0] + " != 0 " ] + map( lambda i: idx[i] +
"-1 > " + idx[i-1], range(1, updatee_degree))
++ conditions = [ idx[0] + " != 0 " ] + [idx[i] + "-1 >
" + idx[i-1] for i in range(1, updatee_degree)]
+
+- for subset in itertools.combinations(range(updatee_degree),
updater_degree-updatee_degree):
+- update_condition = string.join( map(lambda i:conditions[i], subset),
" && ")
++ for subset in itertools.combinations(list(range(updatee_degree)),
updater_degree-updatee_degree):
++ update_condition = " && ".join( [conditions[i] for i
in subset])
+ updater_idx = idx[:updatee_degree]
+ for foo,i in enumerate(subset):
+ updater_idx.insert(i+foo, idx[i]+"-1")
+ updater = data_reference('F', updater_idx)
+- print "{pad} if ({cond}) {lhs} ^= {rhs};".format(pad='
'*updatee_degree, cond=update_condition, lhs=updatee, rhs=updater)
++ print("{pad} if ({cond}) {lhs} ^= {rhs};".format(pad='
'*updatee_degree, cond=update_condition, lhs=updatee, rhs=updater))
+
+- print ' {closing}'.format(closing='}'*updatee_degree)
+- print ''
++ print(' {closing}'.format(closing='}'*updatee_degree))
++ print('')
+ # print '}'
+- print ''
+- print ''
++ print('')
++ print('')
+
+
+
+@@ -60,26 +60,26 @@ def gen_steps(degree,simd=False, T=2):
+ for w in range(degree+1):
+ args = idx[:w]
+
+- print "#define STEP_{w}({args}) {{ \\".format(w=w, args=string.join(
args + ["i"], "," ))
++ print("#define STEP_{w}({args}) {{ \\".format(w=w,
args=",".join( args + ["i"] )))
+ for i in range(w-1,0,-1):
+- print " F[ {LHS} ] ^= F [ {RHS} ]; \\".format(LHS=idx[i-1],
RHS=idx[i])
++ print(" F[ {LHS} ] ^= F [ {RHS} ]; \\".format(LHS=idx[i-1],
RHS=idx[i]))
+ if w > 0:
+- print " F[ 0 ] ^= F [ {RHS} ]; \\".format(RHS=idx[0])
++ print(" F[ 0 ] ^= F [ {RHS} ]; \\".format(RHS=idx[0]))
+ if simd:
+- print ' const simd_t Mask = _mm_cmpeq_epi{}(F[ 0 ], simd_zero);
\\'.format(128>>T)
+- print ' const int mask = _mm_movemask_epi8(Mask); \\'
+- print ' if (unlikely(mask)) { \\'
++ print(' const simd_t Mask = _mm_cmpeq_epi{}(F[ 0 ], simd_zero);
\\'.format(128>>T))
++ print(' const int mask = _mm_movemask_epi8(Mask); \\')
++ print(' if (unlikely(mask)) { \\')
+ else:
+- print " if (unlikely(F[ 0 ] == 0)) { \\"
+- print " solution_buffer[n_solutions_found].int_idx = i; \\"
++ print(" if (unlikely(F[ 0 ] == 0)) { \\")
++ print(" solution_buffer[n_solutions_found].int_idx = i; \\")
+ if simd:
+- print " solution_buffer[n_solutions_found].mask = mask; \\"
++ print(" solution_buffer[n_solutions_found].mask = mask; \\")
+ else:
+- print " solution_buffer[n_solutions_found].mask = 0x000f; \\"
+- print " n_solutions_found++; \\"
+- print " }\\"
+- print "}"
+- print ""
++ print(" solution_buffer[n_solutions_found].mask = 0x000f;
\\")
++ print(" n_solutions_found++; \\")
++ print(" }\\")
++ print("}")
++ print("")
+
+
+
+@@ -97,8 +97,8 @@ def b_k(k, n):
+
+
+ def gen_specialization(degree, T):
+- print ' // we want to specialize each one of the {T2} SIMD-thread to a
combination of the last {T} variables'.format(T2=1<<T,T=T)
+- print ' simd_t v[{T}];'.format(T=T)
++ print(' // we want to specialize each one of the {T2} SIMD-thread to a
combination of the last {T} variables'.format(T2=1<<T,T=T))
++ print(' simd_t v[{T}];'.format(T=T))
+ assert (T >= 2 and T <= 4)
+ size = 32 >> T
+ s = ['0'*size, 'f'*size]
+@@ -108,10 +108,10 @@ def gen_specialization(degree, T):
+ for j in range(1 << T):
+ if ((j*size)%8 == 0 and j != 0):
+ v += ',0x'
+- v += s[j%m/(m >> 1)]
++ v += s[int(j%m/(m >> 1))]
+ m = m << 1
+- print(v + ');')
+- print ''
++ print((v + ');'))
++ print('')
+
+ idx = [ "idx_{0}".format(j) for j in range(degree) ] # indices for the
loops
+ letters = [ 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'o', 'p', 'q', 'r', 's', 't'
]
+@@ -119,23 +119,23 @@ def gen_specialization(degree, T):
+ for updater_degree in range(1, degree+1):
+ for updatee_degree in range(updater_degree):
+
+- print ' // updates degree-{0} term with degree-{1}
terms'.format(updatee_degree, updater_degree)
++ print(' // updates degree-{0} term with degree-{1}
terms'.format(updatee_degree, updater_degree))
+
+ # loops over the updatee indices
+ if updatee_degree > 0:
+- print ' for(int {idx}=0; {idx}<n-{T};
{idx}++)'.format(idx=idx[updatee_degree-1], T=2)
++ print(' for(int {idx}=0; {idx}<n-{T};
{idx}++)'.format(idx=idx[updatee_degree-1], T=2))
+ for i in range(updatee_degree-2, -1, -1):
+- print '{pad}for(int {idx}=0; {idx}<{prev_idx};
{idx}++)'.format(pad=' '*(updatee_degree-i), idx=idx[i], prev_idx=idx[i+1])
++ print('{pad}for(int {idx}=0; {idx}<{prev_idx};
{idx}++)'.format(pad=' '*(updatee_degree-i), idx=idx[i], prev_idx=idx[i+1]))
+
+ # loops over the updater indices
+- print ' {pad}for(int {idx}=0; {idx}<{T};
{idx}++)'.format(idx=letters[updater_degree-updatee_degree-1], T=T, pad='
'*updatee_degree)
++ print(' {pad}for(int {idx}=0; {idx}<{T};
{idx}++)'.format(idx=letters[updater_degree-updatee_degree-1], T=T, pad='
'*updatee_degree))
+ for i in range(updater_degree-updatee_degree-1):
+- print ' {pad}for(int {idx}=0; {idx}<{prev_idx};
{idx}++)'.format(pad=' '*(updatee_degree+i+1),
idx=letters[updater_degree-updatee_degree-2-i],
prev_idx=letters[updater_degree-updatee_degree-i-1],T=T)
++ print(' {pad}for(int {idx}=0; {idx}<{prev_idx};
{idx}++)'.format(pad=' '*(updatee_degree+i+1),
idx=letters[updater_degree-updatee_degree-2-i],
prev_idx=letters[updater_degree-updatee_degree-i-1],T=T))
+ updatee = data_reference('F', idx[:updatee_degree])
+- updater = data_reference('F', idx[:updatee_degree] + map(lambda
x:"n-{T}+{x}".format(T=T,x=x), letters[:updater_degree-updatee_degree]))
+- monomial = string.join(map( lambda i:'v[{0}]'.format(i),
letters[:updater_degree-updatee_degree]), " & ")
+- print " {pad}{LHS} ^= {RHS} & ({monomial});".format(pad='
'*updater_degree, LHS=updatee, RHS=updater, monomial=monomial)
+- print ''
++ updater = data_reference('F', idx[:updatee_degree] +
["n-{T}+{x}".format(T=T,x=x) for x in letters[:updater_degree-updatee_degree]])
++ monomial = " & ".join(['v[{0}]'.format(i) for i in
letters[:updater_degree-updatee_degree]])
++ print(" {pad}{LHS} ^= {RHS} & ({monomial});".format(pad='
'*updater_degree, LHS=updatee, RHS=updater, monomial=monomial))
++ print('')
+
+
+ def gen_main_function_name(degree, simd=False, T=2, n_eliminated_derivatives=0):
+@@ -160,166 +160,166 @@ def gen_main(degree, L, unrolling=True,
+ reverse_indices = indices
+ if reverse:
+ reverse_indices.reverse()
+- lut_indices = map( lambda i: 'idx_{i}(LUT, {indices})'.format(i=i+1,
indices = string.join(reverse_indices[:i+1], ", ")), range(w))
+- print ' {pad}STEP_{w}( {indices}, {i_idx} );'.format( i_idx=i_idx,
pad=' '*w, w=w, indices=string.join(lut_indices, ", ") )
++ lut_indices = ['idx_{i}(LUT, {indices})'.format(i=i+1, indices = ",
".join(reverse_indices[:i+1])) for i in range(w)]
++ print(' {pad}STEP_{w}( {indices}, {i_idx} );'.format( i_idx=i_idx,
pad=' '*w, w=w, indices=", ".join(lut_indices) ))
+
+
+ # this has been moved to the all_functions.h (autogenerated) file
+ # if with_assembly:
+ # print 'extern void func_deg_{d}_el_{el}(__m128i *F, __m128i **F_sp, void
*buf, uint64_t *num, uint64_t idx);\n'.format(d=degree, el=n_eliminated_derivatives);
+
+- print ''
+- print 'typedef struct {'
+- print ' uint64_t int_idx;'
+- print ' uint32_t mask;'
+- print '} solution_t;'
+- print ''
++ print('')
++ print('typedef struct {')
++ print(' uint64_t int_idx;')
++ print(' uint32_t mask;')
++ print('} solution_t;')
++ print('')
+
+- print '// generated with L = {L}'.format(L=L)
+- print gen_main_function_name(degree, simd, T, n_eliminated_derivatives),
'{'
++ print('// generated with L = {L}'.format(L=L))
++ print(gen_main_function_name(degree, simd, T, n_eliminated_derivatives),
'{')
+ if simd:
+- print ' const __m128i simd_zero = _mm_setzero_si128();'
+- print ''
+- print ' // *****initialise an SIMD version of the constants and internal
state'
+- print ' const int N = n_monomials(n, {0});'.format(degree)
+- print ' simd_t * F = NULL;'
+- print ' int foo = posix_memalign((void **) &F, sizeof(simd_t),
N*sizeof(simd_t));'
+- print ' if (foo != 0 || F == NULL) {'
+- print ' perror("[fes/enumeration/simd]");'
+- print ' return;'
+- print ' }'
++ print(' const __m128i simd_zero = _mm_setzero_si128();')
++ print('')
++ print(' // *****initialise an SIMD version of the constants and internal
state')
++ print(' const int N = n_monomials(n, {0});'.format(degree))
++ print(' simd_t * F = NULL;')
++ print(' int foo = posix_memalign((void **) &F, sizeof(simd_t),
N*sizeof(simd_t));')
++ print(' if (foo != 0 || F == NULL) {')
++ print(' perror("[fes/enumeration/simd]");')
++ print(' return;')
++ print(' }')
+
+- print ' for(int i=0; i<N; i++)'
+- print ' F[i] = _mm_set1_epi{}(nonsimd_F[i]); // expand all the
coefficients into SIMD vectors'.format(128 >> T)
+- print ''
+- print ' uint64_t everything_start_time = rdtsc();'
++ print(' for(int i=0; i<N; i++)')
++ print(' F[i] = _mm_set1_epi{}(nonsimd_F[i]); // expand all the
coefficients into SIMD vectors'.format(128 >> T))
++ print('')
++ print(' uint64_t everything_start_time = rdtsc();')
+ gen_specialization(T=T, degree=degree)
+- print ' if (verbose) printf("fes: specialization = %" PRIu64
" cycles\\n", rdtsc()-everything_start_time);'
++ print(' if (verbose) printf("fes: specialization = %" PRIu64
" cycles\\n", rdtsc()-everything_start_time);')
+
+- print ' #define QUIT() { \\'
++ print(' #define QUIT() { \\')
+ if simd:
+- print ' if (F != NULL) free(F); \\'
+- print ' return; \\'
+- print ' }'
+- print ''
++ print(' if (F != NULL) free(F); \\')
++ print(' return; \\')
++ print(' }')
++ print('')
+
+- print ' uint64_t init_start_time = rdtsc();'
++ print(' uint64_t init_start_time = rdtsc();')
+ gen_init_code(degree)
+- print ' if (verbose) printf("fes: initialisation = %" PRIu64 "
cycles\\n", rdtsc()-init_start_time);'
++ print(' if (verbose) printf("fes: initialisation = %" PRIu64 "
cycles\\n", rdtsc()-init_start_time);')
+
+ size_pack_of_solution = 65536
+- print ' uint64_t enumeration_start_time = rdtsc();'
+- print ' uint64_t n_solutions_found = 0;'
+- print ' uint64_t current_solution_index = 0;'
+- print ' uint64_t pack_of_solution[{0}];'.format(size_pack_of_solution)
+- print ' solution_t solution_buffer[{0}];'.format( (1 << L) + (1
<< degree) )
+- print ''
+- print ' #define FLUSH_SOLUTIONS() { \\'
+- print ' if ((*callback)(callback_state, current_solution_index,
pack_of_solution)) \\'
+- print ' QUIT(); \\'
+- print ' }'
+- print ''
+- print ' #define PUSH_SOLUTION(current_solution) { \\'
+- print ' pack_of_solution[current_solution_index] = current_solution; \\'
+- print ' current_solution_index++; \\'
+- print ' if (current_solution_index == {0})'.format(size_pack_of_solution)
+ '{ \\'
+- print ' FLUSH_SOLUTIONS(); \\'
+- print ' current_solution_index = 0; \\'
+- print ' } \\'
+- print ' }'
+- print ''
++ print(' uint64_t enumeration_start_time = rdtsc();')
++ print(' uint64_t n_solutions_found = 0;')
++ print(' uint64_t current_solution_index = 0;')
++ print(' uint64_t pack_of_solution[{0}];'.format(size_pack_of_solution))
++ print(' solution_t solution_buffer[{0}];'.format( (1 << L) + (1
<< degree) ))
++ print('')
++ print(' #define FLUSH_SOLUTIONS() { \\')
++ print(' if ((*callback)(callback_state, current_solution_index,
pack_of_solution)) \\')
++ print(' QUIT(); \\')
++ print(' }')
++ print('')
++ print(' #define PUSH_SOLUTION(current_solution) { \\')
++ print(' pack_of_solution[current_solution_index] = current_solution;
\\')
++ print(' current_solution_index++; \\')
++ print(' if (current_solution_index == {0})'.format(size_pack_of_solution)
+ '{ \\')
++ print(' FLUSH_SOLUTIONS(); \\')
++ print(' current_solution_index = 0; \\')
++ print(' } \\')
++ print(' }')
++ print('')
+ size = 1 << (4 - T)
+ unit = (1 << size)-1
+- print ' #define CHECK_SOLUTIONS() { \\'
+- print ' for(uint64_t i=0; i<n_solutions_found; i++){ \\'
++ print(' #define CHECK_SOLUTIONS() { \\')
++ print(' for(uint64_t i=0; i<n_solutions_found; i++){ \\')
+ for i in range(1 << T):
+- print ' if (solution_buffer[i].mask & 0x{0:04x})
\\'.format(unit << size*i)
+- print ' PUSH_SOLUTION(to_gray(solution_buffer[i].int_idx) + {0}*(1ll
<< (n-{T}))); \\'.format((1 << T) - 1 - i, T=T)
+- print ' } \\'
+- print ' n_solutions_found = 0; \\'
+- print ' }'
++ print(' if (solution_buffer[i].mask & 0x{0:04x})
\\'.format(unit << size*i))
++ print(' PUSH_SOLUTION(to_gray(solution_buffer[i].int_idx) + {0}*(1ll
<< (n-{T}))); \\'.format((1 << T) - 1 - i, T=T))
++ print(' } \\')
++ print(' n_solutions_found = 0; \\')
++ print(' }')
+
+- print ''
+- print ' // special case for i=0'
+- print ' const uint64_t weight_0_start = 0;'
+- print ' STEP_0(0);'
+- print ''
+- print ' // from now on, hamming weight is >= 1'
++ print('')
++ print(' // special case for i=0')
++ print(' const uint64_t weight_0_start = 0;')
++ print(' STEP_0(0);')
++ print('')
++ print(' // from now on, hamming weight is >= 1')
+ for w in range(degree-1):
+ if w == 0:
+ if simd:
+- print ' {pad}for(int {idx}=0; {idx}<n-{T}; {idx}++)
{{'.format(pad=' '*w, idx=idx[w],T=T)
++ print(' {pad}for(int {idx}=0; {idx}<n-{T}; {idx}++)
{{'.format(pad=' '*w, idx=idx[w],T=T))
+ else:
+- print ' {pad}for(int {idx}=0; {idx}<n ; {idx}++)
{{'.format(pad=' '*w, idx=idx[w])
++ print(' {pad}for(int {idx}=0; {idx}<n ; {idx}++)
{{'.format(pad=' '*w, idx=idx[w]))
+
+ else:
+- print ' {pad}for(int {idx}=0; {idx}<{prev_idx}; {idx}++)
{{'.format(pad=' '*w, idx=idx[w], prev_idx=idx[w-1])
+- print ''
+- print ' {pad}// special case when i has hamming weight exactly
{w}'.format(pad=' '*w,w=w+1)
+- print ' {pad}const uint64_t weight_{w}_start = weight_{wm1}_start + (1ll
<< idx_{wm1});'.format(pad=' '*w, w=w+1, wm1 = w)
++ print(' {pad}for(int {idx}=0; {idx}<{prev_idx}; {idx}++)
{{'.format(pad=' '*w, idx=idx[w], prev_idx=idx[w-1]))
++ print('')
++ print(' {pad}// special case when i has hamming weight exactly
{w}'.format(pad=' '*w,w=w+1))
++ print(' {pad}const uint64_t weight_{w}_start = weight_{wm1}_start + (1ll
<< idx_{wm1});'.format(pad=' '*w, w=w+1, wm1 = w))
+ invoke_step(idx[:w+1], "weight_{w}_start".format(w=w+1),
reverse=True)
+- print ''
++ print('')
+
+- print ' {pad}// we are now inside the critical part where the hamming weight is
known to be >= {d}'.format(pad=' '*degree, d=degree)
+- print ' {pad}// Thus, there are no special cases from now
on'.format(pad=' '*degree)
+- print ''
+- print ' {pad}// Because of the last step, the current iteration counter is a
multiple of {L} plus one'.format( pad=' '*degree, L=1<<L)
+- print ' {pad}// This loop sets it to `rolled_end`, which is a multiple of {L},
if possible'.format( pad=' '*degree, L=1<<L)
+- print ''
+- print '{pad}const uint64_t rolled_end = weight_{w}_start + (1ll <<
min({L}, idx_{d}));'.format( pad=' '*degree, d=degree-2, w=degree-1,L=L )
+- print '{pad}for(uint64_t i=1 + weight_{w}_start; i< rolled_end; i++)
{{'.format( pad=' '*degree, w=degree-1 )
+- print ''
++ print(' {pad}// we are now inside the critical part where the hamming weight is
known to be >= {d}'.format(pad=' '*degree, d=degree))
++ print(' {pad}// Thus, there are no special cases from now
on'.format(pad=' '*degree))
++ print('')
++ print(' {pad}// Because of the last step, the current iteration counter is a
multiple of {L} plus one'.format( pad=' '*degree, L=1<<L))
++ print(' {pad}// This loop sets it to `rolled_end`, which is a multiple of {L},
if possible'.format( pad=' '*degree, L=1<<L))
++ print('')
++ print('{pad}const uint64_t rolled_end = weight_{w}_start + (1ll <<
min({L}, idx_{d}));'.format( pad=' '*degree, d=degree-2, w=degree-1,L=L ))
++ print('{pad}for(uint64_t i=1 + weight_{w}_start; i< rolled_end; i++)
{{'.format( pad=' '*degree, w=degree-1 ))
++ print('')
+
+ def gen_k_i_s():
+- print '{pad} int pos = 0;'.format(pad=' '*degree)
+- print '{pad} uint64_t _i = i;'.format(pad=' '*degree)
++ print('{pad} int pos = 0;'.format(pad=' '*degree))
++ print('{pad} uint64_t _i = i;'.format(pad=' '*degree))
+
+ for i in range(1, degree+1):
+- print '{pad} while ((_i & 0x0001) == 0) {{ _i >>= 1;
pos++; }}'.format( pad=' '*(degree))
+- print '{pad} const int {k} = pos;'.format( pad='
'*(degree), k=k[i] )
++ print('{pad} while ((_i & 0x0001) == 0) {{ _i >>= 1;
pos++; }}'.format( pad=' '*(degree)))
++ print('{pad} const int {k} = pos;'.format( pad='
'*(degree), k=k[i] ))
+ if i != degree:
+- print '{pad} _i >>= 1; pos++;'.format( pad='
'*(degree))
++ print('{pad} _i >>= 1; pos++;'.format( pad='
'*(degree)))
+
+
+ gen_k_i_s()
+ invoke_step(k[1:], "i")
+- print '{pad}}}'.format( pad=' '*degree )
++ print('{pad}}}'.format( pad=' '*degree ))
+
+- print ''
+- print '{pad}CHECK_SOLUTIONS();'.format( pad=' '*degree )
+- print ''
++ print('')
++ print('{pad}CHECK_SOLUTIONS();'.format( pad=' '*degree ))
++ print('')
+
+- print '{pad}// Here, the number of iterations to perform is (supposedly)
sufficiently large'.format( pad=' '*degree )
+- print '{pad}// We will therefore unroll the loop {L} times'.format(
pad=' '*degree,L=1<<L )
+- print ''
+- print '{pad}// unrolled critical section where the hamming weight is >=
{degree}'.format( pad=' '*degree, degree=degree)
+- print '{pad}for(uint64_t j={L}; j<(1ull << idx_{d}); j+={L})
{{'.format( pad=' '*degree, d=degree-2, L=1<<L )
++ print('{pad}// Here, the number of iterations to perform is (supposedly)
sufficiently large'.format( pad=' '*degree ))
++ print('{pad}// We will therefore unroll the loop {L} times'.format(
pad=' '*degree,L=1<<L ))
++ print('')
++ print('{pad}// unrolled critical section where the hamming weight is >=
{degree}'.format( pad=' '*degree, degree=degree))
++ print('{pad}for(uint64_t j={L}; j<(1ull << idx_{d}); j+={L})
{{'.format( pad=' '*degree, d=degree-2, L=1<<L ))
+
+ # this rolled version of the critical loop is known to work properly
+ # it is used for debugging
+ if not unrolling:
+- print '{pad} for(int k=0; k<{L}; k++) {{ // pretend-unroll'.format(
pad=' '*degree, L=1<<L)
+- print '{pad} const uint64_t i = j + weight_{w}_start +
k;'.format(pad=' '*degree, w=degree-1)
++ print('{pad} for(int k=0; k<{L}; k++) {{ // pretend-unroll'.format(
pad=' '*degree, L=1<<L))
++ print('{pad} const uint64_t i = j + weight_{w}_start +
k;'.format(pad=' '*degree, w=degree-1))
+ gen_k_i_s()
+ invoke_step(k[1:], "i")
+- print '{pad} }}'.format( pad=' '*degree )
++ print('{pad} }}'.format( pad=' '*degree ))
+
+ else: # this is the actual, fast, unrolled version
+- print '{pad} const uint64_t i = j +
weight_{w}_start;'.format(pad=' '*degree, w=degree-1)
++ print('{pad} const uint64_t i = j +
weight_{w}_start;'.format(pad=' '*degree, w=degree-1))
+ gen_k_i_s()
+
+ eliminated_indices = get_idx_list.get_degD_idx_list(degree, L,
n_eliminated_derivatives)
+ if eliminated_indices != []:
+- print '{pad} // this version of the code assumes that:
'.format(pad=' '*degree)
++ print('{pad} // this version of the code assumes that:
'.format(pad=' '*degree))
+ for i in eliminated_indices:
+- print '{pad} // F[ {idx} ] = 0'.format(pad='
'*degree, idx=i)
++ print('{pad} // F[ {idx} ] = 0'.format(pad='
'*degree, idx=i))
+
+ # set the "greek letters shortcuts"
+ unknown_indices = []
+ for foo in range(degree):
+ unknown_indices.append( k[foo+1] )
+ unlookable_part = [
"LUT[{tab}][{idx}]".format(tab=len(unknown_indices)-1-i, idx=unknown_indices[i])
for i in range(len(unknown_indices)) ]
+- print '{pad} const int {greek} = {stuff};'.format( pad='
'*(degree), greek=greek[i], stuff=string.join(unlookable_part,"+" ))
++ print('{pad} const int {greek} = {stuff};'.format( pad='
'*(degree), greek=greek[len(unknown_indices)-1],
stuff="+".join(unlookable_part)))
+
+ # each time a greek letter is used, the offset is increased by one. This table
stores the offsets
+ current_counter = [0] * degree
+@@ -343,90 +343,90 @@ def gen_main(degree, L, unrolling=True,
+ #outputs the step
+ if (not with_assembly) or unroll_step == 0:
+ if hw == degree and known_indices[hw-1] in eliminated_indices:
+- print '{pad} STEP_{d}({indices}, i + {k});'.format(
pad=' '*degree, d=degree-1, indices=string.join(indices[:hw-1],', '),
k=unroll_step)
++ print('{pad} STEP_{d}({indices}, i + {k});'.format(
pad=' '*degree, d=degree-1, indices=', '.join(indices[:hw-1]),
k=unroll_step))
+ else:
+- print '{pad} STEP_{d}({indices}, i + {k});'.format(
pad=' '*degree, d=degree, indices=string.join(indices,', '),
k=unroll_step)
++ print('{pad} STEP_{d}({indices}, i + {k});'.format(
pad=' '*degree, d=degree, indices=', '.join(indices), k=unroll_step))
+
+ if with_assembly:
+ # sp_list = [ 'F + ' + a for a in greek[:degree-1] ] ## known
to work
+ sp_list = [ a+'*16' for a in greek[:degree-1] ]
+- msg = '{pad} uint64_t F_sp[ {d} ] = {{ {sp}
}};'.format( pad=' '*degree, d=degree-1, sp=string.join(sp_list, ',
') )
+- print msg
+- print '{pad} func_deg_{d}_T_{T}_el_{el}(F, &F_sp[0],
solution_buffer, &n_solutions_found, i);'.format(pad=' '*degree,
d=degree, el=n_eliminated_derivatives,T=T)
++ msg = '{pad} uint64_t F_sp[ {d} ] = {{ {sp}
}};'.format( pad=' '*degree, d=degree-1, sp=', '.join(sp_list) )
++ print(msg)
++ print('{pad} func_deg_{d}_T_{T}_el_{el}(F, &F_sp[0],
solution_buffer, &n_solutions_found, i);'.format(pad=' '*degree,
d=degree, el=n_eliminated_derivatives,T=T))
+
+ # unrolling is over
+
+- print ''
+- print '{pad} CHECK_SOLUTIONS();'.format( pad=' '*degree )
+- print '{pad} }}'.format( pad=' '*degree )
+- print ''
++ print('')
++ print('{pad} CHECK_SOLUTIONS();'.format( pad=' '*degree ))
++ print('{pad} }}'.format( pad=' '*degree ))
++ print('')
+
+ ## end unrolled loop
+ for w in range(degree-1):
+- print '{pad}}}'.format( pad=' '*(degree-w-1) )
++ print('{pad}}}'.format( pad=' '*(degree-w-1) ))
+
+- print ' FLUSH_SOLUTIONS();'
+- print ' uint64_t end_time = rdtsc();'
+- print ' if (verbose) printf("fes: enumeration+check = %" PRIu64
" cycles\\n", end_time - enumeration_start_time);'
++ print(' FLUSH_SOLUTIONS();')
++ print(' uint64_t end_time = rdtsc();')
++ print(' if (verbose) printf("fes: enumeration+check = %" PRIu64 "
cycles\\n", end_time - enumeration_start_time);')
+
+- print ' QUIT();'
+- print '}'
++ print(' QUIT();')
++ print('}')
+
+
+
+ def gen_boilerplate_header(simd=False):
+- print "#include <stdio.h>"
+- print "#include <inttypes.h>"
+- print "#include <stdlib.h>"
++ print("#include <stdio.h>")
++ print("#include <inttypes.h>")
++ print("#include <stdlib.h>")
+ if simd:
+- print '#include <emmintrin.h>'
+- print 'typedef __m128i simd_t;'
+- print ''
+- print '#include "fes.h"'
+- print '#include "idx_LUT.h"'
+- print ''
++ print('#include <emmintrin.h>')
++ print('typedef __m128i simd_t;')
++ print('')
++ print('#include "fes.h"')
++ print('#include "idx_LUT.h"')
++ print('')
+
+ def gen_tester(degree):
+ idx = [ "idx_{0}".format(j) for j in range(degree+1) ] # indices for the
loop
+ vs = [ "v_{0}".format(j) for j in range(degree+1) ] # indices for the
loop
+
+- print 'pck_vector_t packed_eval_deg_{0}(LUT_t LUT, int n, pck_vector_t F[],
uint64_t i) {{'.format(degree)
+- print ' // first expand the values of the variables from `i`'
+- print ' pck_vector_t v[n];'
+- print ' for(int k=0; k<n; k++) {'
+- print ' v[k] = 0;'
+- print ' if (i & 0x0001) v[k] = 0xffffffff;'
+- print ' i = (i >> 1ll);'
+- print ' }'
+- print ''
+- print ' pck_vector_t y = F[0];'
+- print ''
+- print ' for(int {idx}=0; {idx}<n; {idx}++) {{'.format(idx=idx[0])
+- print ' const pck_vector_t {v} = v[{idx}];'.format(v=vs[0], idx=idx[0])
+- print ''
++ print('pck_vector_t packed_eval_deg_{0}(LUT_t LUT, int n, pck_vector_t F[],
uint64_t i) {{'.format(degree))
++ print(' // first expand the values of the variables from `i`')
++ print(' pck_vector_t v[n];')
++ print(' for(int k=0; k<n; k++) {')
++ print(' v[k] = 0;')
++ print(' if (i & 0x0001) v[k] = 0xffffffff;')
++ print(' i = (i >> 1ll);')
++ print(' }')
++ print('')
++ print(' pck_vector_t y = F[0];')
++ print('')
++ print(' for(int {idx}=0; {idx}<n; {idx}++) {{'.format(idx=idx[0]))
++ print(' const pck_vector_t {v} = v[{idx}];'.format(v=vs[0], idx=idx[0]))
++ print('')
+ for i in range(1,degree+1):
+- print ' {pad}// computes the contribution of degree-{i}
terms'.format(pad=' '*i, i=i)
+- print ' {pad}y ^= {coeff} & {v};'.format(pad=' '*i,
coeff=data_reference('F', list(reversed(idx[:i]))), v=vs[i-1])
+- print ''
++ print(' {pad}// computes the contribution of degree-{i}
terms'.format(pad=' '*i, i=i))
++ print(' {pad}y ^= {coeff} & {v};'.format(pad=' '*i,
coeff=data_reference('F', list(reversed(idx[:i]))), v=vs[i-1]))
++ print('')
+ if i < degree:
+- print ' {pad}for(int {idx}=0; {idx}<{prev_idx}; {idx}++)
{{'.format(pad=' '*i, idx=idx[i], prev_idx=idx[i-1])
+- print ' {pad}const pck_vector_t {v} = {prev_v} &
v[{idx}];'.format(pad=' '*i, idx=idx[i], v=vs[i], prev_v=vs[i-1])
+- print ''
+- print ' ', '}'*(degree)
+- print ''
+- print ' return y;'
+- print '}'
++ print(' {pad}for(int {idx}=0; {idx}<{prev_idx}; {idx}++)
{{'.format(pad=' '*i, idx=idx[i], prev_idx=idx[i-1]))
++ print(' {pad}const pck_vector_t {v} = {prev_v} &
v[{idx}];'.format(pad=' '*i, idx=idx[i], v=vs[i], prev_v=vs[i-1]))
++ print('')
++ print(' ', '}'*(degree))
++ print('')
++ print(' return y;')
++ print('}')
+
+
+ if len(sys.argv) < 2:
+- print "usage: enumeration_generator.py [filename]"
++ print("usage: enumeration_generator.py [filename]")
+ exit(1)
+
+
+ try:
+- filename = string.split(sys.argv[1], ".")
++ filename = sys.argv[1].split(".")
+ assert(filename[1] == 'c')
+- parts = string.split(filename[0], "_")
++ parts = filename[0].split("_")
+ assert (parts[0] == "autogenerated")
+ mode = parts[1]
+ assert (parts[2] == "deg")
+@@ -439,7 +439,7 @@ try:
+ elif mode == "c-sequential":
+ gen_boilerplate_header()
+ gen_steps(degree)
+- gen_main(degree, 10-degree/2, unrolling=True)
++ gen_main(degree, int(10-degree/2), unrolling=True)
+
+ else: # we generate the actual enumerations
+ assert (parts[4] == "T")
+@@ -451,14 +451,14 @@ try:
+ if mode == "c-simd":
+ gen_boilerplate_header(simd=True)
+ gen_steps(degree,simd=True)
+- gen_main(degree, 10-degree/2, unrolling=True, simd=True, T=T,
n_eliminated_derivatives=eliminated_terms)
++ gen_main(degree, int(10-degree/2), unrolling=True, simd=True, T=T,
n_eliminated_derivatives=eliminated_terms)
+ elif mode == "c-simd-with-asm":
+ gen_boilerplate_header(simd=True)
+ gen_steps(degree,simd=True, T=T)
+- gen_main(degree, 10-degree/2, unrolling=True, simd=True, T=T,
with_assembly=True, n_eliminated_derivatives=eliminated_terms)
++ gen_main(degree, int(10-degree/2), unrolling=True, simd=True, T=T,
with_assembly=True, n_eliminated_derivatives=eliminated_terms)
+ else:
+ raise ValueError
+
+ except ValueError:
+- print "the name of the file should follow the template
'autogenerated_[mode]_deg_[degree]_el_[number of eliminated coeffs].c'"
++ print("the name of the file should follow the template
'autogenerated_[mode]_deg_[degree]_el_[number of eliminated coeffs].c'")
+ exit(1)
+--- src/src/gen_built_sources.py.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/src/gen_built_sources.py 2019-02-06 11:37:56.394681851 -0700
+@@ -12,7 +12,7 @@ def gen_built_sources_am():
+ built_sources.append('autogenerated_c-sequential_deg_{0}.c'.format(d))
+ built_sources.append('autogenerated_c-tester_deg_{0}.c'.format(d))
+
+- print "plain_c_sources = ", string.join(built_sources, ' \\\n\t')
++ print("plain_c_sources = ", ' \\\n\t'.join(built_sources))
+
+ # C boilerplate, ASM + SIMD case
+ built_sources = []
+@@ -23,7 +23,7 @@ def gen_built_sources_am():
+ for T in [2,3,4]:
+
built_sources.append('autogenerated_c-simd-with-asm_deg_{0}_T_{1}_el_0.c'.format(d,T))
+
+- print "asm_c_sources= ", string.join(built_sources, ' \\\n\t')
++ print("asm_c_sources= ", ' \\\n\t'.join(built_sources))
+
+ # assembly code, ASM + SIMD case
+ built_sources = []
+@@ -32,36 +32,36 @@ def gen_built_sources_am():
+ for d in range(2,max_d+1):
+ for T in [2,3,4]:
+
built_sources.append('autogenerated_asm_deg_{0}_T_{1}_el_0.s'.format(d,T))
+- print "asm_sources = ", string.join(built_sources, ' \\\n\t')
++ print("asm_sources = ", ' \\\n\t'.join(built_sources))
+
+ def gen_include():
+- print '#include <inttypes.h>'
+- print '#include <emmintrin.h>'
+- print '#include "fes.h"'
+- print ''
++ print('#include <inttypes.h>')
++ print('#include <emmintrin.h>')
++ print('#include "fes.h"')
++ print('')
+
+ # plain C stuff
+ for d in range(2,max_d+1):
+- print 'void exhaustive_ia32_deg_{0}(LUT_t LUT, int n, pck_vector_t F[],
solution_callback_t callback, void* callback_state, int verbose); //
autogenerated_sequential_deg_{0}.c'.format(d)
+- print 'pck_vector_t packed_eval_deg_{0}(LUT_t LUT, int n, pck_vector_t F[],
uint64_t i); // autogenerated_tester_deg_{0}.c'.format(d)
+- print ''
++ print('void exhaustive_ia32_deg_{0}(LUT_t LUT, int n, pck_vector_t F[],
solution_callback_t callback, void* callback_state, int verbose); //
autogenerated_sequential_deg_{0}.c'.format(d))
++ print('pck_vector_t packed_eval_deg_{0}(LUT_t LUT, int n, pck_vector_t F[],
uint64_t i); // autogenerated_tester_deg_{0}.c'.format(d))
++ print('')
+
+ # SIMD stuff
+- print '#ifdef HAVE_SSE2'
++ print('#ifdef HAVE_SSE2')
+ for d in range(2,max_d+1):
+ for T in [2,3,4]:
+- print 'void exhaustive_sse2_deg_{0}_T_{1}_el_0(LUT_t LUT, int n,
pck_vector_t nonsimd_F[], solution_callback_t callback, void* callback_state, int
verbose); // autogenerated_simd_deg_{0}_T_{1}_el_0.c'.format(d,T)
++ print('void exhaustive_sse2_deg_{0}_T_{1}_el_0(LUT_t LUT, int n,
pck_vector_t nonsimd_F[], solution_callback_t callback, void* callback_state, int
verbose); // autogenerated_simd_deg_{0}_T_{1}_el_0.c'.format(d,T))
+
+
+- print '#ifdef HAVE_64_BITS'
++ print('#ifdef HAVE_64_BITS')
+ for d in range(2,max_d+1):
+ for T in [2,3,4]:
+- print 'extern void func_deg_{0}_T_{1}_el_0(__m128i *F, uint64_t *F_sp,
void *buf, uint64_t *num, uint64_t idx); //
autogenerated_asm_deg_{0}_T_{1}_el_0.s'.format(d,T)
++ print('extern void func_deg_{0}_T_{1}_el_0(__m128i *F, uint64_t *F_sp,
void *buf, uint64_t *num, uint64_t idx); //
autogenerated_asm_deg_{0}_T_{1}_el_0.s'.format(d,T))
+
+- print '#endif'
+- print '#endif'
++ print('#endif')
++ print('#endif')
+
+- print ''
++ print('')
+
+
+ if sys.argv[1] == 'built_sources.am':
+--- src/src/gen_qhasm_code.py.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/src/gen_qhasm_code.py 2019-02-06 11:38:23.290365251 -0700
+@@ -30,57 +30,57 @@ greek = [ "alpha", "beta", "gamma",
"del
+
+
+ def gen_start_asm(d, el, T):
+- print ".text"
+- print ".p2align 5"
+- print ''
+- print ".globl _func_deg_{0}_T_{1}_el_{2}".format(d, T, el)
+- print ".globl func_deg_{0}_T_{1}_el_{2}".format(d, T, el)
+- print '### void func_deg_{0}_T_{1}_el_{2}(__m128i *F, __m128i **F_sp, void *buf,
uint64_t *num, uint64_t idx);'.format(d, T, el)
+- print ''
+- print '# the ABI (
http://www.x86-64.org/documentation/abi.pdf) says that...'
+- print '# A) we should preserve the values of %rbx, %rbp, %r12...%r15
[callee-save registers]'
+- print '# B) We will receive the arguments of the function in registers :'
+- print '# the pointer to F should be in %rdi'
+- print '# the pointer to *F_sp should be in %rsi'
+- print '# the pointer to buf should be in %rdx'
+- print '# the pointer to num should be in %rcx'
+- print '# idx should be in %r8'
+- print ''
+- print "_func_deg_{0}_T_{1}_el_{2}:".format(d, T, el)
+- print "func_deg_{0}_T_{1}_el_{2}:".format(d, T, el)
+- print ''
+- print '# intialize our stack frame'
+- print "mov %rsp, %r11"
+- print "and $31, %r11"
+- print "add $64, %r11"
+- print "sub %r11, %rsp"
+- print ''
+- print '# save the callee-save registers'
+- print "movq %r11, 0(%rsp)" # apparently useless ?
+- print "movq %r12, 8(%rsp)"
+- print "movq %r13, 16(%rsp)"
+- print "movq %r14, 24(%rsp)"
+- print "movq %r15, 32(%rsp)"
+- print "movq %rbx, 40(%rsp)"
+- print "movq %rbp, 48(%rsp)"
++ print(".text")
++ print(".p2align 5")
++ print('')
++ print(".globl _func_deg_{0}_T_{1}_el_{2}".format(d, T, el))
++ print(".globl func_deg_{0}_T_{1}_el_{2}".format(d, T, el))
++ print('### void func_deg_{0}_T_{1}_el_{2}(__m128i *F, __m128i **F_sp, void *buf,
uint64_t *num, uint64_t idx);'.format(d, T, el))
++ print('')
++ print('# the ABI (
http://www.x86-64.org/documentation/abi.pdf) says
that...')
++ print('# A) we should preserve the values of %rbx, %rbp, %r12...%r15
[callee-save registers]')
++ print('# B) We will receive the arguments of the function in registers :')
++ print('# the pointer to F should be in %rdi')
++ print('# the pointer to *F_sp should be in %rsi')
++ print('# the pointer to buf should be in %rdx')
++ print('# the pointer to num should be in %rcx')
++ print('# idx should be in %r8')
++ print('')
++ print("_func_deg_{0}_T_{1}_el_{2}:".format(d, T, el))
++ print("func_deg_{0}_T_{1}_el_{2}:".format(d, T, el))
++ print('')
++ print('# intialize our stack frame')
++ print("mov %rsp, %r11")
++ print("and $31, %r11")
++ print("add $64, %r11")
++ print("sub %r11, %rsp")
++ print('')
++ print('# save the callee-save registers')
++ print("movq %r11, 0(%rsp)") # apparently useless ?
++ print("movq %r12, 8(%rsp)")
++ print("movq %r13, 16(%rsp)")
++ print("movq %r14, 24(%rsp)")
++ print("movq %r15, 32(%rsp)")
++ print("movq %rbx, 40(%rsp)")
++ print("movq %rbp, 48(%rsp)")
+
+ def gen_end_asm():
+- print '# restore the callee-save registers'
+- print "movq 0(%rsp),%r11"
+- print "movq 8(%rsp),%r12"
+- print "movq 16(%rsp),%r13"
+- print "movq 24(%rsp),%r14"
+- print "movq 32(%rsp),%r15"
+- print "movq 40(%rsp),%rbx"
+- print "movq 48(%rsp),%rbp"
+- print ''
+- print '# restore the stack frame'
+- print "add %r11,%rsp"
+- print ''
+- print '# prepare the return value (?!?)'
+- print 'mov %rdi,%rax' # <---- if I understand correctly, this is
useless, because %rdi is not callee-save, and the return type is void
+- print 'mov %rsi,%rdx' # <---- if I understand correctly, this is
useless, because %rsi is not callee-save, and the return type is void
+- print 'ret'
++ print('# restore the callee-save registers')
++ print("movq 0(%rsp),%r11")
++ print("movq 8(%rsp),%r12")
++ print("movq 16(%rsp),%r13")
++ print("movq 24(%rsp),%r14")
++ print("movq 32(%rsp),%r15")
++ print("movq 40(%rsp),%rbx")
++ print("movq 48(%rsp),%rbp")
++ print('')
++ print('# restore the stack frame')
++ print("add %r11,%rsp")
++ print('')
++ print('# prepare the return value (?!?)')
++ print('mov %rdi,%rax') # <---- if I understand correctly, this is
useless, because %rdi is not callee-save, and the return type is void
++ print('mov %rsi,%rdx') # <---- if I understand correctly, this is
useless, because %rsi is not callee-save, and the return type is void
++ print('ret')
+
+ varMap = {} # mapping from variable names to registers
+
+@@ -96,22 +96,22 @@ regs32 = [ '%edi', '%esi', '%edx', '%ecx
+ def dec_xmm(var):
+ global xmms_ptr
+ assert(xmms_ptr < len(xmms))
+- assert(var not in varMap.keys())
++ assert(var not in list(varMap.keys()))
+ varMap[var] = xmms[ xmms_ptr ]
+ xmms_ptr += 1
+- print "# variable {0} maps to {1}".format(var, varMap[var])
++ print("# variable {0} maps to {1}".format(var, varMap[var]))
+
+ def dec_reg(var, bits=64):
+ global regs_ptr
+ assert(regs_ptr < len(regs))
+- assert(var not in varMap.keys())
++ assert(var not in list(varMap.keys()))
+ assert(bits == 64 or bits == 32)
+ if bits == 64:
+ varMap[var] = regs[ regs_ptr ]
+ else:
+ varMap[var] = regs32[ regs_ptr ]
+ regs_ptr += 1
+- print "# variable {0} maps to {1}".format(var, varMap[var])
++ print("# variable {0} maps to {1}".format(var, varMap[var]))
+
+
+
+@@ -145,23 +145,23 @@ def gen_asm(degree, L, el, T):
+
+ ############################# INIT #########################################
+
+- print ''
+- print "# load the most-frequently used derivatives (F[0]...F[13]) into %xmm
registers"
++ print('')
++ print("# load the most-frequently used derivatives (F[0]...F[13]) into %xmm
registers")
+ for i in mfu_indices:
+- print ("movdqa {0}({1}), {2} ## {2} = F[{3}]".format(i*16,
varMap['F'], varMap['F',i], i))
++ print(("movdqa {0}({1}), {2} ## {2} = F[{3}]".format(i*16,
varMap['F'], varMap['F',i], i)))
+
+- print ''
+- print '# loads the ''greek letters'', i.e. indices of the
derivatives that do not fit into registers'
++ print('')
++ print('# loads the ''greek letters'', i.e. indices of the
derivatives that do not fit into registers')
+ for i in range(degree-1):
+- print 'movq {0}({1}), {2} ## {2} = {3}'.format(i*8,
varMap['F_sp'], varMap[greek[i]], greek[i])
++ print('movq {0}({1}), {2} ## {2} = {3}'.format(i*8,
varMap['F_sp'], varMap[greek[i]], greek[i]))
+
+- print ''
+- print '# note that at this point, the register holding `F_sp` [',
varMap['F_sp'], '] could be used for something else'
+- print ''
++ print('')
++ print('# note that at this point, the register holding `F_sp` [',
varMap['F_sp'], '] could be used for something else')
++ print('')
+
+- print '# initialize the last things that remains to be intialized...'
+- print 'movq ({0}), {1} ## num = *num_ptr'.format(varMap[ 'num_ptr'
], varMap[ 'num' ])
+- print 'pxor {0}, {0} ## zero = 0'.format(varMap['zero'])
++ print('# initialize the last things that remains to be intialized...')
++ print('movq ({0}), {1} ## num = *num_ptr'.format(varMap[ 'num_ptr'
], varMap[ 'num' ]))
++ print('pxor {0}, {0} ## zero = 0'.format(varMap['zero']))
+
+
+
+@@ -172,13 +172,13 @@ def gen_asm(degree, L, el, T):
+ current_counter = [1] * degree
+
+ #this actually unrols the loop
+- print ''
++ print('')
+ for unroll_step in range(1, 1 << L):
+
+
+ hw = min( degree, popcount(unroll_step) )
+- print ''
+- print '##### step {0} [hw={1}]'.format(unroll_step, hw)
++ print('')
++ print('##### step {0} [hw={1}]'.format(unroll_step, hw))
+
+ # computes the set of indices for this step
+ # the first `hw` ones can be determined at compile-time (i.e.
b_k(unroll_step) is defined for k<=hw),
+@@ -213,7 +213,7 @@ def gen_asm(degree, L, el, T):
+
+ # now, if the degree-d derivative has been cancelled, we stop considering
it.
+ if hw >= degree and indices[degree][0] in cancelled_indices:
+- print '##### taking advantage of the fact that F[ {0} ] is known to
be zero'.format( indices[degree][0] )
++ print('##### taking advantage of the fact that F[ {0} ] is known to
be zero'.format( indices[degree][0] ))
+ indices.pop()
+
+ # decorate the assembly code, print summary of the step
+@@ -223,7 +223,7 @@ def gen_asm(degree, L, el, T):
+ stuff.append( '{0}[ {1} + {2} ]'.format(X, Y, i) )
+ else:
+ stuff.append( '{0}[ {1} ]'.format(X, i) )
+- print '##### {0}{1}'.format( string.join(stuff, ' ^= ( '),
')'*(degree+1) )
++ print('##### {0}{1}'.format( ' ^= ( '.join(stuff),
')'*(degree+1) ))
+
+ # know, we start worrying about the implementation of the unformal statement
we just printed
+
+@@ -235,7 +235,7 @@ def gen_asm(degree, L, el, T):
+ locations[ i ] = 'reg'
+
+ # we actually print the XORs
+- print ''
++ print('')
+ for i in range(len(indices)-2, -1,-1):
+
+ first_xor = (i == len(indices)-2) # first XOR of the step ?
+@@ -251,45 +251,45 @@ def gen_asm(degree, L, el, T):
+
+ # reg ^= reg
+ if locations[source] == 'reg':
+- print 'pxor {0}, {1}'.format(varMap['F',
source_offset], varMap['F', target_offset])
++ print('pxor {0}, {1}'.format(varMap['F',
source_offset], varMap['F', target_offset]))
+
+ #reg ^= mem
+ elif locations[target] == 'reg':
+ if first_xor:
+ # no need to fire up the `sum` machinery, because there is a
single XOR from memory
+- print 'pxor {0},
{1}'.format(mem_reference(indices[source]), varMap['F', target_offset])
++ print('pxor {0},
{1}'.format(mem_reference(indices[source]), varMap['F', target_offset]))
+
+ else:
+- print 'pxor {0}, {1}'.format(varMap['sum'],
varMap['F', target_offset] )
++ print('pxor {0}, {1}'.format(varMap['sum'],
varMap['F', target_offset] ))
+
+ # mem ^= mem
+ else:
+ if first_xor:
+ # initialize the `sum` register
+- print ('movdqa {0},
{1}'.format(mem_reference(indices[source]), varMap['sum']));
++ print(('movdqa {0},
{1}'.format(mem_reference(indices[source]), varMap['sum'])));
+
+ # implicitly, `sum` already contains the "source"
+- print 'pxor {0}, {1}'.format( mem_reference(
indices[target]), varMap['sum'] )
+- print 'movdqa {0}, {1}'.format( varMap['sum'],
mem_reference( indices[target] ))
++ print('pxor {0}, {1}'.format( mem_reference(
indices[target]), varMap['sum'] ))
++ print('movdqa {0}, {1}'.format( varMap['sum'],
mem_reference( indices[target] )))
+
+
+ # after the XORs, the comparison
+
+ if (T == 2):
+- print 'pcmpeqd {0}, {1}'.format(varMap['F',0],
varMap['zero'])
++ print('pcmpeqd {0}, {1}'.format(varMap['F',0],
varMap['zero']))
+ elif(T == 3):
+- print 'pcmpeqw {0}, {1}'.format(varMap['F',0],
varMap['zero'])
++ print('pcmpeqw {0}, {1}'.format(varMap['F',0],
varMap['zero']))
+ elif (T == 4):
+- print 'pcmpeqb {0}, {1}'.format(varMap['F',0],
varMap['zero'])
+- print 'pmovmskb {0}, {1}'.format(varMap['zero'],
varMap['mask']) ########## MODIFY MODIFY MODIFY ####
+- print 'test {0}, {0}'.format(varMap['mask'])
+- print 'jne ._report_solution_{0}'.format(unroll_step)
+- print '._step_{0}_end:'.format(unroll_step)
++ print('pcmpeqb {0}, {1}'.format(varMap['F',0],
varMap['zero']))
++ print('pmovmskb {0}, {1}'.format(varMap['zero'],
varMap['mask'])) ########## MODIFY MODIFY MODIFY ####
++ print('test {0}, {0}'.format(varMap['mask']))
++ print('jne ._report_solution_{0}'.format(unroll_step))
++ print('._step_{0}_end:'.format(unroll_step))
+
+
+- print '#############################'
+- print '# end of the unrolled chunk #'
+- print '#############################'
++ print('#############################')
++ print('# end of the unrolled chunk #')
++ print('#############################')
+
+
+ print ('jmp ._ending')
+@@ -300,43 +300,43 @@ def gen_asm(degree, L, el, T):
+
+ ########################## WHEN SOLUTION FOUND
#######################################
+
+- print '########### now the code that reports solutions'
++ print('########### now the code that reports solutions')
+ for i in range(1, (1<<L)):
+
+- print '# here, it has been found that GrayCode(idx+{0}) is a
solution'.format(i)
++ print('# here, it has been found that GrayCode(idx+{0}) is a
solution'.format(i))
+
+- print '._report_solution_{0}:'.format(i)
+- print 'pxor {0}, {0}'.format(varMap['zero']) #zero = 0
+- print 'shl $4, {0}'.format(varMap['num']) #num <<=
4";
+- print 'mov {0}, {1}'.format(varMap['idx'],
varMap['tmp']) #tmp = idx;
+- print 'add ${0}, {1}'.format(i, varMap['tmp']) #tmp +=
i
+- print 'movq {0}, ({1}, {2})'.format(varMap['tmp'],
varMap['buf'], varMap['num']) # buf[num].idx = tmp
+- print 'add $8, {0}'.format(varMap['num']) #num += 8
+- print 'movl {0}, ({1}, {2})'.format(varMap['mask'],
varMap['buf'], varMap['num']) #buf[num].mask = mask
+- print 'shr $4, {0}'.format(varMap['num']) #num >>= 4
+- print 'add $1, {0}'.format(varMap['num']) #num += 1
+- print 'jmp ._step_{0}_end'.format(i) # we return to the enumeration
+- print ''
++ print('._report_solution_{0}:'.format(i))
++ print('pxor {0}, {0}'.format(varMap['zero'])) #zero = 0
++ print('shl $4, {0}'.format(varMap['num'])) #num <<=
4";
++ print('mov {0}, {1}'.format(varMap['idx'],
varMap['tmp'])) #tmp = idx;
++ print('add ${0}, {1}'.format(i, varMap['tmp'])) #tmp +=
i
++ print('movq {0}, ({1}, {2})'.format(varMap['tmp'],
varMap['buf'], varMap['num'])) # buf[num].idx = tmp
++ print('add $8, {0}'.format(varMap['num'])) #num += 8
++ print('movl {0}, ({1}, {2})'.format(varMap['mask'],
varMap['buf'], varMap['num'])) #buf[num].mask = mask
++ print('shr $4, {0}'.format(varMap['num'])) #num >>= 4
++ print('add $1, {0}'.format(varMap['num'])) #num += 1
++ print('jmp ._step_{0}_end'.format(i)) # we return to the enumeration
++ print('')
+
+ ################### End of the function #########################"
+- print "._ending:\n";
++ print("._ending:\n")
+
+- print ''
+- print '# copy back to memory the (most-frequently used) derivatives that were
held in registers'
++ print('')
++ print('# copy back to memory the (most-frequently used) derivatives that were
held in registers')
+ for i in mfu_indices:
+- print 'movdqa {0}, {1}({2})'.format(varMap['F', i], i*16,
varMap['F'])
++ print('movdqa {0}, {1}({2})'.format(varMap['F', i], i*16,
varMap['F']))
+
+- print ''
+- print '# store the number of solutions found in this chunk'
+- print 'movq {0}, 0({1})'.format(varMap['num'],
varMap['num_ptr'])
+- print ''
++ print('')
++ print('# store the number of solutions found in this chunk')
++ print('movq {0}, 0({1})'.format(varMap['num'],
varMap['num_ptr']))
++ print('')
+
+
+ ################### Execute ########################
+
+-filename = string.split(sys.argv[1], ".")
++filename = sys.argv[1].split(".")
+ assert(filename[1] == 's')
+-parts = string.split(filename[0], "_")
++parts = filename[0].split("_")
+ assert (parts[0] == "autogenerated")
+ assert (parts[1] == 'asm')
+ assert (parts[2] == "deg")
+@@ -349,5 +349,5 @@ el = int( parts[7] )
+ assert(T >= 2 and T <= 4)
+
+ gen_start_asm(d, el, T)
+-gen_asm(d, 10-d/2, el, T)
++gen_asm(d, int(10-d/2), el, T)
+ gen_end_asm()
+--- src/src/plop.py.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/src/plop.py 2019-02-06 11:34:58.315778133 -0700
+@@ -1,13 +1,13 @@
+ import time
+ import string
+
+-n = int( raw_input() )
++n = int( input() )
+ debut = []
+ fin = []
+ conferences = [True] * n
+
+ for i in range(n):
+- date_debut, duree = string.split( raw_input(), ";" )
++ date_debut, duree = input().split( ";" )
+ ts = time.mktime( time.strptime( date_debut, "%Y-%m-%d") )
+ debut.append( (ts, i) )
+ fin.append( (ts + 86400*int(duree), i) )
+@@ -27,4 +27,4 @@ try:
+ while not conferences[conf]:
+ now,conf = fin.pop()
+ except IndexError:
+- print N
++ print(N)
+--- src/test/test_suite.py.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/test/test_suite.py 2019-02-06 11:54:15.199910019 -0700
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/python3
+
+ from subprocess import check_output
+
+@@ -32,15 +32,15 @@ def run_test(program, idx, random_seed=N
+ numeric_args = list(idx) + [0, random_seed]
+ if T != None:
+ numeric_args.append(T)
+- args = [program] + map(lambda x:"{0}".format(x), numeric_args)
+- print " ---> ", " ".join(args)
+- program_output = check_output(args)
++ args = [program] + ["{0}".format(x) for x in numeric_args]
++ print(" ---> ", " ".join(args))
++ program_output = check_output(args).decode('utf-8')
+ values = { int(line,16) for line in program_output.split("\n") if line !=
"" }
+ if values != output[idx]:
+- print "TEST FAILED: {0} {1}".format(program, idx)
++ print("TEST FAILED: {0} {1}".format(program, idx))
+ exit(1)
+
+-print "*) NAIVE algorithm"
++print("*) NAIVE algorithm")
+ run_test("./semislow", (19,16,2))
+ run_test("./semislow", (17,15,3))
+ run_test("./semislow", (16,13,4))
+@@ -53,7 +53,7 @@ run_test("./semislow", (14,11,6))
+ #run_test("./semislow_specialize", ["15", "12",
"5"], (15,12,5))
+ #run_test("./semislow_specialize", ["14", "11",
"6"], (14,11,6))
+
+-print "*) C code"
++print("*) C code")
+ run_test("./fast", (19,16,2))
+ run_test("./fast", (17,15,3))
+ run_test("./fast", (16,13,4))
+@@ -66,14 +66,14 @@ run_test("./fast", (14,11,6))
+ #run_test("./simd", (15,12,5))
+ #run_test("./simd", (14,11,6))
+
+-print "*) SIMD, T=2"
++print("*) SIMD, T=2")
+ run_test("./simd", (19,16,2),T=2)
+ run_test("./simd", (17,15,3),T=2)
+ run_test("./simd", (16,13,4),T=2)
+ run_test("./simd", (15,12,5),T=2)
+ run_test("./simd", (14,11,6),T=2)
+
+-print "*) SIMD, T=3"
++print("*) SIMD, T=3")
+ run_test("./simd", (19,16,2),T=3)
+ run_test("./simd", (17,15,3),T=3)
+ run_test("./simd", (16,13,4),T=3)
+@@ -92,12 +92,12 @@ run_test("./simd", (14,11,6),T=3)
+ # run_test("./simd_el", (16,13,4,2))
+ # run_test("./simd_el", (16,13,4,8))
+
+-print "*) MOEBIUS inversion"
++print("*) MOEBIUS inversion")
+ run_test("./moebius", (19,16,2))
+ run_test("./moebius", (17,15,3))
+ run_test("./moebius", (16,13,4))
+ run_test("./moebius", (15,12,5))
+ run_test("./moebius", (14,11,6))
+
+-print ""
+-print "ALL TEST PASSED"
++print("")
++print("ALL TEST PASSED")
diff --git a/fes-undef.patch b/fes-undef.patch
new file mode 100644
index 0000000..1b63ef6
--- /dev/null
+++ b/fes-undef.patch
@@ -0,0 +1,157 @@
+--- src/src/wrapper.c.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/src/wrapper.c 2019-02-06 12:38:46.480652890 -0700
+@@ -249,6 +249,7 @@ void enumeration_wrapper(LUT_t LUT, int
+ if (verbose) printf("fes: Using SIMD code (sse2 instructions
available)\n");
+ if (T == 2){
+ switch (d) {
++#if defined(HAVE_SSE2) && defined(HAVE_64_BITS)
+ case 2: exhaustive_sse2_deg_2_T_2_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 3: exhaustive_sse2_deg_3_T_2_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 4: exhaustive_sse2_deg_4_T_2_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+@@ -257,12 +258,14 @@ void enumeration_wrapper(LUT_t LUT, int
+ case 7: exhaustive_sse2_deg_7_T_2_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 8: exhaustive_sse2_deg_8_T_2_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 9: exhaustive_sse2_deg_9_T_2_el_0(LUT, n, F, callback, callback_state,
verbose); break;
++#endif
+ default:
+ assert(0);
+ }
+ }
+ else if (T == 3){
+ switch (d) {
++#if defined(HAVE_SSE2) && defined(HAVE_64_BITS)
+ case 2: exhaustive_sse2_deg_2_T_3_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 3: exhaustive_sse2_deg_3_T_3_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 4: exhaustive_sse2_deg_4_T_3_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+@@ -271,12 +274,14 @@ void enumeration_wrapper(LUT_t LUT, int
+ case 7: exhaustive_sse2_deg_7_T_3_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 8: exhaustive_sse2_deg_8_T_3_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 9: exhaustive_sse2_deg_9_T_3_el_0(LUT, n, F, callback, callback_state,
verbose); break;
++#endif
+ default:
+ assert(0);
+ }
+ }
+ else if (T == 4){
+ switch (d) {
++#if defined(HAVE_SSE2) && defined(HAVE_64_BITS)
+ case 2: exhaustive_sse2_deg_2_T_4_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 3: exhaustive_sse2_deg_3_T_4_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 4: exhaustive_sse2_deg_4_T_4_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+@@ -285,6 +290,7 @@ void enumeration_wrapper(LUT_t LUT, int
+ case 7: exhaustive_sse2_deg_7_T_4_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 8: exhaustive_sse2_deg_8_T_4_el_0(LUT, n, F, callback, callback_state,
verbose); break;
+ case 9: exhaustive_sse2_deg_9_T_4_el_0(LUT, n, F, callback, callback_state,
verbose); break;
++#endif
+ default:
+ assert(0);
+ }
+--- src/test/simd.c.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/test/simd.c 2019-02-06 14:18:36.051463809 -0700
+@@ -31,7 +31,9 @@ int main(int argc, char **argv) {
+ int degree = 2;
+ int verbose = 0;
+ unsigned long random_seed = 1;
++#if defined(HAVE_SSE2) && defined(HAVE_64_BITS)
+ int T = 2;
++#endif
+
+ if (argc > 1) {
+ n = atoi(argv[1]);
+@@ -41,7 +43,9 @@ int main(int argc, char **argv) {
+ }
+
+ if (argc > 5) { random_seed = atoi(argv[5]);}
++#if defined(HAVE_SSE2) && defined(HAVE_64_BITS)
+ if (argc > 6) T = atoi(argv[6]);
++#endif
+
+ if (n > 64 || n_eqs > 32) {
+ printf("This hack can only handle up to 64 vars and 32 equations\n");
+@@ -67,6 +71,7 @@ int main(int argc, char **argv) {
+ uint64_t start = rdtsc();
+
+ switch (degree) {
++#if defined(HAVE_SSE2) && defined(HAVE_64_BITS)
+ case 2:
+ switch (T) {
+ case 2: exhaustive_sse2_deg_2_T_2_el_0(LUT, n, F, &report_solution, NULL,
verbose); break;
+@@ -115,6 +120,24 @@ int main(int argc, char **argv) {
+ case 3: exhaustive_sse2_deg_9_T_3_el_0(LUT, n, F, &report_solution, NULL,
verbose); break;
+ case 4: exhaustive_sse2_deg_9_T_4_el_0(LUT, n, F, &report_solution, NULL,
verbose); break;
+ } break;
++#else
++ case 2:
++ exhaustive_ia32_deg_2(LUT, n, F, &report_solution, NULL, verbose); break;
++ case 3 :
++ exhaustive_ia32_deg_3(LUT, n, F, &report_solution, NULL, verbose); break;
++ case 4 :
++ exhaustive_ia32_deg_4(LUT, n, F, &report_solution, NULL, verbose); break;
++ case 5 :
++ exhaustive_ia32_deg_5(LUT, n, F, &report_solution, NULL, verbose); break;
++ case 6 :
++ exhaustive_ia32_deg_6(LUT, n, F, &report_solution, NULL, verbose); break;
++ case 7 :
++ exhaustive_ia32_deg_7(LUT, n, F, &report_solution, NULL, verbose); break;
++ case 8 :
++ exhaustive_ia32_deg_8(LUT, n, F, &report_solution, NULL, verbose); break;
++ case 9 :
++ exhaustive_ia32_deg_9(LUT, n, F, &report_solution, NULL, verbose); break;
++#endif
+ default:
+ printf("enumeration in degree %d is not yet implemented\n", degree);
+ exit(0);
+--- src/test/simd_el.c.orig 2013-09-18 02:06:55.000000000 -0600
++++ src/test/simd_el.c 2019-02-06 13:33:28.242736845 -0700
+@@ -25,6 +25,7 @@ typedef void (*enumeration_t)(LUT_t, int
+
+
+ enumeration_t solvers[32] = {
++#if defined(HAVE_SSE2) && defined(HAVE_64_BITS)
+ exhaustive_sse2_deg_2_el_0,
+ exhaustive_sse2_deg_2_el_1,
+ exhaustive_sse2_deg_2_el_2,
+@@ -56,7 +57,42 @@ enumeration_t solvers[32] = {
+ exhaustive_sse2_deg_2_el_28,
+ exhaustive_sse2_deg_2_el_29,
+ exhaustive_sse2_deg_2_el_30,
+- exhaustive_sse2_deg_2_el_31};
++ exhaustive_sse2_deg_2_el_31
++#else
++ exhaustive_ia32_deg_2_el_0,
++ exhaustive_ia32_deg_2_el_1,
++ exhaustive_ia32_deg_2_el_2,
++ exhaustive_ia32_deg_2_el_3,
++ exhaustive_ia32_deg_2_el_4,
++ exhaustive_ia32_deg_2_el_5,
++ exhaustive_ia32_deg_2_el_6,
++ exhaustive_ia32_deg_2_el_7,
++ exhaustive_ia32_deg_2_el_8,
++ exhaustive_ia32_deg_2_el_9,
++ exhaustive_ia32_deg_2_el_10,
++ exhaustive_ia32_deg_2_el_11,
++ exhaustive_ia32_deg_2_el_12,
++ exhaustive_ia32_deg_2_el_13,
++ exhaustive_ia32_deg_2_el_14,
++ exhaustive_ia32_deg_2_el_15,
++ exhaustive_ia32_deg_2_el_16,
++ exhaustive_ia32_deg_2_el_17,
++ exhaustive_ia32_deg_2_el_18,
++ exhaustive_ia32_deg_2_el_19,
++ exhaustive_ia32_deg_2_el_20,
++ exhaustive_ia32_deg_2_el_21,
++ exhaustive_ia32_deg_2_el_22,
++ exhaustive_ia32_deg_2_el_23,
++ exhaustive_ia32_deg_2_el_24,
++ exhaustive_ia32_deg_2_el_25,
++ exhaustive_ia32_deg_2_el_26,
++ exhaustive_ia32_deg_2_el_27,
++ exhaustive_ia32_deg_2_el_28,
++ exhaustive_ia32_deg_2_el_29,
++ exhaustive_ia32_deg_2_el_30,
++ exhaustive_ia32_deg_2_el_31
++#endif
++};
+
+
+ int report_solution(void *state, uint64_t i) {
diff --git a/fes.spec b/fes.spec
index 11f4d66..c67e121 100644
--- a/fes.spec
+++ b/fes.spec
@@ -1,19 +1,30 @@
-#
http://trac.sagemath.org/sage_trac/ticket/13162
-
Name: fes
-Version: 0.1
-Release: 16%{?dist}
-License: GPLv3+
+Version: 0.2
+Release: 1%{?dist}
+License: GPLv2+
Summary: Fast Exhaustive Search
-URL:
http://www.lifl.fr/~bouillag
-Source0:
http://www.lifl.fr/~bouillag/download/fes-0.1.spkg
-ExclusiveArch: x86_64
-BuildRequires: autoconf
-BuildRequires: automake
+URL:
http://www.lifl.fr/~bouillag/fes/
+Source0:
https://bitbucket.org/fes/fes/downloads/%{name}-%{version}.spkg
+# Fix various problems with the configure script and configuration headers
+# 1. @VARIABLE@ expressions are not replaced in src/config.h
+# 2. The Fedora optimization flag is overridden with -O3
+# 3. -Werror causes build failures
+# 4. -msse3 is added to the command line if the build CPU has SSE3 support
+# 5. HAVE_SSE2 and HAVE_64_BITS are defined on all architectures
+Patch0: %{name}-configure.patch
+# Update the python code from python2 to python3
+Patch1: %{name}-python3.patch
+# Remove an extraneous "const"
+Patch2: %{name}-const.patch
+# Remove references to undefined symbols on non-x86_64
+Patch3: %{name}-undef.patch
+
+BuildRequires: gcc
BuildRequires: libtool
-BuildRequires: python2
-BuildRequires: texlive-collection-science
-Patch0: %{name}-dynamic.patch
+BuildRequires: python3-devel
+BuildRequires: tex(latex)
+BuildRequires: tex(aeguill.sty)
+BuildRequires: tex(algpseudocode.sty)
%description
This external library implements an efficient implement of exhaustive
@@ -32,22 +43,31 @@ This package contains the header files and development documentation
for %{name}.
%prep
-%setup -q
-%patch0 -p1
+%autosetup -p0
pushd src
- # Correct FTBFS in rawhide
- sed -e 's/ -Werror//' -i configure.ac
- autoreconf -ifs
+ # Remove prebuilt objects
+ rm src/{a.out,autogenerated*,print,toto,*.pyc} doc/doc.{aux,log,pdf}
+
+ # Regenerate the configure script due to the changes in patch0
+ autoreconf -fi .
popd
%build
pushd src
export CCASFLAGS="%{optflags} -Wa,--noexecstack"
- %configure --disable-static --enable-dynamic
+ export PYTHON=%{__python3}
+ %configure \
+%ifnarch %{ix86} x86_64
+ --disable-sse2 \
+%endif
+ --disable-static --enable-dynamic
+
make %{?_smp_mflags}
+
pushd doc
pdflatex doc.tex
+ pdflatex doc.tex
popd
popd
@@ -56,15 +76,7 @@ make install DESTDIR=%{buildroot} -C src
rm %{buildroot}%{_libdir}/libfes.la
%check
-pushd src
- chmod +x test/test_suite.py
- make check
-%if 0%{?fedora} > 18
- cat test/test_suite.py.log
-%endif
-popd
-
-%ldconfig_scriptlets
+make -C src check
%files
%doc src/AUTHORS
@@ -78,6 +90,17 @@ popd
%{_libdir}/libfes.so
%changelog
+* Wed Feb 6 2019 Jerry James <loganjerry(a)gmail.com> - 0.2-1
+- New upstream version, fixes FTBFS (bz 1603963, 1674882)
+- Correct license from GPLv3+ to GPLv2+
+- Drop upstreamed -dynamic patch
+- Add -configure patch to fix multiple configuration problems
+- Add -python3 patch due to python2 removal in Rawhide
+- Add -const patch to fix warnings
+- Add -undef patch to fix the build on non-x86_64 arches
+- Drop ExclusiveArch as the SSE2 code is now optional
+- Reduce texlive BRs
+
* Thu Jan 31 2019 Fedora Release Engineering <releng(a)fedoraproject.org> - 0.1-16
- Rebuilt for
https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
diff --git a/sources b/sources
index e69de29..1e72dd1 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+SHA512 (fes-0.2.spkg) =
df18f12e868f4e4f7ed228584bf7ea1c13e6c51971d166756b9963fd9761f57db6865881bb87cece183245a24b18496c8b106e8bf8c04cf130038cf4c6fb6cc9