first draft gpu code (lots of memory use)