Skip to content

Commit a57f33e

Browse files
committed
Fix segmentation fault in tests
1 parent 19e26c7 commit a57f33e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/main.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ int main() {
1818
std::vector<my_fp_type> Bs(ps * ns);
1919
std::default_random_engine generator(std::random_device{}());
2020
std::uniform_real_distribution<double> distribution(-100000.0, 100000.0);
21-
for (size_t i = 0; i < ms; i++)
22-
for (size_t j = 0; j < ps; j++)
23-
As[i * ms + j] = distribution(generator);
24-
for (size_t i = 0; i < ps; i++)
25-
for (size_t j = 0; j < ns; j++)
26-
Bs[i * ns + j] = distribution(generator);
27-
As[0] = 1;
21+
for (auto & element : As)
22+
element = distribution(generator);
23+
for (auto & element : Bs)
24+
element = distribution(generator);
25+
As[0] = 1.984375; // 0x3FFE0000 -> 1.11111 10000 00000 00000 000
26+
As[1] = 1.999969482421875; // 0x3FFFFF00 -> 1.11111 11111 11111 00000 000
27+
As[2] = 1.99993896484375; // 0x3FFFFE00 -> 1.11111 11111 11110 00000 000
28+
As[3] = 1.9998779296875; // 0x3FFFCE00 -> 1.11111 11111 11100 00000 000
2829

2930
auto Cs = gemmi<my_fp_type, int8_t, int32_t>(As, Bs, ms, ps, ns, 10);
3031
auto Cs_ref = reference_gemm(As, Bs, ms, ps, ns);

0 commit comments

Comments
 (0)