Skip to content

Commit

Permalink
Workaround and cover issues with -msse4/-mno-sse4
Browse files Browse the repository at this point in the history
  • Loading branch information
hartwork committed Sep 18, 2024
1 parent f84c7ac commit 04fc91c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions resolve_march_native/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import subprocess
import sys
from contextlib import suppress

from .parser import extract_flags
from .runner import run
Expand Down Expand Up @@ -127,6 +128,11 @@ def _resolve(self, march_native_flag_set, march_explicit_flag_set, arch, options
self._process_flags_explicit_has_more(native_unrolled_flag_set,
march_native_flag_set, march_explicit_flag_set)

# Workaround issues with tribool for machines with e.g. SSE4.1 but not SSE4.2
for flag_prefix in ('-m', '-mno-'):
with suppress(KeyError):
native_unrolled_flag_set.remove(f"{flag_prefix}sse4")

return native_unrolled_flag_set

def run(self, options):
Expand Down
19 changes: 19 additions & 0 deletions resolve_march_native/test/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,22 @@ def test_pentium(self):
'pentium-m--target-help--native.txt',
'pentium-m--target-help--explicit.txt',
)

def test_sse4_weirdness_issue_177(self):
expected_flag_set = {
# No "-msse4" here!
'-msse4.1',
'-mxsave',
'--param=l1-cache-size=32',
'--param=l1-cache-line-size=64',
'--param=l2-cache-size=6144',
'-march=core2',
}

self._test_engine(
expected_flag_set,
'harpertown-core2--assembly--native.txt',
'harpertown-core2--assembly--explicit.txt',
'harpertown-core2--target-help--native.txt',
'harpertown-core2--target-help--explicit.txt',
)

0 comments on commit 04fc91c

Please sign in to comment.