modified gpu version to support multiple output files