WIP: Une erreur est due au g_realloc() dans erase_arrow() in /graphics.c (ligne 601)
This commit is contained in:
parent
6bbc3a3aa8
commit
1a7a535f45
|
@ -38,6 +38,7 @@ void show_arrows_array_head(int one_batch_size, long nb_batches_specified, int v
|
|||
void show_one_arrow_in_array(struct arrow_t *arrows, int i);
|
||||
void show_empty_arrows_array();
|
||||
void show_arrows_array (struct arrow_t *arrows, int arrows_nb, int x, int y, int z);
|
||||
void print_arrows_array (struct arrow_t *arrows, int arrows_nb, int invoked_by);
|
||||
void print_user_action(struct arrow_t *arrows, int arrows_nb, int address, int requested_weight,
|
||||
int current_weight, int site, int x, int y, int z);
|
||||
void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
||||
|
|
|
@ -59,19 +59,19 @@ int write_one_arrow_vertex (int offset_vertex,
|
|||
|
||||
switch(site){
|
||||
case EAST:
|
||||
graphics_write_vertex (vx + (site % 2 - 1) * (1 / max) - (site % 2 - 1) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_vertex (vx - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_color (1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
case WEST:
|
||||
graphics_write_vertex (vx + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_vertex (vx - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_color (0.0f, 1.0f, 1.0f);
|
||||
break;
|
||||
case ZENITH:
|
||||
graphics_write_vertex (vx, vy + (site % 2 - 1) * (1 / max) - (site % 2 - 1) * arrow_tip_padding, vz);
|
||||
graphics_write_vertex (vx, vy - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vz);
|
||||
graphics_write_color(0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
case NADIR:
|
||||
graphics_write_vertex (vx, vy + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding, vz);
|
||||
graphics_write_vertex (vx, vy - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vz);
|
||||
graphics_write_color(1.0f, 0.0f, 1.0f);
|
||||
break;
|
||||
case SOUTH:
|
||||
|
|
|
@ -37,9 +37,18 @@
|
|||
* - load (or weight)
|
||||
* - coordinates in space (site, x, y, z)
|
||||
*/
|
||||
static void print_arrows_array (struct arrow_t *arrows, int arrows_nb)
|
||||
void print_arrows_array (struct arrow_t *arrows, int arrows_nb, int invoked_by)
|
||||
{
|
||||
printf(" [rank] load | site x y z");
|
||||
printf(" [rank] load | site x y z (");
|
||||
switch (invoked_by) {
|
||||
case 0: printf("delete)"); break;
|
||||
case 1: printf("create)"); break;
|
||||
case 2: printf("modify)"); break;
|
||||
case 3: printf("address >= 0 && current_weight == requested_weight)"); break;
|
||||
case 4: printf("address == -1 && requested_weight == 0)"); break;
|
||||
case 5: printf("print_user_choices)"); break;
|
||||
case 6: printf("print_evolution)"); break;
|
||||
}
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
printf("\n [%4d] = %2d | %2d, %2d, %2d, %2d", i, arrows[i].load,\
|
||||
arrows[i].site, arrows[i].x, arrows[i].y, arrows[i].z);
|
||||
|
@ -64,7 +73,7 @@ void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
|||
if (show_space_design) printf(" (grilles alternées)");
|
||||
printf("\n");
|
||||
|
||||
if (show_array) print_arrows_array (arrows, arrows_nb);
|
||||
if (show_array) print_arrows_array (arrows, arrows_nb, 5);
|
||||
}
|
||||
|
||||
/* Prints the evolution after adding / removing arrows :
|
||||
|
@ -79,7 +88,7 @@ void print_evolution (struct arrow_t *arrows, int arrows_nb, int modified, int d
|
|||
{
|
||||
printf("evolution\t\t\t\t\t\t\tarrows nb > %6d\t (%d added / %d deleted) (modified : %d)\n",\
|
||||
arrows_nb + modified - deleted * 2, modified - deleted, deleted, modified);
|
||||
if (show_array) print_arrows_array (arrows, arrows_nb);
|
||||
if (show_array) print_arrows_array (arrows, arrows_nb, 6);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -551,8 +551,7 @@ static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x,
|
|||
{
|
||||
sworra[address].load = load;
|
||||
|
||||
// if (! TEST)
|
||||
// print_arrows_array (sworra, arrows_nb);
|
||||
print_arrows_array (sworra, arrows_nb, 2);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -568,7 +567,7 @@ static inline int create_arrow (int arrows_nb, int load, int site, int x, int y,
|
|||
if (newptr)
|
||||
sworra = newptr;
|
||||
else
|
||||
perror("Can't allocate new arrow buffer!\n");
|
||||
perror("In create arrow, can't allocate new arrow buffer !\n");
|
||||
|
||||
sworra[arrows_nb].load = load;
|
||||
sworra[arrows_nb].site = site;
|
||||
|
@ -578,8 +577,7 @@ static inline int create_arrow (int arrows_nb, int load, int site, int x, int y,
|
|||
|
||||
arrows_nb ++;
|
||||
|
||||
// if (! TEST)
|
||||
// print_arrows_array (sworra, arrows_nb);
|
||||
print_arrows_array (sworra, arrows_nb, 1);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -600,15 +598,14 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
|
|||
sworra[address].z = sworra[arrows_nb].z;
|
||||
}
|
||||
|
||||
void *newptr = g_realloc(sworra, arrows_nb * sizeof(struct arrow_t));
|
||||
/* void *newptr = g_realloc(sworra, arrows_nb * sizeof(struct arrow_t)); */
|
||||
|
||||
if (newptr)
|
||||
sworra = newptr;
|
||||
else
|
||||
perror("Can't allocate new arrow buffer!\n");
|
||||
/* if (newptr) */
|
||||
/* sworra = newptr; */
|
||||
/* else */
|
||||
/* perror("In erase arrow, can't allocate new arrow buffer !\n"); */
|
||||
|
||||
// if (! TEST)
|
||||
// print_arrows_array (sworra, arrows_nb);
|
||||
print_arrows_array (sworra, arrows_nb,0);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -654,9 +651,9 @@ static inline int set_arrow (struct arrow_t *sworra, int arrows_nb, int requeste
|
|||
if (address >= 0 && current_weight != requested_weight)
|
||||
return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z);
|
||||
|
||||
// if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(sworra, arrows_nb, x, y, z);
|
||||
if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(sworra, arrows_nb, 3);
|
||||
|
||||
// if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(sworra, arrows_nb, x, y, z);
|
||||
if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(sworra, arrows_nb, 4);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -680,36 +677,44 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
int rand(void);
|
||||
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
||||
|
||||
int arbitrary = 5;
|
||||
int space_X = 1 + rand() % arbitrary,
|
||||
space_Y = 1 + rand() % arbitrary,
|
||||
space_Z = 1 + rand() % arbitrary;
|
||||
int arbitrary = 3;
|
||||
int space_X = 1,// + rand() % arbitrary,
|
||||
space_Y = 1,// + rand() % arbitrary,
|
||||
space_Z = 1;// + rand() % arbitrary;
|
||||
int density_max = space_X * space_Y * space_Z;
|
||||
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
||||
|
||||
int print_arrows_data = 1;
|
||||
int print_arrows_data = 0;
|
||||
|
||||
int load = 0, site = 0, x = 0, y = 0, z = 0;
|
||||
int specif_arrows_nb = rand() % density_max;
|
||||
int specif_arrows_nb = 1;//rand() % density_max;
|
||||
int arrows_nb = 0, cpt = 0, t_initial = 0;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &ts); t_initial = ts.tv_sec;
|
||||
printf("%10d | ", specif_arrows_nb / 1000);
|
||||
int print_inter_results = 0;
|
||||
if (print_inter_results) clock_gettime(CLOCK_REALTIME, &ts); t_initial = ts.tv_sec;
|
||||
if (print_inter_results) printf("%10d | ", specif_arrows_nb / 1000);
|
||||
#pragma omp parallel
|
||||
{
|
||||
while (arrows_nb < specif_arrows_nb){
|
||||
/* while (arrows_nb < specif_arrows_nb){ */
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
rand() % arbitrary + 1, // load / weight
|
||||
rand() % 6, // site,
|
||||
rand() % space_X, // x
|
||||
rand() % space_Y, // y
|
||||
rand() % space_Z); // z
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
0,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
1,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
/* clock_gettime(CLOCK_REALTIME, &ts); < Je n'arrive pas à afficher les temps en cours d'exécutuion */
|
||||
/* if (arrows_nb % 1000 == 0) {cpt++; printf("%8d", arrows_nb / 1000); if (cpt % 22 == 0) printf(" %f\n%10d | ", specif_arrows_nb / 1000, ts.tv_sec - t_initial);} */
|
||||
if (arrows_nb % 1000 == 0) {cpt++; printf("%8d", arrows_nb / 1000); if (cpt % 24 == 0) printf("\n%10d | ", specif_arrows_nb / 1000);}
|
||||
}
|
||||
printf("\n");
|
||||
if (print_inter_results && arrows_nb % 1000 == 0) {cpt++; printf("%8d", arrows_nb / 1000); if (cpt % 24 == 0) printf("\n%10d | ", specif_arrows_nb / 1000);}
|
||||
/* } */
|
||||
printf("I N I T I A L D A T A A R E N O W S P E C I F I E D\n");
|
||||
}
|
||||
// clock_t start, end;
|
||||
|
||||
|
@ -734,15 +739,17 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
/* ); */
|
||||
// end = clock(); printf("Elapsed time %ld\n", end - start);
|
||||
|
||||
print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data);
|
||||
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
/* D A T A A R E N O W A L L S P E C I F I E D */
|
||||
/*--------------------------------------------------------------------------------*/
|
||||
|
||||
/* D R A W I N G C A N S T A R T */
|
||||
/* I N I T I A L D A T A A R E N O W A L L S P E C I F I E D */
|
||||
|
||||
/*---------------------------------------------------------------*/
|
||||
/* A N D C A N B E D R A W N */
|
||||
|
||||
/* V E R T E X F I R S T */
|
||||
/*--------------------------------------------------------------------------------*/
|
||||
|
||||
/* V E R T E X F I R S T */
|
||||
|
||||
int offset_vertex = 0, offset_colors = 0, offset_lines = 0;
|
||||
|
||||
|
@ -804,6 +811,48 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
offset_vertex += write_one_arrow_line (offset_vertex);
|
||||
}
|
||||
|
||||
/* n E W D A T A W I L L N O W B E S P E C I F I E D */
|
||||
|
||||
/* B E F O R E B E I N G D R A W N E D */
|
||||
|
||||
/*--------------------------------------------------------------------------------*/
|
||||
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
0,//rand() % arbitrary + 1, // load / weight
|
||||
0,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
0,//rand() % arbitrary + 1, // load / weight
|
||||
1,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
2,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
3,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
// offset_vertex -= 2;
|
||||
// buffer_vertex_size += 3;
|
||||
|
||||
|
||||
/* assert : arrows_nb > arbitrary; */
|
||||
/* int random_choice, modified = 0, deleted = 0; */
|
||||
|
||||
|
|
Loading…
Reference in New Issue