-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hsa_amd_pointer_info doesn't work when calling from a function? #128
Comments
That's weird. I see the void* vs int* type on the pointer, and the indirection through a function call, but hsa_amd_pointer_info is in a shared library (so abi is fixed), can't imagine why this would matter. Will see if it reproduces locally. Don't think it does. I appended 'func' and 'main' to the print statements to distinguish them,
(my local machine has a gfx906, rocm 4.5, linux 5.4, driver from rocm as opposed to upstream) |
I updated a bit the above code
So It seems to be a real issue at "-O0". So either I misused the library or a bug. |
What's clang++ in this context? Different behaviour on O0 and O1 is a bug and that's relatively unusual on x64 |
upstream clang and AOMP clang don't matter. g++ constantly failed.
|
What if you change if(0) to if(!a_locked)? That way the compiler would be forced to run hsa_amd_memory_lock before checkLocked(a). Without that, it doesn't know that the checkLocked call depends on hsa_amd_memory_lock. |
It doesn't change the above behavior. |
hsa_amd_memory_lock and hsa_amd_pointer_info are both calls to unknown functions in a shared library - the C++ compiler has to pessimistically assume they might mutate the same global state so can't reorder them. Though different behaviour on O0 and O1 does support the x64 compiler bug theory. Sadly this still doesn't reproduce for me, not sure where the config difference lies |
Hi @ye-luo, are you still having this issue? I was able to reproduce the discrepancy between the function and inline versions as well as the discrepancy between -O0 and-O1. The documentation at ROCR-Runtime/src/inc/hsa_ext_amd.h Line 2020 in d614ea8
hsa_amd_pointer_info". Without doing this, the size field is uninitialized, leading to UB. On my repro, with -O0, this consistently results in a size of 0 when the second call is inside the function, and a size of 2 when it is inlined. ROCR-Runtime/src/core/runtime/runtime.cpp Line 870 in d614ea8
Therefore, to address your issue, set |
@schung-amd thank you for pointing out the issue in my code. After setting the info.size, I got consistent behaviors. |
On my machine, I got
hsa_amd_pointer_info failed
.If I change
if(0)
toif(1)
, the call succeeds.reproducer.
The text was updated successfully, but these errors were encountered: