Here is my problem:
1) I have a tree which I want to act upon some branches indepedantly and simultaneously by different threads
2) The program is structured so that the processing of each branch is isolated after the main "manager" thread delegates the work to different thread: memory of branch 1 is processed by thread 1, memory of branch 2 is processed by thread 2 only. Then when all thread have completed (and go to wait/sleep mode) the main manager uses the memory of branch 1 and branch 2 to do other work
3) I am new to multiprocessors and mutlithreading. What I understand is that the volatile keyword can be quite expensive because the data won't be cached and will be written and read in memory each time. And the way my program is structured there would (theoretically!) be no need to use volatile since at any moment of the program the memory is guaranteed to be used only by a single thread at a time (either the manager thread of the branch-specific thread). For example:
a) memory in branch 1 is first used by the main manager thread,
b) then, it delegates to thread 1 which is the only one using the memory until it completes
c) then, memory of branch 1 is worked on by the main manager thread
4) Thread local storage does not seem to be the answer because the branches have numerous sub-branches and you would need to transfer back all the nodes one by one to the main manager thread (which slows everything unecessarily)
5) So what I am looking for is a way to "flush" non-volatile memory. For example, just before going to sleep branch 1 would "flush" its non-volatile memory to guarantee that its processor register and cache data would have been transmitted to the main memory. Thus the main manager thread would be guaranteed to work on up-to-date memory thereafter
6)
a) Is this possible?
b) Is there a C++ way?
d) Is this highly compiler specific?
e) Is this even microprocessor specific?
f) Are there more elegant way (and as fast) to achieve the same result?