Commit 8f931983 authored by Emmanuel Thomé's avatar Emmanuel Thomé

refresh mpfq for 2.2

parent f50099fd
......@@ -107,9 +107,9 @@ static inline void dotprod_64K_128(
for(unsigned int k = 0 ; k < K ; k++) {
uint64_t a = *u++;
for (unsigned int j = 0; j < 64; j += 2) {
*sw = _mm_xor_si128(*sw, mb[a & 3][0]);
_mm_storeu_si128(sw, _mm_xor_si128(_mm_loadu_si128(sw), mb[a & 3][0]));
sw ++;
*sw = _mm_xor_si128(*sw, mb[a & 3][1]);
_mm_storeu_si128(sw, _mm_xor_si128(_mm_loadu_si128(sw), mb[a & 3][1]));
sw ++;
a >>= 2;
}
......@@ -187,7 +187,6 @@ static inline void dotprod_64K_64L(
*/
#if defined(HAVE_SSE2) && GMP_LIMB_BITS == 64
#include <emmintrin.h>
#endif
static inline void vaddmul_tiny_64K_64L(
uint64_t * w,
const uint64_t * u,
......@@ -200,12 +199,10 @@ static inline void vaddmul_tiny_64K_64L(
/* We'll read and write rows two at a time. So we maintain two
* pointers for each, interlaced. */
uint64_t * u0 = (uint64_t *) u;
uint64_t * w0 = (uint64_t *) w;
unsigned int j = 0;
#if defined(HAVE_SSE2) && GMP_LIMB_BITS == 64
uint64_t * u1 = (uint64_t *) (u + K);
uint64_t * w0 = (uint64_t *) w;
uint64_t * w1 = (uint64_t *) (w + L);
for (; j < n - 1; j += 2 ) {
for (unsigned int j = 0; j < n; j += 2 ) {
const uint64_t * v0 = v;
for(unsigned int l = 0 ; l < L ; l++) {
__m128i r = _mm_setzero_si128();
......@@ -215,8 +212,7 @@ static inline void vaddmul_tiny_64K_64L(
__m128i one = _mpfq_mm_set1_epi64_c(1);
for (unsigned int i = 0; i < 64; i++) {
__m128i zw = _mpfq_mm_set1_epi64(*vv);
// r ^= (zw & -(a & one));
r = _mm_xor_si128(r,_mm_and_si128(zw,_mm_sub_epi64(_mm_setzero_si128(),_mm_and_si128(a, one))));
r = _mm_xor_si128(r, _mm_and_si128(zw, _mm_sub_epi64(_mm_setzero_si128(), _mm_and_si128(a, one))));
a = _mm_srli_epi64(a, 1);
vv += L;
}
......@@ -229,10 +225,21 @@ static inline void vaddmul_tiny_64K_64L(
u0 += 2 * K; u1 += 2 * K;
w0 += 2 * L; w1 += 2 * L;
}
#endif
}
#else /* HAVE_SSE2 */
static inline void vaddmul_tiny_64K_64L(
uint64_t * w,
const uint64_t * u,
const uint64_t * v,
unsigned int n,
unsigned int K,
unsigned int L)
{
/* This is just a direct translation of the sse version. Has been
* tested once. */
for (; j < n; j ++ ) {
uint64_t * u0 = (uint64_t *) u;
uint64_t * w0 = (uint64_t *) w;
for (unsigned int j = 0; j < n; j ++ ) {
const uint64_t * v0 = v;
for(unsigned int l = 0 ; l < L ; l++) {
uint64_t rx = 0;
......@@ -254,6 +261,7 @@ static inline void vaddmul_tiny_64K_64L(
}
}
#endif
#endif
#ifdef need_vtranspose_64K_64L
/* Transpose a matrix of 64K rows of 64L bits */
......
......@@ -38,11 +38,32 @@ extern "C" {
#define LEXLE2(X,Y,A,B) LEXGE2(A,B,X,Y)
#define LEXLE3(X,Y,Z,A,B,C) LEXGE3(A,B,C,X,Y,Z)
#ifndef GMP_VERSION_ATLEAST
#ifndef __GNU_MP_VERSION
#define GMP_VERSION_ATLEAST(X,Y,Z) 0
#else
#define GMP_VERSION_ATLEAST(X,Y,Z) \
LEXGE3(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL,X,Y,Z)
#endif
#endif
#ifndef GMP_VERSION_ATMOST
#ifndef __GNU_MP_VERSION
#define GMP_VERSION_ATMOST(X,Y,Z) 1
#else
#define GMP_VERSION_ATMOST(X,Y,Z) \
LEXLE3(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL,X,Y,Z)
#endif
#endif
#ifndef GNUC_VERSION
#ifndef __GNUC__
#define GNUC_VERSION(X,Y,Z) 0
#else
#define GNUC_VERSION(X,Y,Z) \
defined(__GNUC__) && \
(__GNUC__ == X && __GNUC_MINOR__ == Y && __GNUC_PATCHLEVEL__ == Z)
#endif
#endif
#ifndef GNUC_VERSION_ATLEAST
#ifndef __GNUC__
......@@ -62,25 +83,6 @@ LEXLE3(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__,X,Y,Z)
#endif
#endif
#ifndef GMP_VERSION_ATLEAST
#ifndef __GNU_MP_VERSION
#define GMP_VERSION_ATLEAST(X,Y,Z) 0
#else
#define GMP_VERSION_ATLEAST(X,Y,Z) \
LEXGE3(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL,X,Y,Z)
#endif
#endif
#ifndef GMP_VERSION_ATMOST
#ifndef __GNU_MP_VERSION
#define GMP_VERSION_ATMOST(X,Y,Z) 1
#else
#define GMP_VERSION_ATMOST(X,Y,Z) \
LEXLE3(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL,X,Y,Z)
#endif
#endif
/* typedef unsigned long ulong; */
#ifndef MAX
......
This diff is collapsed.
This diff is collapsed.
......@@ -98,7 +98,7 @@ void mpfq_p_1_field_clear(mpfq_p_1_dst_field k)
}
/* *Mpfq::gfp::field::code_for_field_specify, Mpfq::gfp */
void mpfq_p_1_field_specify(mpfq_p_1_dst_field k, unsigned long dummy MAYBE_UNUSED, void * vp)
void mpfq_p_1_field_specify(mpfq_p_1_dst_field k, unsigned long dummy MAYBE_UNUSED, const void * vp)
{
if (dummy == MPFQ_PRIME_MPN) {
fprintf(stderr, "MPFQ_PRIME_MPN is deprecated\n");
......@@ -354,7 +354,7 @@ int mpfq_p_1_fscan(mpfq_p_1_dst_field k, FILE * file, mpfq_p_1_dst_elt z)
int allocated, len=0;
int c, start=0;
allocated=100;
tmp = (char *)mpfq_malloc_check(allocated*sizeof(char));
tmp = (char *)mpfq_malloc_check(allocated);
for(;;) {
c = fgetc(file);
if (c==EOF)
......@@ -367,7 +367,7 @@ int mpfq_p_1_fscan(mpfq_p_1_dst_field k, FILE * file, mpfq_p_1_dst_elt z)
} else {
if (len==allocated) {
allocated+=100 + allocated / 4;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]=c;
len++;
......@@ -376,7 +376,7 @@ int mpfq_p_1_fscan(mpfq_p_1_dst_field k, FILE * file, mpfq_p_1_dst_elt z)
}
if (len==allocated) {
allocated+=1;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]='\0';
int ret=mpfq_p_1_sscan(k,z,tmp);
......@@ -424,13 +424,13 @@ void mpfq_p_1_vec_clear(mpfq_p_1_dst_field K MAYBE_UNUSED, mpfq_p_1_vec * v, uns
int mpfq_p_1_vec_asprint(mpfq_p_1_dst_field K MAYBE_UNUSED, char * * pstr, mpfq_p_1_src_vec w, unsigned int n)
{
if (n == 0) {
*pstr = (char *)mpfq_malloc_check(4*sizeof(char));
*pstr = (char *)mpfq_malloc_check(4);
sprintf(*pstr, "[ ]");
return strlen(*pstr);
}
int alloc = 100;
int len = 0;
*pstr = (char *)mpfq_malloc_check(alloc*sizeof(char));
*pstr = (char *)mpfq_malloc_check(alloc);
char *str = *pstr;
*str++ = '[';
*str++ = ' ';
......@@ -446,7 +446,7 @@ int mpfq_p_1_vec_asprint(mpfq_p_1_dst_field K MAYBE_UNUSED, char * * pstr, mpfq_
int ltmp = strlen(tmp);
if (len+ltmp+4 > alloc) {
alloc = len+ltmp+100 + alloc / 4;
*pstr = (char *)realloc(*pstr, alloc*sizeof(char));
*pstr = (char *)realloc(*pstr, alloc);
}
strncpy(*pstr+len, tmp, ltmp+4);
len += ltmp;
......@@ -531,7 +531,7 @@ int mpfq_p_1_vec_fscan(mpfq_p_1_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_1_
int c;
int allocated, len=0;
allocated=100;
tmp = (char *)mpfq_malloc_check(allocated*sizeof(char));
tmp = (char *)mpfq_malloc_check(allocated);
int nest = 0, mnest = 0;
for(;;) {
c = fgetc(file);
......@@ -544,7 +544,7 @@ int mpfq_p_1_vec_fscan(mpfq_p_1_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_1_
}
if (len==allocated) {
allocated = len + 10 + allocated / 4;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]=c;
len++;
......@@ -556,7 +556,7 @@ int mpfq_p_1_vec_fscan(mpfq_p_1_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_1_
}
if (len==allocated) {
allocated+=1;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]='\0';
int ret=mpfq_p_1_vec_sscan(K,w,n,tmp);
......@@ -1724,8 +1724,8 @@ static void mpfq_p_1_wrapper_field_setopt(mpfq_vbase_ptr vbase MAYBE_UNUSED, uns
mpfq_p_1_field_setopt(vbase->obj, x, y);
}
static void mpfq_p_1_wrapper_field_specify(mpfq_vbase_ptr, unsigned long, void *);
static void mpfq_p_1_wrapper_field_specify(mpfq_vbase_ptr vbase MAYBE_UNUSED, unsigned long dummy MAYBE_UNUSED, void * vp MAYBE_UNUSED)
static void mpfq_p_1_wrapper_field_specify(mpfq_vbase_ptr, unsigned long, const void *);
static void mpfq_p_1_wrapper_field_specify(mpfq_vbase_ptr vbase MAYBE_UNUSED, unsigned long dummy MAYBE_UNUSED, const void * vp MAYBE_UNUSED)
{
mpfq_p_1_field_specify(vbase->obj, dummy, vp);
}
......@@ -1793,7 +1793,7 @@ void mpfq_p_1_oo_field_init(mpfq_vbase_ptr vbase)
vbase->field_degree = (int (*) (mpfq_vbase_ptr)) mpfq_p_1_wrapper_field_degree;
vbase->field_init = (void (*) (mpfq_vbase_ptr)) mpfq_p_1_wrapper_field_init;
vbase->field_clear = (void (*) (mpfq_vbase_ptr)) mpfq_p_1_wrapper_field_clear;
vbase->field_specify = (void (*) (mpfq_vbase_ptr, unsigned long, void *)) mpfq_p_1_wrapper_field_specify;
vbase->field_specify = (void (*) (mpfq_vbase_ptr, unsigned long, const void *)) mpfq_p_1_wrapper_field_specify;
vbase->field_setopt = (void (*) (mpfq_vbase_ptr, unsigned long, void *)) mpfq_p_1_wrapper_field_setopt;
vbase->init = (void (*) (mpfq_vbase_ptr, void *)) mpfq_p_1_wrapper_init;
vbase->clear = (void (*) (mpfq_vbase_ptr, void *)) mpfq_p_1_wrapper_clear;
......
......@@ -149,7 +149,7 @@ unsigned long mpfq_p_1_field_characteristic_bits(mpfq_p_1_dst_field);
static inline
void mpfq_p_1_field_init(mpfq_p_1_dst_field);
void mpfq_p_1_field_clear(mpfq_p_1_dst_field);
void mpfq_p_1_field_specify(mpfq_p_1_dst_field, unsigned long, void *);
void mpfq_p_1_field_specify(mpfq_p_1_dst_field, unsigned long, const void *);
/* *Mpfq::gfp::field::code_for_field_setopt, Mpfq::gfp */
#define mpfq_p_1_field_setopt(f, x, y) /**/
......
......@@ -108,6 +108,12 @@
/* Member templates related to SIMD operation */
/* Object-oriented interface */
/* Mpfq::engine::handler::create_code */
void mpfq_p_1_p_1_wrapper_dotprod(mpfq_vbase_ptr K0 MAYBE_UNUSED, mpfq_vbase_ptr K1 MAYBE_UNUSED, mpfq_p_1_dst_vec xw, mpfq_p_1_src_vec xu1, mpfq_p_1_src_vec xu0, unsigned int n)
{
mpfq_p_1_p_1_dotprod(K0->obj, K1->obj, xw, xu1, xu0, n);
}
/* *simd_gfp::code_for_member_template_dotprod */
void mpfq_p_1_p_1_dotprod(mpfq_p_1_dst_field K0 MAYBE_UNUSED, mpfq_p_1_dst_field K1 MAYBE_UNUSED, mpfq_p_1_dst_vec xw, mpfq_p_1_src_vec xu1, mpfq_p_1_src_vec xu0, unsigned int n)
{
......@@ -124,6 +130,12 @@ void mpfq_p_1_p_1_dotprod(mpfq_p_1_dst_field K0 MAYBE_UNUSED, mpfq_p_1_dst_field
mpfq_p_1_elt_ur_clear(K0, &t);
}
/* Mpfq::engine::handler::create_code */
void mpfq_p_1_p_1_wrapper_addmul_tiny(mpfq_vbase_ptr K MAYBE_UNUSED, mpfq_vbase_ptr L MAYBE_UNUSED, mpfq_p_1_dst_vec w, mpfq_p_1_src_vec u, mpfq_p_1_dst_vec v, unsigned int n)
{
mpfq_p_1_p_1_addmul_tiny(K->obj, L->obj, w, u, v, n);
}
/* *simd_gfp::code_for_member_template_addmul_tiny */
void mpfq_p_1_p_1_addmul_tiny(mpfq_p_1_dst_field K MAYBE_UNUSED, mpfq_p_1_dst_field L MAYBE_UNUSED, mpfq_p_1_dst_vec w, mpfq_p_1_src_vec u, mpfq_p_1_dst_vec v, unsigned int n)
{
......@@ -136,6 +148,12 @@ void mpfq_p_1_p_1_addmul_tiny(mpfq_p_1_dst_field K MAYBE_UNUSED, mpfq_p_1_dst_fi
mpfq_p_1_clear(K, &s);
}
/* Mpfq::engine::handler::create_code */
void mpfq_p_1_p_1_wrapper_transpose(mpfq_vbase_ptr K MAYBE_UNUSED, mpfq_vbase_ptr L MAYBE_UNUSED, mpfq_p_1_dst_vec w, mpfq_p_1_src_vec u)
{
mpfq_p_1_p_1_transpose(K->obj, L->obj, w, u);
}
/* *simd_gfp::code_for_member_template_transpose */
void mpfq_p_1_p_1_transpose(mpfq_p_1_dst_field K MAYBE_UNUSED, mpfq_p_1_dst_field L MAYBE_UNUSED, mpfq_p_1_dst_vec w, mpfq_p_1_src_vec u)
{
......
......@@ -109,8 +109,11 @@
/* Member templates related to SIMD operation */
/* Object-oriented interface */
void mpfq_p_1_p_1_wrapper_dotprod(mpfq_vbase_ptr, mpfq_vbase_ptr, mpfq_p_1_dst_vec, mpfq_p_1_src_vec, mpfq_p_1_src_vec, unsigned int);
void mpfq_p_1_p_1_dotprod(mpfq_p_1_dst_field, mpfq_p_1_dst_field, mpfq_p_1_dst_vec, mpfq_p_1_src_vec, mpfq_p_1_src_vec, unsigned int);
void mpfq_p_1_p_1_wrapper_addmul_tiny(mpfq_vbase_ptr, mpfq_vbase_ptr, mpfq_p_1_dst_vec, mpfq_p_1_src_vec, mpfq_p_1_dst_vec, unsigned int);
void mpfq_p_1_p_1_addmul_tiny(mpfq_p_1_dst_field, mpfq_p_1_dst_field, mpfq_p_1_dst_vec, mpfq_p_1_src_vec, mpfq_p_1_dst_vec, unsigned int);
void mpfq_p_1_p_1_wrapper_transpose(mpfq_vbase_ptr, mpfq_vbase_ptr, mpfq_p_1_dst_vec, mpfq_p_1_src_vec);
void mpfq_p_1_p_1_transpose(mpfq_p_1_dst_field, mpfq_p_1_dst_field, mpfq_p_1_dst_vec, mpfq_p_1_src_vec);
#endif /* MPFQ_P_1_T_H_ */
......
......@@ -98,7 +98,7 @@ void mpfq_p_2_field_clear(mpfq_p_2_dst_field k)
}
/* *Mpfq::gfp::field::code_for_field_specify, Mpfq::gfp */
void mpfq_p_2_field_specify(mpfq_p_2_dst_field k, unsigned long dummy MAYBE_UNUSED, void * vp)
void mpfq_p_2_field_specify(mpfq_p_2_dst_field k, unsigned long dummy MAYBE_UNUSED, const void * vp)
{
if (dummy == MPFQ_PRIME_MPN) {
fprintf(stderr, "MPFQ_PRIME_MPN is deprecated\n");
......@@ -354,7 +354,7 @@ int mpfq_p_2_fscan(mpfq_p_2_dst_field k, FILE * file, mpfq_p_2_dst_elt z)
int allocated, len=0;
int c, start=0;
allocated=100;
tmp = (char *)mpfq_malloc_check(allocated*sizeof(char));
tmp = (char *)mpfq_malloc_check(allocated);
for(;;) {
c = fgetc(file);
if (c==EOF)
......@@ -367,7 +367,7 @@ int mpfq_p_2_fscan(mpfq_p_2_dst_field k, FILE * file, mpfq_p_2_dst_elt z)
} else {
if (len==allocated) {
allocated+=100 + allocated / 4;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]=c;
len++;
......@@ -376,7 +376,7 @@ int mpfq_p_2_fscan(mpfq_p_2_dst_field k, FILE * file, mpfq_p_2_dst_elt z)
}
if (len==allocated) {
allocated+=1;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]='\0';
int ret=mpfq_p_2_sscan(k,z,tmp);
......@@ -424,13 +424,13 @@ void mpfq_p_2_vec_clear(mpfq_p_2_dst_field K MAYBE_UNUSED, mpfq_p_2_vec * v, uns
int mpfq_p_2_vec_asprint(mpfq_p_2_dst_field K MAYBE_UNUSED, char * * pstr, mpfq_p_2_src_vec w, unsigned int n)
{
if (n == 0) {
*pstr = (char *)mpfq_malloc_check(4*sizeof(char));
*pstr = (char *)mpfq_malloc_check(4);
sprintf(*pstr, "[ ]");
return strlen(*pstr);
}
int alloc = 100;
int len = 0;
*pstr = (char *)mpfq_malloc_check(alloc*sizeof(char));
*pstr = (char *)mpfq_malloc_check(alloc);
char *str = *pstr;
*str++ = '[';
*str++ = ' ';
......@@ -446,7 +446,7 @@ int mpfq_p_2_vec_asprint(mpfq_p_2_dst_field K MAYBE_UNUSED, char * * pstr, mpfq_
int ltmp = strlen(tmp);
if (len+ltmp+4 > alloc) {
alloc = len+ltmp+100 + alloc / 4;
*pstr = (char *)realloc(*pstr, alloc*sizeof(char));
*pstr = (char *)realloc(*pstr, alloc);
}
strncpy(*pstr+len, tmp, ltmp+4);
len += ltmp;
......@@ -531,7 +531,7 @@ int mpfq_p_2_vec_fscan(mpfq_p_2_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_2_
int c;
int allocated, len=0;
allocated=100;
tmp = (char *)mpfq_malloc_check(allocated*sizeof(char));
tmp = (char *)mpfq_malloc_check(allocated);
int nest = 0, mnest = 0;
for(;;) {
c = fgetc(file);
......@@ -544,7 +544,7 @@ int mpfq_p_2_vec_fscan(mpfq_p_2_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_2_
}
if (len==allocated) {
allocated = len + 10 + allocated / 4;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]=c;
len++;
......@@ -556,7 +556,7 @@ int mpfq_p_2_vec_fscan(mpfq_p_2_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_2_
}
if (len==allocated) {
allocated+=1;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]='\0';
int ret=mpfq_p_2_vec_sscan(K,w,n,tmp);
......@@ -1724,8 +1724,8 @@ static void mpfq_p_2_wrapper_field_setopt(mpfq_vbase_ptr vbase MAYBE_UNUSED, uns
mpfq_p_2_field_setopt(vbase->obj, x, y);
}
static void mpfq_p_2_wrapper_field_specify(mpfq_vbase_ptr, unsigned long, void *);
static void mpfq_p_2_wrapper_field_specify(mpfq_vbase_ptr vbase MAYBE_UNUSED, unsigned long dummy MAYBE_UNUSED, void * vp MAYBE_UNUSED)
static void mpfq_p_2_wrapper_field_specify(mpfq_vbase_ptr, unsigned long, const void *);
static void mpfq_p_2_wrapper_field_specify(mpfq_vbase_ptr vbase MAYBE_UNUSED, unsigned long dummy MAYBE_UNUSED, const void * vp MAYBE_UNUSED)
{
mpfq_p_2_field_specify(vbase->obj, dummy, vp);
}
......@@ -1793,7 +1793,7 @@ void mpfq_p_2_oo_field_init(mpfq_vbase_ptr vbase)
vbase->field_degree = (int (*) (mpfq_vbase_ptr)) mpfq_p_2_wrapper_field_degree;
vbase->field_init = (void (*) (mpfq_vbase_ptr)) mpfq_p_2_wrapper_field_init;
vbase->field_clear = (void (*) (mpfq_vbase_ptr)) mpfq_p_2_wrapper_field_clear;
vbase->field_specify = (void (*) (mpfq_vbase_ptr, unsigned long, void *)) mpfq_p_2_wrapper_field_specify;
vbase->field_specify = (void (*) (mpfq_vbase_ptr, unsigned long, const void *)) mpfq_p_2_wrapper_field_specify;
vbase->field_setopt = (void (*) (mpfq_vbase_ptr, unsigned long, void *)) mpfq_p_2_wrapper_field_setopt;
vbase->init = (void (*) (mpfq_vbase_ptr, void *)) mpfq_p_2_wrapper_init;
vbase->clear = (void (*) (mpfq_vbase_ptr, void *)) mpfq_p_2_wrapper_clear;
......
......@@ -149,7 +149,7 @@ unsigned long mpfq_p_2_field_characteristic_bits(mpfq_p_2_dst_field);
static inline
void mpfq_p_2_field_init(mpfq_p_2_dst_field);
void mpfq_p_2_field_clear(mpfq_p_2_dst_field);
void mpfq_p_2_field_specify(mpfq_p_2_dst_field, unsigned long, void *);
void mpfq_p_2_field_specify(mpfq_p_2_dst_field, unsigned long, const void *);
/* *Mpfq::gfp::field::code_for_field_setopt, Mpfq::gfp */
#define mpfq_p_2_field_setopt(f, x, y) /**/
......@@ -434,9 +434,9 @@ void mpfq_p_2_dotprod(mpfq_p_2_dst_field, mpfq_p_2_dst_vec, mpfq_p_2_src_vec, mp
/* Member templates related to SIMD operation */
/* Object-oriented interface */
void mpfq_p_2_oo_field_init(mpfq_vbase_ptr);
static inline
void mpfq_p_2_oo_field_clear(mpfq_vbase_ptr);
void mpfq_p_2_oo_field_init(mpfq_vbase_ptr);
#ifdef __cplusplus
}
#endif
......
......@@ -108,6 +108,12 @@
/* Member templates related to SIMD operation */
/* Object-oriented interface */
/* Mpfq::engine::handler::create_code */
void mpfq_p_2_p_2_wrapper_dotprod(mpfq_vbase_ptr K0 MAYBE_UNUSED, mpfq_vbase_ptr K1 MAYBE_UNUSED, mpfq_p_2_dst_vec xw, mpfq_p_2_src_vec xu1, mpfq_p_2_src_vec xu0, unsigned int n)
{
mpfq_p_2_p_2_dotprod(K0->obj, K1->obj, xw, xu1, xu0, n);
}
/* *simd_gfp::code_for_member_template_dotprod */
void mpfq_p_2_p_2_dotprod(mpfq_p_2_dst_field K0 MAYBE_UNUSED, mpfq_p_2_dst_field K1 MAYBE_UNUSED, mpfq_p_2_dst_vec xw, mpfq_p_2_src_vec xu1, mpfq_p_2_src_vec xu0, unsigned int n)
{
......@@ -124,6 +130,12 @@ void mpfq_p_2_p_2_dotprod(mpfq_p_2_dst_field K0 MAYBE_UNUSED, mpfq_p_2_dst_field
mpfq_p_2_elt_ur_clear(K0, &t);
}
/* Mpfq::engine::handler::create_code */
void mpfq_p_2_p_2_wrapper_addmul_tiny(mpfq_vbase_ptr K MAYBE_UNUSED, mpfq_vbase_ptr L MAYBE_UNUSED, mpfq_p_2_dst_vec w, mpfq_p_2_src_vec u, mpfq_p_2_dst_vec v, unsigned int n)
{
mpfq_p_2_p_2_addmul_tiny(K->obj, L->obj, w, u, v, n);
}
/* *simd_gfp::code_for_member_template_addmul_tiny */
void mpfq_p_2_p_2_addmul_tiny(mpfq_p_2_dst_field K MAYBE_UNUSED, mpfq_p_2_dst_field L MAYBE_UNUSED, mpfq_p_2_dst_vec w, mpfq_p_2_src_vec u, mpfq_p_2_dst_vec v, unsigned int n)
{
......@@ -136,6 +148,12 @@ void mpfq_p_2_p_2_addmul_tiny(mpfq_p_2_dst_field K MAYBE_UNUSED, mpfq_p_2_dst_fi
mpfq_p_2_clear(K, &s);
}
/* Mpfq::engine::handler::create_code */
void mpfq_p_2_p_2_wrapper_transpose(mpfq_vbase_ptr K MAYBE_UNUSED, mpfq_vbase_ptr L MAYBE_UNUSED, mpfq_p_2_dst_vec w, mpfq_p_2_src_vec u)
{
mpfq_p_2_p_2_transpose(K->obj, L->obj, w, u);
}
/* *simd_gfp::code_for_member_template_transpose */
void mpfq_p_2_p_2_transpose(mpfq_p_2_dst_field K MAYBE_UNUSED, mpfq_p_2_dst_field L MAYBE_UNUSED, mpfq_p_2_dst_vec w, mpfq_p_2_src_vec u)
{
......
......@@ -109,8 +109,11 @@
/* Member templates related to SIMD operation */
/* Object-oriented interface */
void mpfq_p_2_p_2_wrapper_dotprod(mpfq_vbase_ptr, mpfq_vbase_ptr, mpfq_p_2_dst_vec, mpfq_p_2_src_vec, mpfq_p_2_src_vec, unsigned int);
void mpfq_p_2_p_2_dotprod(mpfq_p_2_dst_field, mpfq_p_2_dst_field, mpfq_p_2_dst_vec, mpfq_p_2_src_vec, mpfq_p_2_src_vec, unsigned int);
void mpfq_p_2_p_2_wrapper_addmul_tiny(mpfq_vbase_ptr, mpfq_vbase_ptr, mpfq_p_2_dst_vec, mpfq_p_2_src_vec, mpfq_p_2_dst_vec, unsigned int);
void mpfq_p_2_p_2_addmul_tiny(mpfq_p_2_dst_field, mpfq_p_2_dst_field, mpfq_p_2_dst_vec, mpfq_p_2_src_vec, mpfq_p_2_dst_vec, unsigned int);
void mpfq_p_2_p_2_wrapper_transpose(mpfq_vbase_ptr, mpfq_vbase_ptr, mpfq_p_2_dst_vec, mpfq_p_2_src_vec);
void mpfq_p_2_p_2_transpose(mpfq_p_2_dst_field, mpfq_p_2_dst_field, mpfq_p_2_dst_vec, mpfq_p_2_src_vec);
#endif /* MPFQ_P_2_T_H_ */
......
......@@ -98,7 +98,7 @@ void mpfq_p_3_field_clear(mpfq_p_3_dst_field k)
}
/* *Mpfq::gfp::field::code_for_field_specify, Mpfq::gfp */
void mpfq_p_3_field_specify(mpfq_p_3_dst_field k, unsigned long dummy MAYBE_UNUSED, void * vp)
void mpfq_p_3_field_specify(mpfq_p_3_dst_field k, unsigned long dummy MAYBE_UNUSED, const void * vp)
{
if (dummy == MPFQ_PRIME_MPN) {
fprintf(stderr, "MPFQ_PRIME_MPN is deprecated\n");
......@@ -354,7 +354,7 @@ int mpfq_p_3_fscan(mpfq_p_3_dst_field k, FILE * file, mpfq_p_3_dst_elt z)
int allocated, len=0;
int c, start=0;
allocated=100;
tmp = (char *)mpfq_malloc_check(allocated*sizeof(char));
tmp = (char *)mpfq_malloc_check(allocated);
for(;;) {
c = fgetc(file);
if (c==EOF)
......@@ -367,7 +367,7 @@ int mpfq_p_3_fscan(mpfq_p_3_dst_field k, FILE * file, mpfq_p_3_dst_elt z)
} else {
if (len==allocated) {
allocated+=100 + allocated / 4;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]=c;
len++;
......@@ -376,7 +376,7 @@ int mpfq_p_3_fscan(mpfq_p_3_dst_field k, FILE * file, mpfq_p_3_dst_elt z)
}
if (len==allocated) {
allocated+=1;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]='\0';
int ret=mpfq_p_3_sscan(k,z,tmp);
......@@ -424,13 +424,13 @@ void mpfq_p_3_vec_clear(mpfq_p_3_dst_field K MAYBE_UNUSED, mpfq_p_3_vec * v, uns
int mpfq_p_3_vec_asprint(mpfq_p_3_dst_field K MAYBE_UNUSED, char * * pstr, mpfq_p_3_src_vec w, unsigned int n)
{
if (n == 0) {
*pstr = (char *)mpfq_malloc_check(4*sizeof(char));
*pstr = (char *)mpfq_malloc_check(4);
sprintf(*pstr, "[ ]");
return strlen(*pstr);
}
int alloc = 100;
int len = 0;
*pstr = (char *)mpfq_malloc_check(alloc*sizeof(char));
*pstr = (char *)mpfq_malloc_check(alloc);
char *str = *pstr;
*str++ = '[';
*str++ = ' ';
......@@ -446,7 +446,7 @@ int mpfq_p_3_vec_asprint(mpfq_p_3_dst_field K MAYBE_UNUSED, char * * pstr, mpfq_
int ltmp = strlen(tmp);
if (len+ltmp+4 > alloc) {
alloc = len+ltmp+100 + alloc / 4;
*pstr = (char *)realloc(*pstr, alloc*sizeof(char));
*pstr = (char *)realloc(*pstr, alloc);
}
strncpy(*pstr+len, tmp, ltmp+4);
len += ltmp;
......@@ -531,7 +531,7 @@ int mpfq_p_3_vec_fscan(mpfq_p_3_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_3_
int c;
int allocated, len=0;
allocated=100;
tmp = (char *)mpfq_malloc_check(allocated*sizeof(char));
tmp = (char *)mpfq_malloc_check(allocated);
int nest = 0, mnest = 0;
for(;;) {
c = fgetc(file);
......@@ -544,7 +544,7 @@ int mpfq_p_3_vec_fscan(mpfq_p_3_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_3_
}
if (len==allocated) {
allocated = len + 10 + allocated / 4;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]=c;
len++;
......@@ -556,7 +556,7 @@ int mpfq_p_3_vec_fscan(mpfq_p_3_dst_field K MAYBE_UNUSED, FILE * file, mpfq_p_3_
}
if (len==allocated) {
allocated+=1;
tmp = (char*)realloc(tmp, allocated*sizeof(char));
tmp = (char*)realloc(tmp, allocated);
}
tmp[len]='\0';
int ret=mpfq_p_3_vec_sscan(K,w,n,tmp);
......@@ -1724,8 +1724,8 @@ static void mpfq_p_3_wrapper_field_setopt(mpfq_vbase_ptr vbase MAYBE_UNUSED, uns
mpfq_p_3_field_setopt(vbase->obj, x, y);
}
static void mpfq_p_3_wrapper_field_specify(mpfq_vbase_ptr, unsigned long, void *);
static void mpfq_p_3_wrapper_field_specify(mpfq_vbase_ptr vbase MAYBE_UNUSED, unsigned long dummy MAYBE_UNUSED, void * vp MAYBE_UNUSED)
static void mpfq_p_3_wrapper_field_specify(mpfq_vbase_ptr, unsigned long, const void *);
static void mpfq_p_3_wrapper_field_specify(mpfq_vbase_ptr vbase MAYBE_UNUSED, unsigned long dummy MAYBE_UNUSED, const void * vp MAYBE_UNUSED)
{
mpfq_p_3_field_specify(vbase->obj, dummy, vp);
}
......@@ -1793,7 +1793,7 @@ void mpfq_p_3_oo_field_init(mpfq_vbase_ptr vbase)
vbase->field_degree = (int (*) (mpfq_vbase_ptr)) mpfq_p_3_wrapper_field_degree;
vbase->field_init = (void (*) (mpfq_vbase_ptr)) mpfq_p_3_wrapper_field_init;
vbase->field_clear = (void (*) (mpfq_vbase_ptr)) mpfq_p_3_wrapper_field_clear;
vbase->field_specify = (void (*) (mpfq_vbase_ptr, unsigned long, void *)) mpfq_p_3_wrapper_field_specify;
vbase->field_specify = (void (*) (mpfq_vbase_ptr, unsigned long, const void *)) mpfq_p_3_wrapper_field_specify;
vbase->field_setopt = (void (*) (mpfq_vbase_ptr, unsigned long, void *)) mpfq_p_3_wrapper_field_setopt;
vbase->init = (void (*) (mpfq_vbase_ptr, void *)) mpfq_p_3_wrapper_init;
vbase->clear = (void (*) (mpfq_vbase_ptr, void *)) mpfq_p_3_wrapper_clear;
......
......@@ -149,7 +149,7 @@ unsigned long mpfq_p_3_field_characteristic_bits(mpfq_p_3_dst_field);
static inline
void mpfq_p_3_field_init(mpfq_p_3_dst_field);
void mpfq_p_3_field_clear(mpfq_p_3_dst_field);
void mpfq_p_3_field_specify(mpfq_p_3_dst_field, unsigned long, void *);
void mpfq_p_3_field_specify(mpfq_p_3_dst_field, unsigned long, const void *);
/* *Mpfq::gfp::field::code_for_field_setopt, Mpfq::gfp */
#define mpfq_p_3_field_setopt(f, x, y) /**/
......@@ -434,9 +434,9 @@ void mpfq_p_3_dotprod(mpfq_p_3_dst_field, mpfq_p_3_dst_vec, mpfq_p_3_src_vec, mp
/* Member templates related to SIMD operation */
/* Object-oriented interface */
void mpfq_p_3_oo_field_init(mpfq_vbase_ptr);
static inline
void mpfq_p_3_oo_field_clear(mpfq_vbase_ptr);
void mpfq_p_3_oo_field_init(mpfq_vbase_ptr);
#ifdef __cplusplus
}
#endif
......
......@@ -108,6 +108,12 @@
/* Member templates related to SIMD operation */