Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecoTracker/PixelSeeding: array subscript ... is above array bounds in Alpaka/FlexiStorage #45179

Open
iarspider opened this issue Jun 10, 2024 · 12 comments · May be fixed by #45340
Open

RecoTracker/PixelSeeding: array subscript ... is above array bounds in Alpaka/FlexiStorage #45179

iarspider opened this issue Jun 10, 2024 · 12 comments · May be fixed by #45340

Comments

@iarspider
Copy link
Contributor

In all IBs, GCC emits the following warnings:

>> Building alpaka/serial edm plugin tmp/el8_amd64_gcc12/src/RecoTracker/PixelSeeding/plugins/RecoTrackerPixelSeedingPortableSerialSync/libRecoTrackerPixelSeedingPortableSerialSync.so
(... gcc invocation ...)
In member function 'operator[]',
    inlined from 'size' at src/HeterogeneousCore/AlpakaInterface/interface/OneToManyAssoc.h:144:55,
    inlined from 'operator()' at src/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernelsImpl.h:553:42,
    inlined from '__invoke_impl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/invoke.h:61:36,
    inlined from '__invoke' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/invoke.h:96:40,
    inlined from '__apply_impl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:1852:27,
    inlined from 'apply' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:1863:31,
    inlined from 'operator()' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/kernel/TaskKernelCpuSerial.hpp:92:31,
    inlined from 'ndLoopImpl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:25:14,
    inlined from 'ndLoopImpl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:44:27,
    inlined from 'ndLoop' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:71:27,
    inlined from 'ndLoopIncIdx' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:83:15,
    inlined from 'operator()' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/kernel/TaskKernelCpuSerial.hpp:86:31:
  src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h:15:60: warning: array subscript 262145 is above array bounds of 'const unsigned int[262145]' [-Warray-bounds]
    15 |     constexpr const I& operator[](int i) const { return m_v[i]; }
      |                                                            ^
src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h: In member function 'operator()':
src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h:21:7: note: while referencing 'm_v'
   21 |     I m_v[S];
      |       ^
In member function 'operator[]',
    inlined from 'size' at src/HeterogeneousCore/AlpakaInterface/interface/OneToManyAssoc.h:144:55,
    inlined from 'operator()' at src/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernelsImpl.h:553:42,
    inlined from '__invoke_impl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/invoke.h:61:36,
    inlined from '__invoke' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/invoke.h:96:40,
    inlined from '__apply_impl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:1852:27,
    inlined from 'apply' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:1863:31,
    inlined from 'operator()' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/kernel/TaskKernelCpuSerial.hpp:92:31,
    inlined from 'ndLoopImpl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:25:14,
    inlined from 'ndLoopImpl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:44:27,
    inlined from 'ndLoop' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:71:27,
    inlined from 'ndLoopIncIdx' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:83:15,
    inlined from 'operator()' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/kernel/TaskKernelCpuSerial.hpp:86:31:
  src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h:15:60: warning: array subscript 262145 is above array bounds of 'const unsigned int[262145]' [-Warray-bounds]
    15 |     constexpr const I& operator[](int i) const { return m_v[i]; }
      |                                                            ^
src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h: In member function 'operator()':
src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h:21:7: note: while referencing 'm_v'
   21 |     I m_v[S];
      |       ^
In member function 'operator[]',
    inlined from 'size' at src/HeterogeneousCore/AlpakaInterface/interface/OneToManyAssoc.h:144:55,
    inlined from 'operator()' at src/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGeneratorKernelsImpl.h:553:42,
    inlined from '__invoke_impl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/invoke.h:61:36,
    inlined from '__invoke' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/invoke.h:96:40,
    inlined from '__apply_impl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:1852:27,
    inlined from 'apply' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:1863:31,
    inlined from 'operator()' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/kernel/TaskKernelCpuSerial.hpp:92:31,
    inlined from 'ndLoopImpl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:25:14,
    inlined from 'ndLoopImpl' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:44:27,
    inlined from 'ndLoop' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:71:27,
    inlined from 'ndLoopIncIdx' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/meta/NdLoop.hpp:83:15,
    inlined from 'operator()' at /data/cmsbld/jenkins/workspace/build-any-ib/w/el8_amd64_gcc12/external/alpaka/1.1.0-0a6641b4bfdf883c8da5b9e8620be504/include/alpaka/kernel/TaskKernelCpuSerial.hpp:86:31:
  src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h:15:60: warning: array subscript 32769 is above array bounds of 'const unsigned int[32769]' [-Warray-bounds]
    15 |     constexpr const I& operator[](int i) const { return m_v[i]; }
      |                                                            ^
src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h: In member function 'operator()':
src/HeterogeneousCore/AlpakaInterface/interface/FlexiStorage.h:21:7: note: while referencing 'm_v'
   21 |     I m_v[S];
      |       ^
@cmsbuild
Copy link
Contributor

cmsbuild commented Jun 10, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

A new Issue was created by @iarspider.

@antoniovilela, @smuzaffar, @makortel, @rappoccio, @sextonkennedy, @Dr15Jones can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@iarspider
Copy link
Contributor Author

iarspider commented Jun 10, 2024

assign HeterogeneousCore/AlpakaInterface,RecoTracker/PixelSeeding

@cmsbuild
Copy link
Contributor

New categories assigned: heterogeneous,reconstruction

@fwyzard,@jfernan2,@makortel,@mandrenguyen you have been requested to review this Pull request/Issue and eventually sign? Thanks

@iarspider
Copy link
Contributor Author

First occurrence in CMSSW_14_1_X_2024-06-05-2300

@slava77
Copy link
Contributor

slava77 commented Jun 10, 2024

@AdrianoDee
in case you haven't received this already

@Dr15Jones
Copy link
Contributor

Dr15Jones commented Jun 27, 2024

This is probably not a real issue. [I think I was wrong initially]

for (auto idx : cms::alpakatools::uniform_elements(acc, tracks_view.hitIndices().nOnes())) {
if (tracks_view.hitIndices().size(idx) == 0)

with the final line calls

constexpr auto size(uint32_t b) const { return off[b + 1] - off[b]; }

notice the b+1. The documentation for uniform_elements has

* `uniform_elements(acc [, first], extent)` returns a one-dimensional iteratable range that spans the element indices
* from `first` (inclusive) to `extent` (exlusive).

so the b+1 will be the size of the container so off[b+1] at first glance seems to be off the end of the container.

However, looking at the definition of nOnes()

constexpr auto nOnes() const { return totOnes() - 1; }

and

constexpr auto totOnes() const { return off.capacity(); }

then assuming capacity is the true size of the container, than off[b+1] for the end condition should be off[ (nOnes()-1) +1] ==off[( (totOnes()-1)-1 ) +1 ] == off[totOnes() -1]

@fwyzard
Copy link
Contributor

fwyzard commented Jun 27, 2024

@Dr15Jones thanks for looking into this issue 👍🏻

@VinInn
Copy link
Contributor

VinInn commented Jun 28, 2024

yep. All that was indeed intentional (at least in the CUDA version).

smuzaffar added a commit to smuzaffar/cmssw that referenced this issue Jun 28, 2024
@smuzaffar
Copy link
Contributor

I have opened #45340 to suppress this error

@Dr15Jones
Copy link
Contributor

One more item, if I add

assert(static_cast<decltype(tracks_view.hitIndices().nOnes())>(idx) < tracks_view.hitIndices().nOnes());

right before the call to size the warning goes away. Evidently that helped the link time optimizer to see the index can not go out of bounds. The question is why the optimizer thinks uniform_elements can go out of bounds when given nOnes() as the end point.

@Dr15Jones
Copy link
Contributor

A bit more investigation, if I change the loop condition to actually be on the end, i.e.

for (auto idx : cms::alpakatools::uniform_elements(acc, tracks_view.hitIndices().totOnes()))

the warning states that the value goes 1 beyond the end, instead of just the end (which is what is actually going on). So the compiler really thinks that cms::alpakatools::uniform_elements end condition is inclusive instead of exclusive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants