3 ms·
What kind of performance is achieveable with some of the features that Vcc enables (true function calls, function pointers, goto), and what are some of the limi
by hjabird 3y ago
What kind of performance is achieveable with some of the features that Vcc enables (true function calls, function pointers, goto), and what are some of the limitations?
On GPU, function calls are much more expensive than on CPU. Usually it seems to be worth inlining as much as possible. Implementing a stack for recursion on GPUs is also likely to have performance implications. The whole point of using a GPU is to obtain good performance, but I can see the argument for having these features in order to port CPU code to GPU code incrementally.
For function pointers, how does that work? Multiple different implementations of the function are needed to support different devices and the host, which limits what a single pointer can do.
EDIT: To answer my second question, neither function nor data pointers are portable between host and device since Vulkan doesn't support unified addressing.
- zozbot234 3y agoStrictly speaking, a stack is only needed for reentrant calls. Function pointers can be implemented via defunctionalization in a whole-program context (i.e. there is a single 'eval' function taking a variant record as an argument, and each case in the variant record marks some function implementation to dispatch to and the corresponding arguments).
- JonChesterfield 3y agoFunction pointers between different architectures can be done. Index into a table, webasm style is the easy option. Writing a prolog that is valid in both architectures works too, I quite like that one. You declare one to be the more important (e.g. x64) and do a hash table lookup on the other. Or the most popular option of crash when calling a pointer from the other arch.