First complete implementation

 - 2 versions of the device function (one with outer loop)
 - one of the versions supports arbitrarily large blocks/grid