Skip to content
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

Missing warp match functions in HIP #9

Closed
Epliz opened this issue Sep 1, 2023 · 3 comments
Closed

Missing warp match functions in HIP #9

Epliz opened this issue Sep 1, 2023 · 3 comments

Comments

@Epliz
Copy link

Epliz commented Sep 1, 2023

Hi,

As pointed out at ROCm/hipamd#65 , match_any/match_all are not available in HIP.
These are available in CUDA (cf. https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#warp-match-functions ), and can be implemented on AMD GPUs on Vega+ architectures (such intrinsic corresponds to "WaveMatch" in HLSL shader model 6.5 https://microsoft.github.io/DirectX-Specs/d3d/HLSL_ShaderModel6_5.html#wavematch-function which is supported by Vega+).

Therefore it seems like they can and should be added.

match_any can for example be implemented as seen at llvm/llvm-project#62477 :

static inline __device__ uint64_t  __match_any(int value) {
  bool active = true;
  uint64_t result = 0;

  while (active) {
    // determine what threads have the same value as the currently first active thread
    int first_active_value = __builtin_amdgcn_readfirstlane(value);
    int predicate = (value == first_active_value);
    uint64_t m = __ballot(predicate); // THIS LINE IS PROBLEMATIC

    // if the current thread has the same value, set its result mask to the current one
    if (predicate) {
      result |= m;
      active = false;
    }
  }

  return result;
}

There used to be compiler bugs making it hard to implement them as with the code above, but they have been fixed.
Feel free to use that code if you want to.

Best regards,
Epliz

@Epliz
Copy link
Author

Epliz commented Sep 1, 2023

@cjatin , you were kind enough to have a look at #2 ; this one is quite similar, so I would appreciate if you could have a look at this one as well :) .

@Epliz Epliz changed the title Missing warp match functions Missing warp match functions in HIP Sep 1, 2023
@cjatin
Copy link
Contributor

cjatin commented Jan 15, 2024

c5ab568

@Epliz
Copy link
Author

Epliz commented Jan 16, 2024

Thanks a lot @cjatin , looking forward to trying it in the next release with it

@Epliz Epliz closed this as completed Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants