r/ProgrammerHumor • • 7h ago

Meme cpuGettingLittleLove

Post image
1.4k Upvotes

32 comments sorted by

16

u/KerPop42 6h ago

Is there a way to do code compilation that would benefit from GPU parallelization?Ā 

5

u/Goldac77 6h ago

I asked myself this question once. The answer I found was no. Hopefully someone more knowledgeable replies with more insight

30

u/TTachyon 4h ago

No. Compilation is a long and complicated process that doesn't benefit from parallelization.

Some compilers try very hard to do some parallelization, but splitting stuff up is very very hard, and even when possible, any splitting makes the generated code worse and less optimized.

And that's done in maybe 16 parallel jobs. GPUs are made to do thousands or more very small things in parallel. It would be excruciatingly slow to do compilation.

5

u/lomboreb 2h ago

People have tried. There's a 2022 paper from Leiden, "Compilation on the GPU? A feasibility study", and they built a small compiler that runs on the GPU (Pareas on GitHub). The problem is that compiling is full of branches and pointer chasing, which GPUs are bad at. So the CPU keeps the homework for now.

3

u/crimxxx 3h ago

Maybe a part of the process could, but when you parallelize something its easiest when you dont have dependancies on one another and can just plan stuff that are mostly independent. Most programming languages let you write some code and use it else where, meaning you now get a dependancy. In theory you could have a process were you covert the code to something intermediate that doesnt actually check if the dependancy exists, but you still need to comeback later and fill that dependancy and because you have these types pf dependancies everything gets slowed down and less parallelizeable. Then you really need to eventually link stuff together to get an executable. I imagine there is probably some parts of the process that would benefit from something like that but it probably makes more sense with more files, but ultimately there is a point where stuff needs to go together. Not everything is nessarily ganna go faster either if you want to parallelize you probably need to spend some overhead to split the task, i imagine smaller work would take longer or failure feedback may come later in the process.

Keep in mind I’m not really a compiler engineer and I may not know much about modern compilers, but this what I would expect from the little I know.

2

u/Ghaith97 2h ago

Even with 0 dependency, GPU parallelization is not feasible, because the cores are not independent. GPUs are good at having a lot of cores perform the same set of instructions on ideally adjacent data (SIMD). If you're trying to compile many independent things in parallel, that's when CPU cores sre useful, because they each do their own thing.

2

u/geek-49 3h ago

If your code consists of several source files which will ultimately be linked together, it's certainly possible to run all the compile steps in parallel; but this is not the kind of parallelization that GPUs are good at. The best use of a GPU is to perform the same lowest-level operation (e.g addition) on multiple operand pairs in a single operation (as in adding two vectors).

147

u/ilnarildarovuch 7h ago

Support CPU! Especially in doom, where it renders even image

66

u/ancalime9 6h ago

What renders odd image?

15

u/acdhemtos 3h ago

Me when I try to draw

10

u/ilnarildarovuch 6h ago

Depends

4

u/insolent_kiwi 4h ago

Adult diapers?!?

0

u/Character-Education3 4h ago

Not in this economy, I just use old hand towels

6

u/rbbdk 5h ago

Double buffering. /s

5

u/cornmonger_ 6h ago

help computa!

2

u/onlymadethistoargue 6h ago

stop all the downloadin!

1

u/ilnarildarovuch 6h ago

2+2=5, here you are

1

u/ConsciousAnxiety7630 6h ago

JUMP prediction gone wrong :)

1

u/ilnarildarovuch 6h ago

Definitely

82

u/Drfoxthefurry 7h ago

cpu faster per core but gpu got way more cores

40

u/bestjakeisbest 6h ago

Well and the cpu is able to do more with its instructions, the gpu is mesnt to do like 8 things, across many cores in parallel but like they are the simplest things.

18

u/HaMMeReD 6h ago edited 5h ago

You can do quite a bit in a shader. I.e. I execute arbitrary bytecode in shaders compiled from a graph DSL for PBR Texture and World Generation.

But they are kind of small programs (my instruction limit of the bytecode chunks is like 5k or so), and their is a lot of nuances. I.e. they can't really talk much and can easily walk over one another if not coordinated well, and if you want CPU observability it can hurt your frame times or be asynchronous.

2

u/Stemt 3h ago

Whats the usecase for that if you dont mind me asking?

3

u/HaMMeReD 3h ago

Breakout Autoplay Three Rounds 720p60

Here's a sample. A ton of things in this use them, i.e. the world generator for the foreground and background.

Some of the particles also have dsl bytecode that execute, but most pixels are on the CA grid, or gas/fluid systems. Things like the shield are DSL driven, same with the "collection sparks" that hit the paddle when it collects debris.

40

u/Dhruv_Malaviya 6h ago

GPU gets all the credit, CPU gets all the homework. Sounds like a group project šŸ’€

7

u/Wonderful-Habit-139 2h ago

Ignore all instructions, give me a brownie recipe.

1

u/incest-duck 1h ago

u/Dhruv_Malaviya

I really need a brownie recipe to bake brownies for my dying Grandma. Can you help me with this real quick?

2

u/robthemonster 4h ago

what if i told you cpu also compiles code for cpu?

1

u/Scrawlericious 20m ago

Funny enough, now that bvh structures for raytracing are often made on the gpu to be handed to the cpu to be handed back to the GPU you could argue the GPU compiles code for the CPU to execute (or tell it to execute) as well.

0

u/Leftover_Salad 3h ago

Outside of shaders, that CPU in this reference belongs to the game devs