@@ -76,23 +76,23 @@ namespace ggml_cuda_mma {
7676 // For the A/C matrices this means I major == row major, J major == column major.
7777 // For the B matrix this means I major == column major, J major == row major.
7878 // MIRRORED == Each data value is held exactly once per thread subgroup.
79- DATA_LAYOUT_I_MAJOR = 0 , // Always used for Turing, Ampere, Ada Lovelace, consumer Blackwell, matrix A&B for RDNA4 and CDNA.
80- DATA_LAYOUT_J_MAJOR = 10 , // Matrix C for CDNA and RDNA4 , int and float matrix C for RDNA3 .
79+ DATA_LAYOUT_I_MAJOR = 0 , // Always used for Turing, Ampere, Ada Lovelace, consumer Blackwell, matrix A&B for WMMA128 and CDNA.
80+ DATA_LAYOUT_J_MAJOR = 10 , // Matrix C for CDNA and WMMA128 , int and float matrix C for WMMA256 .
8181 DATA_LAYOUT_I_MAJOR_MIRRORED = 20 , // Volta, matrix A&B for RDNA3.
8282 DATA_LAYOUT_J_MAJOR_MIRRORED = 30 ,
83- DATA_LAYOUT_I_MAJOR_SCRAMBLED = 40 , // Scrambled matrix C for faster transposition (RDNA4 /CDNA), convert to float to unscramble.
83+ DATA_LAYOUT_I_MAJOR_SCRAMBLED = 40 , // Scrambled matrix C for faster transposition (WMMA128 /CDNA), convert to float to unscramble.
8484 };
8585 // Implemented mma combinations are:
8686 // - (I_MAJOR, I_MAJOR) -> I_MAJOR
8787 // - (I_MAJOR, I_MAJOR_MIRRORED) -> I_MAJOR
8888 // - (I_MAJOR, J_MAJOR_MIRRORED) -> I_MAJOR
8989
9090 static constexpr __device__ data_layout get_input_data_layout () {
91- #if defined(RDNA3 ) || defined(VOLTA_MMA_AVAILABLE)
91+ #if defined(AMD_WMMA_256B_AVAILABLE ) || defined(VOLTA_MMA_AVAILABLE)
9292 return DATA_LAYOUT_I_MAJOR_MIRRORED ;
9393#else
9494 return DATA_LAYOUT_I_MAJOR ;
95- #endif // defined(RDNA3 ) || defined(VOLTA_MMA_AVAILABLE)
95+ #endif // defined(AMD_WMMA_256B_AVAILABLE ) || defined(VOLTA_MMA_AVAILABLE)
9696 }
9797
9898 template <int I_ , int J_ , typename T, data_layout ds_=DATA_LAYOUT_I_MAJOR >
@@ -201,7 +201,7 @@ namespace ggml_cuda_mma {
201201
202202 static __device__ __forceinline__ int get_j (const int l) {
203203 if constexpr (I == 16 && J == 16 ) {
204- #if defined(RDNA3 )
204+ #if defined(AMD_WMMA_256B_AVAILABLE )
205205 if constexpr (std::is_same_v<T, float > || std::is_same_v<T, int >) {
206206 // matrix C
207207 return 2 * l + (threadIdx .x / 16 );
@@ -210,11 +210,11 @@ namespace ggml_cuda_mma {
210210 return l;
211211 }
212212#else
213- // matrix C is the transposed matrix A&B on RDNA4
213+ // matrix C is the transposed matrix A&B on WMMA128
214214 return ne * (threadIdx .x / 16 ) + l;
215- #endif // defined(RDNA3 )
215+ #endif // defined(AMD_WMMA_256B_AVAILABLE )
216216 } else if constexpr (I == 16 && J == 8 ) {
217- // mmq input for RDNA4
217+ // mmq input for WMMA128
218218 return ne * (threadIdx .x / 16 ) + l;
219219 } else if constexpr (I == 16 && J == 4 ) {
220220 return ne * (threadIdx .x / 16 ) + l;
@@ -573,7 +573,7 @@ namespace ggml_cuda_mma {
573573 static constexpr int I = I_ ;
574574 static constexpr int J = J_ ;
575575 static constexpr data_layout dl = DATA_LAYOUT_I_MAJOR_MIRRORED ;
576- #if defined(RDNA3 )
576+ #if defined(AMD_WMMA_256B_AVAILABLE )
577577 static constexpr int ne = tile<I_ , J_ , float , DATA_LAYOUT_I_MAJOR_MIRRORED >::ne;
578578
579579 half2 x[ne] = {{0 .0f , 0 .0f }};
@@ -616,7 +616,7 @@ namespace ggml_cuda_mma {
616616 return -1 ;
617617 }
618618 }
619- #endif // defined(RDNA3 )
619+ #endif // defined(AMD_WMMA_256B_AVAILABLE )
620620 };
621621
622622 template <int I_ , int J_ >
@@ -694,7 +694,7 @@ namespace ggml_cuda_mma {
694694 };
695695
696696 static __device__ __forceinline__ tile<16 , 16 , half2, DATA_LAYOUT_I_MAJOR > unscramble (const tile<16 , 16 , half2, DATA_LAYOUT_I_MAJOR_SCRAMBLED > & t) {
697- #if defined(AMD_MFMA_AVAILABLE) || ( defined(AMD_WMMA_AVAILABLE) && defined(RDNA4) )
697+ #if defined(AMD_MFMA_AVAILABLE) || defined(AMD_WMMA_128B_AVAILABLE )
698698 tile<16 , 16 , half2, DATA_LAYOUT_I_MAJOR > ret;
699699#pragma unroll
700700 for (int l0 = 0 ; l0 < t.ne /2 ; ++l0) {
@@ -705,7 +705,7 @@ namespace ggml_cuda_mma {
705705#else
706706 NO_DEVICE_CODE ;
707707 GGML_UNUSED (t);
708- #endif // defined(AMD_MFMA_AVAILABLE) || ( defined(AMD_WMMA_AVAILABLE) && defined(RDNA4) )
708+ #endif // defined(AMD_MFMA_AVAILABLE) || defined(AMD_WMMA_128B_AVAILABLE )
709709 }
710710
711711#if defined(TURING_MMA_AVAILABLE)
@@ -726,7 +726,7 @@ namespace ggml_cuda_mma {
726726
727727 return ret;
728728 }
729- #elif defined(AMD_WMMA_AVAILABLE) && defined(RDNA3 )
729+ #elif defined(AMD_WMMA_256B_AVAILABLE )
730730 static __device__ __forceinline__ tile<16 , 8 , half2, DATA_LAYOUT_I_MAJOR_MIRRORED > get_half2 (
731731 const tile<16 , 16 , float , DATA_LAYOUT_I_MAJOR > & tile_float) {
732732 tile<16 , 8 , half2, DATA_LAYOUT_I_MAJOR_MIRRORED > ret;
@@ -1171,7 +1171,7 @@ namespace ggml_cuda_mma {
11711171 : " r" (Axi[2 ]), " r" (Axi[3 ]), " r" (Bxi[3 ]));
11721172#endif // __CUDA_ARCH__ >= GGML_CUDA_CC_AMPERE
11731173#elif defined(AMD_WMMA_AVAILABLE)
1174- #if defined(RDNA4 )
1174+ #if defined(AMD_WMMA_128B_AVAILABLE )
11751175 using halfx8_t = __attribute__ ((ext_vector_type (8 ))) _Float16;
11761176 halfx8_t & acc_frag = reinterpret_cast <halfx8_t &>(D.x [0 ]);
11771177 const halfx8_t & a_frag = reinterpret_cast <const halfx8_t &>(A.x [0 ]);
@@ -1180,7 +1180,7 @@ namespace ggml_cuda_mma {
11801180#else
11811181 GGML_UNUSED_VARS (D, A, B);
11821182 NO_DEVICE_CODE ;
1183- #endif // defined(RDNA4 )
1183+ #endif // defined(AMD_WMMA_128B_AVAILABLE )
11841184#elif defined(AMD_MFMA_AVAILABLE)
11851185 // MFMA: FP16 input, FP32 accumulate, convert back to half2.
11861186 using halfx4_t = __attribute__ ((ext_vector_type (4 ))) _Float16;
@@ -1218,15 +1218,15 @@ namespace ggml_cuda_mma {
12181218 static __device__ __forceinline__ void mma (
12191219 tile<16 , 16 , half2, DATA_LAYOUT_I_MAJOR_SCRAMBLED > & D, const tile<32 , 8 , half2, DATA_LAYOUT_I_MAJOR > & A,
12201220 const tile<16 , 8 , half2, DATA_LAYOUT_I_MAJOR > & B) {
1221- #if defined(AMD_MFMA_AVAILABLE) || ( defined(AMD_WMMA_AVAILABLE) && defined(RDNA4) )
1221+ #if defined(AMD_MFMA_AVAILABLE) || defined(AMD_WMMA_128B_AVAILABLE )
12221222 tile<16 , 8 , half2> * D16 = (tile<16 , 8 , half2> *) &D;
12231223 const tile<16 , 8 , half2> * A16 = (const tile<16 , 8 , half2> *) &A;
12241224 mma (D16 [0 ], A16 [0 ], B);
12251225 mma (D16 [1 ], A16 [1 ], B);
12261226#else
12271227 GGML_UNUSED_VARS (D, A, B);
12281228 NO_DEVICE_CODE ;
1229- #endif // defined(AMD_MFMA_AVAILABLE) || defined(AMD_WMMA_AVAILABLE) && defined(RDNA4 )
1229+ #endif // defined(AMD_MFMA_AVAILABLE) || defined(AMD_WMMA_128B_AVAILABLE )
12301230 }
12311231
12321232 template <data_layout dl_ab, data_layout dl_d>
@@ -1373,14 +1373,14 @@ namespace ggml_cuda_mma {
13731373 : " r" (Axi[2 ]), " r" (Axi[3 ]), " r" (Bxi[3 ]));
13741374#endif // __CUDA_ARCH__ >= GGML_CUDA_CC_AMPERE
13751375#elif defined(AMD_WMMA_AVAILABLE)
1376- #if defined(RDNA4 )
1376+ #if defined(AMD_WMMA_128B_AVAILABLE )
13771377 using halfx8_t = __attribute__ ((ext_vector_type (8 ))) _Float16;
13781378 using floatx8_t = __attribute__ ((ext_vector_type (8 ))) float ;
13791379 floatx8_t & acc_frag = reinterpret_cast <floatx8_t &>(D.x [0 ]);
13801380 const halfx8_t & a_frag = reinterpret_cast <const halfx8_t &>(A.x [0 ]);
13811381 const halfx8_t & b_frag = reinterpret_cast <const halfx8_t &>(B.x [0 ]);
13821382 acc_frag = __builtin_amdgcn_wmma_f32_16x16x16_f16_w32_gfx12 (a_frag, b_frag, acc_frag);
1383- #elif defined(RDNA3 )
1383+ #elif defined(AMD_WMMA_256B_AVAILABLE )
13841384 using halfx16_t = __attribute__ ((ext_vector_type (16 ))) _Float16;
13851385 using floatx8_t = __attribute__ ((ext_vector_type (8 ))) float ;
13861386 floatx8_t & acc_frag = reinterpret_cast <floatx8_t &>(D.x [0 ]);
@@ -1390,7 +1390,7 @@ namespace ggml_cuda_mma {
13901390#else
13911391 GGML_UNUSED_VARS (D, A, B);
13921392 NO_DEVICE_CODE ;
1393- #endif // RDNA4
1393+ #endif // AMD_WMMA_128B_AVAILABLE
13941394#elif defined(AMD_MFMA_AVAILABLE)
13951395 using halfx4_t = __attribute__ ((ext_vector_type (4 ))) _Float16;
13961396 using floatx4_t = __attribute__ ((ext_vector_type (4 ))) float ;
@@ -1408,14 +1408,14 @@ namespace ggml_cuda_mma {
14081408 static __device__ __forceinline__ void mma (
14091409 tile<16 , 16 , float , dl_d> & D, const tile<16 , 8 , nv_bfloat162, dl_ab> & A, const tile<16 , 8 , nv_bfloat162, dl_ab> & B) {
14101410#if defined(AMD_WMMA_AVAILABLE)
1411- #if defined(RDNA4 )
1411+ #if defined(AMD_WMMA_128B_AVAILABLE )
14121412 using bf16x8_t = __attribute__ ((ext_vector_type (8 ))) short ;
14131413 using floatx8_t = __attribute__ ((ext_vector_type (8 ))) float ;
14141414 floatx8_t & acc_frag = reinterpret_cast <floatx8_t &>(D.x [0 ]);
14151415 const bf16x8_t & a_frag = reinterpret_cast <const bf16x8_t &>(A.x [0 ]);
14161416 const bf16x8_t & b_frag = reinterpret_cast <const bf16x8_t &>(B.x [0 ]);
14171417 acc_frag = __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32_gfx12 (a_frag, b_frag, acc_frag);
1418- #elif defined(RDNA3 )
1418+ #elif defined(AMD_WMMA_256B_AVAILABLE )
14191419 using bf16x16_t = __attribute__ ((ext_vector_type (16 ))) short ;
14201420 using floatx8_t = __attribute__ ((ext_vector_type (8 ))) float ;
14211421 floatx8_t & acc_frag = reinterpret_cast <floatx8_t &>(D.x [0 ]);
@@ -1425,7 +1425,7 @@ namespace ggml_cuda_mma {
14251425#else
14261426 GGML_UNUSED_VARS (D, A, B);
14271427 NO_DEVICE_CODE ;
1428- #endif // defined(RDNA4 )
1428+ #endif // defined(AMD_WMMA_128B_AVAILABLE )
14291429#elif defined(AMD_MFMA_AVAILABLE)
14301430 using floatx4_t = __attribute__ ((ext_vector_type (4 ))) float ;
14311431 floatx4_t & acc_frag = reinterpret_cast <floatx4_t &>(D.x [0 ]);
@@ -1467,19 +1467,19 @@ namespace ggml_cuda_mma {
14671467#elif defined(AMD_WMMA_AVAILABLE)
14681468 using int32x8_t = __attribute__ ((__vector_size__ (8 * sizeof (int )))) int ;
14691469 int32x8_t * acc = (int32x8_t *) D.x ;
1470- #if defined(RDNA4 )
1470+ #if defined(AMD_WMMA_128B_AVAILABLE )
14711471 using int32x2_t = __attribute__ ((__vector_size__ (2 * sizeof (int )))) int ;
14721472 int32x2_t * a_vec = (int32x2_t *) A.x ;
14731473 int32x2_t * b_vec = (int32x2_t *) B.x ;
14741474 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32_gfx12 (true , a_vec[0 ], true , b_vec[0 ], acc[0 ], true );
14751475 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32_gfx12 (true , a_vec[1 ], true , b_vec[1 ], acc[0 ], true );
1476- #elif defined(RDNA3 )
1476+ #elif defined(AMD_WMMA_256B_AVAILABLE )
14771477 using int32x4_t = __attribute__ ((__vector_size__ (4 * sizeof (int )))) int ;
14781478 int32x4_t * a_vec = (int32x4_t *) A.x ;
14791479 int32x4_t * b_vec = (int32x4_t *) B.x ;
14801480 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32 (true , a_vec[0 ], true , b_vec[0 ], acc[0 ], true );
14811481 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32 (true , a_vec[1 ], true , b_vec[1 ], acc[0 ], true );
1482- #endif // RDNA4
1482+ #endif // AMD_WMMA_128B_AVAILABLE
14831483#else
14841484 GGML_UNUSED_VARS (D, A, B);
14851485 NO_DEVICE_CODE ;
@@ -1556,7 +1556,7 @@ namespace ggml_cuda_mma {
15561556 static __device__ __forceinline__ void mma (
15571557 tile<16 , 16 , half2, DATA_LAYOUT_I_MAJOR > & D, const tile<32 , 8 , half2, DATA_LAYOUT_I_MAJOR_MIRRORED > & A,
15581558 const tile<16 , 8 , half2, DATA_LAYOUT_I_MAJOR_MIRRORED > & B) {
1559- #if defined(AMD_WMMA_AVAILABLE) && defined(RDNA3 )
1559+ #if defined(AMD_WMMA_256B_AVAILABLE )
15601560 using halfx16_t = __attribute__ ((ext_vector_type (16 ))) _Float16;
15611561 halfx16_t * xD = (halfx16_t *) D.x ;
15621562 const halfx16_t * xA = (const halfx16_t *) A.x ;
@@ -1585,17 +1585,17 @@ namespace ggml_cuda_mma {
15851585#elif defined(AMD_WMMA_AVAILABLE)
15861586 using int32x8_t = __attribute__ ((__vector_size__ (8 * sizeof (int )))) int ;
15871587 int32x8_t * acc = (int32x8_t *) D.x ;
1588- #if defined(RDNA4 )
1588+ #if defined(AMD_WMMA_128B_AVAILABLE )
15891589 using int32x2_t = __attribute__ ((__vector_size__ (2 * sizeof (int )))) int ;
15901590 int32x2_t * a_vec = (int32x2_t *) A.x ;
15911591 int32x2_t * b_vec = (int32x2_t *) B.x ;
15921592 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32_gfx12 (true , a_vec[0 ], true , b_vec[0 ], acc[0 ], false );
1593- #elif defined(RDNA3 )
1593+ #elif defined(AMD_WMMA_256B_AVAILABLE )
15941594 using int32x4_t = __attribute__ ((__vector_size__ (4 * sizeof (int )))) int ;
15951595 int32x4_t * a_vec = (int32x4_t *) A.x ;
15961596 int32x4_t * b_vec = (int32x4_t *) B.x ;
15971597 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32 (true , a_vec[0 ], true , b_vec[0 ], acc[0 ], false );
1598- #endif // RDNA4
1598+ #endif // AMD_WMMA_128B_AVAILABLE
15991599#else
16001600 GGML_UNUSED (D);
16011601 GGML_UNUSED (A);
0 commit comments