1
1

mpool/grdma: use the rcache even if not using mpi_leave_pinned or

mpi_leave_pinned_pipeline

This change should improve performance is the non-pinned case where
the same memory region is involved in multiple simultaneous transfers.

cmr=v1.7.3:reviewer=brbarret

This commit was SVN r28973.
Этот коммит содержится в:
Nathan Hjelm 2013-07-31 23:50:41 +00:00
родитель 83a3fc2fd2
Коммит 8429485a39

Просмотреть файл

@ -213,10 +213,11 @@ int mca_mpool_grdma_register(mca_mpool_base_module_t *mpool, void *addr,
mca_mpool_base_registration_t **reg) mca_mpool_base_registration_t **reg)
{ {
mca_mpool_grdma_module_t *mpool_grdma = (mca_mpool_grdma_module_t*)mpool; mca_mpool_grdma_module_t *mpool_grdma = (mca_mpool_grdma_module_t*)mpool;
const bool bypass_cache = !!(flags & MCA_MPOOL_FLAGS_CACHE_BYPASS);
const bool persist = !!(flags & MCA_MPOOL_FLAGS_PERSIST);
mca_mpool_base_registration_t *grdma_reg; mca_mpool_base_registration_t *grdma_reg;
ompi_free_list_item_t *item; ompi_free_list_item_t *item;
unsigned char *base, *bound; unsigned char *base, *bound;
bool bypass_cache = !!(flags & MCA_MPOOL_FLAGS_CACHE_BYPASS);
int rc; int rc;
OPAL_THREAD_LOCK(&mpool->rcache->lock); OPAL_THREAD_LOCK(&mpool->rcache->lock);
@ -230,18 +231,17 @@ int mca_mpool_grdma_register(mca_mpool_base_module_t *mpool, void *addr,
/* look through existing regs if not persistent registration requested. /* look through existing regs if not persistent registration requested.
* Persistent registration are always registered and placed in the cache */ * Persistent registration are always registered and placed in the cache */
if(!(flags & MCA_MPOOL_FLAGS_PERSIST) && !bypass_cache) { if(!(bypass_cache || persist)) {
/* check to see if memory is registered */ /* check to see if memory is registered */
mpool->rcache->rcache_find(mpool->rcache, addr, size, reg); mpool->rcache->rcache_find(mpool->rcache, addr, size, reg);
if(*reg != NULL && if (*reg && !(flags & MCA_MPOOL_FLAGS_INVALID)) {
(mca_mpool_grdma_component.leave_pinned || if (0 == (*reg)->ref_count) {
((*reg)->flags & MCA_MPOOL_FLAGS_PERSIST) || /* Leave pinned must be set for this to still be in the rcache. */
((*reg)->base == base && (*reg)->bound == bound))) {
if(0 == (*reg)->ref_count &&
mca_mpool_grdma_component.leave_pinned) {
opal_list_remove_item(&mpool_grdma->pool->lru_list, opal_list_remove_item(&mpool_grdma->pool->lru_list,
(opal_list_item_t*)(*reg)); (opal_list_item_t *)(*reg));
} }
/* This segment fits fully within an existing segment. */
mpool_grdma->stat_cache_hit++; mpool_grdma->stat_cache_hit++;
(*reg)->ref_count++; (*reg)->ref_count++;
OPAL_THREAD_UNLOCK(&mpool->rcache->lock); OPAL_THREAD_UNLOCK(&mpool->rcache->lock);
@ -251,16 +251,11 @@ int mca_mpool_grdma_register(mca_mpool_base_module_t *mpool, void *addr,
mpool_grdma->stat_cache_miss++; mpool_grdma->stat_cache_miss++;
*reg = NULL; /* in case previous find found something */ *reg = NULL; /* in case previous find found something */
/* If no suitable registration is in cache and leave_pinned isn't /* Unless explicitly requested by the caller always store the
* set don't use the cache. * registration in the rcache. This will speed up the case where
* This is optimisation in case limit is not set. If limit is set we * no leave pinned protocol is in use but the same segment is in
* have to put registration into the cache to determine when we hit * use in multiple simultaneous transactions. We used to set bypass_cache
* memory registration limit. * here is !mca_mpool_grdma_component.leave_pinned. */
* NONE: cache is still used for persistent registrations so previous
* find can find something */
if(!mca_mpool_grdma_component.leave_pinned) {
bypass_cache = true;
}
} }
OMPI_FREE_LIST_GET_MT(&mpool_grdma->reg_list, item); OMPI_FREE_LIST_GET_MT(&mpool_grdma->reg_list, item);
@ -373,7 +368,7 @@ int mca_mpool_grdma_find(struct mca_mpool_base_module_t *mpool, void *addr,
return rc; return rc;
} }
static inline bool registration_is_cachebale(mca_mpool_base_registration_t *reg) static inline bool registration_is_cacheable(mca_mpool_base_registration_t *reg)
{ {
return (mca_mpool_grdma_component.leave_pinned && return (mca_mpool_grdma_component.leave_pinned &&
!(reg->flags & !(reg->flags &
@ -396,7 +391,7 @@ int mca_mpool_grdma_deregister(struct mca_mpool_base_module_t *mpool,
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
if(registration_is_cachebale(reg)) { if(registration_is_cacheable(reg)) {
opal_list_append(&mpool_grdma->pool->lru_list, (opal_list_item_t *) reg); opal_list_append(&mpool_grdma->pool->lru_list, (opal_list_item_t *) reg);
} else { } else {
rc = dereg_mem (reg); rc = dereg_mem (reg);