]> git.mcshandy.xyz Git - barrow_crawler/commitdiff
Reworked that edge case handling because it fucked with literal edges lmao. Still...
authorRandy McShandy <randy@mcshandy.xyz>
Wed, 13 Dec 2023 05:07:12 +0000 (23:07 -0600)
committerRandy McShandy <randy@mcshandy.xyz>
Wed, 13 Dec 2023 05:07:12 +0000 (23:07 -0600)
main.c

diff --git a/main.c b/main.c
index cf979eaf117508186b84de8582910552137c4dac..1fc6dcad55049e80a1caafb9a0291708d343651d 100755 (executable)
--- a/main.c
+++ b/main.c
@@ -186,15 +186,15 @@ void* iterator(void* _arg)
        RD_Opts opts = warg->opts;
        int start_x = warg->start_x;
        int start_y = warg->start_y;
-       int w = (warg->width + start_x >= GRID_X) ? GRID_X-1 - start_x: warg->width;
-       int h = (warg->height + start_y >= GRID_Y) ? GRID_Y-1 - start_y : warg->height;
+       int w = warg->width;//(warg->width + start_x >= GRID_X) ? GRID_X-1 - start_x: warg->width;
+       int h = warg->height;//(warg->height + start_y >= GRID_Y) ? GRID_Y-1 - start_y : warg->height;
 
        for (warg->iterations = 0; warg->iterations < warg->max_iterations; warg->iterations++)
        {
                printf("worker %d: work unit %d/%d\n", warg->worker_id, warg->iterations, warg->max_iterations);
-               for (int x = start_x; x < w + start_x; x++)
+               for (int x = start_x; x < w + start_x && x < GRID_X; x++)
                {
-                       for (int y = start_y; y < h + start_y; y++)
+                       for (int y = start_y; y < h + start_y && y < GRID_Y; y++)
                        {
                                FVec2 each = grid[x][y];
                                grid_prime[x][y].a = rd_a_prime(grid, opts, x, y, laplacian_kernel, each.a, each.b);
@@ -308,7 +308,7 @@ int main(int argc, char** argv)
 
        srand(time(NULL));
 
-       RD_Opts opts = meiosis;
+       RD_Opts opts = puffer;
 
        for (int x = 0; x < GRID_X; x++)
        {
@@ -355,44 +355,6 @@ int main(int argc, char** argv)
                pthread_create(&threads[t], NULL, iterator, &wargs[t]);
        }
 
-       int max_iterations = (GRID_X / 128.0f) * opts.max_iterations;
-       max_iterations = warg.max_iterations;
-       /*
-       for (int iterations = 0; iterations < max_iterations; iterations++)
-       {
-               printf("boss: waiting on workers\n");
-               pthread_mutex_lock(warg.mutex);
-               while (*warg.waiting_workers < warg.worker_count)
-               {
-                       pthread_cond_wait(warg.boss_cond, warg.mutex);
-               }
-               pthread_mutex_unlock(warg.mutex);
-
-               grid_temp = grid;
-               grid = grid_prime;
-               grid_prime = grid_temp;
-               printf("boss: workload %d/%d\n", iterations, max_iterations);
-               {
-                       // segfault somewhere in here lmao
-                                if (1 && (iterations % (max_iterations/100) == 0))
-                                {
-                                char buffer[GRID_X][GRID_Y];
-                                for (int x = 0; x < GRID_X; x++)
-                                {
-                                for (int y = 0; y < GRID_Y; y++)
-                                {
-                                buffer[x][y] = (uint8_t)(255.0f * grid[x][y].a);
-                                }
-                                }
-                                char name[64] = {0};
-                                sprintf(name, "img/%s/%d.png", opts.name, iterations);
-                                stbi_write_png(name, GRID_X, GRID_Y, 1, buffer, GRID_X * sizeof(uint8_t));
-                                }
-               }
-
-       }
-       */
-
        int should_quit = 0;
        while(!should_quit)
        {
@@ -408,7 +370,7 @@ int main(int argc, char** argv)
                pthread_join(threads[t], NULL);
        }
 
-       printf("Opts: {\nIterations: %d\nTime delta: %f\nDiffA: %f\nDiffB: %f\nFeed: %f\nKill: %f\n\n}\n", max_iterations, opts.delta_t, opts.diff_a, opts.diff_b, opts.feed, opts.kill);
+       printf("Opts: {\nIterations: %d\nTime delta: %f\nDiffA: %f\nDiffB: %f\nFeed: %f\nKill: %f\n\n}\n", wargs[0].max_iterations, opts.delta_t, opts.diff_a, opts.diff_b, opts.feed, opts.kill);
 
        // It's end of execution, who cares
        free(grid);