@@ -28,8 +28,14 @@ SKIPPED_TESTS=0
2828VERBOSE_MODE=true
2929IGNORE_LOW_COMPUTE_FAILURES=false
3030
31- # Puzzles that require higher compute capability (>= 8.0 on NVIDIA)
32- NVIDIA_HIGH_COMPUTE_REQUIRED_PUZZLES=(" p16" " p19" " p28" " p29" " p33" " p34" )
31+ # Puzzles that require higher compute capability on NVIDIA
32+ # >= 8.0 (Ampere): Tensor Cores, full async copy (RTX 30xx, A100+)
33+ NVIDIA_COMPUTE_80_REQUIRED_PUZZLES=(" p16" " p19" " p28" " p29" " p33" )
34+ # >= 9.0 (Hopper): SM90+ cluster programming (H100+)
35+ NVIDIA_COMPUTE_90_REQUIRED_PUZZLES=(" p34" )
36+
37+ # Puzzles that are not supported on Apple GPUs
38+ APPLE_UNSUPPORTED_PUZZLES=(" p09" " p10" " p16" " p19" " p20" " p21" " p22" " p28" " p29" " p30" " p31" " p32" " p33" " p34" )
3339
3440# Arrays to store results
3541declare -a FAILED_TESTS_LIST
@@ -71,29 +77,45 @@ detect_gpu_compute_capability() {
7177 # Try to detect NVIDIA GPU compute capability
7278 local compute_capability=" "
7379
74- # Method 1: Try nvidia-smi
80+ # Method 1: Try nvidia-smi with expanded GPU list
7581 if command -v nvidia-smi > /dev/null 2>&1 ; then
7682 local gpu_name=$( nvidia-smi --query-gpu=name --format=csv,noheader,nounits 2> /dev/null | head -1)
7783 if [ -n " $gpu_name " ]; then
78- # Check for H100 or other SM90+ GPUs
79- if echo " $gpu_name " | grep -qi " H100\|A100\|RTX 40[0-9][0-9]\|RTX 4090\|L40S" ; then
80- if echo " $gpu_name " | grep -qi " H100" ; then
81- compute_capability=" 9.0"
82- elif echo " $gpu_name " | grep -qi " RTX 40[0-9][0-9]\|RTX 4090\|L40S" ; then
83- compute_capability=" 8.9"
84- elif echo " $gpu_name " | grep -qi " A100" ; then
85- compute_capability=" 8.0"
86- fi
84+ # Check for known GPU families and their compute capabilities
85+ if echo " $gpu_name " | grep -qi " H100" ; then
86+ compute_capability=" 9.0"
87+ elif echo " $gpu_name " | grep -qi " RTX 40[0-9][0-9]\|RTX 4090\|L40S\|L4" ; then
88+ compute_capability=" 8.9"
89+ elif echo " $gpu_name " | grep -qi " RTX 30[0-9][0-9]\|RTX 3090\|RTX 3080\|RTX 3070\|RTX 3060\|A40\|A30\|A10" ; then
90+ compute_capability=" 8.6"
91+ elif echo " $gpu_name " | grep -qi " A100" ; then
92+ compute_capability=" 8.0"
93+ elif echo " $gpu_name " | grep -qi " V100" ; then
94+ compute_capability=" 7.0"
95+ elif echo " $gpu_name " | grep -qi " T4\|RTX 20[0-9][0-9]\|RTX 2080\|RTX 2070\|RTX 2060" ; then
96+ compute_capability=" 7.5"
8797 fi
8898 fi
8999 fi
90100
91101 # Method 2: Try Python with GPU detection script if available
92- if [ -z " $compute_capability " ] && [ -f " ../scripts/gpu_specs.py" ]; then
93- local gpu_info=$( python3 ../scripts/gpu_specs.py 2> /dev/null | grep -i " compute capability" | head -1)
94- if [ -n " $gpu_info " ]; then
95- compute_capability=$( echo " $gpu_info " | grep -o ' [0-9]\+\.[0-9]\+' | head -1)
96- fi
102+ # Try multiple possible paths for gpu_specs.py
103+ local gpu_specs_paths=(
104+ " ../scripts/gpu_specs.py" # From solutions/ directory
105+ " scripts/gpu_specs.py" # From repo root
106+ " ./scripts/gpu_specs.py" # From repo root (explicit)
107+ )
108+
109+ if [ -z " $compute_capability " ]; then
110+ for gpu_specs_path in " ${gpu_specs_paths[@]} " ; do
111+ if [ -f " $gpu_specs_path " ]; then
112+ local gpu_info=$( python3 " $gpu_specs_path " 2> /dev/null | grep -i " compute capability" | head -1)
113+ if [ -n " $gpu_info " ]; then
114+ compute_capability=$( echo " $gpu_info " | grep -o ' [0-9]\+\.[0-9]\+' | head -1)
115+ break
116+ fi
117+ fi
118+ done
97119 fi
98120
99121 echo " $compute_capability "
@@ -115,7 +137,50 @@ has_high_compute_capability() {
115137 fi
116138}
117139
118- is_nvidia_high_compute_required_puzzle () {
140+ get_nvidia_puzzle_min_compute () {
141+ local puzzle_name=" $1 "
142+
143+ # Check if puzzle requires compute 9.0+ (Hopper)
144+ for required_puzzle in " ${NVIDIA_COMPUTE_90_REQUIRED_PUZZLES[@]} " ; do
145+ if [[ " $puzzle_name " == * " $required_puzzle " * ]]; then
146+ echo " 90"
147+ return 0
148+ fi
149+ done
150+
151+ # Check if puzzle requires compute 8.0+ (Ampere)
152+ for required_puzzle in " ${NVIDIA_COMPUTE_80_REQUIRED_PUZZLES[@]} " ; do
153+ if [[ " $puzzle_name " == * " $required_puzzle " * ]]; then
154+ echo " 80"
155+ return 0
156+ fi
157+ done
158+
159+ # No special compute requirement
160+ echo " 0"
161+ return 0
162+ }
163+
164+ should_skip_puzzle_for_apple () {
165+ local puzzle_name=" $1 "
166+ local gpu_platform=$( detect_gpu_platform)
167+
168+ # Only apply to Apple platforms
169+ if [ " $gpu_platform " != " apple" ]; then
170+ return 1 # Not restricted for non-Apple platforms
171+ fi
172+
173+ # Check if puzzle is in the unsupported list
174+ for unsupported_puzzle in " ${APPLE_UNSUPPORTED_PUZZLES[@]} " ; do
175+ if [[ " $puzzle_name " == * " $unsupported_puzzle " * ]]; then
176+ return 0 # Should skip
177+ fi
178+ done
179+
180+ return 1 # Don't skip
181+ }
182+
183+ should_skip_puzzle_for_low_compute () {
119184 local puzzle_name=" $1 "
120185 local gpu_platform=$( detect_gpu_platform)
121186
@@ -124,12 +189,22 @@ is_nvidia_high_compute_required_puzzle() {
124189 return 1 # Not restricted for non-NVIDIA platforms
125190 fi
126191
127- for required_puzzle in " ${NVIDIA_HIGH_COMPUTE_REQUIRED_PUZZLES[@]} " ; do
128- if [[ " $puzzle_name " == * " $required_puzzle " * ]]; then
129- return 0
130- fi
131- done
132- return 1
192+ # Get current GPU's compute capability
193+ local compute_cap=$( detect_gpu_compute_capability)
194+ if [ -z " $compute_cap " ]; then
195+ # Can't detect, assume low compute
196+ local numeric_cap=0
197+ else
198+ local major=$( echo " $compute_cap " | cut -d' .' -f1)
199+ local minor=$( echo " $compute_cap " | cut -d' .' -f2)
200+ local numeric_cap=$(( major * 10 + minor))
201+ fi
202+
203+ # Get puzzle's minimum compute requirement
204+ local required_compute=$( get_nvidia_puzzle_min_compute " $puzzle_name " )
205+
206+ # Skip if GPU doesn't meet requirement
207+ [ " $numeric_cap " -lt " $required_compute " ]
133208}
134209
135210# Usage function
@@ -141,7 +216,7 @@ usage() {
141216 echo " "
142217 echo -e " ${BOLD} Options:${NC} "
143218 echo -e " ${YELLOW} -v, --verbose${NC} Show output for all tests (not just failures)"
144- echo -e " ${YELLOW} --ignore-low-compute-failures${NC} Ignore failures from NVIDIA puzzles requiring compute >= 8.0 ( p16, p28, p29, p33, p34)"
219+ echo -e " ${YELLOW} --ignore-low-compute-failures${NC} Skip NVIDIA puzzles requiring higher compute ( 8.0+: p16,p19, p28,p29,p33 | 9.0+: p34)"
145220 echo -e " ${YELLOW} -h, --help${NC} Show this help message"
146221 echo " "
147222 echo -e " ${BOLD} Parameters:${NC} "
@@ -156,7 +231,7 @@ usage() {
156231 echo -e " ${BOLD} Examples:${NC} "
157232 echo -e " ${GREEN} $0 ${NC} ${GRAY} # Run all puzzles${NC} "
158233 echo -e " ${GREEN} $0 -v${NC} ${GRAY} # Run all puzzles with verbose output${NC} "
159- echo -e " ${GREEN} $0 --ignore-low-compute-failures${NC} ${GRAY} # Run all puzzles, ignore compute <8.0 failures (for T4/CI)${NC} "
234+ echo -e " ${GREEN} $0 --ignore-low-compute-failures${NC} ${GRAY} # Run all puzzles, skip high- compute puzzles (for T4/V100 CI)${NC} "
160235 echo -e " ${GREEN} $0 p23${NC} ${GRAY} # Run only p23 tests with all flags${NC} "
161236 echo -e " ${GREEN} $0 p26 --double-buffer${NC} ${GRAY} # Run p26 with specific flag${NC} "
162237 echo -e " ${GREEN} $0 -v p26 --double-buffer${NC} ${GRAY} # Run p26 with specific flag (verbose)${NC} "
@@ -224,24 +299,36 @@ execute_or_skip_test() {
224299 local cmd=" $3 "
225300 local full_name=" ${test_name} $( [ -n " $flag " ] && echo " ($flag )" || echo " " ) "
226301
302+ # Check if this should be skipped for Apple GPU (always skip unsupported puzzles)
303+ if should_skip_puzzle_for_apple " $test_name " ; then
304+ print_test_start " $test_name " " $flag "
305+ echo -e " ${YELLOW}${BULLET}${NC} ${YELLOW} SKIPPED${NC} ${GRAY} $full_name ${NC} ${PURPLE} (not supported on Apple GPU)${NC} "
306+ SKIPPED_TESTS=$(( SKIPPED_TESTS + 1 ))
307+ SKIPPED_TESTS_LIST+=(" $full_name (Apple unsupported)" )
308+ TOTAL_TESTS=$(( TOTAL_TESTS + 1 ))
309+ return 0 # Skipped successfully
310+ fi
311+
227312 # Check if this should be skipped due to low compute capability BEFORE running
228- if [ " $IGNORE_LOW_COMPUTE_FAILURES " = " true" ] && is_nvidia_high_compute_required_puzzle " $test_name " && ! has_high_compute_capability; then
313+ if [ " $IGNORE_LOW_COMPUTE_FAILURES " = " true" ] && should_skip_puzzle_for_low_compute " $test_name " ; then
314+ local required_compute=$( get_nvidia_puzzle_min_compute " $test_name " )
315+ local required_version=$( echo " $required_compute " | sed ' s/\([0-9]\)\([0-9]\)/\1.\2/' )
229316 print_test_start " $test_name " " $flag "
230- echo -e " ${YELLOW}${BULLET}${NC} ${YELLOW} SKIPPED${NC} ${GRAY} $full_name ${NC} ${PURPLE} (NVIDIA requires compute >=8.0 )${NC} "
317+ echo -e " ${YELLOW}${BULLET}${NC} ${YELLOW} SKIPPED${NC} ${GRAY} $full_name ${NC} ${PURPLE} (requires NVIDIA compute >=$required_version )${NC} "
231318 SKIPPED_TESTS=$(( SKIPPED_TESTS + 1 ))
232319 IGNORED_LOW_COMPUTE_TESTS_LIST+=(" $full_name " )
233320 TOTAL_TESTS=$(( TOTAL_TESTS + 1 ))
234321 return 0 # Skipped successfully
322+ fi
323+
324+ # Run the test normally
325+ print_test_start " $test_name " " $flag "
326+ if capture_output " $cmd " " $VERBOSE_MODE " ; then
327+ print_test_result " $test_name " " $flag " " PASS"
235328 else
236- # Run the test normally
237- print_test_start " $test_name " " $flag "
238- if capture_output " $cmd " " $VERBOSE_MODE " ; then
239- print_test_result " $test_name " " $flag " " PASS"
240- else
241- print_test_result " $test_name " " $flag " " FAIL"
242- fi
243- return 0
329+ print_test_result " $test_name " " $flag " " FAIL"
244330 fi
331+ return 0
245332}
246333
247334capture_output () {
@@ -412,8 +499,9 @@ if [ "$IGNORE_LOW_COMPUTE_FAILURES" = "false" ]; then
412499 gpu_platform=$( detect_gpu_platform)
413500 if [ " $gpu_platform " = " nvidia" ] && ! has_high_compute_capability; then
414501 IGNORE_LOW_COMPUTE_FAILURES=true
415- echo -e " ${YELLOW}${BOLD} Auto-detected:${NC} NVIDIA GPU with compute capability <8.0"
416- echo -e " Automatically ignoring failures for high compute puzzles (p16, p19, p28, p29, p33, p34)"
502+ compute_cap=$( detect_gpu_compute_capability)
503+ echo -e " ${YELLOW}${BOLD} Auto-detected:${NC} NVIDIA GPU with compute capability ${compute_cap:- <8.0} "
504+ echo -e " Automatically skipping high-compute puzzles (8.0+: p16,p19,p28,p29,p33 | 9.0+: p34)"
417505 echo " "
418506 fi
419507fi
@@ -502,9 +590,9 @@ print_summary() {
502590
503591 # Show ignored low compute tests if any
504592 if [ ${# IGNORED_LOW_COMPUTE_TESTS_LIST[@]} -gt 0 ]; then
505- echo -e " ${PURPLE}${BOLD} Ignored High Compute Required Tests :${NC} "
593+ echo -e " ${PURPLE}${BOLD} Skipped Tests (Insufficient Compute) :${NC} "
506594 for test in " ${IGNORED_LOW_COMPUTE_TESTS_LIST[@]} " ; do
507- echo -e " ${PURPLE}${BULLET}${NC} $test ${GRAY} (requires compute capability >=8.0) ${NC} "
595+ echo -e " ${PURPLE}${BULLET}${NC} $test "
508596 done
509597 echo " "
510598 fi
@@ -563,14 +651,15 @@ print_startup_banner() {
563651 ;;
564652 " apple" )
565653 echo -e " ${BULLET} Metal Support: ${GREEN} Available${NC} "
654+ echo -e " ${BULLET} Auto-Skip: ${YELLOW} Some puzzles unsupported${NC} ${GRAY} (14 puzzles will be skipped)${NC} "
566655 ;;
567656 * )
568657 echo -e " ${BULLET} Status: ${YELLOW} Unknown GPU platform${NC} "
569658 ;;
570659 esac
571660
572661 if [ " $IGNORE_LOW_COMPUTE_FAILURES " = " true" ]; then
573- echo -e " ${BULLET} Low Compute Failure Mode: ${YELLOW} IGNORED ${NC} ${GRAY} (--ignore-low-compute-failures enabled )${NC} "
662+ echo -e " ${BULLET} Skip Mode: ${YELLOW} HIGH-COMPUTE PUZZLES SKIPPED ${NC} ${GRAY} (--ignore-low-compute-failures)${NC} "
574663 fi
575664 echo " "
576665}
0 commit comments