#include <stdio.h>
#include <stdlib.h>
#include <givaro/givtimer.h>
#include <givaro/givrandom.h>
#include <givaro/gfq.h>
#ifndef GIVMIN
#define GIVMIN(a,b) (((a)<(b))?(a):(b))
#endif
typedef GFqDom<int64_t>
Domain;
#ifndef NB
#define NB 1000000
#endif
#ifndef TAILLE
#define TAILLE 256
#endif
int main(
int argc,
char ** argv)
{
GivRandom generator;
int64_t P (65521);
int64_t expo(1);
int offset = 0;
if (argc > ++offset) P = atoi( argv[ offset ] );
if (argc > ++offset) expo = atoi( argv[ offset ] );
Timer inver;
inver.clear();
inver.start();
std::cout << "."<< std::flush;
GFq.random(generator,z1[i]) ;
GFq.nonzerorandom(generator,z2[i]) ;
GFq.random(generator,z23[i]) ;
}
std::cout << "."<< std::flush;
inver.stop();
std::cout << "Init et Tableaux des modulo " << P << " :\n" << inver << std::endl << std::flush;
Timer tim;tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.mul(z3[i], z1[i], z2[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" Mul: " << coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.add(z3[i], z1[i], z2[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" Add: " << coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.axpyin(z3[i], z1[i], z2[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" MulAdd IN place: " << 2*coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.axpy(z3[i], z1[i], z2[i], z23[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" MulAdd: " << 2*coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.sub(z3[i], z1[i], z2[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" Sub: " << coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
#if 0
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.div(z3[i], z1[i], z2[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" Div: " << coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
#endif
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" Neg: " << (coef / tim.usertime())
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
GFq.random(generator,z1[i]) ;
GFq.nonzerorandom(generator,z2[i]) ;
GFq.random(generator,z23[i]) ;
}
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.add(z3[i], z1[i], z2[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" Add: " << coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.sub(z3[i], z1[i], z2[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" Sub: " << coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.axpyin(z3[i], z1[i], z2[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" MulAdd IN place: " << 2*coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
GFq.axpy(z3[i], z1[i], z2[i], z23[i]);
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" MulAdd: " << 2*coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
tim.clear();tim.start();
for (
int k=0; k<
NB; ++k)
for(
int i=0; i<
TAILLE; ++i)
tim.stop();
std::cout <<
NB <<
" * " <<
TAILLE <<
" Neg: " << coef / tim.usertime()
<< "Mop/s\n" << tim << ", ex: " << z3[0] << std::endl << std::flush;
}
int main(int argc, char **argv)
Definition: benchmark-recint_exp.C:20
Rep Element
Definition: gfq.h:79
#define NB
Definition: gfq_atomic.C:32
#define TAILLE
Definition: gfq_atomic.C:35
GFqDom< int64_t >::Element Modulo
Definition: gfq_atomic.C:28
GFqDom< int64_t > Domain
Definition: gfq_atomic.C:27
Namespace in which the whole Givaro library resides.
Definition: all_field.C:23
GFqDom< TT > GFq
Definition: gfq.h:39