-
I used
@code_warntypeoncompute_pair_interaction!and got no type issues. I also did the same for a simplified version where I removed allforloops andifstatements (basically chose oneparticleand oneneighborand computed the force instead of looping over all of them).@code_warntypedidn’t output anything bad. I’m not entirely sure this means my code is type-stable because there was an incident in the past where@code_warntypecame back fine but it turned out that there was a statement likeone_of_many_structs_grouped_under_abstract_type.shared_fieldthat needed to be rewritten as....shared_field::Float64in order to have performant code. -
@use_threadsis a macro that becomesThreads.@threadsiflj.multithreadedistrue; otherwise it becomes a normalforloop without threads (see post). With three threads, this gives about a x2 boost to speed compare to a single thread. Note that if I replace@use_threads lj.multithreadedwithThreads.@threads, the performance is nearly identical. -
There are about 17 allocations (2.7 KiB) per function call. 16 of those allocations comes from the threading regardless if I use
@use_threadsorThreads.@threads. I haven’t quite found where that remaining allocation comes from, though it seems insignificant. Is it possible for@timeor@btimeto miss some allocations in a function?
Edit: I will try Duane_Wilson’s suggestion with Setfield and see if switching all my structs to immutable has any effect.