use bit matrix instead of bool matrix, separate cuda stuff