llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[AMDGPU][GlobalISel] Missing opcodes/intrinsics rules in AMDGPURegBankLegalize

Open vangthao95 opened this issue 7 months ago • 25 comments

Missing opcode/intrinsic rules in AMDGPURegBankLegalizeRules.cpp for uniform/divergent register-bank legalization.

Note: This list may not be complete or up to date. Some items may have pull requests in review or have already landed.

Opcodes

  • [x] G_AMDGPU_FLAT_LOAD_MONITOR
  • [x] G_AMDGPU_GLOBAL_LOAD_MONITOR
  • [x] G_AMDGPU_SPONENTRY
  • [x] G_ATOMICRMW_USUB_COND
  • [x] G_ATOMICRMW_USUB_SAT
  • [x] G_BITCAST
  • [x] G_FCONSTANT
  • [x] G_FMAXIMUMNUM
  • [x] G_FMINIMUMNUM
  • [x] G_FPTOSI_SAT
  • [x] G_FPTOUI_SAT
  • [x] G_INTRINSIC_FPTRUNC_ROUND

Intrinsics

  • [x] amdgcn_cluster_load_async_to_lds_b128
  • [x] amdgcn_cluster_load_async_to_lds_b32
  • [x] amdgcn_cluster_load_async_to_lds_b64
  • [x] amdgcn_cluster_load_async_to_lds_b8
  • [x] amdgcn_cluster_load_b128
  • [x] amdgcn_cluster_load_b32
  • [x] amdgcn_cluster_load_b64
  • [x] amdgcn_cvt_f16_bf8
  • [x] amdgcn_cvt_f16_fp8
  • [x] amdgcn_cvt_f32_bf8
  • [x] amdgcn_cvt_f32_fp8
  • [x] amdgcn_cvt_f32_fp8_e5m3
  • [x] amdgcn_cvt_off_f32_i4
  • [x] amdgcn_cvt_pk_bf8_f16
  • [x] amdgcn_cvt_pk_bf8_f32
  • [x] amdgcn_cvt_pk_f16_bf8
  • [x] amdgcn_cvt_pk_f16_fp8
  • [x] amdgcn_cvt_pk_f32_bf8
  • [x] amdgcn_cvt_pk_f32_fp8
  • [x] amdgcn_cvt_pk_fp8_f16
  • [x] amdgcn_cvt_pk_fp8_f32
  • [x] amdgcn_cvt_pk_fp8_f32_e5m3
  • [x] amdgcn_cvt_scalef32_2xpk16_bf6_f32
  • [x] amdgcn_cvt_scalef32_2xpk16_fp6_f32
  • [x] amdgcn_cvt_scalef32_f16_bf8
  • [x] amdgcn_cvt_scalef32_f16_fp8
  • [x] amdgcn_cvt_scalef32_f32_bf8
  • [x] amdgcn_cvt_scalef32_f32_fp8
  • [x] amdgcn_cvt_scalef32_pk32_bf6_f16
  • [x] amdgcn_cvt_scalef32_pk32_f16_bf6
  • [x] amdgcn_cvt_scalef32_pk32_f16_fp6
  • [x] amdgcn_cvt_scalef32_pk32_f32_bf6
  • [x] amdgcn_cvt_scalef32_pk32_f32_fp6
  • [x] amdgcn_cvt_scalef32_pk32_fp6_f16
  • [x] amdgcn_cvt_scalef32_pk_bf8_f16
  • [x] amdgcn_cvt_scalef32_pk_bf8_f32
  • [x] amdgcn_cvt_scalef32_pk_f16_bf8
  • [x] amdgcn_cvt_scalef32_pk_f16_fp4
  • [x] amdgcn_cvt_scalef32_pk_f16_fp8
  • [x] amdgcn_cvt_scalef32_pk_f32_bf8
  • [x] amdgcn_cvt_scalef32_pk_f32_fp4
  • [x] amdgcn_cvt_scalef32_pk_f32_fp8
  • [x] amdgcn_cvt_scalef32_pk_fp4_f16
  • [x] amdgcn_cvt_scalef32_pk_fp4_f32
  • [x] amdgcn_cvt_scalef32_pk_fp8_f16
  • [x] amdgcn_cvt_scalef32_pk_fp8_f32
  • [ ] amdgcn_cvt_scalef32_sr_bf8_f16 (in progress)
  • [ ] amdgcn_cvt_scalef32_sr_bf8_f32 (in progress)
  • [ ] amdgcn_cvt_scalef32_sr_fp8_f16 (in progress)
  • [ ] amdgcn_cvt_scalef32_sr_fp8_f32 (in progress)
  • [x] amdgcn_cvt_scalef32_sr_pk32_bf6_bf16
  • [x] amdgcn_cvt_scalef32_sr_pk32_bf6_f16
  • [x] amdgcn_cvt_scalef32_sr_pk32_bf6_f32
  • [x] amdgcn_cvt_scalef32_sr_pk32_fp6_f16
  • [x] amdgcn_cvt_scalef32_sr_pk32_fp6_f32
  • [x] amdgcn_cvt_scalef32_sr_pk_fp4_f16
  • [x] amdgcn_cvt_scalef32_sr_pk_fp4_f32
  • [x] amdgcn_cvt_sr_bf8_f16
  • [x] amdgcn_cvt_sr_bf8_f32
  • [x] amdgcn_cvt_sr_f16_f32
  • [x] amdgcn_cvt_sr_fp8_f16
  • [x] amdgcn_cvt_sr_fp8_f32
  • [x] amdgcn_cvt_sr_fp8_f32_e5m3
  • [x] amdgcn_cvt_sr_pk_f16_f32
  • [x] amdgcn_ds_atomic_async_barrier_arrive_b64
  • [x] amdgcn_ds_atomic_barrier_arrive_rtn_b64
  • [x] amdgcn_flat_prefetch
  • [x] amdgcn_frexp_exp
  • [x] amdgcn_global_load_tr4_b64
  • [x] amdgcn_global_load_tr6_b96
  • [x] amdgcn_global_prefetch
  • [x] amdgcn_global_store_async_from_lds_b128
  • [x] amdgcn_global_store_async_from_lds_b32
  • [x] amdgcn_global_store_async_from_lds_b64
  • [x] amdgcn_global_store_async_from_lds_b8
  • [x] amdgcn_load_to_lds
  • [x] amdgcn_log
  • [x] amdgcn_permlane_bcast
  • [x] amdgcn_permlane_down
  • [x] amdgcn_permlane_idx_gen
  • [x] amdgcn_permlane_up
  • [x] amdgcn_permlane_xor
  • [x] amdgcn_raw_buffer_load_async_lds
  • [x] amdgcn_raw_ptr_buffer_load_async_lds
  • [x] amdgcn_rcp
  • [x] amdgcn_rsq
  • [x] amdgcn_rsq_clamp
  • [x] amdgcn_s_alloc_vgpr
  • [x] amdgcn_sat_pk4_i4_i8
  • [x] amdgcn_sat_pk4_u4_u8
  • [ ] amdgcn_s_bitreplicate (in progress)
  • [x] amdgcn_set_inactive
  • [x] amdgcn_set_inactive_chain_arg
  • [x] amdgcn_sqrt
  • [x] amdgcn_struct_buffer_load_async_lds
  • [x] amdgcn_struct_ptr_buffer_load_async_lds
  • [x] amdgcn_unreachable
  • [x] amdgcn_wave_shuffle

vangthao95 avatar Apr 16 '26 17:04 vangthao95

@llvm/issue-subscribers-backend-amdgpu

Author: vangthao95

There are missing opcode/intrinsic rules in `AMDGPURegBankLegalizeRules.cpp` for legalizing register banks depending on whether the instruction is uniform or divergent. Below is a list of opcodes/intrinsics that are missing. Note that this list may not be complete or up to date, some may have pull requests in review or have already been landed.
G_AMDGPU_FLAT_LOAD_MONITOR
G_AMDGPU_GLOBAL_LOAD_MONITOR
G_AMDGPU_SPONENTRY
G_ATOMICRMW_USUB_COND
G_ATOMICRMW_USUB_SAT
G_BITCAST
G_FCONSTANT
G_FMAXIMUMNUM
G_FMINIMUMNUM
G_FPTOSI_SAT
G_FPTOUI_SAT
G_INTRINSIC_FPTRUNC_ROUND
G_PREFETCH
amdgcn_cluster_load_async_to_lds_b128
amdgcn_cluster_load_async_to_lds_b32
amdgcn_cluster_load_async_to_lds_b64
amdgcn_cluster_load_async_to_lds_b8
amdgcn_cluster_load_b128
amdgcn_cluster_load_b32
amdgcn_cluster_load_b64
amdgcn_cvt_f16_bf8
amdgcn_cvt_f16_fp8
amdgcn_cvt_f32_bf8
amdgcn_cvt_f32_fp8
amdgcn_cvt_f32_fp8_e5m3
amdgcn_cvt_off_f32_i4
amdgcn_cvt_pk_bf8_f16
amdgcn_cvt_pk_bf8_f32
amdgcn_cvt_pk_f16_bf8
amdgcn_cvt_pk_f16_fp8
amdgcn_cvt_pk_f32_bf8
amdgcn_cvt_pk_f32_fp8
amdgcn_cvt_pk_fp8_f16
amdgcn_cvt_pk_fp8_f32
amdgcn_cvt_pk_fp8_f32_e5m3
amdgcn_cvt_scalef32_2xpk16_bf6_f32
amdgcn_cvt_scalef32_2xpk16_fp6_f32
amdgcn_cvt_scalef32_f16_bf8
amdgcn_cvt_scalef32_f16_fp8
amdgcn_cvt_scalef32_f32_bf8
amdgcn_cvt_scalef32_f32_fp8
amdgcn_cvt_scalef32_pk32_bf6_f16
amdgcn_cvt_scalef32_pk32_f16_bf6
amdgcn_cvt_scalef32_pk32_f16_fp6
amdgcn_cvt_scalef32_pk32_f32_bf6
amdgcn_cvt_scalef32_pk32_f32_fp6
amdgcn_cvt_scalef32_pk32_fp6_f16
amdgcn_cvt_scalef32_pk_bf8_f16
amdgcn_cvt_scalef32_pk_bf8_f32
amdgcn_cvt_scalef32_pk_f16_bf8
amdgcn_cvt_scalef32_pk_f16_fp4
amdgcn_cvt_scalef32_pk_f16_fp8
amdgcn_cvt_scalef32_pk_f32_bf8
amdgcn_cvt_scalef32_pk_f32_fp4
amdgcn_cvt_scalef32_pk_f32_fp8
amdgcn_cvt_scalef32_pk_fp4_f16
amdgcn_cvt_scalef32_pk_fp4_f32
amdgcn_cvt_scalef32_pk_fp8_f16
amdgcn_cvt_scalef32_pk_fp8_f32
amdgcn_cvt_scalef32_sr_bf8_f16
amdgcn_cvt_scalef32_sr_bf8_f32
amdgcn_cvt_scalef32_sr_fp8_f16
amdgcn_cvt_scalef32_sr_fp8_f32
amdgcn_cvt_scalef32_sr_pk32_bf6_bf16
amdgcn_cvt_scalef32_sr_pk32_bf6_f16
amdgcn_cvt_scalef32_sr_pk32_bf6_f32
amdgcn_cvt_scalef32_sr_pk32_fp6_f16
amdgcn_cvt_scalef32_sr_pk32_fp6_f32
amdgcn_cvt_scalef32_sr_pk_fp4_f16
amdgcn_cvt_scalef32_sr_pk_fp4_f32
amdgcn_cvt_sr_bf8_f16
amdgcn_cvt_sr_bf8_f32
amdgcn_cvt_sr_f16_f32
amdgcn_cvt_sr_fp8_f16
amdgcn_cvt_sr_fp8_f32
amdgcn_cvt_sr_fp8_f32_e5m3
amdgcn_cvt_sr_pk_f16_f32
amdgcn_ds_atomic_async_barrier_arrive_b64
amdgcn_ds_atomic_barrier_arrive_rtn_b64
amdgcn_flat_prefetch
amdgcn_frexp_exp
amdgcn_global_load_tr4_b64
amdgcn_global_load_tr6_b96
amdgcn_global_prefetch
amdgcn_global_store_async_from_lds_b128
amdgcn_global_store_async_from_lds_b32
amdgcn_global_store_async_from_lds_b64
amdgcn_global_store_async_from_lds_b8
amdgcn_load_to_lds
amdgcn_log
amdgcn_permlane_bcast
amdgcn_permlane_down
amdgcn_permlane_idx_gen
amdgcn_permlane_up
amdgcn_permlane_xor
amdgcn_raw_buffer_load_async_lds
amdgcn_raw_ptr_buffer_load_async_lds
amdgcn_rcp
amdgcn_rsq
amdgcn_rsq_clamp
amdgcn_s_alloc_vgpr
amdgcn_sat_pk4_i4_i8
amdgcn_sat_pk4_u4_u8
amdgcn_s_bitreplicate
amdgcn_set_inactive
amdgcn_set_inactive_chain_arg
amdgcn_sqrt
amdgcn_s_quadmask
amdgcn_struct_buffer_load_async_lds
amdgcn_struct_ptr_buffer_load_async_lds
amdgcn_s_wqm
amdgcn_tensor_load_to_lds
amdgcn_tensor_store_from_lds
amdgcn_unreachable
amdgcn_wave_shuffle

llvmbot avatar Apr 16 '26 17:04 llvmbot

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
  2. Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
  3. Fix the issue locally.
  4. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  5. Create a Git commit.
  6. Run git clang-format HEAD~1 to format your changes.
  7. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

llvmbot avatar Apr 17 '26 16:04 llvmbot

@llvm/issue-subscribers-good-first-issue

Author: vangthao95

There are missing opcode/intrinsic rules in `AMDGPURegBankLegalizeRules.cpp` for legalizing register banks depending on whether the instruction is uniform or divergent. Below is a list of opcodes/intrinsics that are missing. Note that this list may not be complete or up to date, some may have pull requests in review or have already been landed.

G_AMDGPU_FLAT_LOAD_MONITOR G_AMDGPU_GLOBAL_LOAD_MONITOR G_AMDGPU_SPONENTRY G_ATOMICRMW_USUB_COND G_ATOMICRMW_USUB_SAT G_BITCAST G_FCONSTANT G_FMAXIMUMNUM G_FMINIMUMNUM G_FPTOSI_SAT G_FPTOUI_SAT ~~G_INTRINSIC_FPTRUNC_ROUND~~ In-progress G_PREFETCH amdgcn_cluster_load_async_to_lds_b128 amdgcn_cluster_load_async_to_lds_b32 amdgcn_cluster_load_async_to_lds_b64 amdgcn_cluster_load_async_to_lds_b8 amdgcn_cluster_load_b128 amdgcn_cluster_load_b32 amdgcn_cluster_load_b64 amdgcn_cvt_f16_bf8 amdgcn_cvt_f16_fp8 amdgcn_cvt_f32_bf8 amdgcn_cvt_f32_fp8 amdgcn_cvt_f32_fp8_e5m3 ~~amdgcn_cvt_off_f32_i4~~ In-progress amdgcn_cvt_pk_bf8_f16 ~~amdgcn_cvt_pk_bf8_f32~~ In-progress amdgcn_cvt_pk_f16_bf8 amdgcn_cvt_pk_f16_fp8 ~~amdgcn_cvt_pk_f32_bf8~~ In-progress ~~amdgcn_cvt_pk_f32_fp8~~ In-progress amdgcn_cvt_pk_fp8_f16 ~~amdgcn_cvt_pk_fp8_f32~~ In-progress amdgcn_cvt_pk_fp8_f32_e5m3 amdgcn_cvt_scalef32_2xpk16_bf6_f32 amdgcn_cvt_scalef32_2xpk16_fp6_f32 amdgcn_cvt_scalef32_f16_bf8 amdgcn_cvt_scalef32_f16_fp8 amdgcn_cvt_scalef32_f32_bf8 amdgcn_cvt_scalef32_f32_fp8 amdgcn_cvt_scalef32_pk32_bf6_f16 amdgcn_cvt_scalef32_pk32_f16_bf6 amdgcn_cvt_scalef32_pk32_f16_fp6 amdgcn_cvt_scalef32_pk32_f32_bf6 amdgcn_cvt_scalef32_pk32_f32_fp6 amdgcn_cvt_scalef32_pk32_fp6_f16 amdgcn_cvt_scalef32_pk_bf8_f16 amdgcn_cvt_scalef32_pk_bf8_f32 amdgcn_cvt_scalef32_pk_f16_bf8 amdgcn_cvt_scalef32_pk_f16_fp4 amdgcn_cvt_scalef32_pk_f16_fp8 amdgcn_cvt_scalef32_pk_f32_bf8 amdgcn_cvt_scalef32_pk_f32_fp4 amdgcn_cvt_scalef32_pk_f32_fp8 amdgcn_cvt_scalef32_pk_fp4_f16 amdgcn_cvt_scalef32_pk_fp4_f32 amdgcn_cvt_scalef32_pk_fp8_f16 amdgcn_cvt_scalef32_pk_fp8_f32 ~~amdgcn_cvt_scalef32_sr_bf8_f16~~ In-progress ~~amdgcn_cvt_scalef32_sr_bf8_f32~~ In-progress ~~amdgcn_cvt_scalef32_sr_fp8_f16~~ In-progress ~~amdgcn_cvt_scalef32_sr_fp8_f32~~ In-progress ~~amdgcn_cvt_scalef32_sr_pk32_bf6_bf16~~ In-progress ~~amdgcn_cvt_scalef32_sr_pk32_bf6_f16~~ In-progress amdgcn_cvt_scalef32_sr_pk32_bf6_f32 ~~amdgcn_cvt_scalef32_sr_pk32_fp6_f16~~ In-progress amdgcn_cvt_scalef32_sr_pk32_fp6_f32 ~~amdgcn_cvt_scalef32_sr_pk_fp4_f16~~ In-progress ~~amdgcn_cvt_scalef32_sr_pk_fp4_f32~~ In-progress amdgcn_cvt_sr_bf8_f16 amdgcn_cvt_sr_bf8_f32 amdgcn_cvt_sr_f16_f32 amdgcn_cvt_sr_fp8_f16 amdgcn_cvt_sr_fp8_f32 amdgcn_cvt_sr_fp8_f32_e5m3 amdgcn_cvt_sr_pk_f16_f32 amdgcn_ds_atomic_async_barrier_arrive_b64 amdgcn_ds_atomic_barrier_arrive_rtn_b64 amdgcn_flat_prefetch ~~amdgcn_frexp_exp~~ In-progress amdgcn_global_load_tr4_b64 amdgcn_global_load_tr6_b96 amdgcn_global_prefetch amdgcn_global_store_async_from_lds_b128 amdgcn_global_store_async_from_lds_b32 amdgcn_global_store_async_from_lds_b64 amdgcn_global_store_async_from_lds_b8 amdgcn_load_to_lds amdgcn_log amdgcn_permlane_bcast amdgcn_permlane_down amdgcn_permlane_idx_gen amdgcn_permlane_up amdgcn_permlane_xor ~~amdgcn_raw_buffer_load_async_lds~~ In-progress ~~amdgcn_raw_ptr_buffer_load_async_lds~~ In-progress amdgcn_rcp amdgcn_rsq amdgcn_rsq_clamp amdgcn_s_alloc_vgpr amdgcn_sat_pk4_i4_i8 amdgcn_sat_pk4_u4_u8 ~~amdgcn_s_bitreplicate~~ In-progress ~~amdgcn_set_inactive~~ In-progress ~~amdgcn_set_inactive_chain_arg~~ In-progress amdgcn_sqrt amdgcn_s_quadmask amdgcn_struct_buffer_load_async_lds amdgcn_struct_ptr_buffer_load_async_lds amdgcn_s_wqm amdgcn_tensor_load_to_lds amdgcn_tensor_store_from_lds amdgcn_unreachable amdgcn_wave_shuffle

llvmbot avatar Apr 17 '26 16:04 llvmbot

Hi I'd like to give this issue a shot. Is there anyone currently working on it?

aidanshilling avatar Apr 19 '26 15:04 aidanshilling

To clarify the scope of this issue, would a complete PR include adding all of these opcodes? (assuming the list is up to date) Or could I pick a group of them and do it in chunks?

Also I believe this will require an ISA reference and I was wondering which ISA are in scope for this issue? RDNA 3/4, CDNA etc?

aidanshilling avatar Apr 19 '26 15:04 aidanshilling

@aidanshilling thank you for your interest in contributing to llvm-project and the AMDGPU backend.

To clarify the scope of this issue, would a complete PR include adding all of these opcodes? assuming the list is up to date) Or could I pick a group of them and do it in chunks?

Ideally, you'd pick one of the opcodes or intrinsics and work on that. For some intrinsics, there's an opportunity to batch them together. Please refer to ongoing work.

It would be easier for everyone if you could mention what opcodes/intrinsics you are working on, as part of this issue, so that the other contributors are informed.

We request that you pick up the next TODO only after current work is merged.

Also I believe this will require an ISA reference and I was wondering which ISA are in scope for this issue? RDNA 3/4, CDNA etc?

Programming documentation is available here. I believe the existing SDAG backend for the various targets that we support should be enough to get started.

Thanks again.

chinmaydd avatar Apr 19 '26 16:04 chinmaydd

@chinmaydd Thanks! Hopefully I can be of some help.

It would be easier for everyone if you could mention what opcodes/intrinsics you are working on, as part of this issue, so that the other contributors are informed.

Sure, can do. I'm pretty new to this and don't want to slow anything down, are there any opcodes that are lower priority you'd recommend I take on? Otherwise I'll follow the current work for a bit and single out something small for my first issue.

We request that you pick up the next TODO only after current work is merged.

For sure, no problem. Just to clarify does this mean I should wait to submit anything until all of @vangthao95 's current PR's open for LegalizeRules are merged in the ongoing work?

Programming documentation is available here. I believe the existing SDAG backend for the various targets that we support should be enough to get started.

Awesome thank you!

aidanshilling avatar Apr 19 '26 18:04 aidanshilling

are there any opcodes that are lower priority you'd recommend I take on?

amdgcn_s_alloc_vgpr seems straightforward. LMK if you'd like to try your hand at that. I can cross it off the above list.

For sure, no problem. Just to clarify does this mean I should wait to submit anything until all of @vangthao95 's current PR's open for LegalizeRules are merged in the ongoing work?

Not really, work can go along in parallel.

chinmaydd avatar Apr 19 '26 21:04 chinmaydd

@chinmaydd Sure I'll give amdgcn_s_alloc_vgpr a go.

aidanshilling avatar Apr 19 '26 22:04 aidanshilling

Hi @chinmaydd, I would also like to give this issue a shot, would you recommend any other straightforward opcodes?

asadium avatar Apr 20 '26 06:04 asadium

Hi @chinmaydd, I would also like to give this issue a shot, would you recommend any other straightforward opcodes?

maybe G_FPTOSI_SAT, G_FPTOUI_SAT probably same as non-sat version

petar-avramovic avatar Apr 20 '26 13:04 petar-avramovic

Got it, I will give G_FPTOSI_SAT and G_FPTOUI_SAT a shot

asadium avatar Apr 20 '26 13:04 asadium

I'll take on amdgcn_sat_pk4_i4_i8 next if no one else is working on it.

aidanshilling avatar Apr 20 '26 15:04 aidanshilling

@chinmaydd I tihnk amdgcn_sat_pk4_u4_u8 would basically share the exact same legalize ruels as amdgcn_sat_pk4_i4_i8 based on the tablegen data since they are both VOP1 & have 32in 16out. Assuming I'm correct on that should I just include that in my pr as well?

aidanshilling avatar Apr 20 '26 21:04 aidanshilling

Assuming I'm correct on that should I just include that in my pr as well?

Yes, they are a tightly bound pair

arsenm avatar Apr 20 '26 21:04 arsenm

Hi! Is it possible for me to work on amdgcn_sqrt if no one is currently working on it? If it is not possible, any other recommendation?

slant14 avatar Apr 21 '26 12:04 slant14

Hi! Is it possible for me to work on amdgcn_sqrt if no one is currently working on it? If it is not possible, any other recommendation?

Yes, go for it

arsenm avatar Apr 21 '26 12:04 arsenm

I can go for amdgcn_cvt_sr_fp8_f32, amdgcn_cvt_sr_bf8_f32. If I understand these correctly they are just converting 32-bit floating points that are either storied in SGPR or VGPR and converting them to lower precision divergent formats that must be in VGPR? So it would likely just be a case of using .uni() and .div() and mapping the in's and outs correctly?

Edit: Looks like based on the test for cvt.fp8 I would also need to handle the reverse f32->fp8 and the pk variants as well.

so we'd need:

amdgcn_cvt_sr_fp8_f32, amdgcn_cvt_sr_bf8_f32 amdgcn_cvt_pk_fp8_f32, amdgcn_cvt_pk_bf8_f32 and amdgcn_cvt_f32_bf8, amdgcn_cvt_f32_fp8

aidanshilling avatar Apr 22 '26 13:04 aidanshilling

Hi @aidanshilling, thank you for your interest in helping out! amdgcn_cvt_sr_fp8_f32 and amdgcn_cvt_sr_bf8_f32 converts a 32bit floating point into either fp8 or bf8 and stores it back into a 32bit register. There is no SALU form so the result must be in VGPRs for the uniform rule. I believe amdgcn_cvt_pk_f32_bf8 and amdgcn_cvt_pk_f32_fp8 are also related to these intrinsics if you are interested.

vangthao95 avatar Apr 22 '26 17:04 vangthao95

@vangthao95 yea for sure! That makes sense, I see amdgcn_cvt_pk_f32_bf8 and amdgcn_cvt_pk_f32_fp8 in the test file as well. I think I've already got the other 6 worked out so those shouldn't be much different. Ill get these all built and tested and make a PR.

aidanshilling avatar Apr 22 '26 17:04 aidanshilling