WIP: filling graphic buffers step by step (up to 4 000 000 arrows)

This commit is contained in:
Jean Sirmai 2023-10-04 20:16:44 +02:00
parent 0587219bd3
commit 5f8be7fc38
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 114 additions and 29 deletions

77
gdb.txt Normal file
View File

@ -0,0 +1,77 @@
The program is not being run.
Temporary breakpoint 1 at 0x404740: file src/main.c, line 42.
Starting program: /home/jean/Gem-Graph/gem-graph-client/bin/gem-graph-client
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/libthread_db.so.1".
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffce58) at src/main.c:42
42 app = gem_graph_client_application_new("org.alec.gemgraph",
Continuing.
[New Thread 0x7fffef5ff640 (LWP 21368)]
[New Thread 0x7fffee2f5640 (LWP 21369)]
[New Thread 0x7fffecfeb640 (LWP 21370)]
[Thread 0x7fffecfeb640 (LWP 21370) exited]
[New Thread 0x7fffecfeb640 (LWP 21371)]
[New Thread 0x7fffe49b5640 (LWP 21372)]
[New Thread 0x7fffe41b4640 (LWP 21373)]
[New Thread 0x7fffe2eaa640 (LWP 21374)]
[New Thread 0x7fffe1ba0640 (LWP 21375)]
[New Thread 0x7fffe0896640 (LWP 21376)]
[New Thread 0x7fffdf58c640 (LWP 21377)]
[New Thread 0x7fffde282640 (LWP 21378)]
[New Thread 0x7fffdcf78640 (LWP 21379)]
[New Thread 0x7fffdbc6e640 (LWP 21380)]
[Thread 0x7fffe49b5640 (LWP 21372) exited]
[Thread 0x7fffde282640 (LWP 21378) exited]
[Thread 0x7fffdf58c640 (LWP 21377) exited]
[Thread 0x7fffe0896640 (LWP 21376) exited]
[Thread 0x7fffe1ba0640 (LWP 21375) exited]
[Thread 0x7fffe41b4640 (LWP 21373) exited]
[Thread 0x7fffdbc6e640 (LWP 21380) exited]
[Thread 0x7fffdcf78640 (LWP 21379) exited]
[Thread 0x7fffe2eaa640 (LWP 21374) exited]
[Thread 0x7fffecfeb640 (LWP 21371) exited]
[New Thread 0x7fffecfeb640 (LWP 21381)]
[New Thread 0x7fffdbc6e640 (LWP 21382)]
[New Thread 0x7fffdcf78640 (LWP 21383)]
[New Thread 0x7fffde282640 (LWP 21384)]
[New Thread 0x7fffe33ff640 (LWP 21385)]
[New Thread 0x7fffe20f5640 (LWP 21386)]
[New Thread 0x7fffe0deb640 (LWP 21387)]
[New Thread 0x7fffe05ea640 (LWP 21388)]
[New Thread 0x7fffdda81640 (LWP 21389)]
[New Thread 0x7fffdb46d640 (LWP 21390)]
[New Thread 0x7fffd965a640 (LWP 21391)]
[New Thread 0x7fffd8350640 (LWP 21392)]
[New Thread 0x7fffd7046640 (LWP 21393)]
[New Thread 0x7fffd5d3c640 (LWP 21394)]
[New Thread 0x7fffd4a32640 (LWP 21395)]
[New Thread 0x7fffd3728640 (LWP 21396)]
[New Thread 0x7fffd241e640 (LWP 21397)]
[New Thread 0x7fffd1c1d640 (LWP 21398)]
[Thread 0x7fffd241e640 (LWP 21397) exited]
[Thread 0x7fffd1c1d640 (LWP 21398) exited]
[New Thread 0x7fffd1c1d640 (LWP 21399)]
[New Thread 0x7fffd241e640 (LWP 21400)]
[Thread 0x7fffd1c1d640 (LWP 21399) exited]
[Thread 0x7fffd241e640 (LWP 21400) exited]
[New Thread 0x7fffd241e640 (LWP 21401)]
[New Thread 0x7fffd1c1d640 (LWP 21402)]
[Thread 0x7fffd7046640 (LWP 21393) exited]
Thread 1 "gem-graph-clien" received signal SIGINT, Interrupt.
0x00007ffff5ab4d4b in __memmove_sse2_unaligned_erms () from /gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/libc.so.6
Breakpoint 2 at 0x4088a5: file src/graphics/graphics.c, line 697.
Continuing.
[Thread 0x7fffd5d3c640 (LWP 21394) exited]
Thread 1 "gem-graph-clien" received signal SIGINT, Interrupt.
0x00007ffff5b77dca in __memset_avx2_unaligned_erms () from /gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/libc.so.6
Breakpoint 3 at 0x408320: file src/graphics/graphics.c, line 873.
Continuing.
Thread 1 "gem-graph-clien" received signal SIGINT, Interrupt.
0x00007ffff5ab4e3e in __memmove_sse2_unaligned_erms () from /gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/libc.so.6
Quit
quit

View File

@ -45,7 +45,7 @@ static volatile int buffer_lines_size = 0;
static volatile int buffer_colors_size = 0; static volatile int buffer_colors_size = 0;
static volatile int buffer_plans_size = 0; static volatile int buffer_plans_size = 0;
#define TEST 1 #define TEST 0
/* /*
* Dynamic array of ptrs to dynamically allocated gl_area_entry * Dynamic array of ptrs to dynamically allocated gl_area_entry
@ -762,9 +762,9 @@ static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requeste
} }
} }
printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight); //printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight);
show_user_action(arrows, arrows_nb, address, requested_weight, current_weight, site, x, y, z); if (TEST) show_user_action(arrows, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
if (address == -1 && requested_weight > 0) if (address == -1 && requested_weight > 0)
return create_arrow (arrows_nb, requested_weight, site, x, y, z); return create_arrow (arrows_nb, requested_weight, site, x, y, z);
@ -775,9 +775,9 @@ static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requeste
if (address >= 0 && current_weight != requested_weight) if (address >= 0 && current_weight != requested_weight)
return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z); return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z);
if (! TEST && address >= 0 && current_weight == requested_weight) show_arrows_array(arrows, arrows_nb, x, y, z); // if (! TEST && address >= 0 && current_weight == requested_weight) show_arrows_array(arrows, arrows_nb, x, y, z);
if (! TEST && address == -1 && requested_weight == 0) show_arrows_array(arrows, arrows_nb, x, y, z); // if (! TEST && address == -1 && requested_weight == 0) show_arrows_array(arrows, arrows_nb, x, y, z);
return arrows_nb; return arrows_nb;
} }
@ -867,7 +867,7 @@ static void show_user_action(struct arrow_t *arrows, int arrows_nb, int address,
* *
* Draws space and arrows * Draws space and arrows
*/ */
void main_test_graphics (void) void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
{ {
// assert : space dimensions (x,y,z) > 0 TODO NOT checked before init // assert : space dimensions (x,y,z) > 0 TODO NOT checked before init
// assert : arrows localization within space and sites TODO NOT checked when invoking set_arrow() // assert : arrows localization within space and sites TODO NOT checked when invoking set_arrow()
@ -879,14 +879,20 @@ void main_test_graphics (void)
int rand(void); int rand(void);
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min); void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
int arbitrary = 500; int arbitrary = 4000000;
int space_X = 1 + rand() % arbitrary, int space_arbitrary = 200;
space_Y = 1 + rand() % arbitrary, int space_X = 200 + rand() % space_arbitrary,
space_Z = 1 + rand() % arbitrary; space_Y = 200 + rand() % space_arbitrary,
space_Z = 200 + rand() % space_arbitrary;
int density_max = space_X * space_Y * space_Z; int density_max = space_X * space_Y * space_Z;
int arrows_nb = 0; int arrows_nb = 0;
int pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc int pref_show_grids = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
// xyz, 0, x, y, z, xy, xz, yz, xyz // xyz, 0, x, y, z, xy, xz, yz, xyz
int weight = 0, site = 0,
stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0;
int offset_after_grids = buffer_vertex_size / 3;
int buffer_lines_size_after_cubes = buffer_lines_size;
int offset_up_to_this_cube_coords = 0, x, y, z;
/* arrows = g_malloc0(arrows_nb * sizeof(struct arrow_t)); */ /* arrows = g_malloc0(arrows_nb * sizeof(struct arrow_t)); */
@ -912,9 +918,6 @@ void main_test_graphics (void)
if (pref_show_grids % 3 == 0) grid_write_y (space_X, space_Y, space_Z); if (pref_show_grids % 3 == 0) grid_write_y (space_X, space_Y, space_Z);
if (pref_show_grids % 5 == 0) grid_write_z (space_X, space_Y, space_Z); if (pref_show_grids % 5 == 0) grid_write_z (space_X, space_Y, space_Z);
if (pref_show_grids > 0) grid_write_ridges (space_X, space_Y, space_Z); if (pref_show_grids > 0) grid_write_ridges (space_X, space_Y, space_Z);
int offset_after_grids = buffer_vertex_size / 3;
int buffer_lines_size_after_cubes = buffer_lines_size;
int offset_up_to_this_cube_coords = 0, x, y, z;
/* ARROWS */ /* ARROWS */
/* NB The 12 vertices required to draw 6 arrows in each cube /* NB The 12 vertices required to draw 6 arrows in each cube
@ -922,21 +925,19 @@ void main_test_graphics (void)
/* Therefore: if (arrows_nb > 0) is not required (next line) */ /* Therefore: if (arrows_nb > 0) is not required (next line) */
arrows_write_terminations (space_X, space_Y, space_Z); arrows_write_terminations (space_X, space_Y, space_Z);
for (int k = 0; k < arbitrary; k++) /* Writing 100 by 100*/
volatile int remaining = arbitrary;
while (remaining) {
for (int l = 0; l < 10; l++) {
arrows_nb = set_arrow (arrows, arrows_nb, arrows_nb = set_arrow (arrows, arrows_nb,
rand() % arbitrary, // load / weight rand() % arbitrary, // load / weight
rand() % 6, // site, rand() % 6, // site,
rand() % space_X, // x rand() % space_X, // x
rand() % space_Y, // y rand() % space_Y, // y
rand() % space_Z); // z rand() % space_Z); // z
}
remaining -= 100;
// ligne suivante inutile: < ce sont les sous-fonctions de set_arrow() qui appellent
// show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1, 1);
int weight = 0, site = 0,
stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0;
if (arrows_nb > 0)
for (int i = 0; i < arrows_nb; i++) { for (int i = 0; i < arrows_nb; i++) {
weight = arrows[i].load; weight = arrows[i].load;
site = arrows[i].site; site = arrows[i].site;
@ -958,6 +959,13 @@ void main_test_graphics (void)
} }
free(arrows); free(arrows);
arrows = NULL;
arrows_nb = 0;
if (TEST) printf("\nCreated %d arrows", arbitrary - remaining);
}
// ligne suivante inutile: < ce sont les sous-fonctions de set_arrow() qui appellent
// show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1, 1);
show_buffers_states(space_X, space_Y, space_Z, arrows_nb, show_buffers_states(space_X, space_Y, space_Z, arrows_nb,
offset_after_grids, buffer_vertex_size, offset_after_grids, buffer_vertex_size,