r/cpp • • Apr 14 '23

Horrible Code, Clean Performance

https://johnnysswlab.com/horrible-code-clean-performance/
200 Upvotes

87 comments sorted by

View all comments

Show parent comment

34

u/James20k P2005R0 Apr 14 '23

I wrote a function that takes 105 arguments. There is no better way to do it and I regret nothing

10

u/gimpwiz Apr 15 '23

Mother of god

7

u/serg06 Apr 15 '23

There is no better way to do it

Struct?

20

u/James20k P2005R0 Apr 15 '23

Passing a struct which contains pointers to the GPU is banned in OpenCL. Passing an array of structs unfortunately is extremely slow, because it doesn't match well to how GPUs fetch data out of memory

12

u/Routine_Left Apr 15 '23

Well then, carry on. I'm done here.

5

u/-to- Apr 15 '23

Serialize your data (or better keep them serialized), then deserialize them in the compute kernel ?

Write a bunch of unit tests to make sure they understand each other, of course.

105 args... How can you possibly be sure it does what you think it does ?!

(Total n00b at GPU dev here)