@@ -69,45 +69,51 @@ void ForeachPackedAndRawType() {
6969
7070// Generates inputs: deterministic, within max SfpStream range.
7171template <typename MatT>
72- MatStorageT<MatT> GenerateMat (const Extents2D& extents, hwy::ThreadPool& pool) {
72+ MatStorageT<MatT> GenerateMat (const Extents2D& extents, MatPadding padding,
73+ hwy::ThreadPool& pool) {
7374 gcpp::CompressWorkingSet ws;
75+ ws.tls .resize (pool.NumWorkers ());
7476 MatStorageT<float > raw (" raw" , extents, MatPadding::kPacked );
75- MatStorageT<MatT> compressed (" mat" , extents, MatPadding:: kPacked );
77+ MatStorageT<MatT> compressed (" mat" , extents, padding );
7678 const float scale = SfpStream::kMax / extents.Area ();
77- pool.Run (0 , extents.rows , [&](const size_t r, size_t /* thread*/ ) {
79+ pool.Run (0 , extents.rows , [&](const size_t r, size_t thread) {
7880 float * HWY_RESTRICT row = raw.Row (r);
7981 for (size_t c = 0 ; c < extents.cols ; c++) {
8082 float f = static_cast <float >(r * extents.cols + c) * scale;
8183 if ((r + c) & 1 ) f = -f; // Also generate some negative values.
8284 row[c] = f;
8385 }
86+ Compress (raw.Row (r), raw.Cols (), ws.tls [thread],
87+ MakeSpan (compressed.Row (r), compressed.Cols ()),
88+ /* packed_ofs=*/ 0 );
8489 });
8590
86- Compress (raw.PackedScale1 (), raw.Extents ().Area (), ws, compressed.Span (),
87- /* packed_ofs=*/ 0 , pool);
8891 compressed.SetScale (0 .6f ); // Arbitrary value, different from 1.
8992 return compressed;
9093}
9194
92- // `extents` describes the transposed matrix.
95+ // Same, but `extents` describes the transposed matrix.
9396template <typename MatT>
9497MatStorageT<MatT> GenerateTransposedMat (const Extents2D extents,
98+ MatPadding padding,
9599 hwy::ThreadPool& pool) {
96100 gcpp::CompressWorkingSet ws;
101+ ws.tls .resize (pool.NumWorkers ());
97102 MatStorageT<float > raw (" raw" , extents, MatPadding::kPacked );
98- MatStorageT<MatT> compressed (" trans" , extents, MatPadding:: kPacked );
103+ MatStorageT<MatT> compressed (" trans" , extents, padding );
99104 const float scale = SfpStream::kMax / extents.Area ();
100- pool.Run (0 , extents.rows , [&](const size_t r, size_t /* thread*/ ) {
105+ pool.Run (0 , extents.rows , [&](const size_t r, size_t thread) {
101106 float * HWY_RESTRICT row = raw.Row (r);
102107 for (size_t c = 0 ; c < extents.cols ; c++) {
103108 float f = static_cast <float >(c * extents.rows + r) * scale;
104109 if ((r + c) & 1 ) f = -f; // Also generate some negative values.
105110 row[c] = f;
106111 }
112+ Compress (raw.Row (r), raw.Cols (), ws.tls [thread],
113+ MakeSpan (compressed.Row (r), compressed.Cols ()),
114+ /* packed_ofs=*/ 0 );
107115 });
108116
109- Compress (raw.PackedScale1 (), raw.Extents ().Area (), ws, compressed.Span (),
110- /* packed_ofs=*/ 0 , pool);
111117 // Arbitrary value, different from 1, must match `GenerateMat`.
112118 compressed.SetScale (0 .6f );
113119 return compressed;
0 commit comments