libera/#commonlisp - IRC Chatlog
Search
19:52:49
jcowan
There are two possible interpretations of declarations: "I declare that this value is a fixnum even if sometimes it isn't, and I allow you to send me straight to Hell if it isn't" and "I declare that this is value is a fixnum, and if it isn't, I want you to signal a condition."
19:54:18
Bike
sbcl also offers "i declare that this is a fixnum and i'd appreciate if you checked but like don't worry too much man"
19:55:49
Bike
i would also like to implement "I declare that this is a fixnum and if you actually use that information signal a condition, but otherwise who cares" but that's pretty involved to do
19:58:30
aeth
I think it comes down to there being two kinds of types (at least in CL): types-for-reliability and types-for-performance
20:00:10
Bike
sbcl documents what it does in its manual, or do you mean like, a general introduction to how compilers can use these kinds of types
20:00:10
hexology
and again, i'm sure this is not a bottleneck in most applications unless it's some kind of numerical simulation that doesn't call out to some foreign routine
20:00:49
White_Flame
a lot of my microptimization is eliminating function calls and taking advantage of tail calls
20:01:10
hexology
i've skimmed this https://www.sbcl.org/manual/index.html#Handling-of-Types but maybe i need to peruse deeply instead
20:14:09
aeth
and the type declarations would mostly be single-float/double-float, with any difficulty being around the boxing of the double-float
20:21:02
aeth
hexology, when referring to THE and the type system, said "unless it's some kind of numerical simulation that doesn't call out to some foreign routine" then type declarations likely won't be the bottleneck
20:21:56
aeth
but a numerical simulation is likely going to use floating point, which is going to be way easier to deal with in the type system than integers, which have to stay within the defined range (x + y will always stay a float, but won't always stay in the defined integer range)
20:22:11
aeth
with the added caveat that turning off float traps is probably as important as declaring the type
20:27:46
NotThatRPG
jcowan: I believe that the spec only makes the first of the two interpretations canonical, but I also believe it leaves the way open for implementations to use the second.
20:29:21
jcowan
It says the consequences are undefined, which certainly *allows* a condition to be signaled.
20:30:28
jcowan
Of course, with NaN-boxing there is no need to unbox double-floats, as they are already unboxed.
20:35:59
hexology
re: floats, i'm running into a similar issue with sbcl not being convinced that in my *particular* case, my input to sqrt is always positive and so should sqrt should always return a real number
20:36:24
hexology
so i definitely think there's something worth writing about here, if there's expert knowledge to be written down
20:42:59
Bike
i mean, you can compile the code in different ways if the compiler is allowed to make some assumptions about the floating point environment, but that's not quite the same
20:43:24
Bike
hexology: i'm not sure what there would be to write down there beyond that you'll have to declare the input positive... what's going on?
20:45:21
Bike
i have some personal notes on CL arithmetic optimization strategies for my own purposes, but they're pretty sparse and not really directed at programmers
22:36:45
Lycurgus
in looking for a state machine thing in cl, i couldn seem to do better than cl-monad-macros
0:13:57
resttime
Bike: Asked in #sbcl about my add-vop and your answer seemed to be it. (move r x) (inst add r y) in the generator works as expected
0:44:44
Bike
ah, well there you go then. a little surprising it doesn't move them itself, it looks like the parent vop has stuff for indicating that
0:52:36
akoana
hmm, what's happening here: https://termbin.com/71e4, with (let ((prod 1))...) I'm getting a big number, with (let ((prod 1.0))...) it works as expected, strange
0:59:44
hayley
I wouldn't be surprised if you got a ratio with very large components, but the actual value is quite small.
1:03:12
akoana
sorry the 2n stuff is a remnant of previous experiments, here a cleaned up version + results: https://termbin.com/b9a4
1:05:28
akoana
I did the tests with 100000 iterations in emacs before, so I gave up looking at the result :)
1:08:05
akoana
Bike, hayley: Thank you very much - I was about losing my confidence in lisp - you have saved my soul
5:45:24
resttime
I have three functions, add-fixnums, add-floats, add-doubles and their disassembly with optimizations: https://plaster.tymoon.eu/view/3349#3349
5:46:25
resttime
Is there a reason why add-doubles seems use many(?) more lines of assembly than add-floats?
5:47:22
resttime
My thoughts were that a double-float operation would be at least as single-float, only that the instruction used for addition would be different
5:48:28
hayley
This can be avoided when the ADD-... functions are declared INLINE, and when the functions are used in another function. (Though the effect will only be visible when disassembling that other function, and not in disassembly for any ADD-... function.)
5:51:13
White_Flame
and add-floats is longer than add-fixnums because it has to tag the single-float
5:52:53
resttime
Ohhhhh, I'm seeing the unbox/box of doubles because of how SBCL uses pointer tagging instead of NaN boxing
5:56:26
resttime
hayley: If I understood this correctly does that mean the box/unbox is still necessary in this outer function, but only happens at the entrypoint and endpoint of the function once?
5:59:39
White_Flame
you don't see the unboxing, because sbcl hides some of the arg-handling prologue
6:05:07
resttime
Interesting, somewhat related is there an SBCL function for printing the real memory representation of an object? I wanna see how a double is represented in memory
6:13:53
White_Flame
of course, that's just a single (in the upper 32 bits), and will work for immediate values. It doesn't display the heap representation word layout, though
6:38:44
resttime
Hmmm, in the case of a simple-array of double-float's, are these doubles layed out in contiguously in memory boxed or unboxed?
6:46:05
resttime
Oh nice and I see that (upgraded-array-element-type 'bignum) ; => T which makes sense since to me since bignum would be considered more abstraction