3 ms·
At a certain level you are correct. A compiler certainly should not be reordering FP calculations, for instance. However, at the level these abstractions are ty
by noelwelsh 10y ago
At a certain level you are correct. A compiler certainly should not be reordering FP calculations, for instance. However, at the level these abstractions are typically used they are absolutely fine. For example, if you want to add up the number of hits your web site has received you will be absolutely fine to use a 64-bit integer and treat addition as associative. There is no possibility of overflow. Similarly, if you train a machine learning model using gradient descent you can compute your gradients in parallel and then sum them, taking advantage of associativity, and this will work out fine. (See Hogwild! for some proofs that #YOLO is an acceptable strategy for SGD https://people.eecs.berkeley.edu/~brecht/papers/hogwildTR.pdf https://people.eecs.berkeley.edu/~brecht/papers/hogwildTR.pd...)
So, basically, semigroups and other abstractions are a-ok where they are typically used.