@@ -62,7 +62,7 @@ void testing_matmul_batch_offset_impl(const Arguments& arg)
6262
6363 int32_t batch_count = arg.batch_count ;
6464
65- // Batch offsets (from YAML - assumed to be in BYTES )
65+ // Batch offsets (from YAML - in ELEMENTS )
6666 int64_t offset_a = arg.batch_offset_a ;
6767 int64_t offset_b = arg.batch_offset_b ;
6868 int64_t offset_c = arg.batch_offset_c ;
@@ -86,22 +86,16 @@ void testing_matmul_batch_offset_impl(const Arguments& arg)
8686 size_t size_C_sub = size_t (ldc) * size_t (N);
8787 size_t size_D_sub = size_t (ldd) * size_t (N);
8888
89- // Convert byte offsets to element offsets
90- // Note: offsets must be aligned to element size
91- size_t offset_a_elem = offset_a / sizeof (Ti);
92- size_t offset_b_elem = offset_b / sizeof (Ti);
93- size_t offset_c_elem = offset_c / sizeof (To);
94- size_t offset_d_elem = offset_d / sizeof (To);
95-
9689 // Full buffer sizes: [offset padding] + [matrix data]
9790 // The offset padding comes FIRST because:
9891 // - Pointer array points to buffer BASE
9992 // - Kernel adds offset to BASE to get actual data location
10093 // - So actual data is at BASE + offset
101- size_t size_A_full = offset_a_elem + size_A_sub;
102- size_t size_B_full = offset_b_elem + size_B_sub;
103- size_t size_C_full = offset_c_elem + size_C_sub;
104- size_t size_D_full = offset_d_elem + size_D_sub;
94+ // Offsets are already in elements (the API takes element offsets).
95+ size_t size_A_full = offset_a + size_A_sub;
96+ size_t size_B_full = offset_b + size_B_sub;
97+ size_t size_C_full = offset_c + size_C_sub;
98+ size_t size_D_full = offset_d + size_D_sub;
10599
106100 // Allocate host memory for full buffers
107101 host_vector<Ti> h_A_full (size_A_full * batch_count);
@@ -116,9 +110,9 @@ void testing_matmul_batch_offset_impl(const Arguments& arg)
116110 for (int b = 0 ; b < batch_count; b++)
117111 {
118112 // Initialize each batch's sub-matrix at the offset location
119- Ti* A_batch = h_A_full.data () + b * size_A_full + offset_a_elem ;
120- Ti* B_batch = h_B_full.data () + b * size_B_full + offset_b_elem ;
121- To* C_batch = h_C_full.data () + b * size_C_full + offset_c_elem ;
113+ Ti* A_batch = h_A_full.data () + b * size_A_full + offset_a ;
114+ Ti* B_batch = h_B_full.data () + b * size_B_full + offset_b ;
115+ To* C_batch = h_C_full.data () + b * size_C_full + offset_c ;
122116
123117 // Simple initialization: A and B with small integers
124118 for (int64_t j = 0 ; j < A_col; j++)
@@ -308,9 +302,9 @@ void testing_matmul_batch_offset_impl(const Arguments& arg)
308302 for (int b = 0 ; b < batch_count; b++)
309303 {
310304 // Get pointers to sub-matrices (with element offset applied)
311- Ti* A_sub = h_A_full.data () + b * size_A_full + offset_a_elem ;
312- Ti* B_sub = h_B_full.data () + b * size_B_full + offset_b_elem ;
313- To* C_sub = h_C_full.data () + b * size_C_full + offset_c_elem ;
305+ Ti* A_sub = h_A_full.data () + b * size_A_full + offset_a ;
306+ Ti* B_sub = h_B_full.data () + b * size_B_full + offset_b ;
307+ To* C_sub = h_C_full.data () + b * size_C_full + offset_c ;
314308 To* D_sub = h_D_gold.data () + b * size_D_sub;
315309
316310 // Simple GEMM: D = alpha * A * B + beta * C
@@ -346,7 +340,7 @@ void testing_matmul_batch_offset_impl(const Arguments& arg)
346340 for (int b = 0 ; b < batch_count; b++)
347341 {
348342 // GPU result is at (base + offset) within each batch's buffer
349- To* result_gpu = h_D_full.data () + b * size_D_full + offset_d_elem ;
343+ To* result_gpu = h_D_full.data () + b * size_D_full + offset_d ;
350344 To* result_cpu = h_D_gold.data () + b * size_D_sub;
351345
352346 for (size_t i = 0 ; i < size_D_sub; i++)
0 commit comments