Skip to content

Commit 33d1550

Browse files
committed
tests: strided-canonicalization scramble suite + fire counters
Asserts every outer ordering of scale, ce+e, ce+ce (both arms), hce+e and hce+ce fires the strided kernel and matches an owning-ToT oracle, plus a negative case. Scale fire-counters are #ifdef TA_STRIDED_DGEMM_COUNT.
1 parent e439c74 commit 33d1550

3 files changed

Lines changed: 606 additions & 0 deletions

File tree

‎src/TiledArray/tensor/tensor.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#include <atomic>
4242
#include <chrono>
43+
#include <cstddef>
4344
#include <cstdint>
4445
#include <cstdlib>
4546
#include <iostream>
@@ -137,6 +138,13 @@ struct ScaleRegimeCounters {
137138
};
138139
inline ScaleRegimeCounters g_scale[2]; // [0]=tot_x_t, [1]=t_x_tot
139140

141+
#ifdef TA_STRIDED_DGEMM_COUNT
142+
// Test-observable strided scale-GEMM fire counters: [0]=tot_x_t, [1]=t_x_tot.
143+
// Incremented once per strided scale GEMM (independent of TA_GEMM_TIMING).
144+
// Type matches the arena counters (g_strided_dgemm_ce_*_calls in arena_einsum.h).
145+
inline std::atomic<std::size_t> g_scale_strided_calls[2]{};
146+
#endif
147+
140148
/// Manual (non-scoped) phase clock for regions that set locals used later, so a
141149
/// timed scope can't wrap them. No-op unless TA_GEMM_TIMING is set. Mirrors the
142150
/// arena_einsum.h phase_start/phase_stop pattern.
@@ -3420,6 +3428,10 @@ class Tensor {
34203428
static_cast<std::uint64_t>(A),
34213429
std::memory_order_relaxed);
34223430
}
3431+
#ifdef TA_STRIDED_DGEMM_COUNT
3432+
detail::g_scale_strided_calls[0].fetch_add(
3433+
1, std::memory_order_relaxed);
3434+
#endif
34233435
const integer Ai = static_cast<integer>(A);
34243436
detail::ScopedScaleTimer _scale_gt(detail::g_scale[0].gemm_ns);
34253437
TiledArray::math::blas::gemm(
@@ -3584,6 +3596,10 @@ class Tensor {
35843596
static_cast<std::uint64_t>(A),
35853597
std::memory_order_relaxed);
35863598
}
3599+
#ifdef TA_STRIDED_DGEMM_COUNT
3600+
detail::g_scale_strided_calls[1].fetch_add(
3601+
1, std::memory_order_relaxed);
3602+
#endif
35873603
const integer Ai = static_cast<integer>(A);
35883604
detail::ScopedScaleTimer _scale_gt(detail::g_scale[1].gemm_ns);
35893605
TiledArray::math::blas::gemm(

‎tests/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ set(ta_test_src_files ta_test.cpp
107107
arena_tensor.cpp
108108
arena_tensor_kernels.cpp
109109
arena_strided_dgemm.cpp
110+
strided_canonicalize.cpp
110111
tot_construction.cpp
111112
)
112113

0 commit comments

Comments
 (0)