Conversation
- some attributes are 8 bytes but passed pointer was 4 bytes Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix an AddressSanitizer (ASAN) error in the hipMemPoolSetAttribute performance test by changing the variable type from int to uint64_t. The ASAN error occurred because some attributes require 8-byte values but a 4-byte pointer was being passed.
Changes:
- Changed the
valuevariable type frominttouint64_tin theMemPoolSetAttributeBenchmarkoperator
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| uint64_t value{0}; | ||
|
|
||
| TIMED_SECTION(kTimerTypeCpu) { HIP_CHECK(hipMemPoolSetAttribute(mem_pool, attribute, &value)); } | ||
|
|
There was a problem hiding this comment.
The fix changes the value type to uint64_t, but this is only correct for hipMemPoolAttrReleaseThreshold. The other three attributes being tested (hipMemPoolReuseFollowEventDependencies, hipMemPoolReuseAllowOpportunistic, hipMemPoolReuseAllowInternalDependencies) expect value type int according to the API documentation. This will cause incorrect behavior or potential memory safety issues when testing those attributes. The code should use different variable types based on the attribute being tested, similar to how it's done in hipMemPoolApi.cc lines 71-80 where uint64_t is used for hipMemPoolAttrUsedMemHigh and int is used for hipMemPoolReuseFollowEventDependencies.
| uint64_t value{0}; | |
| TIMED_SECTION(kTimerTypeCpu) { HIP_CHECK(hipMemPoolSetAttribute(mem_pool, attribute, &value)); } | |
| if (attribute == hipMemPoolAttrReleaseThreshold) { | |
| uint64_t value{0}; | |
| TIMED_SECTION(kTimerTypeCpu) { | |
| HIP_CHECK(hipMemPoolSetAttribute(mem_pool, attribute, &value)); | |
| } | |
| } else { | |
| int value{0}; | |
| TIMED_SECTION(kTimerTypeCpu) { | |
| HIP_CHECK(hipMemPoolSetAttribute(mem_pool, attribute, &value)); | |
| } | |
| } |
Motivation
Technical Details
JIRA ID
Test Plan
Test Result
Submission Checklist