1
1

SHADOW ALLOCATOR: minor code optimization

Signed-off-by: Sergey Oblomov <sergeyo@mellanox.com>
Этот коммит содержится в:
Sergey Oblomov 2019-05-16 09:38:01 +03:00
родитель 277c2a9e5c
Коммит a51badd627
3 изменённых файлов: 4 добавлений и 4 удалений

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

@ -50,9 +50,9 @@ void sshmem_ucx_shadow_destroy(sshmem_ucx_shadow_allocator_t *allocator);
int sshmem_ucx_shadow_alloc(sshmem_ucx_shadow_allocator_t *allocator, int sshmem_ucx_shadow_alloc(sshmem_ucx_shadow_allocator_t *allocator,
unsigned count, unsigned *index); unsigned count, unsigned *index);
/* reallocate existing allocated buffer. if possible - used inplace /* Reallocate existing allocated buffer. If possible - used inplace
* reallocation. * reallocation.
* parameter 'inplace' - out, in case if zero - new buffer was allocated * Parameter 'inplace' - out, in case if zero - new buffer was allocated
* (inplace is not possible), user should remove original buffer after data * (inplace is not possible), user should remove original buffer after data
* is copied, else (if inplace == 0) - no additional action required */ * is copied, else (if inplace == 0) - no additional action required */
int sshmem_ucx_shadow_realloc(sshmem_ucx_shadow_allocator_t *allocator, int sshmem_ucx_shadow_realloc(sshmem_ucx_shadow_allocator_t *allocator,

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

@ -336,7 +336,7 @@ static unsigned sshmem_ucx_memheap_ptr2index(map_segment_t *s, void *ptr)
return ((char*)ptr - (char*)s->super.va_base) / ALLOC_ELEM_SIZE; return ((char*)ptr - (char*)s->super.va_base) / ALLOC_ELEM_SIZE;
} }
void sshmem_ucx_memheap_wordcopy(void *dst, void *src, size_t size) static void sshmem_ucx_memheap_wordcopy(void *dst, void *src, size_t size)
{ {
const size_t count = (size + sizeof(uint64_t) - 1) / sizeof(uint64_t); const size_t count = (size + sizeof(uint64_t) - 1) / sizeof(uint64_t);
uint64_t *dst64 = (uint64_t*)dst; uint64_t *dst64 = (uint64_t*)dst;

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

@ -128,7 +128,7 @@ int sshmem_ucx_shadow_realloc(sshmem_ucx_shadow_allocator_t *allocator,
return OSHMEM_SUCCESS; return OSHMEM_SUCCESS;
} }
if (count < elem->block_size) { if (count < old_count) {
/* requested block is shorter than allocated block /* requested block is shorter than allocated block
* then just cut current buffer */ * then just cut current buffer */
sshmem_ucx_shadow_set_elem(elem + count, sshmem_ucx_shadow_set_elem(elem + count,