Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.

Prefetching optimization

matthieuschaller1
938 Views

I am looking at the documenation of the compiler flag "-qopt-prefetch" and I am wondering two things:

 - Is there a drawback to always have it on? i.e. could the compiler make bad pre-fetching choices and create slower code if I switch it on?

 - Is that flag part of any of the meta-flags like -O2?

Thanks for your advice!

Labels (1)
0 Kudos
3 Replies
AbhishekD_Intel
Moderator
923 Views

Hi Matthieu,


Thank you for reaching out to us.

Prefetching optimization will totally depend on your use-case. Based on your use-case you will experience the benefits and drawbacks of it.

Suppose your use-case has some small array streams, small irregular memory address patterns, and L1 cache miss reduction operations, then there will be a more chance of positive impact using Prefetching.

Because arrays and some recursive data structure accesses can be easily predicted and will have a positive impact over software prefetching. However, data structures like hashing are much harder to prefetch effectively.


Or Suppose in your use-case when the number of instructions in a loop is extremely small, it can be challenging to insert software prefetching instructions to provide timely prefetching requests because there are no enough computations between prefetching instructions.


So depending on your use-case you can take the advantage of prefetching, you can also set the levels of prefetching (-qopt-prefetch[=n]) or can disable it (-qno-opt-prefetch), depending on the scenario or you can also add the prefetching intrinsic (_mm_prefetch()) if you fill compiler is creating overhead while prefetching.


For more details please refer below link:

https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/advanced-optimization-options/qopt-prefetch-qopt-prefetch.html



The O2 optimization may enable data prefetching depending on the application. Whereas if you specify O3 level optimization, it will enable more aggressive prefetching.


Hope the above details will give you insights about the use of prefetch.



Warm Regards,

Abhishek





0 Kudos
AbhishekD_Intel
Moderator
910 Views

Hi,


Please give us an update if your issue is resolved.

If you still have some issues related to this thread please post us.



Thank You,

Abhishek


0 Kudos
AbhishekD_Intel
Moderator
901 Views

Hi,


We are assuming that the provided solution helped you. So we will stop monitoring this thread

Please post a new thread if you have any other issues.


Thank You


0 Kudos
Reply