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

introduction struct task_t : phase 2

parent da6a3825
Branches
No related tags found
No related merge requests found
......@@ -81,16 +81,6 @@ void getGoodY(char* goodY, const u64* X, const u64* lowSumPol, int v)
}
void getTabTmp(u64* tabTmp, const u64* X, const u64* lowSumPol, const u64* sumPolY)
{
for (int i = 0 ; i < k ; i++) {
for (int j = 0 ; j < nbiter ; j++) {
u64 uX = unrotate(X[j], i);
tabTmp[i * nbiter + j] = (((lowSumPol[j] % (1 << known_low)) ^ (uX % (1 << known_low))) << known_up) + (i ^ (uX >> (k - known_up))) - sumPolY[j];
}
}
}
static inline int checkY(const char* goodY, int i, u64 Y)
{
int idx = Y + i * (1 << (known_up + known_low));
......@@ -206,7 +196,9 @@ void pcg(pcg128_t *S, u64* X, pcg128_t S0, pcg128_t* c, int n)
void init_task(struct task_t *t)
{
t->goodY = setupGoodY();
t->goodY = malloc((1<<(known_low + known_up)) * sizeof(char) * nbtest / 8);
for (u64 y = 0 ; y < nbtest * (1<< (known_low + known_up)) / 8 ; y++)
t->goodY[y] = 0;
}
......@@ -220,8 +212,22 @@ void prepare_task(const u64 *X, u64 W0, u64 WC, struct task_t *t)
t->lowSumPol[nbiter + i] = (W0 * ((u64) powA[i + nbiter]) + WC * ((u64) polA[i + nbiter]));
t->sumPolTest[i] = W0 * ((u64) (powA[i + nbiter] >> known_low) - 1) + WC * ((u64) (polA[i + nbiter] >> known_low) - 1);
}
getGoodY(t->goodY, X, t->lowSumPol, 1);
getTabTmp(t->tabTmp, X, t->lowSumPol, t->sumPolY);
// getTabTmp(t->tabTmp, X, t->lowSumPol, t->sumPolY);
for (int i = 0 ; i < k ; i++) {
for (int j = 0 ; j < nbiter ; j++) {
u64 uX = unrotate(X[j], i);
t->tabTmp[i * nbiter + j] = (((t->lowSumPol[j] % (1 << known_low)) ^ (uX % (1 << known_low))) << known_up) + (i ^ (uX >> (k - known_up))) - t->sumPolY[j];
}
}
for (int i = 0 ; i < nbiter ; i++)
t->rot[i] = 0;
}
void finish_task(const u64 *X, struct task_t *t)
{
getGoodY(t->goodY, X, t->lowSumPol, 0);
}
\ No newline at end of file
......@@ -38,6 +38,7 @@ struct task_t {
void init_var_globales();
void init_task(struct task_t *t);
void prepare_task(const u64 *X, u64 W0, u64 WC, struct task_t *t);
void finish_task(const u64 *X, struct task_t *t);
double wtime();
static inline void prodMatVecFFU(double* res, double* M, u64* v, int n){
......
......@@ -50,7 +50,7 @@ int main()
printf("DS640 = %llu\n", DS640);
}*/
}
getGoodY(task.goodY, X, task.lowSumPol, 0);
finish_task(X, &task);
}
}
printf("temps total = %f\n", wtime() - t1);
......
......@@ -31,7 +31,6 @@ int testValid (FILE* f, int n)
/**** Polynômes en WC et W0 utilisés dans la résolution ****/
int a = solve_isgood(task.goodY, task.rot, task.tabTmp, task.sumPolY, task.sumPolTest);
cpt += a;
if (a) {
......@@ -41,7 +40,7 @@ int testValid (FILE* f, int n)
}
/* reset goodY */
getGoodY(task.goodY, X, task.lowSumPol, 0);
finish_task(X, &task);
}
return cpt;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment