https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113085

--- Comment #10 from 颜森道 <yansendao at 126 dot com> ---
Re-reported as PR 128694, which is now closed as a duplicate of this one.

I have a patch for this.  alloc-pinned-1.c, -2.c and -5.c compute

  SIZE = sysconf (_SC_PAGESIZE) - 128

and abort in CHECK_SIZE (SIZE * 5) with "insufficient lockable memory;
please increase ulimit" when RLIMIT_MEMLOCK is not larger than that.  With
64 KiB pages that is a little over 319 KiB, while 64 KiB is a common
default for RLIMIT_MEMLOCK (comment #7), so the tests cannot possibly run
on such a machine.  I can reproduce the same failure on x86_64 by running
the testsuite with "ulimit -l 16" instead of on a 64 KiB page kernel.

The patch adds check_effective_target_omp_pinned_mem to
libgomp/testsuite/lib/libgomp.exp and requires it from those three tests.
It compiles and runs a small program that reads RLIMIT_MEMLOCK and tests
exactly the condition CHECK_SIZE tests, so the tests are reported as
unsupported only when they are known to abort.  If the limit cannot be
queried, or the compiler is a cross compiler, the check reports success
and the tests run; CHECK_SIZE stays in place as the backstop.  The nvptx
variant locks the memory through CUDA, so the requirement is guarded with
"{ target { ! offload_device_nvptx } }" and does not apply there.

I understand the concern in comment #1 that skipping these tests would
mask a failure for another reason.  They are reported as unsupported only
when the limit is demonstrably too small for what they lock, which is
exactly the case that emits the abort message; a failure for any other
reason still shows up as a failure.

Tested on x86_64-pc-linux-gnu:
  - with the default limit, alloc-pinned-{1,2,3,4,5,6,8}.c all pass;
  - with "ulimit -l 16", alloc-pinned-{1,2,5}.c are unsupported and
    alloc-pinned-{3,4,6,8}.c still pass.

The alloc-pinned-3.c and -4.c failures on powerpc64 BE mentioned in
comments #5 and #8 are a different problem (set_pin_limit in the test
aborts) and are not addressed here.

Patch attached; I will post it to gcc-patches as well.

Reply via email to