#!/bin/sh

BASE=/usr/libexec/VeryFastTree/VeryFastTree

test_and_run () {
	if grep -q "$1" /proc/cpuinfo && [ -x "${BASE}-$1" ]; then
		cmd="${BASE}-$1"
		shift
		exec "${cmd}" "$@"
	fi
}

for SIMD in avx512f avx2 avx sse4_1 ; do test_and_run ${SIMD} "$@" ; done

# fallback to base option
exec "${BASE}-sse2" "$@"
