Skip to content

Commit bbce2d0

Browse files
[rocm-libraries] ROCm/rocm-libraries#12616 (commit dda0b49)
perf(rocrand): add __restrict__ to pointers to preserve philox4_32_10 f64 benchmark performance (#12616) ## Motivation rocRAND device benchmark (rocrand-device) shows a ~13.35% performance drop on MI300X (gfx942) for the normal distribution with the philox4_32_10 engine and f64 type when comparing the WW38 staging compiler build against the WW38 base build. The solution is to add __restrict__ on the states and data parameters of generate_kernel() in benchmark_device_api.hpp. This avoids LDS usage and an increase in VGPRs for this benchmark that limits the blocksize to 128 instead of 256, resulting in uneven work distribution. JIRA ID : AIPRIMS-262 ## Technical Details Adds __restrict__ on the states and data parameters of generate_kernel() in benchmark_device_api.hpp. ## Test Plan Unit tests pass with no performance regressions. ## Test Result Unit tests pass with no performance regressions. ## Submission Checklist - [ ] Look over the contributing guidelines at https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.
1 parent cb02279 commit bbce2d0

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Documentation for rocRAND is available at
44
[https://rocm.docs.amd.com/projects/rocRAND/en/latest/](https://rocm.docs.amd.com/projects/rocRAND/en/latest/)
55

6+
## rocRAND 5.2.0 for ROCm 10.2.0
7+
8+
### Optimized
9+
10+
* Added `__restrict__` qualifiers to the device API benchmark, enabling better compiler optimization.
11+
612
## rocRAND 5.1.0 for ROCm 10.1.0
713

814
### Optimized

‎CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ if(BUILD_ADDRESS_SANITIZER AND BUILD_SHARED_LIBS)
183183
endif()
184184

185185
# Set version variables
186-
rocm_setup_version( VERSION "5.1.0" )
186+
rocm_setup_version( VERSION "5.2.0" )
187187
set ( rocrand_VERSION ${rocRAND_VERSION} )
188188
# Old-style version number used within the library's API. rocrand_get_version should be modified.
189189
math(EXPR rocrand_VERSION_NUMBER "${rocRAND_VERSION_MAJOR} * 100000 + ${rocRAND_VERSION_MINOR} * 100 + ${rocRAND_VERSION_PATCH}")

‎benchmark/benchmark_device_api.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ struct unrolled
335335

336336
template<typename EngineState, typename T, typename Generator>
337337
__global__ __launch_bounds__(get_max_block_size<EngineState>())
338-
void generate_kernel(EngineState* states,
338+
void generate_kernel(EngineState* __restrict__ states,
339339
T* __restrict__ data,
340340
const size_t size,
341341
Generator generator)
@@ -397,7 +397,7 @@ struct runner
397397

398398
template<typename T, typename Generator>
399399
__global__ __launch_bounds__(RAND_DEFAULT_MAX_BLOCK_SIZE)
400-
void generate_kernel(rand_state_mtgp32_t* states,
400+
void generate_kernel(rand_state_mtgp32_t* __restrict__ states,
401401
T* __restrict__ data,
402402
const size_t size,
403403
Generator generator)
@@ -587,7 +587,7 @@ void init_scrambled_sobol_kernel(EngineState* states,
587587
// generate_kernel for the normal and scrambled sobol generators
588588
template<typename EngineState, typename T, typename Generator>
589589
__global__ __launch_bounds__(RAND_DEFAULT_MAX_BLOCK_SIZE)
590-
void generate_sobol_kernel(EngineState* states,
590+
void generate_sobol_kernel(EngineState* __restrict__ states,
591591
T* __restrict__ data,
592592
const size_t size,
593593
Generator generator)

0 commit comments

Comments
 (0)