Skip to content

Commit 8fb2549

Browse files
committed
Use jit if openmp not available, and print Windows diagnostics
1 parent 83a5ba6 commit 8fb2549

9 files changed

Lines changed: 52 additions & 30 deletions

File tree

.github/workflows/build.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
os: [ubuntu-latest, windows-2022, macos-13, macos-14]
12+
#os: [ubuntu-latest, windows-2022, macos-13, macos-14]
13+
os: [windows-2022, macos-13]
1314

1415
steps:
1516
- uses: actions/checkout@v5
@@ -50,15 +51,15 @@ jobs:
5051
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
5152
path: ./wheelhouse/*.whl
5253

53-
build_sdist:
54-
name: Build source distribution
55-
runs-on: ubuntu-latest
56-
steps:
57-
- uses: actions/checkout@v5
58-
59-
- name: Build sdist
60-
run: pipx run build --sdist
61-
62-
- uses: actions/upload-artifact@v4
63-
with:
64-
path: dist/*.tar.gz
54+
# build_sdist:
55+
# name: Build source distribution
56+
# runs-on: ubuntu-latest
57+
# steps:
58+
# - uses: actions/checkout@v5
59+
#
60+
# - name: Build sdist
61+
# run: pipx run build --sdist
62+
#
63+
# - uses: actions/upload-artifact@v4
64+
# with:
65+
# path: dist/*.tar.gz

pyproject.toml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,33 @@ repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel} --exclude libcud
5151
before-test = "pip install torch --index-url https://download.pytorch.org/whl/cpu"
5252

5353
[tool.cibuildwheel.windows]
54-
# Activate VS environment so torch.compile can find the compiler.
55-
before-test = 'call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"'
54+
# Activate VS environment and run extensive diagnostics
55+
before-test = '''
56+
echo "--- Diagnostics before vcvars64.bat ---"
57+
echo "PATH is:"
58+
echo %PATH%
59+
echo "Attempting to locate cl.exe:"
60+
where cl
61+
echo "Installed packages:"
62+
pip freeze
63+
echo "-----------------------------------------"
64+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
65+
echo "--- Diagnostics after vcvars64.bat ---"
66+
echo "PATH is:"
67+
echo %PATH%
68+
echo "INCLUDE is:"
69+
echo %INCLUDE%
70+
echo "LIB is:"
71+
echo %LIB%
72+
echo "Attempting to locate cl.exe:"
73+
where cl
74+
echo "Attempting to run cl.exe:"
75+
cl /help
76+
echo "--------------------------------------"
77+
'''
5678
test-command = "pytest tests/test_scalar.py"
5779

5880
[tool.cibuildwheel.macos]
59-
# Install libomp for linking during build and for runtime in the test env.
60-
before-build = "brew install libomp"
61-
before-test = "brew install libomp"
62-
# Set flags to find and enable OpenMP during the build.
63-
environment = { CFLAGS="-Xclang -fopenmp -I$(brew --prefix libomp)/include", LDFLAGS="-L$(brew --prefix libomp)/lib" }
6481
test-command = "pytest tests/test_scalar.py"
6582

6683
[tool.scikit-build.sdist]

src/deepwave/elastic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,7 +2524,7 @@ def elastic_func(
25242524

25252525
if python_backend:
25262526
if python_backend is True:
2527-
mode = "compile"
2527+
mode = "compile" if deepwave.backend_utils.USE_OPENMP else "jit"
25282528
elif isinstance(python_backend, str):
25292529
mode = python_backend.lower()
25302530
else:

src/deepwave/scalar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,7 @@ def scalar_func(
23482348

23492349
if python_backend:
23502350
if python_backend is True:
2351-
mode = "compile"
2351+
mode = "compile" if deepwave.backend_utils.USE_OPENMP else "jit"
23522352
elif isinstance(python_backend, str):
23532353
mode = python_backend.lower()
23542354
else:

src/deepwave/scalar_born.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ def scalar_born_func(
19791979

19801980
if python_backend:
19811981
if python_backend is True:
1982-
mode = "compile"
1982+
mode = "compile" if deepwave.backend_utils.USE_OPENMP else "jit"
19831983
elif isinstance(python_backend, str):
19841984
mode = python_backend.lower()
19851985
else:

tests/test_callbacks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,9 @@ def do_nothing(state: deepwave.common.CallbackState) -> None:
413413

414414

415415
def test_scalar_backward_callback_only_call_count() -> None:
416-
"""Check that the backward callback is called the correct number of times
417-
when no forward callback is provided.
416+
"""Check that the backward callback is called the correct number of times.
417+
418+
Check it when no forward callback is provided.
418419
"""
419420
v = torch.ones(10, 10) * 1500
420421
v.requires_grad_()

tests/test_callbacks_born.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,13 @@ def do_nothing(state: deepwave.common.CallbackState) -> None:
309309
for i in range(len(out1)):
310310
assert torch.allclose(out1[i], out2[i])
311311
assert torch.allclose(grad1_v, grad2_v)
312+
assert torch.allclose(grad1_scatter, grad2_scatter)
312313

313314

314315
def test_scalar_born_backward_callback_only_call_count() -> None:
315-
"""Check that the backward callback is called the correct number of times
316-
when no forward callback is provided.
316+
"""Check that the backward callback is called the correct number of times.
317+
318+
Check it when no forward callback is provided.
317319
"""
318320
v = torch.ones(10, 10) * 1500
319321
scatter = torch.ones(10, 10)

tests/test_callbacks_elastic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ def do_nothing(state: deepwave.common.CallbackState) -> None:
373373

374374

375375
def test_elastic_backward_callback_only_call_count() -> None:
376-
"""Check that the backward callback is called the correct number of times
377-
when no forward callback is provided.
376+
"""Check that the backward callback is called the correct number of times.
377+
378+
Check it when no forward callback is provided.
378379
"""
379380
lamb = torch.ones(10, 10) * 2200
380381
mu = torch.ones(10, 10) * 1000

tests/test_scalar_born.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def test_forward_cpu_gpu_match() -> None:
623623
prop_kwargs={"python_backend": python},
624624
)
625625
for cpui, gpui in zip(actual_cpu, actual_gpu):
626-
assert torch.allclose(cpui, gpui.cpu(), atol=1e-5)
626+
assert torch.allclose(cpui, gpui.cpu(), atol=5e-5)
627627

628628

629629
def test_unused_source_receiver(

0 commit comments

Comments
 (0)