On 20.08.23 07:45, Bernd Machenschalk wrote:
> thanks. As I wrote, I already got it working, without changing the app
> or requiring an app_info.xml. The changes it requires are solely on
> the server side.
Here's what I did:
The client already has some support for a "generic OpenCL coprocessor",
and it detects the Apple M GPU as such a thing.
Sidenote: the comment in
https://github.com/BOINC/boinc/blob/master/lib/coproc.h#L152
about the COPROC class
"// objects will always be a derived class (COPROC_CUDA, COPROC_ATI)"
seems misleading, as apparently for generic coprocessors this class is
instantiated directly. Would have saved me some time to know that. In my
code I at first derived a CORPROCESSOR_GENERIC class.
Anyway, the tricky thing here is that the client reports the exact type
of the GPU as "Apple M1", "Apple M2" etc. You probably don't want to
write a plan class for each model that exists now or comes out in the
future. OTOH the client needs to be told the exact type as it was
detected to identify the coprocessor to use.
I can see two solutions to this:
1. In parsing the "type", the type might be shortened to a common phrase
(e.g. "Apple M"). Then, however, the full type must be preserved
somewhere else (e.g. in a field "full_type"). This is the solution I
implemented at first. It is similar to commit
https://github.com/BOINC/boinc/commit/26eaa0edb5a7e8cf93cc3f0a85164529bedd3890
The plan class can normally scan for the shortened type, but should then
set custom_coproc_type to that full_type
COPROC* cpp = (COPROC*)sreq.coprocs.lookup1("Apple M");
...
strcpy(hu.custom_coproc_type,cp.full_type);
However, there are a few drawbacks to this:
- It seems a bit misplaces to handle a special case of a particular
coproc in the pretty generic coproc class, and odd to mess around with
the reported type in the _parsing_ process at all.
- I learned that the above commit (and also mine) would break existing
modifications other projects made to use Apple M GPUs (PrimeGriD)
2. Add another lookup() function to scan a coproc type only for the
beginning of type string, not for an exact match. This doesn't change -
and thus possibly break - existing behavior or local modifications that
rely on it. it's just an addition that can be used for this case of an
Apple M GPU plan class and similar cases in the future. I'm attaching
this solution only. A plan class for Apple M GPUs would then use that
lookup function, and then set the custom_coproc_type to the actual type:
COPROC* cpp = (COPROC*)sreq.coprocs.lookup1("Apple M");
...
strcpy(hu.custom_coproc_type,cp.type);
With that, for the reasons given above, I suggest to revert commit
https://github.com/BOINC/boinc/commit/26eaa0edb5a7e8cf93cc3f0a85164529bedd3890
I think this was meant to help, but to my knowledge it was never
discussed or tested in actual use.
Bernd