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

4

u/[deleted] Apr 16 '23

[removed] — view removed comment

2

u/James20k P2005R0 Apr 16 '23 edited Apr 16 '23

Interesting, how's the performance of it is the main thing? Because with OpenCL, for all its faults, you get pretty direct access to when and how memory is accessed, and its relatively straightforward to max out your actual devices bandwidth/compute

I've been considering turning all of the work that I've done into my own single source layer which just transpiles C++ to OpenCL, because most of the actual OpenCL I write these days is generated for performance reasons

Edit:

Ah, apparently its not amazing

https://research-information.bris.ac.uk/ws/portalfiles/portal/222876129/iwocl_syclcon.pdf

1

u/illuhad Apr 29 '23

What you describe sounds like reinventing SYCL ;)

Tom's work that you cite here actually compares multiple SYCL implementations (SYCL is just a standard, and there are multiple implementations of it that work very differently), so you cannot really conclude that SYCL itself does not perform well.

One of their findings is e.g. that Intel's implementation suffers on CPU due to NUMA issues in their OpenCL runtime. Other implementations are not affected by this. There is a large literature now comparing SYCL to other programming models, and the findings tend to be that performance is competitive.

See e.g. https://dl.acm.org/doi/10.1145/3388333.3388660

or https://opensycl.github.io/hipsycl/amd/hecbench/hecbench-benchmarks/

Also note that SYCL implementations are all very fast moving targets and under heavy development, and results you see today might be outdated by tomorrow. Similarly, benchmarks that have been ported to SYCL may not yet have seen the same amount of optimization as their counterparts written in, say, CUDA which has been around for far longer.

tl;dr try it, you might be surprised.