[DepthMap] Support AdaptiveCpp/SYCL with Apple Metal #2160
philippremy
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Picking up from issue #439:
I already did some initial testing when MR #2077 was developed and AliceVision generally is in a good position to make the SYCL kernels for DepthMap computation work with the experimental Apple Metal backend of AdaptiveCpp. It basically works out of the box with the only issue being the usage of
doublethroughout several SYCL kernels. Metal Shading Language does not support 64-bit floating point numbers and AdaptiveCpp (currently) has no software emulation / automatic demotion of these, so the resulting binaries will just throw errors at runtime because theMTLCompilerServicedaemon fails to compile the generated MSL.The SYCL kernels could very easily be adapted for this by just removing all usages of
double. IMHO there are some questions to answer first, however:doubleintofloat?doublein the resulting AIR (whether explicit or implicit) orMTLCompilerServicewill fail to emit machine code.doublehandling for MSL (they list that as in-scope explicitly)?double?Regarding the initial question I definitively do not bring the required Math knowledge with me to answer it. I'd guess that there is/was a reason why the CUDA kernel authors used
double. This is a somewhat uncommon choice on GPUs and one would probably avoid it if possible. For the final mesh output however, I did not really notice that much of a difference. Rolling our owndoublesoftware emulation would not be impossible, but it certainly is a significant undertaking. We would need to implement edge cases (NaN, infinity, ±0) and rather complex functions (likesin()andcos()). Switching code for backends seems to be totally possible, IIRC there is a helper function/'lamda' in the AdaptiveCpp namespace which guards code per backend.Note
For those who just want to test this quick-and-dirty, you essentially want to do the following in all files with SYCL code:
Turn all explicit and implicit
doubleusages into regularfloat:So this:
should turn roughly into this:
The GCC/Clang
-Wimplicit-float-conversionflag might be of help here when you think you missed something (the literals sometimes sneak their way through the code :D).All reactions