MIOpen icon indicating copy to clipboard operation
MIOpen copied to clipboard

Move repetitive code into a dedicated header

Open CAHEK7 opened this issue 1 year ago • 2 comments

Based on https://github.com/ROCm/MIOpen/pull/2737#discussion_r1486010993 discussion. The project contains lots of copy-pasted functions like integer division with ceil rounding or various power of 2 checks, it would be nice to move that code into dedicated header and reuse it everywhere. Ideally it should be generalized and templated.

  • [ ] uint32_t Ceil(uint32_t val, uint32_t div)
  • [ ] uint32_t RoundUpNearestPower2Positive(uint32_t v)
  • [ ] uint32_t RoundUpToMultiple(uint32_t val, uint32_t factor)
  • [ ] bool isPow2(uint32_t val) (questionable, it's not a widely used function)
  • [ ] anything else?

CAHEK7 avatar Feb 12 '24 13:02 CAHEK7

There might be a use case for uin64_t versions as well. Also it would be good if we can improve naming if it's possible.

Kirpich30000 avatar Feb 12 '24 17:02 Kirpich30000

It's probably a good place for all those functions. https://github.com/ROCm/MIOpen/blob/develop/src/include/miopen/mlo_internal.hpp

CAHEK7 avatar Jul 25 '24 13:07 CAHEK7

Closing since MIOpen is being migrated to ROCm/rocm-libraries. Please re-open there if you believe this is still an issue.

JonathanLichtnerAMD avatar Jul 29 '25 01:07 JonathanLichtnerAMD