Moved GPU implementation to its own method.