1
General / Re: Multithreading - synchronize or not?
« Last post by mika on Today at 01:48:51 pm »https://en.wikipedia.org/wiki/Memory_barrier
Assuming ONLY ONE thread each:
...
If you only write to aEven, so you may only need a WriteBarrier on entry into the "if" block. You can check for each block if you read, write, or read/write shared data ... Though the "inc" is a read/write...
yes "ONLY ONE thread each", ONLY ONE at a time
FlagEven:=1; is for perfomance measurments with "EverSpin" thread thats count time spent no each flag state. Agree, not needed in final product.
I did try memory barrier like "sfence" , "lfence", "mfence".. but i can not mesure diference in perfomance. Results are inconsitent as is, and effect of "fneces" is not distinguishable. maybe i have wrongly constructed exaple.
From documentation about "fence" i understand that they are local to thread instructions and only help to keep in check "out of order" execution of instructions. Nothing about faster or forced data synchroniztion with main memory.