Skip to content

Commit

Permalink
Cast computation to uint
Browse files Browse the repository at this point in the history
  • Loading branch information
gordicaleksa committed Jun 19, 2024
1 parent fd564f7 commit 66950f3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions llmc/cuda_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ __device__ __host__ constexpr unsigned int SquirrelNoise5(int positionX, unsigne
}
__device__ __host__ constexpr unsigned int Get2dNoiseUint(int indexX, int indexY, unsigned int seed)
{
constexpr int PRIME_NUMBER = 198491317; // Large prime number with non-boring bits
return SquirrelNoise5(indexX + (PRIME_NUMBER * indexY), seed);
constexpr unsigned int PRIME_NUMBER = 198491317u; // Large prime number with non-boring bits
unsigned int x = static_cast<unsigned int>(indexX);
unsigned int y = static_cast<unsigned int>(indexY);

return SquirrelNoise5(x + (PRIME_NUMBER * y), seed);
}

// stochastic rounding built on top of Squirel Noise above (with seed updated per step via xorshift)
Expand Down

0 comments on commit 66950f3

Please sign in to comment.