News for hackers. Stuff that matters.

ScottMichaud

There are situations where you can have a linked list perform faster than a vector. It's good to consider linked lists if you have the time to think about your solution and profile multiple options... but the point is that memory latency is a huge hurdle to overcome.

For context: A cold memory fetch is ~200 cycles. That's around 10 incorrectly-predicted branches. That's around 100 correctly-predicted branches. You need to be skipping a lot of work to justify injecting 100s of cycles of lag inside a loop of some sort.

(And, of course, those situations would need to be the common, relevant case. Don't follow a 10x performance speed-up in a one-off situation at a time no-one cares about to justify a 5x slowdown in a critical, hot loop.)

If you have big objects, then this might also start to become a concern. However, in those cases, a vector of pointers (or structs of pointers + metadata) would appear as a new challenger. In that case, you would only take the latency hit if you actually need to go to the object (and those objects could be held in contiguous storage, etc. etc. etc.).

Chances are that, unless you have data for your specific case showing otherwise, vector will probably win. It should be the default unless you have a reason not to, and evidence to back it up.

Re:Vulkan and OpenCL will merge into a single API on Monday May 22, 2017 @03:57PM (#14396453)
I'm still writing up the interview that I did with them (Tom Olson and Neil Trevett) on Friday, after the initial post was published, but they do intend to merge OpenCL into Vulkan.

One thing they did want me to make clear, though, is that this is an OpenCL decision. Vulkan's roadmap isn't changing. While I'll elaborate in the follow-up post, it's to move OpenCL more low-level and abstract (ex: as I said above, FP32 makes no sense for many DSPs or deep-learning accelerators).

Re:Vulkan and OpenCL will merge into a single API on Sunday May 21, 2017 @12:20AM (#14385681)
Hello. I'm the author of the PC Perspective story that this post cites.

https://www.pcper.com/reviews/General-Tech/Breaking-OpenCL-M...

I am currently writing up another post, which is based on an interview I did with Tom Olson (Chairman of Vulkan) and Neil Trevett (President of Khronos Group) on Friday. While the implications of the announcement are smaller than I speculated (ex: the Khronos Group weren't concerned about Apple's ownership over OpenCL's trademarks and a few necessary patents) the announcement is correct.

Neil: "Congratulations. You win the prize for finding the extra press release hidden in the quote."

I'm still digesting the dense, ~40 minute discussion, but OpenCL's roadmap is to merge into Vulkan's. There's a bunch of reasons for it (ex: OpenCL pushes FP32 support onto hardware where it doesn't make sense, like DSPs and deep-learning applications) but I'll elaborate on that with the follow-up. Might take a few days though.

Also, here's Neil's presentation from IWOCL: https://www.khronos.org/developers/library/2017-iwocl