Consider alternatives to int arrays for bits ?
Maybe this has already been discussed, decided... but just in case.
We're using int[] arrays for storing zeros and ones, e.g. encoder output, and I presume the rest of the machinery work directly on these int[] arrays. I bring it up because each entry in the array is using 32 bits when it could use only 1. Now reading up a bit I can see how wasting the space might be useful to align better with bus width, but my guess is we would rather use a 64 bit wide value if that is our aim.
http://stackoverflow.com/questions/8804435/alternative-to-java-bitset-with-array-like-performance
https://github.com/lemire/RoaringBitmap
I vote performance over the memory:
Mike Nakis answer here: http://stackoverflow.com/questions/8804435/alternative-to-java-bitset-with-array-like-performance
"If you really must squeeze the maximum performance out of this thing, and if memory does not matter, you can try storing each one of your flags in an integer whose bit size is equal to the width of the data bus of your CPU.You are probably on a 64-bit address bus CPU, so try long integers."
Hi,
When I first started, I did in fact look into this issue and decided that the use of int[] were the best approach. We also need to take into account that there is a lot of bit/position analysis occurring within the code (and's & or's etc.); in addition to iteration over bits - so there are definitely trade-offs. If there is a choice of performance versus memory the clear choice is performance but we have to make sure that we're looking at the total picture.
These are good questions that I think we should revisit once we get to a point (and NuPIC gets to the point) where we can declare a complete body of versioned code.
Regards, David
On Sun, Nov 16, 2014 at 11:59 AM, Kirill [email protected] wrote:
I vote performance over the memory:
Mike Nakis answer here: http://stackoverflow.com/questions/8804435/alternative-to-java-bitset-with-array-like-performance
"If you really must squeeze the maximum performance out of this thing, and if memory does not matter, you can try storing each one of your flags in an integer whose bit size is equal to the width of the data bus of your CPU.You are probably on a 64-bit address bus CPU, so try long integers."
— Reply to this email directly or view it on GitHub https://github.com/numenta/htm.java/issues/116#issuecomment-63230138.
We find it hard to hear what another is saying because of how loudly "who one is", speaks...