Skip to content

Commit 218d502

Browse files
committed
Add RDNA1 and RDNA2 architecture detection
Add detection functions for RDNA1 and RDNA2 GPU architectures to enable proper hardware identification and kernel dispatch. This infrastructure enables subsequent commits to properly distinguish between RDNA generations and apply appropriate tensor core constraints, as RDNA1/RDNA2 have limited tensor core capabilities compared to RDNA3/4.
1 parent c3277eb commit 218d502

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

mojo/stdlib/stdlib/sys/info.mojo

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,56 @@ fn is_nvidia_gpu[subarch: StaticString]() -> Bool:
561561
return is_nvidia_gpu() and CompilationTarget._is_arch[subarch]()
562562

563563

564+
@always_inline("nodebug")
565+
fn _is_amd_rdna1() -> Bool:
566+
"""Returns True if the target triple of the compiler is `amdgcn-amd-amdhsa`
567+
and we are compiling for the any of the Radeon RX 5000 series
568+
sub-architectures:
569+
570+
amdgpu:gfx1010: Navi 10 (RX 5700 XT/5700)
571+
amdgpu:gfx1011: Navi 12
572+
amdgpu:gfx1012: Navi 14 (RX 5500 XT/5500)
573+
amdgpu:gfx1013: Navi 14
574+
575+
Returns:
576+
True if the RDNA1 and False otherwise.
577+
"""
578+
return (
579+
is_amd_gpu["amdgpu:gfx1010"]()
580+
or is_amd_gpu["amdgpu:gfx1011"]()
581+
or is_amd_gpu["amdgpu:gfx1012"]()
582+
or is_amd_gpu["amdgpu:gfx1013"]()
583+
)
584+
585+
586+
@always_inline("nodebug")
587+
fn _is_amd_rdna2() -> Bool:
588+
"""Returns True if the target triple of the compiler is `amdgcn-amd-amdhsa`
589+
and we are compiling for the any of the Radeon RX 6000 series
590+
sub-architectures:
591+
592+
amdgpu:gfx1030: Navi 21 (RX 6900/6800)
593+
amdgpu:gfx1031: Navi 22 (RX 6700)
594+
amdgpu:gfx1032: Navi 23 (RX 6600)
595+
amdgpu:gfx1033: Navi 24
596+
amdgpu:gfx1034: Navi 24
597+
amdgpu:gfx1035: Rembrandt APU
598+
amdgpu:gfx1036: Raphael APU
599+
600+
Returns:
601+
True if the RDNA2 and False otherwise.
602+
"""
603+
return (
604+
is_amd_gpu["amdgpu:gfx1030"]()
605+
or is_amd_gpu["amdgpu:gfx1031"]()
606+
or is_amd_gpu["amdgpu:gfx1032"]()
607+
or is_amd_gpu["amdgpu:gfx1033"]()
608+
or is_amd_gpu["amdgpu:gfx1034"]()
609+
or is_amd_gpu["amdgpu:gfx1035"]()
610+
or is_amd_gpu["amdgpu:gfx1036"]()
611+
)
612+
613+
564614
@always_inline("nodebug")
565615
fn _is_amd_rdna3() -> Bool:
566616
return (
@@ -582,7 +632,9 @@ fn _is_amd_rdna4() -> Bool:
582632

583633
@always_inline("nodebug")
584634
fn _is_amd_rdna() -> Bool:
585-
return _is_amd_rdna3() or _is_amd_rdna4()
635+
return (
636+
_is_amd_rdna1() or _is_amd_rdna2() or _is_amd_rdna3() or _is_amd_rdna4()
637+
)
586638

587639

588640
@always_inline("nodebug")

0 commit comments

Comments
 (0)