|
Memclave Artifact Documentation
|
The Memclave Client Library is used to interact with PIM ranks running Memclave. It serves as a replacement to UPMEM's host library and follows a similar programming paradigm. These pages document the libraries usage.
The Memclave Client Library is meant to be used together with other CMake based projects. A viable CMakeLists.txt for the project below could be
which would build the addition example. The subkernel still has to be build seperately.
We demonstrate a simple use-case as a usage example: A program that adds two integer vectors by transfering them to a PIM rank and then reads the result. First, just like in UPMEM's case, we have to allocate a rank of DPUs:
Here you may already notice that Memclave uses a different mechanism for handling errors. Instead of explicitly returning error codes, errors are stored in a single variable of a rank. Future operations on the rank are NOPs, if an error value is set. This allows chaining multiple PIM operations, without having to do explicit error handling each time.
After allocation, we wait for the rank to become available. This is important for edge-cases, were the loader has just started up and is not yet ready. We also set the number of worker threads responsible for copying data.
Once we know the rank is ready, we can exchange a key with the DPU rank. For the example, we'll use a random key fetched from /dev/urandom.
The key exchange will take roughly 10s. Once a session key is established, we can deploy a subkernel, in our case the addition subkernel to the rank and transfer input data.
Once all inputs are transfered and a kernel is loaded, we can start processing on the DPU side and wait for it to finish.
Finally, all that is left is fetching back the data and confirming that everything worked out.
Here you may also notice that our memory transfer functions have a different signature. We use C99's array pointers to describe data movement, instead of UPMEM's transfer matrix approach.