Skip to content

Commit

Permalink
limit value of cache_aware to 1.0
Browse files Browse the repository at this point in the history
If someone changes DIM or VFDIM, the initialization of cache_aware
may become larger than 1.0.  This should not happen.

Signed-off-by: Stephen M. Cameron <[email protected]>
  • Loading branch information
smcameron committed Apr 28, 2023
1 parent c0dbdd1 commit 94405f9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gaseous-giganticus.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,10 @@ static void init_particles(struct particle **pp, union vec3 **prev_particle_pos,
int pn, px, py;
struct fij fij = { 0, 0, 0 };
struct particle *p;

if (cache_aware > 1.0) /* can happen if someone redefines DIM to be large */
cache_aware = 1.0;

int cache_aware_limit = (int) (cache_aware * nparticles);

printf("Initializing %d particles", nparticles); fflush(stdout);
Expand Down

0 comments on commit 94405f9

Please sign in to comment.