Re: Compute in a lock free way

2022-06-06 Thread Laurynas Biveinis
> > 128-bit > > atomics are more limited than 64-bit ones on x86_64, i.e. to load the > > 128 bit value you still have to do CAS instead of simple load, > > resulting in a more expensive implementation; > > You do not have to, on x86_64 the SIMD mov operations are atomic on 128 bits. Indeed. Thank

Re: Compute in a lock free way

2022-06-04 Thread Dain Ironfoot
Thanks so much Remi! Really like how you separated the computation and the thread-safety part. Wish I had thought of that :) -- You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group. To unsubscribe from this group and stop receiving emails from i

Re: Compute in a lock free way

2022-06-04 Thread Remi Forax
> From: "Dain Ironfoot" > To: "mechanical-sympathy" > Sent: Saturday, June 4, 2022 5:11:49 PM > Subject: Re: Compute in a lock free way > Thank you so much Remi!! > I took your advice of using CAS to update both of them and came up with this > (Can'

Re: Compute in a lock free way

2022-06-04 Thread Dain Ironfoot
Thanks Heinz! Please correct me if I am wrong but your approach, on a high level, sounds similar to Remi's approach? In Remi's approach, we are CASing and atomically updating the state ourselves. However, in your approach, we would delegate it to LongAccumulator? On Saturday, June 4, 2022 at

Re: Compute in a lock free way

2022-06-04 Thread Dain Ironfoot
urday, June 4, 2022 at 3:45:50 AM UTC-5 fo...@univ-mlv.fr wrote: > *From: *"Dain Ironfoot" > *To: *"mechanical-sympathy" > *Sent: *Saturday, June 4, 2022 12:53:55 AM > *Subject: *Compute in a lock free way > > Hello, > I am writing a class to calculate

Re: Compute in a lock free way

2022-06-04 Thread Dain Ironfoot
urday, June 4, 2022 at 3:45:50 AM UTC-5 fo...@univ-mlv.fr wrote: > *From: *"Dain Ironfoot" > *To: *"mechanical-sympathy" > *Sent: *Saturday, June 4, 2022 12:53:55 AM > *Subject: *Compute in a lock free way > > Hello, > I am writing a class to calculate

Re: Compute in a lock free way

2022-06-04 Thread John
Hello anonymous internet user :) I cant understand the full context of the problem and am curious about it. I don't understand how aggregating prices into a mean value but can be used to produce a meaningful signal. So some questions: Do you reset the average periodically? Do you take snapsho

Re: Compute in a lock free way

2022-06-04 Thread Dr Heinz M. Kabutz
What is the maximum count and sum? Could the two fit into a 64 bit long? If so a LongAccumulator could be made to work. On Sat, 04 Jun 2022 at 01:53, Dain Ironfoot wrote: > Hello, > > I am writing a class to calculate average of prices. We use it to generate > buy/sell signal for some financial

Re: Compute in a lock free way

2022-06-04 Thread Remi Forax
- Original Message - > From: "Laurynas Biveinis" > To: "mechanical-sympathy" > Sent: Saturday, June 4, 2022 11:03:28 AM > Subject: Re: Compute in a lock free way >> I am writing a class to calculate average of prices. We use it to generate

Re: Compute in a lock free way

2022-06-04 Thread Laurynas Biveinis
> I am writing a class to calculate average of prices. We use it to generate > buy/sell signal for some financial instruments therefore latency is crucial. > Prices are sent via different threads therefore class needs to be thread-safe. > > Am I correct in understanding that I have to use a lock

Re: Compute in a lock free way

2022-06-04 Thread Remi Forax
> From: "Dain Ironfoot" > To: "mechanical-sympathy" > Sent: Saturday, June 4, 2022 12:53:55 AM > Subject: Compute in a lock free way > Hello, > I am writing a class to calculate average of prices. We use it to generate > buy/sell signal for some f

Compute in a lock free way

2022-06-03 Thread Dain Ironfoot
Hello, I am writing a class to calculate average of prices. We use it to generate buy/sell signal for some financial instruments therefore latency is crucial. Prices are sent via different threads therefore class needs to be thread-safe. Am I correct in understanding that I have to use a loc