int mca_mpool_grdma_deregister(struct mca_mpool_base_module_t *mpool, mca_mpool_base_registration_t *reg) { mca_mpool_grdma_module_t *mpool_grdma = (mca_mpool_grdma_module_t *) mpool; int rc = OMPI_SUCCESS; assert(reg->ref_count > 0); OPAL_THREAD_LOCK(&mpool->rcache->lock); reg->ref_count--; if(reg->ref_count > 0) { OPAL_THREAD_UNLOCK(&mpool->rcache->lock); return OMPI_SUCCESS; } if(registration_is_cachebale(reg)) { opal_list_append(&mpool_grdma->pool->lru_list, (opal_list_item_t *) reg); } else { rc = dereg_mem (reg); } OPAL_THREAD_UNLOCK(&mpool->rcache->lock); /* Cleanup any vmas that we have deferred deletion on */ mpool->rcache->rcache_clean(mpool->rcache); return rc; }
int mca_rcache_rgpusm_deregister_no_lock(struct mca_rcache_base_module_t *rcache, mca_rcache_base_registration_t *reg) { mca_rcache_rgpusm_module_t *rcache_rgpusm = (mca_rcache_rgpusm_module_t*)rcache; int rc = OPAL_SUCCESS; assert(reg->ref_count > 0); reg->ref_count--; opal_output(-1, "Deregister: reg->ref_count=%d", (int)reg->ref_count); if(reg->ref_count > 0) { return OPAL_SUCCESS; } if(mca_rcache_rgpusm_component.leave_pinned && registration_is_cachebale(reg)) { /* if leave_pinned is set don't deregister memory, but put it * on LRU list for future use */ opal_list_prepend(&rcache_rgpusm->lru_list, (opal_list_item_t*)reg); } else { /* Remove from rcache first */ if(!(reg->flags & MCA_RCACHE_FLAGS_CACHE_BYPASS)) mca_rcache_base_vma_delete (rcache_rgpusm->vma_module, reg); assert(reg->ref_count == 0); rc = cuda_closememhandle (NULL, reg); if(OPAL_SUCCESS == rc) { opal_free_list_return (&rcache_rgpusm->reg_list, (opal_free_list_item_t*)reg); } } return rc; }
int mca_mpool_rgpusm_deregister(struct mca_mpool_base_module_t *mpool, mca_mpool_base_registration_t *reg) { mca_mpool_rgpusm_module_t *mpool_rgpusm = (mca_mpool_rgpusm_module_t*)mpool; int rc = OMPI_SUCCESS; assert(reg->ref_count > 0); OPAL_THREAD_LOCK(&mpool->rcache->lock); reg->ref_count--; opal_output(-1, "Deregister: reg->ref_count=%d", (int)reg->ref_count); if(reg->ref_count > 0) { OPAL_THREAD_UNLOCK(&mpool->rcache->lock); return OMPI_SUCCESS; } if(mca_mpool_rgpusm_component.leave_pinned && registration_is_cachebale(reg)) { /* if leave_pinned is set don't deregister memory, but put it * on LRU list for future use */ opal_list_prepend(&mpool_rgpusm->lru_list, (opal_list_item_t*)reg); } else { /* Remove from rcache first */ if(!(reg->flags & MCA_MPOOL_FLAGS_CACHE_BYPASS)) mpool->rcache->rcache_delete(mpool->rcache, reg); /* Drop the rcache lock before deregistring the memory */ OPAL_THREAD_UNLOCK(&mpool->rcache->lock); { mca_mpool_rgpusm_module_t *mpool_rgpusm = (mca_mpool_rgpusm_module_t *)mpool; assert(reg->ref_count == 0); rc = mpool_rgpusm->resources.deregister_mem(mpool_rgpusm->resources.reg_data, reg); } OPAL_THREAD_LOCK(&mpool->rcache->lock); if(OMPI_SUCCESS == rc) { OMPI_FREE_LIST_RETURN_MT(&mpool_rgpusm->reg_list, (ompi_free_list_item_t*)reg); } } OPAL_THREAD_UNLOCK(&mpool->rcache->lock); /* Cleanup any vmas that we have deferred deletion on */ mpool->rcache->rcache_clean(mpool->rcache); return rc; }
int mca_rcache_rgpusm_deregister(struct mca_rcache_base_module_t *rcache, mca_rcache_base_registration_t *reg) { mca_rcache_rgpusm_module_t *rcache_rgpusm = (mca_rcache_rgpusm_module_t*)rcache; int rc = OPAL_SUCCESS; assert(reg->ref_count > 0); OPAL_THREAD_LOCK(&rcache->lock); reg->ref_count--; opal_output(-1, "Deregister: reg->ref_count=%d", (int)reg->ref_count); if(reg->ref_count > 0) { OPAL_THREAD_UNLOCK(&rcache->lock); return OPAL_SUCCESS; } if(mca_rcache_rgpusm_component.leave_pinned && registration_is_cachebale(reg)) { /* if leave_pinned is set don't deregister memory, but put it * on LRU list for future use */ opal_output_verbose(20, mca_rcache_rgpusm_component.output, "RGPUSM: Deregister: addr=%p, size=%d: cacheable and pinned, leave in cache, PUSH IN LRU", reg->base, (int)(reg->bound - reg->base + 1)); opal_list_prepend(&rcache_rgpusm->lru_list, (opal_list_item_t*)reg); } else { /* Remove from rcache first */ if(!(reg->flags & MCA_RCACHE_FLAGS_CACHE_BYPASS)) mca_rcache_base_vma_delete (rcache_rgpusm->vma_module, reg); /* Drop the rcache lock before deregistring the memory */ OPAL_THREAD_UNLOCK(&rcache->lock); { assert(reg->ref_count == 0); rc = cuda_closememhandle (NULL, reg); } OPAL_THREAD_LOCK(&rcache->lock); if(OPAL_SUCCESS == rc) { opal_free_list_return (&rcache_rgpusm->reg_list, (opal_free_list_item_t*)reg); } } OPAL_THREAD_UNLOCK(&rcache->lock); return rc; }
int mca_mpool_rgpusm_deregister_no_lock(struct mca_mpool_base_module_t *mpool, mca_mpool_base_registration_t *reg) { mca_mpool_rgpusm_module_t *mpool_rgpusm = (mca_mpool_rgpusm_module_t*)mpool; int rc = OPAL_SUCCESS; assert(reg->ref_count > 0); reg->ref_count--; opal_output(-1, "Deregister: reg->ref_count=%d", (int)reg->ref_count); if(reg->ref_count > 0) { return OPAL_SUCCESS; } if(mca_mpool_rgpusm_component.leave_pinned && registration_is_cachebale(reg)) { /* if leave_pinned is set don't deregister memory, but put it * on LRU list for future use */ opal_list_prepend(&mpool_rgpusm->lru_list, (opal_list_item_t*)reg); } else { /* Remove from rcache first */ if(!(reg->flags & MCA_MPOOL_FLAGS_CACHE_BYPASS)) mpool->rcache->rcache_delete(mpool->rcache, reg); { mca_mpool_rgpusm_module_t *mpool_rgpusm = (mca_mpool_rgpusm_module_t *)mpool; assert(reg->ref_count == 0); rc = mpool_rgpusm->resources.deregister_mem(mpool_rgpusm->resources.reg_data, reg); } if(OPAL_SUCCESS == rc) { opal_free_list_return (&mpool_rgpusm->reg_list, (opal_free_list_item_t*)reg); } } return rc; }