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);
srand(time(NULL));
- RD_Opts opts = meiosis;
+ RD_Opts opts = puffer;
for (int x = 0; x < GRID_X; x++)
{
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)
{
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);