> On 9 Jan 2019, at 09:53, Raj <rajlistu...@gmail.com> wrote:
> 
> Hello all,
> 
> While going through the VPP code, I have not fully understood  what
> the following functions mean and when should they be used?
> 
> 1.   static_always_inline void
>   vlib_buffer_enqueue_to_next (vlib_main_t * vm, vlib_node_runtime_t * node,
>                                u32 * buffers, u16 * nexts, uword count)
> 
>   I could see following comments about this function
>   /*
>    * Send the packets along their respective next-node graph arcs
>    * Considerable locality of reference is expected, most if not all
>    * packets in the inbound vector will traverse the same next-node
>    * arc
>    */
> I tried reading through the code but could not figure out what this
> function does, and how this is implemented. I see that the code has
> optimizations for various CPU, but not could not figure out what those
> optimizations are.

This function simply gets array of buffer indices and array of next indices,
and enqueues those buffers to be processed by those next nodes...


> 
> 2.  #define vlib_prefetch_buffer_header    (b, type )
>           CLIB_PREFETCH (b, 64, type)
> 
> This gets expanded to:
> #define _CLIB_PREFETCH(n,size,type)                             \
>  if ((size) > (n)*CLIB_CACHE_LINE_BYTES)                       \
>    __builtin_prefetch (_addr + (n)*CLIB_CACHE_LINE_BYTES,      \
>                        CLIB_PREFETCH_##type,                   \
>                        /* locality */ 3);
> 
> type can be either LOAD or STORE. What is the purpose of these two operations?
> 
> I am sure I am missing some thing with respect to understanding
> prefetch. I assume LOAD will prefetch data from memory, and STORE
> performs its inverse operation?


On x86, there was only load prefetch for a long time, recently store prefetch 
is introduced
with Skylake microarchitecture. You can find explanation here:

https://www.felixcloutier.com/x86/prefetchwt1 
<https://www.felixcloutier.com/x86/prefetchwt1>

Please note that compiler will emit PREFETCHWT1 instruction only if your
code is using multi-versioning in VPP (use of VLIB_NODE_FN() macro + 
MULTIARCH_SOURCES in CMakeLists.txt file).
and only when skylake is detected on runtime.

Otherwise CLIB_PREFETCH (x, 64, STORE) will produce identical results 
like you did LOAD....

-- 
Damjan

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#11882): https://lists.fd.io/g/vpp-dev/message/11882
Mute This Topic: https://lists.fd.io/mt/28982509/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to