libera/#clasp - IRC Chatlog
Search
2:39:14
Bike
https://github.com/clasp-developers/clasp/blob/main/src/lisp/kernel/cmp/cmpintrinsics.lsp#L147 well it looks like the existing definitions should be fine? maybe i'm misunderstanding the goal here
2:40:02
Bike
with primitives you want a delay but the translators should just be able to do what theyre already doing
2:40:02
drmeister
Currently (macroexpand 'cmp::%t%) -> (LLVM-SYS:TYPE-GET-INT8-TY (COMPILER:THREAD-LOCAL-LLVM-CONTEXT))
2:42:51
drmeister
I'm afraid of the situation where it gets resolved to a thread local type at compile time.
2:46:33
drmeister
I've switched cmp:*primitives* so it doesn't contain the thread local types anymore. I pushed the changes to unboxed-floats
2:56:05
drmeister
I don't want to muck around with your code too much. Can you give me a primop defining macro?
2:57:15
drmeister
Bike: You know what else is interesting about this? We could get llvm to do inlining of these intrinsics.
3:12:21
drmeister
I'm going to use :double-float rather than :double and :single-float rather than :float - that will make it match the keywords you are using.
3:51:17
drmeister
If we change the cmp:%double% to :double-float then we could simplify the definition.
3:53:28
Bike
i can do a macro tomorrow. i was going to do one that includes the translate-primop body so everything's in one place
3:56:25
Bike
i don't think it makes sense to incorporate the intrinsic into the defprimop since some primops don't have corresponding intrinsics
4:00:17
drmeister
(disassemble '(lambda (x) (geom::ovector3-getx x)) :type :ir) says "Undefined function OVECTOR3-GETX"
4:03:27
Bike
https://github.com/clasp-developers/clasp/blob/main/src/lisp/kernel/cleavir/setup.lisp#L176-L192 add it in here, i think
4:03:43
Bike
yeah, this is all pretty unwieldly. i'll put together something more convenient tomorrow
4:15:42
Bike
i think the easiest solution would be if i define a cleavir-primop:primop special operator that takes the name as its first pseudo parameter
4:23:44
Bike
just to be clear, you probably don't want to use primops directly in the application code. you could do like (declaim (inline ovector3-getx)) (defun ovector3-getx (ovector3) (core:primop %ovector3-getx ovector3)) and then you have an actual function but the compiler can still work with obvious calls
4:25:50
Bike
and i might want to port the representation selection stuff from clasp to cleavir, it's pretty general
4:28:51
Bike
the short version is i got type inference going well enough that long stretches of floating point operations can be compiled without boxing and without making the compiler unusably slow
4:29:09
Bike
and it's generalizable to other type directed optimizations, though doing them while preserving safety is a little less obvious
11:51:14
drmeister
yitzi: For my bond through ring detection problem. The winding algorithm works on 2d planes. Molecular rings aren't flat. So I'm calculating a plane (centroid, normal) for each ring and projecting the ring into the plane and then calculating the intersection of each bond that cuts across the plane with the plane and then calculating the winding number.
11:54:04
yitzi
drmeister: Understand. I think there might be some other methods, but I haven't worked it out quite yet.
12:05:56
yitzi
drmeister: I think that there might be small errors possible if the bond is close to the edge of the ring due to projecting ring atoms onto plane that is not perpendicular to the bond in question.
12:08:10
yitzi
Basically. instead of find the ring plane, instead one would make a plane perpendicular to the bond by using a vector that is parallel to bond as the normal and the point along the bond that is closest to all the ring atoms as the center.
12:09:08
yitzi
Then project each ring atom onto the plane by using a vector that runs from one one the bond atoms to the ring atom in question. Finally, do the winding test.
12:15:10
yitzi
drmeister: I'll to work it a bit more, it just occurred to me that you could use the other bond atom as the center of the plane and skip finding the point closest to the ring. Its early so I could be completely off base here.
12:15:55
drmeister
One thing is the bonds will never be really close to the ring edges because of the geometry optimization.
12:16:09
drmeister
They should cut pretty much straight through the center of the ring or not at all.