[Chapel Merge] Second attempt to emit C `const` qualifier for `c_ptrConst` type

Branch: refs/heads/main
Revision: 349baea38219367dd7eb6c205770ba25994d47f0
Author: riftEmber
Link: Second attempt to emit C `const` qualifier for `c_ptrConst` type by riftEmber · Pull Request #24809 · chapel-lang/chapel · GitHub
Log Message:
Second attempt to emit C const qualifier for c_ptrConst type (#24809)

Take two at emitting the const qualifier for c_ptrConsts in
generated C code.

The first commit restores work from
Emit C `const` qualifier for `c_ptrConst` type by riftEmber · Pull Request #24746 · chapel-lang/chapel · GitHub by reverting the revert
PR Revert "Emit C `const` qualifier for `c_ptrConst` type" by riftEmber · Pull Request #24803 · chapel-lang/chapel · GitHub.

Fixes for bugs observed in nightly testing are in following commits.
They were all instances of arrays passed with default intent (which is
const ref) but which the underlying C library wants as a mutable
pointer, meaning we need to give them ref intent.

Reviewer info:

  • The first commit is unnecessary to review as it just contains the work
    from Emit C `const` qualifier for `c_ptrConst` type by riftEmber · Pull Request #24746 · chapel-lang/chapel · GitHub.
  • A huge number of rote changes are made in the package modules, too
    many to review individually. One package module is changed per commit,
    and each commit message links to the docs I referenced. I don't expect a
    reviewer to read through the files, but probably rather just spot-check
    for the correct approach and that the patterns I describe below are
    reasonable.
  • LAPACK: Made ALL array arguments ref except for a few exceptions,
    as there are simply an overwhelming number of functions. It is likely
    some are incorrect, and we can fix them if they come up later; this is
    documented in Known (likely) issue with LAPACK module formal constness · Issue #24868 · chapel-lang/chapel · GitHub.
  • BLAS: I found groups of similar functions (matrix-vector
    multiplication, matrix-matrix multiplication, copy/swap, rank updates,
    etc), checked which parameter(s) are outputs, and made only those ref.
  • MPI: Just worked through the instances that complained as there
    weren't too many, and checked those against the documentation to make
    sure updating them made sense.
  • FFTW: Made all plan inputs mutable as per the documentation (which
    states the input and output may be the same thing for in-place use).

TODO:

Resolves https://github.com/Cray/chapel-private/issues/6092.

[reviewed by @mppf , thanks!]

Testing:

  • nightly test failures reproduced and fixed
  • paratest
  • C backend paratest
  • GPU paratest

Compare: Comparing 144322ada1ff7573f494040ba7396dc38827514f...ecc9597c5aee91dbd2aad1a3028c5c164a4446c4 · chapel-lang/chapel · GitHub

Diff:
M compiler/codegen/cg-expr.cpp
M compiler/codegen/cg-type.cpp
M make/compiler/Makefile.gnu
M make/compiler/Makefile.intel
M modules/packages/BLAS.chpl
M modules/packages/FFTW.chpl
M modules/packages/LAPACK.chpl
M modules/packages/MPI.chpl
M runtime/include/chpl-comm-compiler-macros.h
M runtime/include/chplio.h
M runtime/include/chpltypes.h
M runtime/include/gpu/chpl-gpu-gen-common.h
M runtime/src/chplio.c
M test/extern/bradc/cprintarr.h
M test/extern/bradc/extern_string_test-remote.h
M test/extern/diten/testVoidExternFns.h
M test/extern/kbrady/array_fns.h
M test/extern/passArrays/passViewToExtern.h
M test/studies/shootout/k-nucleotide/bharshbarg/knucleotide-associative.chpl
M test/studies/shootout/k-nucleotide/bharshbarg/knucleotide-chaining.chpl
M test/users/bugzilla/bug794131/bug794131.chpl
M test/users/ibertolacc/void_extern_proc_array.chpl
https://github.com/chapel-lang/chapel/pull/24809.diff