Skip to content

Commit

Permalink
Merge branch '285-discrete_cdf-is-incorrectly-used-by-some-prngs' int…
Browse files Browse the repository at this point in the history
…o 'develop_stream'

Use discrete_alias instead of discrete_cdf with all PRNGs

Closes #285

See merge request amd/libraries/rocRAND!333
  • Loading branch information
ex-rzr authored and Naraenda committed Jul 9, 2024
2 parents 8f7e2af + 23dc7c9 commit 615fc5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Documentation for rocRAND is available at
[https://rocm.docs.amd.com/projects/rocRAND/en/latest/](https://rocm.docs.amd.com/projects/rocRAND/en/latest/)

## (Unreleased) rocRAND-3.2.0 for ROCm 6.3.0

### Changes

* `rocrand_discrete` for MTGP32, LFSR113 and ThreeFry generators now uses the alias method, which is faster than binary search in CDF.

## (Unreleased) rocRAND-3.1.1 for ROCm 6.2.0

## Fixes
Expand Down
12 changes: 6 additions & 6 deletions library/include/rocrand/rocrand_discrete.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ __forceinline__ __device__ unsigned int
rocrand_discrete(rocrand_state_mtgp32* state,
const rocrand_discrete_distribution discrete_distribution)
{
return rocrand_device::detail::discrete_cdf(rocrand(state), *discrete_distribution);
return rocrand_device::detail::discrete_alias(rocrand(state), *discrete_distribution);
}

/**
Expand Down Expand Up @@ -376,7 +376,7 @@ __forceinline__ __device__ __host__ unsigned int
rocrand_discrete(rocrand_state_lfsr113* state,
const rocrand_discrete_distribution discrete_distribution)
{
return rocrand_device::detail::discrete_cdf(rocrand(state), *discrete_distribution);
return rocrand_device::detail::discrete_alias(rocrand(state), *discrete_distribution);
}

/**
Expand All @@ -395,7 +395,7 @@ __forceinline__ __device__ __host__ unsigned int
rocrand_discrete(rocrand_state_threefry2x32_20* state,
const rocrand_discrete_distribution discrete_distribution)
{
return rocrand_device::detail::discrete_cdf(rocrand(state), *discrete_distribution);
return rocrand_device::detail::discrete_alias(rocrand(state), *discrete_distribution);
}

/**
Expand All @@ -414,7 +414,7 @@ __forceinline__ __device__ __host__ unsigned int
rocrand_discrete(rocrand_state_threefry2x64_20* state,
const rocrand_discrete_distribution discrete_distribution)
{
return rocrand_device::detail::discrete_cdf(rocrand(state), *discrete_distribution);
return rocrand_device::detail::discrete_alias(rocrand(state), *discrete_distribution);
}

/**
Expand All @@ -433,7 +433,7 @@ __forceinline__ __device__ __host__ unsigned int
rocrand_discrete(rocrand_state_threefry4x32_20* state,
const rocrand_discrete_distribution discrete_distribution)
{
return rocrand_device::detail::discrete_cdf(rocrand(state), *discrete_distribution);
return rocrand_device::detail::discrete_alias(rocrand(state), *discrete_distribution);
}

/**
Expand All @@ -452,7 +452,7 @@ __forceinline__ __device__ __host__ unsigned int
rocrand_discrete(rocrand_state_threefry4x64_20* state,
const rocrand_discrete_distribution discrete_distribution)
{
return rocrand_device::detail::discrete_cdf(rocrand(state), *discrete_distribution);
return rocrand_device::detail::discrete_alias(rocrand(state), *discrete_distribution);
}

/** @} */ // end of group rocranddevice
Expand Down

0 comments on commit 615fc5a

Please sign in to comment.