Let’s Talk Stacks


I’ve been learning Apple’s proprietary GPU API Metal, specifically the C++ header version commonly referred to as metal-cpp. The first thing I noticed out of the gate was all of the documentation and tutorials sort of lean towards the use of Xcode. I’m not particularly against using Xcode, but with our capstone project, I’ve been using VSCode, and a simple Makefile. Adapting to this implementation was considerably challenging, as it wasn’t entirely clear what libraries to link and how Xcode compiles and links shaders “under the hood”. I suppose the request I would have for the relatively new metal-cpp headers is to have more thorough documentation for workflows external to Xcode, but also documentation on in C++. I found that all code examples or documentation were in the native Objective-C language or swift, which took a bit of brain power for me to adapt to C++. Lastly, I think Metal could learn a thing or two from CUDA. CUDA supports the C++ std library, and has a compilation workflow which allows you to actually write a kernel in C++.

In our capstone project, we are writing GPU kernels in CUDA and Metal, so code duplication is inevitably prevalent without the implementation some clever code-unification strategy such as LAMMPS’ unification solution for OpenCL and CUDA. The drawback of Metal basically boils down to xrun’s inability to compile a C++ file as a intermediate representation file (.ir) and lack of support of the C++ std library.

My favorite technology stack is by far the sqlite3 C++ library. The implementation is well documented, reliable and simple in all contexts, just add the header and link the library, nice!!! I know this is an unreasonable expectation for more involved libraries such as GPU APIs but hey, there’s got to be some middle ground here. It took me 1 hour to get sqlite3 up and running in C++, where metal’s C++ header library took me north of 3 hours.

The takeaway here is flexible libraries are stellar. No matter how popular your technology stack is, demonstrating that your implementation is flexible for as many workflows as possible is an honorable act of humanity.

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *