(no commit message)
[libreriscv.git] / openpower / sv / cookbook / fortran_maxloc.mdwn
1 # Fortran MAXLOC SVP64 demo
2
3 MAXLOC is a notoriously difficult function for SIMD to cope with.
4 SVP64 however has similar capabilities to Z80 CPIR and LDIR
5
6 <https://bugs.libre-soc.org/show_bug.cgi?id=676>
7
8 ```
9 int m2(int * const restrict a, int n)
10 {
11 int m, nm;
12 int i;
13
14 m = INT_MIN;
15 nm = -1;
16 for (i=0; i<n; i++)
17 {
18 if (a[i] > m)
19 {
20 m = a[i];
21 nm = i;
22 }
23 }
24 return nm;
25 }
26 ```
27
28 [[!tag svp64_cookbook ]]
29
30 Read:
31 <https://www.intel.com/content/www/us/en/developer/articles/technical/optimizing-maxloc-operation-using-avx-512-vector-instructions.html#gs.12t5y0>
32
33 <img src="https://www.intel.com/content/dam/developer/articles/technical/optimizing-maxloc-operation-using-avx-512-vector-instructions/optimizing-maxloc-operation-using-avx-512-vector-instructions-code2.png
34 " alt="NLnet foundation logo" width="50%" />