Skip to content

Commit 57199df

Browse files
committed
Minor infrastructure improvements
1 parent d6639ff commit 57199df

3 files changed

Lines changed: 53 additions & 22 deletions

File tree

‎Docs/Building.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ Install native packages:
403403
sudo apt update
404404

405405
# Build tools
406-
sudo apt install build-essential clang cmake git
406+
sudo apt install build-essential clang llvm cmake git
407407

408408
# Test tools
409409
sudo apt install imagemagick python3-pip python3-venv

‎Test/astc_test_image.py‎

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import argparse
3636
from pathlib import Path
37+
import re
3738
import sys
3839
from typing import Optional
3940

@@ -342,8 +343,7 @@ def get_encoder_params(encoder_name: str, reference_name: str,
342343
_, version, simd = encoder_name.split('-')
343344

344345
# Version-specific variants
345-
compatible_prefixes = ['5.']
346-
if any(True for x in compatible_prefixes if version.startswith(x)):
346+
if re.match(r'[0-9]+\.', version):
347347
encoder = te.Encoder2xRel(version, simd)
348348
name = f'reference-{version}-{simd}'
349349
out_dir = f'Test/Images/{test_set_name}'
@@ -366,6 +366,29 @@ def get_encoder_params(encoder_name: str, reference_name: str,
366366
return (encoder, name, out_dir, used_reference_name)
367367

368368

369+
def find_reference_encoders(test_dir: Path) -> list[str]:
370+
'''
371+
Find reference encoders with result CSVs in the image tree.
372+
373+
Args:
374+
test_dir: The root of the test image tree.
375+
376+
Return:
377+
The sorted, unique reference encoder names.
378+
'''
379+
quality_pattern = '|'.join(TEST_QUALITIES)
380+
result_pattern = re.compile(
381+
rf'astc_reference-(.+)_(?:{quality_pattern})_results\.csv')
382+
reference_encoders = set()
383+
384+
for result_file in test_dir.rglob('astc_reference-*_results.csv'):
385+
match = result_pattern.fullmatch(result_file.name)
386+
if match and result_file.is_file():
387+
reference_encoders.add(f'ref-{match.group(1)}')
388+
389+
return sorted(reference_encoders)
390+
391+
369392
def parse_command_line():
370393
'''
371394
Parse the command line.
@@ -374,17 +397,10 @@ def parse_command_line():
374397
Namespace: The parsed command line container.
375398
'''
376399
parser = argparse.ArgumentParser()
400+
test_dir = Path(__file__).parent / 'Images'
377401

378402
# All reference encoders
379-
reference_encoders = [
380-
'rebuild',
381-
382-
'ref-5.7-neon',
383-
'ref-5.7-sse2', 'ref-5.7-sse4.1', 'ref-5.7-avx2',
384-
385-
'ref-main-neon', 'ref-main-sve_256', 'ref-main-sve_128',
386-
'ref-main-sse2', 'ref-main-sse4.1', 'ref-main-avx2'
387-
]
403+
reference_encoders = ['rebuild'] + find_reference_encoders(test_dir)
388404

389405
# All test encoders
390406
test_encoders = [
@@ -403,12 +419,13 @@ def parse_command_line():
403419
'sse2', 'sse4.1', 'avx2'
404420
]
405421

406-
encoder_choices = reference_encoders + test_encoders
422+
encoder_choices = list(test_encoders)
407423
encoder_choices.append('all-aarch64')
408424
encoder_choices.append('all-x86')
409425

410426
parser.add_argument('--encoder', dest='encoders', default='avx2',
411-
choices=encoder_choices, help='test encoder variant')
427+
help='test encoder variant or '
428+
'ref-<version>-<variant>')
412429

413430
parser.add_argument('--reference', default='ref-main-avx2',
414431
choices=reference_encoders,
@@ -426,8 +443,6 @@ def parse_command_line():
426443
parser.add_argument('--block-size', dest='block_sizes', action='append',
427444
choices=block_size_choices, help='test block size')
428445

429-
test_dir = Path(__file__).parent / 'Images'
430-
431446
test_set_choices = [x.name for x in test_dir.iterdir() if x.is_dir()]
432447
test_set_choices.sort()
433448
test_set_choices.append('all')
@@ -458,6 +473,13 @@ def parse_command_line():
458473

459474
args = parser.parse_args()
460475

476+
# Allow new reference encoders before their result CSVs have been generated
477+
if args.encoders not in encoder_choices:
478+
pattern = r'ref-(?:main|[0-9]+\.[^-]+)-(.+)'
479+
match = re.fullmatch(pattern, args.encoders)
480+
if (match is None) or (match.group(1) not in test_encoders):
481+
parser.error(f'--encoder: invalid choice: {args.encoders!r}')
482+
461483
# Turn things into canonical format lists
462484
if args.encoders == 'all-aarch64':
463485
args.encoders = test_encoders_arm64

‎Test/astc_update_ref.sh‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,29 @@ fi
88
echo "Generating new ref-$1 results"
99

1010
if [ "$1" = "main" ]; then
11-
binary_path="./bin/astcenc-avx2"
11+
binary_path="./bin/"
1212
else
13-
binary_path="./Binaries/${1}/astcenc-avx2"
13+
binary_path="./Binaries/${1}/"
1414
fi
1515

16-
if [ ! -x "$binary_path" ]; then
17-
echo "ERROR: Binary not found or not executable: $binary_path" >&2
16+
if [ ! -d "$binary_path" ]; then
17+
echo "ERROR: Binary directory not found: $binary_path" >&2
1818
exit 1
1919
fi
2020

21-
echo "Using binary from $binary_path"
21+
echo "Using binaries from $binary_path"
2222
echo ""
2323

24+
25+
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 6 --reference rebuild --encoder ref-$1-sve2_256 -j12
26+
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 6 --reference rebuild --encoder ref-$1-sve2_128 -j12
27+
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 6 --reference rebuild --encoder ref-$1-sve_256 -j12
28+
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 6 --reference rebuild --encoder ref-$1-sve_128 -j12
29+
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 6 --reference rebuild --encoder ref-$1-neon -j12
30+
31+
32+
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 8 --reference rebuild --encoder "ref-${1}-avx512" -j12
2433
python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 8 --reference rebuild --encoder "ref-${1}-avx2" -j12
2534
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 8 --reference rebuild --encoder ref-$1-sse4.1 -j12
2635
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 8 --reference rebuild --encoder ref-$1-sse2 -j12
27-
#python3 ./Test/astc_test_image.py --test-set all --block-size all --test-quality all --repeats 6 --reference rebuild --encoder ref-$1-neon -j3
36+

0 commit comments

Comments
 (0)