CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

what does cache do?

Register Blogs Community New Posts Updated Threads Search

Like Tree11Likes
  • 2 Post By wyldckat
  • 2 Post By Tobi
  • 7 Post By jwstolk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 30, 2013, 11:39
Default what does cache do?
  #1
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
Code:
cache
{
    grad(U);
}
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 9, 2013, 06:58
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ehsan,

A bit more context to the question would make it a lot easier to help... in other words, how is this being used?
In even other words, how can I test what this does, if you don't indicate how you've tried to use it!?

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 9, 2013, 08:01
Default
  #3
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
Hi
I saw it in a case I was curious about only that what does.never mind.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 9, 2013, 08:07
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Then I guess I'll have to give a generic answer ... the term "cache" is explained in Wikipedia: http://en.wikipedia.org/wiki/Cache_%28computing%29
Quote:
In computer science, a cache (/ˈkæʃ/ KASH)[1] is a component that transparently stores data so that future requests for that data can be served faster. The data that is stored within a cache might be values that have been computed earlier or duplicates of original values that are stored elsewhere. If requested data is contained in the cache (cache hit), this request can be served by simply reading the cache, which is comparatively faster. Otherwise (cache miss), the data has to be recomputed or fetched from its original storage location, which is comparatively slower. Hence, the greater the number of requests that can be served from the cache, the faster the overall system performance becomes.
saeed jamshidi and reverseila like this.
__________________
wyldckat is offline   Reply With Quote

Old   October 27, 2019, 07:19
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,


I am just interested which fields should be cached and when? It is obvious that recalculating a field requires much longer than caching it after the first evaluation. However, how can we determine, which field we should cache and which not?



  • If I would build my own solver e.q. a stress solver for linear elastic problems, the grad(U) field has to be evaluated several times. Here, I guess the cache option for grad(U) would be speed up the calculation
  • While using FOAM standard solvers, how can we determine which field to cache and which not?


Is there any rule or any hint? E.g., we could cache actually each field
Okay, if it is just needed once, then it will probably decrease the calculation speed a bit based on caching the data always. However, it was just an example.
lourencosm and reverseila like this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 8, 2020, 02:03
Default
  #6
New Member
 
Jaap Stolk
Join Date: Nov 2014
Posts: 11
Rep Power: 11
jwstolk is on a distinguished road
Quote:
Originally Posted by Tobi View Post
It is obvious that recalculating a field requires much longer than caching it after the first evaluation.

Only when using memory takes no time. With recent CPU's the calculation times and the number of cores has improved much faster than memory bandwidth. CPU-cache is practically irrelevant since OpenFOAM cycles through a large dataset that is usually larger than could fit in the CPU-cache.


If the memory bandwidth is the bottleneck on your hardware, it may be faster to re-calculate the value instead of saving a copy. It also depends on how difficult it is to re-calculate the value. what works for "U" may not work for other values.


Take a run that is typical of what you are using the hardware for (cell size, solver selection, decomposition, etc.) and run that twice, with only the cache U disable as difference between the settings, and check which one runs faster.


Same for hyper-threading: hyper-threading usually makes CFD's run slower but I had some quad-core systems with quad-channel RAM. On that specific hardware, hyper-threading enabled (8 threads) was slightly faster. Just test it with a typical workload.
Tobi, Yann, randolph and 4 others like this.
jwstolk is offline   Reply With Quote

Old   August 16, 2022, 10:50
Default
  #7
Member
 
Giles Richardson
Join Date: Jun 2012
Location: Cambs UK
Posts: 98
Rep Power: 13
ufocfd is on a distinguished road
good question - do you need to cache the grad(U) in simpleFoam?

Quote:
Originally Posted by immortality View Post
Code:
cache
{
    grad(U);
}
ufocfd is offline   Reply With Quote

Old   August 18, 2022, 09:42
Default
  #8
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
No you don't. You don't need to cache any quantity but if it is used several times, its much cheaper to save the first calculation and simply take the results in any other place.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 05:36
copy cache file to each processor newOFuser OpenFOAM 2 August 7, 2012 17:06
row cache lock!!cfx-slover problem Della CFX 0 March 19, 2011 03:34
Can't cache (1024, 0) HANA FLUENT 0 December 6, 2008 02:27
Ram, cache and cpu upgrade help zonexo Main CFD Forum 14 January 24, 2007 09:05


All times are GMT -4. The time now is 06:34.