Skip to content

mm_init/mm_finalize

According to this Cuda Run time library unload discussion

it is a bad design practice to put calls to the CUDA runtime API in constructors that may run before main and destructors that may run after main.

In our case: if the user forgets to call mm_clear_registry (-> reset locale static state via get_ctx_singelton ) then we may get cuda unloading errors, like:

terminate called after throwing an instance of 'memman::err::FreeError' what(): /home/k/k202076/icon/icon-charm/src/core/memman/cuda_var_data.hpp:151 in function deallocate: throws Error when Freeing context: CUDA call returned: cudaErrorCudartUnloading:driver shutting down Aborted

I could not yet provoke a similar error by "forgetting" to delete the user-managed device contexts ( bound to user_device_ctxs in memman_c.cpp). But I think it is a good idea to clean these contexts in a controlled way, too. Especially if, in the future, the mmgr manages these contexts internally.

Therefore I think that it would be good to provide a mm_finalize user function which takes care of cleanup. Otherwise the user will get exposed to unnecessary technical details when doing the cleanup using the current interfaces.

It also seems preferable to have a mm_initialize user function (although the argument may not be as strong) to initialize the future internally-managed gpu contexts. Otherwise these states have to be created on-the-fly.

Edited by Joerg Behrens
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information