Skip to content

Fix CRKSPH OpenCL kernel compilation - #439

Open
lililii124 wants to merge 1 commit into
pypr:mainfrom
lililii124:fix/crksph-opencl-378
Open

Fix CRKSPH OpenCL kernel compilation#439
lililii124 wants to merge 1 commit into
pypr:mainfrom
lililii124:fix/crksph-opencl-378

Conversation

@lililii124

Copy link
Copy Markdown

The default CRKSPH scheme in kelvin_helmholtz_instability --opencl fails to build its generated OpenCL kernels. This change removes the invalid Python-style casts in gj_solve, uses floating-point bounds in the momentum and energy limiters, and computes the sound speed with sqrt to avoid an ambiguous pow overload.

The array dot-product helper is named dot_product to avoid colliding with OpenCL's built-in dot. CRKSPH and MAGMA2 helper registrations and calls use the new name; dot remains an alias for existing Python callers.

The regression test compiles and executes both CRKSPH equation stages and compares density, pressure, sound speed, correction coefficients/gradients, acceleration and energy rate against Cython. It covers single and double precision, skipping double precision on devices without FP64 support.

Validation on Windows, Python 3.11, Compyle 0.9.1, and Intel UHD Graphics 730:

  • Before the fix, the new test reproduces BUILD_PROGRAM_FAILURE with invalid float(...) expressions and ambiguous min calls.
  • python -m pytest pysph/sph/tests/test_linalg.py pysph/sph/tests/test_kernel_corrections.py pysph/sph/tests/test_crksph.py -q: 31 passed, 1 skipped (FP64 unsupported on this GPU).
  • python -m pysph.examples.gas_dynamics.kelvin_helmholtz_instability --opencl --max-steps 2 --disable-output -d <output-directory>: completed successfully with 47,524 particles including periodic ghosts.
  • git diff --check: passed.

Double-precision execution could not be verified locally: the alternative Intel CPU OpenCL runtime terminates with an internal compiler error. The FP64 regression case is included for supported CI devices. The example run is a two-step smoke test, not a long-duration validation of the physical solution.

Fixes #378.

Avoid invalid casts and OpenCL builtin overload conflicts; add CPU/OpenCL numerical regression coverage. Fixes pypr#378.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot run gas dynamic example in GPU

1 participant