Skip to content

CPU and GPU simulation builds disagree for model_eqns=1 after the MFC_GPU guard change #1787

Description

@sbryngelson

Found in review of the common-stage-independence refactor (b6bf034c, "Refactor variable conversion into common code").

In s_convert_conservative_to_primitive_variables the guard around the mixture-variable call changed from #ifdef MFC_SIMULATION to #ifdef MFC_GPU (src/common/m_variables_conversion.fpp:473).

MFC_GPU is defined only for --gpu acc / --gpu mp (cmake/MFCTargets.cmake:172,181), so a CPU-only simulation build now takes the #else host branch, which routes through s_convert_to_mixture_variables. That wrapper dispatches on model_eqns (m_variables_conversion.fpp:62):

  • model_eqns == 1 (gamma-law) -> s_convert_mixture_to_mixture_variables, reading gamma/pi_inf from the state vector
  • GPU branch -> s_convert_species_to_mixture_variables_kernel, computing gamma_K = alpha_K(1)*gammas(1)

These are different quantities. So ./mfc.sh build and ./mfc.sh build --gpu acc produce different primitives from the same restart for model_eqns == 1, and the CPU result also differs from master. For model_eqns 2/3 the two paths are equivalent, which is why this is invisible in normal use.

model_eqns = 1 is a supported simulation input (toolchain/mfc/case_validator.py:353), so this is reachable.

No test covers it: nothing in tests/ or examples/ sets model_eqns = 1.

Suggested fix: restore the MFC_SIMULATION semantics (or make the host branch call the same kernel), and add a model_eqns = 1 regression case so CPU/GPU divergence here is caught.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions