@@ -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;
@@ -1021,7 +1021,7 @@ namespace ggml_cuda_mma {
10211021 : " r" (Axi[2 ]), " r" (Axi[3 ]), " r" (Bxi[3 ]));
10221022#endif // __CUDA_ARCH__ >= GGML_CUDA_CC_AMPERE
10231023#elif defined(AMD_WMMA_AVAILABLE)
1024- #if defined(RDNA4 )
1024+ #if defined(AMD_WMMA_128B_AVAILABLE )
10251025 using halfx8_t = __attribute__ ((ext_vector_type (8 ))) _Float16;
10261026 halfx8_t & acc_frag = reinterpret_cast <halfx8_t &>(D.x [0 ]);
10271027 const halfx8_t & a_frag = reinterpret_cast <const halfx8_t &>(A.x [0 ]);
@@ -1030,7 +1030,7 @@ namespace ggml_cuda_mma {
10301030#else
10311031 GGML_UNUSED_VARS (D, A, B);
10321032 NO_DEVICE_CODE ;
1033- #endif // defined(RDNA4 )
1033+ #endif // defined(AMD_WMMA_128B_AVAILABLE )
10341034#elif defined(AMD_MFMA_AVAILABLE)
10351035 // MFMA: FP16 input, FP32 accumulate, convert back to half2.
10361036 using halfx4_t = __attribute__ ((ext_vector_type (4 ))) _Float16;
@@ -1068,15 +1068,15 @@ namespace ggml_cuda_mma {
10681068 static __device__ __forceinline__ void mma (
10691069 tile<16 , 16 , half2, DATA_LAYOUT_I_MAJOR_SCRAMBLED > & D, const tile<32 , 8 , half2, DATA_LAYOUT_I_MAJOR > & A,
10701070 const tile<16 , 8 , half2, DATA_LAYOUT_I_MAJOR > & B) {
1071- #if defined(AMD_MFMA_AVAILABLE) || ( defined(AMD_WMMA_AVAILABLE) && defined(RDNA4) )
1071+ #if defined(AMD_MFMA_AVAILABLE) || defined(AMD_WMMA_128B_AVAILABLE )
10721072 tile<16 , 8 , half2> * D16 = (tile<16 , 8 , half2> *) &D;
10731073 const tile<16 , 8 , half2> * A16 = (const tile<16 , 8 , half2> *) &A;
10741074 mma (D16 [0 ], A16 [0 ], B);
10751075 mma (D16 [1 ], A16 [1 ], B);
10761076#else
10771077 GGML_UNUSED_VARS (D, A, B);
10781078 NO_DEVICE_CODE ;
1079- #endif // defined(AMD_MFMA_AVAILABLE) || defined(AMD_WMMA_AVAILABLE) && defined(RDNA4 )
1079+ #endif // defined(AMD_MFMA_AVAILABLE) || defined(AMD_WMMA_128B_AVAILABLE )
10801080 }
10811081
10821082 template <data_layout dl_ab, data_layout dl_d>
@@ -1223,14 +1223,14 @@ namespace ggml_cuda_mma {
12231223 : " r" (Axi[2 ]), " r" (Axi[3 ]), " r" (Bxi[3 ]));
12241224#endif // __CUDA_ARCH__ >= GGML_CUDA_CC_AMPERE
12251225#elif defined(AMD_WMMA_AVAILABLE)
1226- #if defined(RDNA4 )
1226+ #if defined(AMD_WMMA_128B_AVAILABLE )
12271227 using halfx8_t = __attribute__ ((ext_vector_type (8 ))) _Float16;
12281228 using floatx8_t = __attribute__ ((ext_vector_type (8 ))) float ;
12291229 floatx8_t & acc_frag = reinterpret_cast <floatx8_t &>(D.x [0 ]);
12301230 const halfx8_t & a_frag = reinterpret_cast <const halfx8_t &>(A.x [0 ]);
12311231 const halfx8_t & b_frag = reinterpret_cast <const halfx8_t &>(B.x [0 ]);
12321232 acc_frag = __builtin_amdgcn_wmma_f32_16x16x16_f16_w32_gfx12 (a_frag, b_frag, acc_frag);
1233- #elif defined(RDNA3 )
1233+ #elif defined(AMD_WMMA_256B_AVAILABLE )
12341234 using halfx16_t = __attribute__ ((ext_vector_type (16 ))) _Float16;
12351235 using floatx8_t = __attribute__ ((ext_vector_type (8 ))) float ;
12361236 floatx8_t & acc_frag = reinterpret_cast <floatx8_t &>(D.x [0 ]);
@@ -1240,7 +1240,7 @@ namespace ggml_cuda_mma {
12401240#else
12411241 GGML_UNUSED_VARS (D, A, B);
12421242 NO_DEVICE_CODE ;
1243- #endif // RDNA4
1243+ #endif // AMD_WMMA_128B_AVAILABLE
12441244#elif defined(AMD_MFMA_AVAILABLE)
12451245 using halfx4_t = __attribute__ ((ext_vector_type (4 ))) _Float16;
12461246 using floatx4_t = __attribute__ ((ext_vector_type (4 ))) float ;
@@ -1258,14 +1258,14 @@ namespace ggml_cuda_mma {
12581258 static __device__ __forceinline__ void mma (
12591259 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) {
12601260#if defined(AMD_WMMA_AVAILABLE)
1261- #if defined(RDNA4 )
1261+ #if defined(AMD_WMMA_128B_AVAILABLE )
12621262 using bf16x8_t = __attribute__ ((ext_vector_type (8 ))) __bf16;
12631263 using floatx8_t = __attribute__ ((ext_vector_type (8 ))) float ;
12641264 floatx8_t & acc_frag = reinterpret_cast <floatx8_t &>(D.x [0 ]);
12651265 const bf16x8_t & a_frag = reinterpret_cast <const bf16x8_t &>(A.x [0 ]);
12661266 const bf16x8_t & b_frag = reinterpret_cast <const bf16x8_t &>(B.x [0 ]);
12671267 acc_frag = __builtin_amdgcn_wmma_f32_16x16x16_bf16_w32_gfx12 (a_frag, b_frag, acc_frag);
1268- #elif defined(RDNA3 )
1268+ #elif defined(AMD_WMMA_256B_AVAILABLE )
12691269 using bf16x16_t = __attribute__ ((ext_vector_type (16 ))) __bf16;
12701270 using floatx8_t = __attribute__ ((ext_vector_type (8 ))) float ;
12711271 floatx8_t & acc_frag = reinterpret_cast <floatx8_t &>(D.x [0 ]);
@@ -1275,7 +1275,7 @@ namespace ggml_cuda_mma {
12751275#else
12761276 GGML_UNUSED_VARS (D, A, B);
12771277 NO_DEVICE_CODE ;
1278- #endif // defined(RDNA4 )
1278+ #endif // defined(AMD_WMMA_128B_AVAILABLE )
12791279#elif defined(AMD_MFMA_AVAILABLE)
12801280 using floatx4_t = __attribute__ ((ext_vector_type (4 ))) float ;
12811281 floatx4_t & acc_frag = reinterpret_cast <floatx4_t &>(D.x [0 ]);
@@ -1317,19 +1317,19 @@ namespace ggml_cuda_mma {
13171317#elif defined(AMD_WMMA_AVAILABLE)
13181318 using int32x8_t = __attribute__ ((__vector_size__ (8 * sizeof (int )))) int ;
13191319 int32x8_t * acc = (int32x8_t *) D.x ;
1320- #if defined(RDNA4 )
1320+ #if defined(AMD_WMMA_128B_AVAILABLE )
13211321 using int32x2_t = __attribute__ ((__vector_size__ (2 * sizeof (int )))) int ;
13221322 int32x2_t * a_vec = (int32x2_t *) A.x ;
13231323 int32x2_t * b_vec = (int32x2_t *) B.x ;
13241324 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32_gfx12 (true , a_vec[0 ], true , b_vec[0 ], acc[0 ], true );
13251325 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32_gfx12 (true , a_vec[1 ], true , b_vec[1 ], acc[0 ], true );
1326- #elif defined(RDNA3 )
1326+ #elif defined(AMD_WMMA_256B_AVAILABLE )
13271327 using int32x4_t = __attribute__ ((__vector_size__ (4 * sizeof (int )))) int ;
13281328 int32x4_t * a_vec = (int32x4_t *) A.x ;
13291329 int32x4_t * b_vec = (int32x4_t *) B.x ;
13301330 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32 (true , a_vec[0 ], true , b_vec[0 ], acc[0 ], true );
13311331 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32 (true , a_vec[1 ], true , b_vec[1 ], acc[0 ], true );
1332- #endif // RDNA4
1332+ #endif // AMD_WMMA_128B_AVAILABLE
13331333#else
13341334 GGML_UNUSED_VARS (D, A, B);
13351335 NO_DEVICE_CODE ;
@@ -1406,7 +1406,7 @@ namespace ggml_cuda_mma {
14061406 static __device__ __forceinline__ void mma (
14071407 tile<16 , 16 , half2, DATA_LAYOUT_I_MAJOR > & D, const tile<32 , 8 , half2, DATA_LAYOUT_I_MAJOR_MIRRORED > & A,
14081408 const tile<16 , 8 , half2, DATA_LAYOUT_I_MAJOR_MIRRORED > & B) {
1409- #if defined(AMD_WMMA_AVAILABLE) && defined(RDNA3 )
1409+ #if defined(AMD_WMMA_256B_AVAILABLE )
14101410 using halfx16_t = __attribute__ ((ext_vector_type (16 ))) _Float16;
14111411 halfx16_t * xD = (halfx16_t *) D.x ;
14121412 const halfx16_t * xA = (const halfx16_t *) A.x ;
@@ -1435,17 +1435,17 @@ namespace ggml_cuda_mma {
14351435#elif defined(AMD_WMMA_AVAILABLE)
14361436 using int32x8_t = __attribute__ ((__vector_size__ (8 * sizeof (int )))) int ;
14371437 int32x8_t * acc = (int32x8_t *) D.x ;
1438- #if defined(RDNA4 )
1438+ #if defined(AMD_WMMA_128B_AVAILABLE )
14391439 using int32x2_t = __attribute__ ((__vector_size__ (2 * sizeof (int )))) int ;
14401440 int32x2_t * a_vec = (int32x2_t *) A.x ;
14411441 int32x2_t * b_vec = (int32x2_t *) B.x ;
14421442 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32_gfx12 (true , a_vec[0 ], true , b_vec[0 ], acc[0 ], false );
1443- #elif defined(RDNA3 )
1443+ #elif defined(AMD_WMMA_256B_AVAILABLE )
14441444 using int32x4_t = __attribute__ ((__vector_size__ (4 * sizeof (int )))) int ;
14451445 int32x4_t * a_vec = (int32x4_t *) A.x ;
14461446 int32x4_t * b_vec = (int32x4_t *) B.x ;
14471447 acc[0 ] = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w32 (true , a_vec[0 ], true , b_vec[0 ], acc[0 ], false );
1448- #endif // RDNA4
1448+ #endif // AMD_WMMA_128B_AVAILABLE
14491449#else
14501450 GGML_UNUSED (D);
14511451 GGML_UNUSED (A);
0 commit comments