2

I have a powershell script, Find/replace string with carriage return and line feed in PowerShell, that I often run. It parses many files and naturally, it utilizes a majority of the CPU (2 cores).

Is there a way to utilize GPU acceleration in powershell?

Community
  • 1
  • 1
Jerry Sweeton
  • 163
  • 2
  • 4
  • 15

1 Answers1

3

The script you have there is likely not CPU-bound. It definitely cannot use more than one of your cores, i.e. 50 %. I'm fairly confident that the slowest part of that is reading and writing the files.

There are a few tasks that can be done very efficiently by the GPU, but for that the data already has to be in memory. That is, the slowest part (reading the files and writing them afterwards) still remains.

Then there is the case that the GPU is well-suited for doing the same or similar operations on large amounts of data, but text replacement (regexes even less so) is a different beast. Keep in mind that GPUs are very efficient at shuffling around large arrays of floating-point numbers. Characters are anything but that.

Joey
  • 344,408
  • 85
  • 689
  • 683
  • And data better be in the video card memory. Tranferring from DRAM to GPU can also be time consuming. – Vincent Hubert Aug 01 '14 at 16:05
  • That too, but I opted to omit that here for brevity and simplicity. The basic problem that he wants to speed up something that is slowed down by something totally unrelated (and cannot even run usefully on a GPU) still remains :-) – Joey Aug 01 '14 at 16:07
  • Ok, I lied, partially. There is a [GPU-based regex matcher](http://bkase.github.io/CUDA-grep/finalreport.html). However, that's only the matching part, not regex replacement. And the data still has to get from the hard drive to the GPU. And back. – Joey Aug 01 '14 at 16:13
  • Thanks for the feedback. Perhaps I should lobby for a new computer with more horsepower. =) – Jerry Sweeton Aug 01 '14 at 16:45
  • If these files are stored on a server then your network may well be your bottleneck. Perhaps a PS session on the server that you run the script through would speed things up for you. Or if they're local a solid state drive would speed things up just make sure your writes are full file writes where possible, or at least large blocks of data, and not line-by-line appends if you run it off a solid state drive. – TheMadTechnician Aug 01 '14 at 16:54