Skip to content

Commit

Permalink
freelist: use uintptr_t for pointer arithmetic
Browse files Browse the repository at this point in the history
stack-info: PR: #560, branch: aws-nslick/stack/7
Signed-off-by: Nicholas Sielicki <[email protected]>
  • Loading branch information
aws-nslick committed Sep 4, 2024
1 parent b7da2b6 commit 74856f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions include/nccl_ofi_freelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,20 @@ static inline void nccl_ofi_freelist_entry_set_undefined(nccl_ofi_freelist_t *fr
size_t redzone_offset = offsetof(struct nccl_ofi_freelist_reginfo_t, redzone);

/* Entry after reginfo structure is accessible but undefined */
nccl_net_ofi_mem_undefined_unaligned(entry_p + reginfo_offset + reginfo_size,
nccl_net_ofi_mem_undefined_unaligned((void*)((uintptr_t)entry_p + reginfo_offset + reginfo_size),
user_entry_size - reginfo_offset - reginfo_size);
/* Redzone at the end of the reginfo structure is
* marked as not accessible */
nccl_net_ofi_mem_noaccess_unaligned(entry_p + reginfo_offset + redzone_offset,
nccl_net_ofi_mem_noaccess_unaligned((void*)((uintptr_t)entry_p + reginfo_offset + redzone_offset),
MEMCHECK_REDZONE_SIZE);
/* Members of reginfo structure except first and last
* member are accessible and defined */
nccl_net_ofi_mem_defined_unaligned(entry_p + reginfo_offset + elem_size,
nccl_net_ofi_mem_defined_unaligned((void*)((uintptr_t)entry_p + reginfo_offset + elem_size),
redzone_offset - elem_size);
/* First member of reginfo structure, i.e.,
* nccl_ofi_freelist_elem_t structure, is marked as
* not accessible */
nccl_net_ofi_mem_noaccess_unaligned(entry_p + reginfo_offset, elem_size);
nccl_net_ofi_mem_noaccess_unaligned((void*)((uintptr_t)entry_p + reginfo_offset), elem_size);
/* First part of entry until reginfo structure is
* accessible but undefined */
nccl_net_ofi_mem_undefined(entry_p, reginfo_offset);
Expand Down
12 changes: 6 additions & 6 deletions include/nccl_ofi_memcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ static inline void nccl_net_ofi_mem_noaccess(void *data, size_t size);
static inline void nccl_net_ofi_mem_defined_unaligned(void *data, size_t size)
{
void *aligned = (void *)NCCL_OFI_ROUND_DOWN((uintptr_t)data, MEMCHECK_GRANULARITY);
size_t offset = data - aligned;
nccl_net_ofi_mem_defined(data - offset, size + offset);
size_t offset = (uintptr_t)data - (uintptr_t)aligned;
nccl_net_ofi_mem_defined((void*)((uintptr_t)data - offset), size + offset);
}

/**
Expand All @@ -97,8 +97,8 @@ static inline void nccl_net_ofi_mem_defined_unaligned(void *data, size_t size)
static inline void nccl_net_ofi_mem_undefined_unaligned(void *data, size_t size)
{
void *aligned = (void *)NCCL_OFI_ROUND_DOWN((uintptr_t)data, MEMCHECK_GRANULARITY);
size_t offset = data - aligned;
nccl_net_ofi_mem_undefined(data - offset, size + offset);
size_t offset = (uintptr_t)data - (uintptr_t)aligned;
nccl_net_ofi_mem_undefined((void*)((uintptr_t)data - offset), size + offset);
}

/**
Expand All @@ -108,8 +108,8 @@ static inline void nccl_net_ofi_mem_undefined_unaligned(void *data, size_t size)
static inline void nccl_net_ofi_mem_noaccess_unaligned(void *data, size_t size)
{
void *aligned = (void *)NCCL_OFI_ROUND_DOWN((uintptr_t)data, MEMCHECK_GRANULARITY);
size_t offset = data - aligned;
nccl_net_ofi_mem_noaccess(data - offset, size + offset);
size_t offset = (uintptr_t)data - (uintptr_t)aligned;
nccl_net_ofi_mem_noaccess((void*)((uintptr_t)data - offset), size + offset);
}

/**
Expand Down

0 comments on commit 74856f4

Please sign in to comment.