[SOLVED] PD 32 // prefetch distance (fp words)

$25

File Name: PD_32_//_prefetch_distance_(fp_words).zip
File Size: 348.54 KB

5/5 - (1 vote)

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License
Prefetching
Prefetching is used to place a cache line in memory before it is to be used, thus hiding the latency of fetching from off-chip memory.
There are two key issues here:

Copyright By Assignmentchef assignmentchef

1. Issuing the prefetch at the right time
2. Issuing the prefetch at the right distance
The right time:
If the prefetch is issued too late, then the memory values wont be back when the program wants to use them, and the processor has to wait anyway.
If the prefetch is issued too early, then there is a chance that the prefetched values could be evicted from cache by another need before they can be used.
The right distance:
The prefetch distance is how far ahead the prefetch memory is than the memory we are using right now.
Too far, and the values sit in cache for too long, and possibly get evicted.
Too near, and the program is ready for the values before they have arrived.
Computer Graphics
mjb March 30, 2019
Computer Graphics
Prefetching
Mike Bailey
prefetch.pptx
mjb March 30, 2019
Prefetching in g++
void __builtin_prefetch( void *, int rw, int locality );
#define WILL_READ_ONLY #define WILL_READ_AND_WRITE
// prefetch distance (fp words)
#define LOCALITY_NONE #define LOCALITY_LOW #define LOCALITY_MED #define LOCALITY_HIGH
#define PD
for( int i = 0; i < ArraySize; i++ ) {if( (i%16) == 0 ) {__builtin_prefetch ( &a[ i+PD ], __builtin_prefetch ( &b[ i+PD ],a[ i ] = a[ i ] + b[ i ];WILL_READ_AND_WRITE, WILL_READ_ONLY,LOCALITY_LOW ); LOCALITY_LOW ); Computer Graphicsmjb March 30, 2019 Prefetching in icc and icpcOverall, icc and icpc seem to do a good job of prefetching without you doing anything extra, but if you want to be sure: #pragma prefetch var:which-prefetch:#vector-iterations #pragma prefetch a:0:8 #pragma prefetch a:1:32 #pragma prefetch b:1:32for( int i = 0; i < ArraySize; i++ ) {vprefetch0 vprefetch1} There can be two memory prefetches inside a loopif( (i%16) == 0 ) {__builtin_prefetch ( &a[ i+PD ], __builtin_prefetch ( &b[ i+PD ],a[ i ] = a[ i ] + b[ i ];WILL_READ_AND_WRITE, WILL_READ_ONLY,LOCALITY_LOW ); LOCALITY_LOW ); Computer Graphicsmjb March 30, 2019Prefetching in Visual Studiovoid _m_prefetch( void * );Loads a cache line into cache and sets the cache line state to exclusive.#define PD 32 // prefetch distance (fp words)for( int i = 0; i < ArraySize; i++ ) {if( (i%16) == 0 ) {_m_prefetch( &a[ i+PD ] ); _m_prefetch( &b[ i+PD ] );a[ i ] = a[ i ] + b[ i ]; Computer Graphicsmjb March 30, 2019for( inti=0; i CS : assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] PD 32 // prefetch distance (fp words)
$25