News for hackers. Stuff that matters.
Re:CUDA Grep by sjf on Thursday June 27, 2019 @12:29PM (#20295970)
They ignored a key detail in their benchmark. They did not include the time it took to transfer the input file from memory to the GPU, (the GPU cores can only operate on graphics memory). This is easily going to be the most time consuming part. They also didn't include any IO operations in their timing, so instead of a 10x speedup, it is more likely to be a couple of percent faster as grep is going to be IO bound. This is a neat project, but there is a reason we are not using the GPU for regex matching.
Re:CUDA Grep by bkase on Thursday June 27, 2019 @01:15PM (#20296438)
One of the authors here:

Yes you are right, you should not replace grep for one off regexes due to the latency of the io operations. As far as I recall, memory throughput however is much higher on house than on CPUs (or at least this was true in 2012). Our intended use cases for this sort of a grep were cases where you are finding many needles in enormous haystacks such as: Looking for malicious machine code in executables that you download off of the internet (virus scanning), or searching for certain genetic sequences in DNA code. I believe we discussed this in our final presentation, but perhaps we left it out of the written report.

Yes we probably should have included the numbers to show why you wouldn't want to use this instead of grep for simple tasks. I am sorry we missed it.

Re:CUDA Grep by jldugger on Thursday June 27, 2019 @01:55PM (#20296853)
But getting any of that data off disk will typically be the bottleneck.

(Also, you'd want BLAST for DNA instead of grep, but perhaps this was an intentional simplification)

Re:CUDA Grep by calvinmorrison on Thursday June 27, 2019 @03:14PM (#20297577)
well if you're looking for certain motifs or k-mers (https://en.wikipedia.org/wiki/K-mer), it's mostly scanning through pre-processed FASTA files.

My last K-mer counter I wrote was CPU/Memory bound (big enough size strings means big hash tables to store this stuff in, or using something like a bloom filter (Jellyfish's approach), not IO bound.

Anyway, for anyone who wants to write something fun, fasta parsers / k-mer counters are a good weekend project.

here was my work in the area (shameless plug, though i'm not in the field anymore)

https://github.com/mutantturkey/dna-utils.

just tested again against a 400mbish genome fasta file from ncbi and it's still clearly an cpu/memory issue with huge hash tables. See below (4^x is the potential combinations of K-mers). K=9 is done with a 4^9 array (sane in memory), 4^12 is a sparse array (stored as a a std::unordered_map, because it's too large to allocate that much space in memory). One is obviously way slower

calvin@bison:~/src/dna-utils$ time ./kmer_total_count -k 9 -i 3816_ref_Abrus_2018_chrUn.fa.2 >/dev/null

real 0m4.235s

user 0m4.116s

sys 0m0.108s

calvin@bison:~/src/dna-utils$ time ./kmer_total_count -k 12 -i 3816_ref_Abrus_2018_chrUn.fa.2 >/dev/null

real 0m25.524s

user 0m25.292s

sys 0m0.152s

calvin@bison:~/src/dna-utils

Re:CUDA Grep by zeusk on Thursday June 27, 2019 @04:16PM (#20298243)
I'm quite certain Windows Defender uses (or used, at some point) GPUs in the machine to accelerate malware pattern matching. I remember a coworker talking about a funny bug as a consequence when the graphics driver executable itself was infected.
Re:CUDA Grep by cl0ckt0wer on Thursday June 27, 2019 @05:13PM (#20298812)
There's an article on the announcement last year: https://arstechnica.com/gadgets/2018/04/intel-microsoft-to-u...
Re:CUDA Grep by dmix on Thursday June 27, 2019 @08:42PM (#20300433)
That is for their enterprise "Microsoft Defender Advanced Threat Protection" endpoint security product which scans live memory for any hidden malware not writing to disk. Which would otherwise be consuming far more CPU than the typical default windows security software. Which is why they needed GPU in the first place. But it's an interesting solution none-the-less.

https://www.microsoft.com/en-us/microsoft-365/windows/micros...

Re:CUDA Grep by stochastic_monk on Thursday June 27, 2019 @07:42PM (#20300053)
I’ve run into this for simple tasks on a GPU, like merging sorted lists. The massive parallelism can’t make up for the transfer costs unless the operations performed are expensive enough. The “roofline” model is usually the perspective used for this kind of accelerator application.
Re:CUDA Grep by dr_zoidberg on Thursday June 27, 2019 @08:37PM (#20300400)
Reminded me of a 12 year old paper on file carving by Marziale, Richard and Roussev[0].

[0] https://www.dfrws.org/sites/default/files/session-files/pres...

Re:CUDA Grep by hinkley on Thursday June 27, 2019 @03:35PM (#20297788)
I know in pretty nearly all the domains I've worked, discrete packets of data will use regexp directly.

If we are using something more 'grep'-like, it's for large quantities of data, and in many cases we could treat these as a stream. So as long as the bandwidth to the GPU is sufficient, a little stall at the beginning would represent an undue hardship, if the results come back faster.

Re:CUDA Grep by cma on Thursday June 27, 2019 @01:08PM (#20296354)
Some GPUs have integrated memory with the CPU and don't need to do the transfer, it could still speed things up there couldn't it?

Also, they didn't ignore the key detail, they mention it: "This is without taking into account the overhead of transferring data to the GPU."

Re:CUDA Grep by alfalfasprout on Thursday June 27, 2019 @01:09PM (#20296368)
Yeah, but integrated GPUs wouldn't be usable with CUDA.
Re:CUDA Grep by Athas on Thursday June 27, 2019 @01:36PM (#20296663)
I have not been able to inspect the code (dead links), but from the description of their approach, they do not depend on anything particularly fancy from CUDA. An OpenCL implementation seems just as feasible.
Re:CUDA Grep by cma on Thursday June 27, 2019 @01:19PM (#20296468)
Nvidia makes several with integrated memory. Nintendo Switch is based on one etc.
Re:CUDA Grep by justinmeiners on Thursday June 27, 2019 @07:51PM (#20300114)
Perhaps on PCs, but plenty of mobile and consoles use a shared memory architecture.
Re:CUDA Grep by shaklee3 on Friday June 28, 2019 @12:29AM (#20301478)
The tegra products are all integrated.
Re:CUDA Grep by bkase on Thursday June 27, 2019 @01:16PM (#20296449)
Oh good, I'm glad we did mention this!
Re:CUDA Grep by ben509 on Thursday June 27, 2019 @01:14PM (#20296419)
> They did not include the time it took to transfer the input file from memory to the GPU

Fair point, it's more support for this HN post[2] making the case for memory-mapping files to GPU.

> This is a neat project, but there is a reason we are not using the GPU for regex matching.

I think it's more interesting that it's a general facility for running automata on a GPU, as it's opening up the universe of things that can be accelerated by a GPU. For instance, Numba[1] is a library to run arbitrary math code, and it has a feature for generating code to run on the GPU.

[1]: http://numba.pydata.org/numba-doc/latest/cuda/index.html

[2]: https://news.ycombinator.com/item?id=11892030

Re:CUDA Grep by shaklee3 on Thursday June 27, 2019 @01:51PM (#20296794)
CUDA already has this built in (for many years) using UVM. That won't take away the bottleneck of the transfer, but it does make it transparent to the user by handling all the paging/copies.
Re:CUDA Grep by mzs on Thursday June 27, 2019 @02:13PM (#20297011)
I thought that just made GPU memory map equal to CPUs' and you need much for VM (like paging).
Re:CUDA Grep by randyrand on Friday June 28, 2019 @04:19AM (#20302408)
Totally disagree. Moving memory to the GPU can be parallelized while doing the computation. For larger files that can fully saturate the gpu's bandwidth, it's completely negligible. "Easily the most time consuming part", no. Not even close.

Also, IO bound? Again, no. My consumer MBP can read at 3.2GB/s. Good luck doing regex on that in real time on a CPU. This is a CPU bound operation for a typical high end configuration.

Does this make sense for a 1MB file? probably not. But anything well beyond that it will be way faster.

Here's a great talk about how you should think about GPU performance: https://www.nvidia.com/content/GTC-2010/pdfs/2238_GTC2010.pd...

Re:CUDA Grep by ejbs on Friday June 28, 2019 @04:22AM (#20302426)
> They did not include the time it took to transfer the input file from memory to the GPU

To give some context: PCIe 3.0 x16 achieves about 11-12 GB/s. So, transfers for benchmarked 53MB file would add ~4.8 ms (per direction, assuming pinned host memory)

Now, they could also pursue a streaming approach, processing in "micro-batches". I.e., pipelining input transfers (HOST->GPU), GPU-based processing, and transfer of results (GPU->HOST), as pursued by [1] (disclaimer: I'm a co-author). This lower's processing latency. Since the interconnect is full-duplex, it would just limit the processing rate to about ~11 GB/s (i.e., 5 ms for mentioned 53MB). To be fair, though, input has to be sufficiently large, such that there are (a) enough micro-batches to overlap transfer and compute and (b) the micro-batches can be chosen to be still large enough to exploit full parallelism of the GPU.

[1] https://arxiv.org/pdf/1905.13415.pdf

Re:CUDA Grep by lmeyerov on Thursday June 27, 2019 @10:43PM (#20301056)
Or you can flip your assumptions and run 10X faster... everywhere. It was a tough investment, but we went GPU-first via Apache Arrow & Nvidia RAPIDS. (In this case, I'd look at RAPIDS / NVStrings before this.)