Skip segments in tests where the calculated chunk size is too small.

If the memory map contains very small segments and we have many active CPUs,
the tests that split the segments into chunks distributed across the CPUs may
end up with chunks that are too small for the test algorithm. With 4K pages
and the current limit of 256 active CPUs, this is currently only a problem
for the block move and modulo-n tests, but if we ever support more than 512
active CPUs, it could affect the other tests too.

For now, just skip segments that are too small in the affected tests. As it
only affects the block move and modulo-n tests and only affects very small
regions of memory, the loss of test coverage is negligable.

This may fix issue #216.
This commit is contained in:
Martin Whitaker 2022-12-10 15:24:26 +00:00
parent 9a86f115f4
commit 5a2bc4c960
5 changed files with 14 additions and 0 deletions

View File

@ -39,6 +39,7 @@ int test_block_move(int my_cpu, int iterations)
for (int i = 0; i < vm_map_size; i++) { for (int i = 0; i < vm_map_size; i++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, i, 16 * sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, i, 16 * sizeof(testword_t));
if ((end - start) < 15) continue; // we need at least 16 words for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;
@ -89,6 +90,7 @@ int test_block_move(int my_cpu, int iterations)
for (int i = 0; i < vm_map_size; i++) { for (int i = 0; i < vm_map_size; i++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, i, 16 * sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, i, 16 * sizeof(testword_t));
if ((end - start) < 15) continue; // we need at least 16 words for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;
@ -201,6 +203,7 @@ int test_block_move(int my_cpu, int iterations)
for (int i = 0; i < vm_map_size; i++) { for (int i = 0; i < vm_map_size; i++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, i, 16 * sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, i, 16 * sizeof(testword_t));
if ((end - start) < 15) continue; // we need at least 16 words for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;

View File

@ -39,6 +39,7 @@ int test_modulo_n(int my_cpu, int iterations, testword_t pattern1, testword_t pa
for (int i = 0; i < vm_map_size; i++) { for (int i = 0; i < vm_map_size; i++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t));
if ((end - start) < (n - 1)) continue; // we need at least n words for this test
end -= n; // avoids pointer overflow when incrementing p end -= n; // avoids pointer overflow when incrementing p
testword_t *p = start + offset; // we assume each chunk has at least 'n' words, so this won't overflow testword_t *p = start + offset; // we assume each chunk has at least 'n' words, so this won't overflow
@ -71,6 +72,7 @@ int test_modulo_n(int my_cpu, int iterations, testword_t pattern1, testword_t pa
for (int j = 0; j < vm_map_size; j++) { for (int j = 0; j < vm_map_size; j++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t));
if ((end - start) < (n - 1)) continue; // we need at least n words for this test
int k = 0; int k = 0;
testword_t *p = start; testword_t *p = start;
@ -111,6 +113,7 @@ int test_modulo_n(int my_cpu, int iterations, testword_t pattern1, testword_t pa
for (int i = 0; i < vm_map_size; i++) { for (int i = 0; i < vm_map_size; i++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t));
if ((end - start) < (n - 1)) continue; // we need at least n words for this test
end -= n; // avoids pointer overflow when incrementing p end -= n; // avoids pointer overflow when incrementing p
testword_t *p = start + offset; // we assume each chunk has at least 'offset' words, so this won't overflow testword_t *p = start + offset; // we assume each chunk has at least 'offset' words, so this won't overflow

View File

@ -41,6 +41,7 @@ int test_mov_inv_fixed(int my_cpu, int iterations, testword_t pattern1, testword
for (int i = 0; i < vm_map_size; i++) { for (int i = 0; i < vm_map_size; i++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t));
if (end < start) continue; // we need at least one word for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;
@ -99,6 +100,7 @@ int test_mov_inv_fixed(int my_cpu, int iterations, testword_t pattern1, testword
for (int j = 0; j < vm_map_size; j++) { for (int j = 0; j < vm_map_size; j++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t));
if (end < start) continue; // we need at least one word for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;
@ -134,6 +136,7 @@ int test_mov_inv_fixed(int my_cpu, int iterations, testword_t pattern1, testword
for (int j = vm_map_size - 1; j >= 0; j--) { for (int j = vm_map_size - 1; j >= 0; j--) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t));
if (end < start) continue; // we need at least one word for this test
testword_t *p = end; testword_t *p = end;
testword_t *ps = end; testword_t *ps = end;

View File

@ -51,6 +51,7 @@ int test_mov_inv_random(int my_cpu)
for (int i = 0; i < vm_map_size; i++) { for (int i = 0; i < vm_map_size; i++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t));
if (end < start) continue; // we need at least one word for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;
@ -88,6 +89,7 @@ int test_mov_inv_random(int my_cpu)
for (int j = 0; j < vm_map_size; j++) { for (int j = 0; j < vm_map_size; j++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t));
if (end < start) continue; // we need at least one word for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;

View File

@ -41,6 +41,7 @@ int test_mov_inv_walk1(int my_cpu, int iterations, int offset, bool inverse)
for (int i = 0; i < vm_map_size; i++) { for (int i = 0; i < vm_map_size; i++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, i, sizeof(testword_t));
if (end < start) continue; // we need at least one word for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;
@ -78,6 +79,7 @@ int test_mov_inv_walk1(int my_cpu, int iterations, int offset, bool inverse)
for (int j = 0; j < vm_map_size; j++) { for (int j = 0; j < vm_map_size; j++) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t));
if (end < start) continue; // we need at least one word for this test
testword_t *p = start; testword_t *p = start;
testword_t *pe = start; testword_t *pe = start;
@ -115,6 +117,7 @@ int test_mov_inv_walk1(int my_cpu, int iterations, int offset, bool inverse)
for (int j = vm_map_size - 1; j >= 0; j--) { for (int j = vm_map_size - 1; j >= 0; j--) {
testword_t *start, *end; testword_t *start, *end;
calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t)); calculate_chunk(&start, &end, my_cpu, j, sizeof(testword_t));
if (end < start) continue; // we need at least one word for this test
testword_t *p = end; testword_t *p = end;
testword_t *ps = end; testword_t *ps = end;