spirit-code / spirit

Atomistic Spin Simulation Framework
http://spirit-code.github.io
MIT License
118 stars 52 forks source link

Reading in configuration chains takes too long #445

Closed SpiritSuperUser closed 5 years ago

SpiritSuperUser commented 6 years ago

when a long chain is read in, this takes extremely long. Up to a couple of seconds per image. This is quite annoying when long chains are read in. I suppose there is somehow a way to improve this since I at least do not see why it is necessary that the time per image increases with increasing length of the already existing chain. If I would have to guess, I would say that's because each image is added separately and array sizes etc. are adjusted and additionally there happens some copying of the whole (existing part of the) chain each time. But that's just a guess, I did not take a look at the code :) If that's the case, this should be easy to solve by checking in the beginning how long the chain will be in the end, adjusting everything, and then just write the read in data to the arrays. This should scale linearly with the number of images.

the attached screenshot shows the number of images over time while reading in a chain with 146 images. Yes, it takes a couple of minutes! 22500 spins each.

screen shot 2018-08-28 at 17 10 06
SpiritSuperUser commented 6 years ago

chain_update_data is called after each image. This is not necessary. One call at the end of the chain would be sufficient. >99% of the time is wasted for this for the last iterations.

GPMueller commented 6 years ago

Fixed this with 1e08b5db17ed4499dec07417026e642f6ca637cd by adding an efficient Chain_Set_Length function, avoiding the repeated calls to Chain_Push_Back (and thereby to Chain_Update_Data. Please check whether this really fixed the problem in your case.

SpiritSuperUser commented 5 years ago

I just checked it and the problem seems to be fixed. The chain is read-in in a reasonable time.