Fault-Only-First Indexed Loads Instructions


lidawei14@...
 

Hi all, 

In this page I would like to discuss about fault-only-first indexed load instructions since we have
certain using cases, for example, SPEC CPU 2006 4.1.bzip2 src/blocksort.c:line 712.

For fault-only-first instructions like vleff.v, they support data dependent loop exits like code below: 
```
for (i=0; i<N; i++){
    t= a[i];
    if (t< 3)
        return t;
}
```

but in some cases we have indirect data access pattern:
```
for (i=0; i<N; i++){
    t= a[b[i]];
    if (t< 3)
        return t;
}
```

We will need to load indices b[i] first and then do an indexed fault-only-first load for a[],
thus this raises a need for fault-only-first indexed load instructions in our V extension. 
In the spec it says fault-only-first instructions could be implemented in future versions,
then I believe it makes sense to have a discussion here.


jerry.shih@...
 

Does the index of b[i] for a[ ] might be invalid in "SPEC CPU 2006" test?


lidawei14@...
 

        while (True) {
            if (unLo > unHi) break;
            n = ((Int32)block[ptr[unLo]+d]) - med;
            if (n == 0) {
               mswap(ptr[unLo], ptr[ltLo]);
               ltLo++; unLo++; continue;
            };
            if (n >  0) break;
            unLo++;
         }

The loop above is from actual SPEC CPU 401.bzip2,
I think those if statements guarantee correctness of
memory access of block[], thus I think my answer is
positive.
 


Jonathan Behrens <behrensj@...>
 

This instruction would enable U-mode software to probe any page in memory to determine whether it was currently mapped or not, without giving the OS any opportunity to intervene. Currently it is only possible to detect that information via issuing a normal memory load and timing how long it takes (which only works if the OS chooses not to terminate the process in its page fault handler).

Jonathan


On Tue, Jun 16, 2020 at 9:22 AM lidawei14 via lists.riscv.org <lidawei14=huawei.com@...> wrote:
        while (True) {
            if (unLo > unHi) break;
            n = ((Int32)block[ptr[unLo]+d]) - med;
            if (n == 0) {
               mswap(ptr[unLo], ptr[ltLo]);
               ltLo++; unLo++; continue;
            };
            if (n >  0) break;
            unLo++;
         }

The loop above is from actual SPEC CPU 401.bzip2,
I think those if statements guarantee correctness of
memory access of block[], thus I think my answer is
positive.