Norman,
I appreciate your point of view, especially as I know your background, and through the many conversations that we’ve had over this topic, and please understand that I absolutely do not mean to offend or upset you, even if what I write might seem like it.
You know how much work it is to do this in pure Xojo, I am sure that Xojo know how challenging it currently is also. But I persisted and fought through, even dealing with other restrictions that the App Store impose, trying to squeeze more performance out of my apps. It’s a demoralizing bad minefield of work v.s. improvement, but hey, that’s kind of the overall opinion of macOS development nowadays.
I admire @Peter Stys for his persistence, more so because he and I are trying to accomplish the same thing, which is to process images as fast as possible.
When I decided to attempt this with a different tool, I went in expecting all kinds of problems and a general “spend a lot of time/little progress” situation. Which is exactly the opposite of what I got. I can’t emphasize enough how simple it was, and how eye opening that multi-core programming isn’t as difficult as I believed it to be. The first time I tried to run the code (in a language that I am not as well versed as Xojo) it just worked. I had to tweak it to find the best balance of task per core, but it worked.
Which is why I have shared the core code that it took, obviously it’s missing the actually image processing code and the wrapping code so that it can be called from within Xojo.
It is my understanding (and I can be completely wrong) that GCD utilizes blocks, which we can use in Xojo at the moment. However block access on non-main threads are very fragile. For Apple’s platforms, Xojo don’t need to re-invent the wheel, they just need to make their framework thread safe, and maybe not all of it. If they start small, and progress over time, it goes from being a task that isn’t started because it’s overwhelming to one day, being accomplished.
Hence why I started this very thread, to illustrate what I and others would need. The simplest of tasks that I want to improve performance would involve looping through a shared block of memory (each core would have only a range to loop through), reading numeric values, applying math to those values and putting them back.
Yes I can do this with helpers, but it took far longer to get all the pieces together to do that, than simply write the above code using an alternative tool.
There is also another reason as to why I am hoping for GCD adoption over helpers or “scripting languages”, I have a great deal of customers who have 45+ megapixel cameras, including one who uses a 100 megapixel Hassleblad. I do most of my processing in 128-BPP floating point, so these images can use a large amount of memory, for some of these cases I’ve elected to NOT use the GPU, because there is no way I know of how to test if there is enough memory available on the GPU (there are two other reasons as to why I am looking to do certain tasks on the CPU with machine RAM than via GPU), while in these cases all the customers have enough RAM. It makes most sense to allow each core based task to access to the same area of memory. The macOS supports two different mechanisms for sharing memory (that I am aware of), but the App Store only supports one, what happens if Apple decide for “Security & Privacy” to no longer allow this. My app is dead. Meanwhile I am pretty confident that GCD will continue to allow this (as it’s the same app).
I think I’ve flogged this dead horse long enough, the ball is in Xojo’s court now, hopefully with this information they’ll consider altering their framework and invest in providing functionality that will improve the performance of Xojo based apps.