Skip to content
Snippets Groups Projects
Commit dc6361d6 authored by Bouillaguet Charles's avatar Bouillaguet Charles
Browse files

petit nettoyage

parent 922bc29b
Branches
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ CFLAGS = -O3 -Wall -Wextra -Werror -march=native -mtune=native -fopenmp -g
LDFLAGS = -fopenmp
LDLIBS = -lm
all: main benchmark test
all: main benchmark test test_falsenegative
fonctions.o: fonctions.h
main.o: fonctions.h pcg_setseq.h
......@@ -22,3 +22,6 @@ clean:
check: test test_falsenegative
prove -v ./test ./test_falsenegative
bench: benchmark
./benchmark
\ No newline at end of file
......@@ -38,7 +38,6 @@ void init_var_globales()
invG[i] *= 1ull << (k - known_up - known_low);
}
//////////////////// chrono //////////////////
double wtime()
{
......@@ -47,6 +46,11 @@ double wtime()
return (double) ts.tv_sec + ts.tv_usec / 1e6;
}
static inline u64 unrotate(u64 Xi, int i)
{
return (Xi >> (k-i)) | (Xi << i);
}
char * setupGoodY()
{
char* goodY = malloc((1<<(known_low + known_up)) * sizeof(char) * nbtest / 8);
......@@ -90,13 +94,13 @@ static inline int checkY(const char* goodY, int i, u64 Y)
return (goodY[j] >> l) & 1;
}
static inline bool confirm(u64 Y0, u64 DS640, const u64* sumPolTest, const char* goodY)
static inline bool confirm(u64 Y0, u64 DS640, const struct task_t *task)
{
/**** Confirmation du DS640 ****/
for (int i = 0 ; i < nbtest ; i++) {
u64 tmp2 = ((u64) polA[i + nbiter]) * DS640 + sumPolTest[i]; //ATTENTION cast pcg128_t
u64 tmp2 = ((u64) polA[i + nbiter]) * DS640 + task->sumPolTest[i]; //ATTENTION cast pcg128_t
u64 Yi1 = (Y0 + (tmp2 >> (k - known_low - known_up))) % (1 << (known_low + known_up)); //avec ou sans retenue OK!
if (!(checkY(goodY, i, Yi1)))
if (!(checkY(task->goodY, i, Yi1)))
return 0;
}
return 1;
......@@ -147,7 +151,7 @@ bool solve_isgood(const struct task_t *task)
DS640 += Greduite[i] * light_crazy_round(u[i]);
}
return confirm(Y0, DS640, task->sumPolTest, task->goodY);
return confirm(Y0, DS640, task);
}
......@@ -178,7 +182,7 @@ void solve(const struct task_t *task, u64* DS640, u64* Y0)
(*DS640) += Greduite[i] * crazy_round(u[i]);
}
assert(confirm(*Y0, *DS640, task->sumPolTest, task->goodY));
assert(confirm(*Y0, *DS640, task));
}
......@@ -201,7 +205,6 @@ void init_task(struct task_t *t)
t->goodY[y] = 0;
}
void prepare_task(const u64 *X, u64 W0, u64 WC, struct task_t *t)
{
for (int i = 0 ; i < nbiter ; i++) {
......
#include <stdint.h>
#include <stdbool.h>
//#include "pcg_oneseq.h"
#include "pcg_setseq.h" //inclus dans pcg_oneseq
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <omp.h>
#include "pcg_setseq.h"
typedef long long i64;
typedef unsigned long long u64;
......@@ -42,37 +42,9 @@ void finish_task(const u64 *X, struct task_t *t);
double wtime();
bool solve_isgood(const struct task_t *task);
void solve(const struct task_t *task, u64* DS640, u64* Y0);
void pcg(pcg128_t *S, u64* X, pcg128_t S0, pcg128_t* c, int n);
static inline void prodMatVecFFU(double* res, double* M, u64* v, int n){
int i, j;
for(i=0 ; i<n ; i++){
res[i] = 0;
for(j=0 ; j<n ; j++)
res[i]+= M[i * n + j] * v[j];
}
}
////////////////Fonctions pour la récupération de S//////////////
static inline void rotateX(u64* rX, const u64* X, const int* rot){ //pas verifié, repris de pcg_random
for(int i = 0 ; i < nbiter ; i++)
rX[i]= (X[i] >> rot[i]) | (X[i] << ((- rot[i]) & (k-1)));
}
static inline void unrotateX(u64* urX, const u64* X, const int* rot){//pas verifié, repris de pcg_random
for(int i = 0 ; i < nbiter ; i++)
urX[i]= (X[i] >> ((- rot[i]) & (k-1))) | (X[i] << rot[i]);
}
static inline u64 unrotate1(u64 Xi)
{
return (Xi >> (k-1)) | (Xi << 1);
}
static inline u64 unrotate(u64 Xi, int i)
{
return (Xi >> (k-i)) | (Xi << i);
}
///// tout ceci ne sert que dans test.c
void getY(u64 *Y, u64 W0, u64 WC, int* rot, u64* uX);
void getYprim(u64 *Yprim, u64 *Y, u64 W0, u64 WC);
......@@ -80,16 +52,3 @@ void getDY(u64 *DY, u64* Yprim);
void FindDS64(u64* DS64, u64 *Y0, u64* uX,int* rot, u64* lowSumPol, u64* sumPolY);
u64 FindDS640(u64* Y, u64* uX, int* rot,u64 *lowSumPol,u64* sumPolY);
int testDS640(u64 DS640, u64* X, u64 Y0, u64* sumPolTest, u64* lowSumPol);
\ No newline at end of file
int testValid(FILE* f, int n);
//void pcgone(pcg128_t *S, u64* X, pcg128_t S0, int n);
void pcg(pcg128_t *S, u64* X, pcg128_t S0, pcg128_t* c, int n);
/***** Tests *****/
int testFonctions();
void printVal(pcg128_t S0, pcg128_t c);
......@@ -3,6 +3,13 @@
#include "fonctions.h"
static inline void unrotateX(u64* urX, const u64* X, const int* rot)
{
for(int i = 0 ; i < nbiter ; i++)
urX[i]= (X[i] >> ((- rot[i]) & (k-1))) | (X[i] << rot[i]);
}
int testFonctions()
{
assert(known_low == 11);
......
......@@ -65,7 +65,7 @@ int main()
ok |= (known_low == 12) && (successes > 0.99*nbtests);
ok |= (known_low == 13) && (successes == nbtests);
if (ok)
printf("ok 1 - %d tests OK\n", nbtests);
printf("ok 1 - %d tests OK\n", successes);
else
printf("not ok 1 - #success = %d / %d\n", successes, nbtests);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment