You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Memory inefficiency in onekey4/calc_average_bg.m and onekey4/calc_datacubes.m
The raw images are 800px by 800px, 16-bit images (image size is 800x800x2=1280000 bytes + metadata 261 bytes), and for some reason the code loads these as double precision floats. This has no benefits and increases the size in memory by factor of 4 (from 16 bit to 64 bit).
The memory load isn't a problem because at any given time there are only two images in memory (1 background and 1 raw) but this results in slower runtime by about 30%.
As a rough sketch, matlab's imread() takes about 3ms to read from an SSD, and there are about 700k images in one experiment, which amounts to about 44 minutes. About 10 extra minutes of runtime is spent just on typecasting the uint images to float without any benefit for precision. Also, performing math operation on double is slower than single or uint16. Simple addition operation for double is 10 times slower than for uint16 and twice as slow as it is for single. Considering that onekey code takes hours to run there are probably a lot of operations involved and probably a lot of time that can be saved.
Memory inefficiency in onekey4/calc_average_bg.m and onekey4/calc_datacubes.m
The raw images are 800px by 800px, 16-bit images (image size is 800x800x2=1280000 bytes + metadata 261 bytes), and for some reason the code loads these as double precision floats. This has no benefits and increases the size in memory by factor of 4 (from 16 bit to 64 bit).
The memory load isn't a problem because at any given time there are only two images in memory (1 background and 1 raw) but this results in slower runtime by about 30%.
As a rough sketch, matlab's imread() takes about 3ms to read from an SSD, and there are about 700k images in one experiment, which amounts to about 44 minutes. About 10 extra minutes of runtime is spent just on typecasting the uint images to float without any benefit for precision. Also, performing math operation on double is slower than single or uint16. Simple addition operation for double is 10 times slower than for uint16 and twice as slow as it is for single. Considering that onekey code takes hours to run there are probably a lot of operations involved and probably a lot of time that can be saved.
https://github.itap.purdue.edu/Nolte-Group/alpha-prime-system/blob/841dd47dbbf2029f57cba587c1b7fb3b283dfbda/onekey4/calc_average_bg.m#L17
https://github.itap.purdue.edu/Nolte-Group/alpha-prime-system/blob/841dd47dbbf2029f57cba587c1b7fb3b283dfbda/onekey4/calc_datacubes.m#L29
https://github.itap.purdue.edu/Nolte-Group/alpha-prime-system/blob/841dd47dbbf2029f57cba587c1b7fb3b283dfbda/onekey4/calc_datacubes.m#L39
The text was updated successfully, but these errors were encountered: