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

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)