Skip to content

Commit

Permalink
[armci] remove blocks guarded by ALLOC_MUNMAP, ACC_SMP
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaypanyala committed Jul 26, 2024
1 parent 1f7fd75 commit 8c12925
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 93 deletions.
7 changes: 1 addition & 6 deletions armci/src/common/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,6 @@ int armci_rem_strided(int op, void* scale, int proc,
#endif

if(nb_handle)
#ifdef ACC_SMP
if(!ARMCI_ACC(op))
#endif
{
/* INIT_SENDBUF_INFO(nb_handle,buf,op,proc); same as _armci_buf_set_tag, why here? */
_armci_buf_set_tag(buf,nb_handle->tag,0);
Expand Down Expand Up @@ -1005,9 +1002,7 @@ int armci_rem_strided(int op, void* scale, int proc,
armci_send_req(proc, msginfo, bufsize);
}
#if !defined(MPI_SPAWN) && !defined(MPI_MT)
#ifdef ACC_SMP
if(!ARMCI_ACC(op))
#endif

armci_save_strided_dscr(&buf0,dst_ptr,dst_stride_arr,count,
stride_levels,1);
#endif
Expand Down
80 changes: 3 additions & 77 deletions armci/src/memory/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,6 @@
#include "message.h"
#include "armcip.h"

#ifdef ALLOC_MUNMAP
#if HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
static size_t pagesize=0;
static int logpagesize=0;
/* allow only that big shared memory segment (in MB)- incresed from 128 11/02 */
#define MAX_ALLOC_MUNMAP 128
#define MAX_ALLOC_MUNMAP_ 368
static long max_alloc_munmap=MAX_ALLOC_MUNMAP;
#endif

#if defined(SUN)
extern char *shmat();
#endif
Expand Down Expand Up @@ -181,39 +166,6 @@ static int id_search_no_fork=0;
#define CLEANUP_CMD(command) sprintf(command,"/usr/bin/ipcrm -m %d",id);
#endif


#ifdef ALLOC_MUNMAP
# define ALGN_MALLOC(s,a) malloc((s))
#endif

static char* alloc_munmap(size_t size)
{
char *tmp;
unsigned long iptr;
size_t bytes = size+pagesize-1;

if(armci_elan_starting_address){
tmp = armci_elan_starting_address;
armci_elan_starting_address += size;
# ifdef ALLOC_MUNMAP_ALIGN
armci_elan_starting_address += ALLOC_MUNMAP_ALIGN;
# endif
if(DEBUG_) {printf("%d: address for shm attachment is %p size=%ld\n",
armci_me,tmp,(long)size); fflush(stdout); }
} else {
tmp = ALGN_MALLOC(bytes, getpagesize());
if(tmp){
iptr = (unsigned long)tmp + pagesize-1;
iptr >>= logpagesize; iptr <<= logpagesize;
if(DEBUG_) printf("%d:unmap ptr=%p->%p size=%d pagesize=%d\n",armci_me,
tmp,(char*)iptr,(int)size,pagesize);
tmp = (char*)iptr;
if(munmap(tmp, size) == -1) armci_die("munmap failed",0);
if(DEBUG_){printf("%d: unmap OK\n",armci_me); fflush(stdout);}
}else armci_die("alloc_munmap: malloc failed",(int)size);
}
return tmp;
}
#endif

/*\ A wrapper to shmget. Just to be sure that ID is not 0.
Expand Down Expand Up @@ -467,17 +419,6 @@ void armci_shmem_init()
armci_die("no usable amount of shared memory available: only got \n",
(int)LBOUND);

# if defined(ALLOC_MUNMAP)
/* cap down for special memory allocator unless ARMCI_DEFAULT_SHMMAX
not set - the user knows what is doing*/
# if !defined(REGION_ALLOC)
if(!getenv("ARMCI_DEFAULT_SHMMAX"))
if(x>max_alloc_munmap && !armci_elan_starting_address) x=max_alloc_munmap;
# else
x = 10; /* mb */
# endif
# endif

if(DEBUG_){
printf("%d:shmem_init: %d mbytes max segment size\n",armci_me,x);fflush(stdout);}

Expand Down Expand Up @@ -686,10 +627,6 @@ char *temp = (char*)0, *pref_addr=(char*)0;
/* make sure the next shmem region will be adjacent to previous one */

if(temp) pref_addr= temp SHM_OP (MinShmem*SHM_UNIT);
#ifdef ALLOC_MUNMAP
else
pref_addr = alloc_munmap((size_t) (MinShmem*SHM_UNIT));
# endif

if(DEBUG_)
fprintf(stderr,"%d:trying id=%d pref=%ld tmp=%ld u=%d\n",armci_me,
Expand Down Expand Up @@ -763,11 +700,7 @@ size_t sz;

if(DEBUG_)fprintf(stderr, "in allocate size=%ld\n",size);

#ifdef ALLOC_MUNMAP
pref_addr = alloc_munmap((size_t) size);
#else
pref_addr = (char*)0; /* first time let the OS choose address */
#endif

/* allocate shmem in as many segments as neccesary */
for(i =0; i< newreg; i++){
Expand Down Expand Up @@ -959,11 +892,7 @@ static char *temp;
/* attach if not attached yet */
if(!region_list[reg].attached){

# ifdef ALLOC_MUNMAP
char *pref_addr = alloc_munmap((size_t) (size));
# else
char *pref_addr = (char*)0;
# endif
char *pref_addr = (char*)0;
if ( (long) (temp = shmat((int) *id, pref_addr, shmflag)) == -1L){
fprintf(stderr,"%d:attach error:id=%ld off=%ld seg=%ld\n",armci_me,*id,offset,MinShmem);
shmem_errmsg((size_t)MinShmem*1024);
Expand Down Expand Up @@ -1004,11 +933,8 @@ void *armci_allocate(long size)
char * temp;
int id,shmflag=0;
size_t sz = (size_t)size;
#ifdef ALLOC_MUNMAP
char *pref_addr = alloc_munmap((size_t) (MinShmem*SHM_UNIT));
#else
char *pref_addr = (char*)0;
#endif
char *pref_addr = (char*)0;

#if defined(SGI_N32) && defined(SHM_SGI_ANYADDR)
shmflag= SHM_SGI_ANYADDR;
#endif
Expand Down
11 changes: 3 additions & 8 deletions armci/src/xfer/strided.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,8 @@ void armci_acc_1D(int op, void *scale, int proc, void *src, void *dst, int bytes
int total_of_2D;
int index[MAX_STRIDE_LEVEL], unit[MAX_STRIDE_LEVEL];

# if defined(ACC_COPY)

# ifdef ACC_SMP
if(ARMCI_ACC(op) && !(SAMECLUSNODE(proc)) )
# else
# if defined(ACC_COPY)
if ( ARMCI_ACC(op) && proc!=armci_me)
# endif
/* copy remote data, accumulate, copy back*/
return (armci_acc_copy_strided(op,scale, proc, src_ptr, src_stride_arr,
dst_ptr, dst_stride_arr, count, stride_levels));
Expand Down Expand Up @@ -871,9 +866,9 @@ static int _armci_accs( int optype, void *scale,

direct=SAMECLUSNODE(proc);

#if defined(ACC_COPY) && !defined(ACC_SMP)
#if defined(ACC_COPY)
if(armci_me != proc) direct=0;
#endif /*ACC_COPY && !ACC_SMP*/
#endif /*ACC_COPY*/

if(direct) {
rc = armci_op_strided(optype,scale, proc, src_ptr, src_stride_arr,dst_ptr,
Expand Down
4 changes: 2 additions & 2 deletions armci/src/xfer/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ int PARMCI_AccV( int op, /* oeration code */
ORDER(op,proc); /* ensure ordering */
direct=SAMECLUSNODE(proc);

# if defined(ACC_COPY) && !defined(ACC_SMP)
# if defined(ACC_COPY)
if(armci_me != proc) direct=0;
# endif

Expand Down Expand Up @@ -620,7 +620,7 @@ int PARMCI_NbAccV( int op, /* oeration code */
else
nb_handle = (armci_ihdl_t)armci_set_implicit_handle(op, proc);

# if defined(ACC_COPY) && !defined(ACC_SMP)
# if defined(ACC_COPY)
if(armci_me != proc) direct=0;
# endif

Expand Down

0 comments on commit 8c12925

Please sign in to comment.