1
1

fix memheap void pointer arithmetics

Refs trac:3763

This commit was SVN r29856.

The following Trac tickets were found above:
  Ticket 3763 --> https://svn.open-mpi.org/trac/ompi/ticket/3763
Этот коммит содержится в:
Mike Dubman 2013-12-11 06:35:03 +00:00
родитель 435eaf4671
Коммит 8da74bec34
7 изменённых файлов: 24 добавлений и 23 удалений

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

@ -73,7 +73,7 @@ typedef struct openib_device_t {
struct ibv_context *ib_dev_context;
struct ibv_device_attr ib_dev_attr;
struct ibv_pd *ib_pd;
opal_value_array_t ib_mr_array;;
opal_value_array_t ib_mr_array;
struct ibv_mr *ib_mr_shared;
} openib_device_t;
#endif /* MPAGE_ENABLE */

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

@ -245,7 +245,7 @@ static int _shm_attach(map_segment_t *s, size_t size, int use_hp, int do_rmid)
s->shmid = shmid;
s->start = addr;
s->size = size;
s->end = s->start + s->size;
s->end = (void*)((uintptr_t)s->start + s->size);
s->context = &shm_context;
return OSHMEM_SUCCESS;
@ -297,7 +297,7 @@ MAP_ANONYMOUS |
s->shmid = MEMHEAP_SHM_INVALID;
s->start = addr;
s->size = size;
s->end = s->start + s->size;
s->end = (void*)((uintptr_t)s->start + s->size);
s->context = NULL;
return OSHMEM_SUCCESS;
@ -474,7 +474,7 @@ static int _ibv_attach(map_segment_t *s, size_t size)
s->shmid = device->ib_mr_shared->handle;
s->start = ib_mr->addr;
s->size = size;
s->end = s->start + s->size;
s->end = (void*)((uintptr_t)s->start + s->size);
s->context = &memheap_device;
}
}

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

@ -199,7 +199,7 @@ static void memheap_attach_segment(mca_spml_mkey_t *mkey, int tr_id)
/* workaround mtt problem - request aligned addresses */
++mr_count;
addr = (void *)(mca_memheap_base_start_address + mca_memheap_base_mr_interleave_factor*1024ULL*1024ULL*1024ULL*mr_count);
addr = (void *)((uintptr_t)mca_memheap_base_start_address + mca_memheap_base_mr_interleave_factor*1024ULL*1024ULL*1024ULL*mr_count);
ib_mr = ibv_reg_shared_mr(MEMHEAP_SHM_GET_ID(mkey->handle.key),
device->ib_pd, addr, access_flag);
if (NULL == ib_mr)
@ -528,8 +528,9 @@ static inline void* va2rva(void* va,
void* local_base,
void* remote_base)
{
return (void*) (remote_base > local_base ? (uintptr_t)va + (remote_base - local_base) :
(uintptr_t)va - (local_base - remote_base));
return (void*) (remote_base > local_base ?
(uintptr_t)va + ((uintptr_t)remote_base - (uintptr_t)local_base) :
(uintptr_t)va - ((uintptr_t)local_base - (uintptr_t)remote_base));
}
mca_spml_mkey_t * mca_memheap_base_get_cached_mkey(int pe,
@ -599,7 +600,7 @@ uint64_t mca_memheap_base_find_offset(int pe,
s = __find_va(va);
return ((s && s->is_active) ? (rva - s->mkeys_cache[pe][tr_id].va_base) : 0);
return ((s && s->is_active) ? ((uintptr_t)rva - (uintptr_t)(s->mkeys_cache[pe][tr_id].va_base)) : 0);
}
int mca_memheap_base_is_symmetric_addr(const void* va)
@ -618,10 +619,10 @@ int mca_memheap_base_detect_addr_type(void* va)
if (s->type == MAP_SEGMENT_STATIC) {
addr_type = ADDR_STATIC;
} else if ((uintptr_t)va >= (uintptr_t) s->start
&& (uintptr_t)va < (uintptr_t) (s->start + mca_memheap.memheap_size)) {
&& (uintptr_t)va < (uintptr_t) ((uintptr_t)s->start + mca_memheap.memheap_size)) {
addr_type = ADDR_USER;
} else {
assert( (uintptr_t)va >= (uintptr_t)(s->start + mca_memheap.memheap_size) && (uintptr_t)va < (uintptr_t)s->end);
assert( (uintptr_t)va >= (uintptr_t) ((uintptr_t)s->start + mca_memheap.memheap_size) && (uintptr_t)va < (uintptr_t)s->end);
addr_type = ADDR_PRIVATE;
}
}

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

@ -31,7 +31,7 @@ int mca_memheap_base_reg(mca_memheap_map_t *memheap_map)
i,
s->start,
s->end,
(long long)(s->end - s->start),
(long long)((uintptr_t)s->end - (uintptr_t)s->start),
s->type,
s->shmid);
ret = _reg_segment(s, &memheap_map->num_transports);
@ -56,7 +56,7 @@ int mca_memheap_base_dereg(mca_memheap_map_t *memheap_map)
i,
s->start,
s->end,
(long long)(s->end - s->start));
(long long)((uintptr_t)s->end - (uintptr_t)s->start));
ret = _dereg_segment(s);
}
@ -110,7 +110,7 @@ static int _reg_segment(map_segment_t *s, int *num_btl)
if (!rc) {
s->mkeys = MCA_SPML_CALL(register((void *)(unsigned long)s->start,
s->end - s->start,
(uintptr_t)s->end - (uintptr_t)s->start,
MEMHEAP_SHM_CODE(s->type, s->shmid),
num_btl));
if (NULL == s->mkeys) {

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

@ -62,12 +62,12 @@ int mca_memheap_base_static_init(mca_memheap_map_t *map)
s->shmid = MEMHEAP_SHM_INVALID;
s->start = memheap_context.mem_segs[i].start;
s->end = memheap_context.mem_segs[i].end;
s->size = s->end - s->start;
s->size = ((uintptr_t)s->end - (uintptr_t)s->start);
s->type = MAP_SEGMENT_STATIC;
s->context = NULL;
map->n_segments++;
total_mem += s->end - s->start;
total_mem += ((uintptr_t)s->end - (uintptr_t)s->start);
}
MEMHEAP_VERBOSE(1,
"Memheap static memory: %llu byte(s), %d segments",
@ -177,12 +177,12 @@ static int _load_segments(void)
memset(&seg, 0, sizeof(seg));
sscanf(line,
"%llx-%llx %s %llx %s %llx %s",
(long long *) &seg.start,
(long long *) &seg.end,
(unsigned long long *) &seg.start,
(unsigned long long *) &seg.end,
seg.perms,
(long long *) &seg.offset,
(unsigned long long *) &seg.offset,
seg.dev,
(long long *) &seg.inode,
(unsigned long long *) &seg.inode,
seg.pathname);
if (OSHMEM_ERROR == _check_address(&seg))

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

@ -19,7 +19,7 @@
#define DL_DEBUG 0
#define FOOTERS 0
/* print error if *alloc() is called with incorrect params */
#define USAGE_ERROR_ACTION(m, p) do { printf("PTMALLOC: USAGE ERROR DETECTED: m=%p ptr=%p\n", m, p); } while (0)
#define USAGE_ERROR_ACTION(m, p) do { printf("PTMALLOC: USAGE ERROR DETECTED: m=%p ptr=%p\n", (void*)m, (void*)p); } while (0)
int mca_memheap_ptmalloc_getpagesize(void);
void *mca_memheap_ptmalloc_sbrk(size_t size);

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

@ -132,13 +132,13 @@ OSHMEM_DECLSPEC int oshmem_shmem_register_params(void);
#if OSHMEM_PARAM_CHECK == 1
#define RUNTIME_CHECK_ERROR(format, ...) \
#define RUNTIME_CHECK_ERROR(...) \
do { \
fprintf(stderr, "[%s]%s[%s:%d:%s] ", \
orte_process_info.nodename, \
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), \
__FILE__, __LINE__, __func__); \
fprintf(stderr, format, ## __VA_ARGS__); \
fprintf(stderr, __VA_ARGS__); \
} while(0);
/**
@ -179,7 +179,7 @@ OSHMEM_DECLSPEC int oshmem_shmem_register_params(void);
#define RUNTIME_CHECK_ADDR(x) \
if (OPAL_UNLIKELY(!MCA_MEMHEAP_CALL(is_symmetric_addr((x))))) \
{ \
RUNTIME_CHECK_ERROR("Required address %p is not in symmetric space\n", (x)); \
RUNTIME_CHECK_ERROR("Required address %p is not in symmetric space\n", ((void*)x)); \
oshmem_shmem_abort(-1); \
}
#define RUNTIME_CHECK_WITH_MEMHEAP_SIZE(x) \