Newest at the top
2025-06-23 18:47:10 +0200 | <tomsmeding> | because Haskell2010 certainly also doesn't have stgDoubleToWord64 |
2025-06-23 18:46:57 +0200 | <tomsmeding> | EvanR: are you specifically referring to ISO standardised C, or C as implemented in practice? |
2025-06-23 18:46:31 +0200 | <haskellbridge> | <magic_rb> Ive been saying its a low level systems language since forever |
2025-06-23 18:46:17 +0200 | <haskellbridge> | <magic_rb> Only people that have not interacted with the haskell community say that haskell is a high level language |
2025-06-23 18:46:17 +0200 | <EvanR> | standard C does not have all these primitives so it might be beating C at "low level" |
2025-06-23 18:45:52 +0200 | <EvanR> | lol |
2025-06-23 18:45:49 +0200 | <tomsmeding> | I'm not sure about "best" |
2025-06-23 18:45:42 +0200 | <EvanR> | haskell is the best low level bit bashing language? |
2025-06-23 18:45:15 +0200 | tmciver | (~tim@syn-198-255-177-240.res.spectrum.com) tmciver |
2025-06-23 18:45:09 +0200 | <tomsmeding> | who said haskell was a high-level language |
2025-06-23 18:44:09 +0200 | <tomsmeding> | https://github.com/tomsmeding/ad-dualrev-th/blob/master/src/Data/Vector/Storable/Mutable/CAS.hs |
2025-06-23 18:44:04 +0200 | <tomsmeding> | the primop is atomicCasWordAddr# -- it works on Word#, not Int#, I misremembered |
2025-06-23 18:44:02 +0200 | tmciver | (~tim@syn-198-255-177-240.res.spectrum.com) (Ping timeout: 244 seconds) |
2025-06-23 18:43:47 +0200 | <tomsmeding> | *stg, not stf |
2025-06-23 18:43:43 +0200 | <tomsmeding> | word64ToWord# . stfDOubleToWord64 :: Double# -> Word# |
2025-06-23 18:43:11 +0200 | <haskellbridge> | <magic_rb> Howd you solve the problem? |
2025-06-23 18:43:00 +0200 | <tomsmeding> | cue assembler syntax error |
2025-06-23 18:42:53 +0200 | <tomsmeding> | so I thought, well, I'll just unsafeCoerce# the Double# to an Int#, right? It's the same number of bits, and CAS doesn't care about the contents of those bits |
2025-06-23 18:42:23 +0200 | <tomsmeding> | which makes sense because CPUs generally only provide it on native words |
2025-06-23 18:42:13 +0200 | <tomsmeding> | I actually ran into this in practice because I wanted to do a primitive compare-and-swap on a storable vector of Doubles, but GHC only provides a CAS primop on Int |
2025-06-23 18:41:28 +0200 | <[exa]> | yes that's just...lovely I guess :D |
2025-06-23 18:40:36 +0200 | <tomsmeding> | in case you hadn't seen that yet |
2025-06-23 18:40:27 +0200 | <tomsmeding> | [exa]: you might also appreciate https://play.haskell.org/saved/ygIqjecU |
2025-06-23 18:40:22 +0200 | cawfee | (root@2001:19f0:4400:79a1::babe) (Ping timeout: 252 seconds) |
2025-06-23 18:39:55 +0200 | <[exa]> | yeah I know, was just curious :D |
2025-06-23 18:39:33 +0200 | <haskellbridge> | <magic_rb> [exa] yeah the optimization was completely my fault, i took as a "hey it should be a noop" challenge |
2025-06-23 18:38:54 +0200 | <tomsmeding> | using Int and not Word64 because GHC has nice unboxed literal syntax for Int# but not for Word64# |
2025-06-23 18:38:36 +0200 | <tomsmeding> | magic_rb: https://play.haskell.org/saved/ygIqjecU |
2025-06-23 18:38:36 +0200 | <mreh> | it's not intuitive, at least to me, but I guess the value wraps and it gets the right answer |
2025-06-23 18:37:37 +0200 | <tomsmeding> | [exa]: they didn't, I think, mreh just wanted the thing that fromIntegral does but somehow expected fromIntegral to do something different |
2025-06-23 18:36:52 +0200 | <[exa]> | I wish to know how'd someone manage to turn i8 to u8 conversion into a cost centre |
2025-06-23 18:36:42 +0200 | mreh | reads up, ah looks like it |
2025-06-23 18:36:03 +0200 | <mreh> | what does GHC do? rebox then unbox it again? |
2025-06-23 18:35:44 +0200 | <haskellbridge> | <magic_rb> Other wise its a noop |
2025-06-23 18:35:39 +0200 | <haskellbridge> | <magic_rb> Only in this case :P |
2025-06-23 18:35:33 +0200 | <EvanR> | lol |
2025-06-23 18:35:30 +0200 | <EvanR> | a no-op that is slow |
2025-06-23 18:35:25 +0200 | <haskellbridge> | <magic_rb> tomsmeding getting syntax errors from your assembler, good one XD |
2025-06-23 18:35:05 +0200 | <haskellbridge> | <magic_rb> Yeah unsafeCoerce breaks the unboxed arithmetic optimization sadly |
2025-06-23 18:34:46 +0200 | <tomsmeding> | yes |
2025-06-23 18:34:44 +0200 | <tomsmeding> | but GHC aggressively unboxes arithmetic, as it should |
2025-06-23 18:34:43 +0200 | ames | (~amelia@offtopia/offtopian/amelia) {ames} |
2025-06-23 18:34:40 +0200 | <EvanR> | e.g. Int8 and Word8 |
2025-06-23 18:34:27 +0200 | <tomsmeding> | EvanR: it's a no-op on boxed values |
2025-06-23 18:34:20 +0200 | <EvanR> | hold on unsafeCoerce isn't a no-op? |
2025-06-23 18:34:20 +0200 | ames | (~amelia@offtopia/offtopian/amelia) (Quit: Bye!) |
2025-06-23 18:34:18 +0200 | prdak | (~Thunderbi@user/prdak) (Ping timeout: 252 seconds) |
2025-06-23 18:34:11 +0200 | peterbecich | (~Thunderbi@syn-047-229-123-186.res.spectrum.com) (Ping timeout: 252 seconds) |
2025-06-23 18:33:55 +0200 | <tomsmeding> | been there, done that |
2025-06-23 18:33:53 +0200 | <tomsmeding> | but unsafeCoerce# is really unsafe: if you unsafeCoerce# a Double# to a Word64#, which one would think should just work on a machine with 64-bit doubles, GHC will generate Word64# instructions on a floating-point register and you'll get syntax errors from your assembler |