git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8226 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2012-06-06 22:47:51 +00:00
parent f46eb9dedb
commit ef9e700545
1408 changed files with 58053 additions and 57983 deletions

View File

@ -1,22 +1,22 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
Original Version:
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Steve Plimpton, sjplimp@sandia.gov
See the README file in the top-level LAMMPS directory.
See the README file in the top-level LAMMPS directory.
-----------------------------------------------------------------------
-----------------------------------------------------------------------
USER-CUDA Package and associated modifications:
https://sourceforge.net/projects/lammpscuda/
https://sourceforge.net/projects/lammpscuda/
Christian Trott, christian.trott@tu-ilmenau.de
Lars Winterfeld, lars.winterfeld@tu-ilmenau.de
Theoretical Physics II, University of Technology Ilmenau, Germany
Theoretical Physics II, University of Technology Ilmenau, Germany
See the README file in the USER-CUDA directory.
See the README file in the USER-CUDA directory.
This software is distributed under the GNU General Public License.
------------------------------------------------------------------------- */
@ -28,7 +28,7 @@
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
@ -99,13 +99,13 @@ void AtomVecChargeCuda::grow_send(int n,double** buf_send,int flag) //need to b
if(*buf_send) CudaWrapper_FreePinnedHostData((void*) (*buf_send));
*buf_send = (double*) CudaWrapper_AllocPinnedHostData((*maxsend+BUFEXTRA)*sizeof(double),false);
memcpy(*buf_send,tmp,old_maxsend*sizeof(double));
delete [] tmp;
delete [] tmp;
}
else
{
*buf_send = (double *)
*buf_send = (double *)
memory->srealloc(*buf_send,(*maxsend+BUFEXTRA)*sizeof(double),
"comm:buf_send");
"comm:buf_send");
}
}
else {
@ -118,7 +118,7 @@ void AtomVecChargeCuda::grow_send(int n,double** buf_send,int flag) //need to b
{
memory->sfree(*buf_send);
*buf_send = (double *) memory->smalloc((*maxsend+BUFEXTRA)*sizeof(double),
"comm:buf_send");
"comm:buf_send");
}
}
}
@ -126,7 +126,7 @@ void AtomVecChargeCuda::grow_send(int n,double** buf_send,int flag) //need to b
void AtomVecChargeCuda::grow_both(int n)
{
if(cuda->finished_setup)
cuda->downloadAll();
cuda->downloadAll();
AtomVecCharge::grow(n);
if(cuda->finished_setup)
{
@ -136,27 +136,27 @@ void AtomVecChargeCuda::grow_both(int n)
}
int AtomVecChargeCuda::pack_comm(int n, int* iswap, double *buf,
int pbc_flag, int *pbc) //usually this should not be called since comm->communicate handles the communication if only positions are exchanged
int pbc_flag, int *pbc) //usually this should not be called since comm->communicate handles the communication if only positions are exchanged
{
if(not cuda->finished_setup || cuda->oncpu)
return AtomVecCharge::pack_comm(n,iswap,buf,pbc_flag,pbc);
int m = Cuda_CommCuda_PackComm(&cuda->shared_data,n,*iswap,(void*) buf,pbc,pbc_flag);
if((sizeof(X_FLOAT)!=sizeof(double)) && m)
m=(m+1)*sizeof(X_FLOAT)/sizeof(double);
return m;
return AtomVecCharge::pack_comm(n,iswap,buf,pbc_flag,pbc);
int m = Cuda_CommCuda_PackComm(&cuda->shared_data,n,*iswap,(void*) buf,pbc,pbc_flag);
if((sizeof(X_FLOAT)!=sizeof(double)) && m)
m=(m+1)*sizeof(X_FLOAT)/sizeof(double);
return m;
}
int AtomVecChargeCuda::pack_comm_vel(int n, int* iswap, double *buf,
int pbc_flag, int *pbc) //usually this should not be called since comm->communicate handles the communication if only positions are exchanged
int pbc_flag, int *pbc) //usually this should not be called since comm->communicate handles the communication if only positions are exchanged
{
if(not cuda->finished_setup || cuda->oncpu)
return AtomVecCharge::pack_comm_vel(n,iswap,buf,pbc_flag,pbc);
int m = Cuda_CommCuda_PackCommVel(&cuda->shared_data,n,*iswap,(void*) buf,pbc,pbc_flag);
if((sizeof(X_FLOAT)!=sizeof(double)) && m)
m=(m+1)*sizeof(X_FLOAT)/sizeof(double);
return m;
return AtomVecCharge::pack_comm_vel(n,iswap,buf,pbc_flag,pbc);
int m = Cuda_CommCuda_PackCommVel(&cuda->shared_data,n,*iswap,(void*) buf,pbc,pbc_flag);
if((sizeof(X_FLOAT)!=sizeof(double)) && m)
m=(m+1)*sizeof(X_FLOAT)/sizeof(double);
return m;
}
/* ---------------------------------------------------------------------- */
@ -164,7 +164,7 @@ int AtomVecChargeCuda::pack_comm_vel(int n, int* iswap, double *buf,
void AtomVecChargeCuda::unpack_comm(int n, int first, double *buf) //usually this should not be called since comm->communicate handles the communication if only positions are exchanged
{
if(not cuda->finished_setup || cuda->oncpu)
{AtomVecCharge::unpack_comm(n,first,buf); return;}
{AtomVecCharge::unpack_comm(n,first,buf); return;}
Cuda_CommCuda_UnpackComm(&cuda->shared_data,n,first,(void*)buf);
}
@ -172,7 +172,7 @@ void AtomVecChargeCuda::unpack_comm(int n, int first, double *buf) //usually thi
void AtomVecChargeCuda::unpack_comm_vel(int n, int first, double *buf) //usually this should not be called since comm->communicate handles the communication if only positions are exchanged
{
if(not cuda->finished_setup || cuda->oncpu)
{AtomVecCharge::unpack_comm_vel(n,first,buf); return;}
{AtomVecCharge::unpack_comm_vel(n,first,buf); return;}
Cuda_CommCuda_UnpackCommVel(&cuda->shared_data,n,first,(void*)buf);
}
@ -182,7 +182,7 @@ void AtomVecChargeCuda::unpack_comm_vel(int n, int first, double *buf) //usually
int AtomVecChargeCuda::pack_reverse(int n, int first, double *buf) //usually this should not be called since comm->communicate handles the communication if only forces are exchanged
{
if(not cuda->finished_setup || cuda->oncpu)
return AtomVecCharge::pack_reverse(n,first,buf);
return AtomVecCharge::pack_reverse(n,first,buf);
int i,m,last;
cuda->cu_f->download();
@ -202,7 +202,7 @@ int AtomVecChargeCuda::pack_reverse(int n, int first, double *buf) //usually thi
void AtomVecChargeCuda::unpack_reverse(int n, int *list, double *buf)//usually this should not be called since comm->communicate handles the communication if only forces are exchanged
{
if(not cuda->finished_setup || cuda->oncpu)
{AtomVecCharge::unpack_reverse(n,list,buf); return;}
{AtomVecCharge::unpack_reverse(n,list,buf); return;}
int i,j,m;
@ -220,24 +220,24 @@ void AtomVecChargeCuda::unpack_reverse(int n, int *list, double *buf)//usually t
/* ---------------------------------------------------------------------- */
int AtomVecChargeCuda::pack_border(int n, int *iswap, double *buf,
int pbc_flag, int *pbc)
int pbc_flag, int *pbc)
{
if(not cuda->finished_setup || cuda->oncpu)
return AtomVecCharge::pack_border(n,iswap,buf,pbc_flag,pbc);
int m = Cuda_AtomVecChargeCuda_PackBorder(&cuda->shared_data,n,*iswap,(void*) buf,pbc,pbc_flag);
return AtomVecCharge::pack_border(n,iswap,buf,pbc_flag,pbc);
int m = Cuda_AtomVecChargeCuda_PackBorder(&cuda->shared_data,n,*iswap,(void*) buf,pbc,pbc_flag);
return m;
}
int AtomVecChargeCuda::pack_border_vel(int n, int *iswap, double *buf,
int pbc_flag, int *pbc)
int pbc_flag, int *pbc)
{
if(not cuda->finished_setup || cuda->oncpu)
return AtomVecCharge::pack_border_vel(n,iswap,buf,pbc_flag,pbc);
int m = Cuda_AtomVecChargeCuda_PackBorderVel(&cuda->shared_data,n,*iswap,(void*) buf,pbc,pbc_flag);
return AtomVecCharge::pack_border_vel(n,iswap,buf,pbc_flag,pbc);
int m = Cuda_AtomVecChargeCuda_PackBorderVel(&cuda->shared_data,n,*iswap,(void*) buf,pbc,pbc_flag);
return m;
}
@ -246,10 +246,10 @@ int AtomVecChargeCuda::pack_border_vel(int n, int *iswap, double *buf,
void AtomVecChargeCuda::unpack_border(int n, int first, double *buf)
{
if(not cuda->finished_setup || cuda->oncpu)
{AtomVecCharge::unpack_border(n,first,buf); return;}
{AtomVecCharge::unpack_border(n,first,buf); return;}
while(atom->nghost+atom->nlocal+n>=cuda->shared_data.atom.nmax) //ensure there is enough space on device to unpack data
{
grow_both(0);
grow_both(0);
}
int flag=Cuda_AtomVecChargeCuda_UnpackBorder(&cuda->shared_data,n,first,(void*)buf);
if(flag) {printf(" # CUDA: Error: Failed to unpack Border atoms (This might be a bug).\n");}
@ -258,10 +258,10 @@ void AtomVecChargeCuda::unpack_border(int n, int first, double *buf)
void AtomVecChargeCuda::unpack_border_vel(int n, int first, double *buf)
{
if(not cuda->finished_setup || cuda->oncpu)
{AtomVecCharge::unpack_border_vel(n,first,buf); return;}
{AtomVecCharge::unpack_border_vel(n,first,buf); return;}
while(atom->nghost+atom->nlocal+n>=cuda->shared_data.atom.nmax) //ensure there is enough space on device to unpack data
{
grow_both(0);
grow_both(0);
}
int flag=Cuda_AtomVecChargeCuda_UnpackBorderVel(&cuda->shared_data,n,first,(void*)buf);
if(flag) {printf(" # CUDA: Error: Failed to unpack Border atoms (This might be a bug).\n");}
@ -269,74 +269,74 @@ void AtomVecChargeCuda::unpack_border_vel(int n, int first, double *buf)
/* ----------------------------------------------------------------------
pack data for atom I for sending to another proc
xyz must be 1st 3 values, so comm::exchange() can test on them
xyz must be 1st 3 values, so comm::exchange() can test on them
------------------------------------------------------------------------- */
int AtomVecChargeCuda::pack_exchange(int dim, double *buf)
{
if(cuda->oncpu)
return AtomVecCharge::pack_exchange(dim,buf);
return AtomVecCharge::pack_exchange(dim,buf);
if(not cuda_init_done||domain->box_change)
{
Cuda_AtomVecChargeCuda_Init(&cuda->shared_data);
cuda_init_done=true;
Cuda_AtomVecChargeCuda_Init(&cuda->shared_data);
cuda_init_done=true;
}
double** buf_pointer=(double**) buf;
if(*maxsend<atom->nghost || *buf_pointer==NULL)
{
grow_send(atom->nghost>*maxsend?atom->nghost:*maxsend,buf_pointer,0);
*maxsend=atom->nghost>*maxsend?atom->nghost:*maxsend;
grow_send(atom->nghost>*maxsend?atom->nghost:*maxsend,buf_pointer,0);
*maxsend=atom->nghost>*maxsend?atom->nghost:*maxsend;
}
if(max_nsend==0) grow_copylist(200);
int nsend_atoms = Cuda_AtomVecChargeCuda_PackExchangeList(&cuda->shared_data,*maxsend,dim,*buf_pointer);
if(nsend_atoms>max_nsend) grow_copylist(nsend_atoms+100);
if(nsend_atoms*NCUDAEXCHANGE>*maxsend)
if(nsend_atoms*NCUDAEXCHANGE>*maxsend)
{
grow_send((int) (nsend_atoms+100)*NCUDAEXCHANGE,buf_pointer,0);
Cuda_AtomVecChargeCuda_PackExchangeList(&cuda->shared_data,*maxsend,dim,*buf_pointer);
grow_send((int) (nsend_atoms+100)*NCUDAEXCHANGE,buf_pointer,0);
Cuda_AtomVecChargeCuda_PackExchangeList(&cuda->shared_data,*maxsend,dim,*buf_pointer);
}
int nlocal=atom->nlocal-nsend_atoms;
for(int i=0;i<nsend_atoms;i++) copylist2[i]=1;
for(int j=1;j<nsend_atoms+1;j++)
{
int i = static_cast <int> ((*buf_pointer)[j]);
if(i>=nlocal) copylist2[i-nlocal]=-1;
int i = static_cast <int> ((*buf_pointer)[j]);
if(i>=nlocal) copylist2[i-nlocal]=-1;
}
int actpos=0;
for(int j=1;j<nsend_atoms+1;j++)
{
int i = static_cast <int> ((*buf_pointer)[j]);
if(i<nlocal)
{
while(copylist2[actpos]==-1) actpos++;
copylist[j-1]=nlocal+actpos;
actpos++;
}
int i = static_cast <int> ((*buf_pointer)[j]);
if(i<nlocal)
{
while(copylist2[actpos]==-1) actpos++;
copylist[j-1]=nlocal+actpos;
actpos++;
}
}
cu_copylist->upload();
cuda->shared_data.atom.nlocal=nlocal;
int m = Cuda_AtomVecChargeCuda_PackExchange(&cuda->shared_data,nsend_atoms,*buf_pointer,cu_copylist->dev_data());
if (atom->nextra_grow)
for(int j=0;j<nsend_atoms;j++)
{
int i=static_cast <int> ((*buf_pointer)[j+1]);
int nextra=0;
for (int iextra = 0; iextra < atom->nextra_grow; iextra++) {
int dm = modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&((*buf_pointer)[m]));
m+=dm;
nextra+=dm;
nextra+=dm;
if(i<nlocal)modify->fix[atom->extra_grow[iextra]]->copy_arrays(copylist[j],i);
if(m>*maxsend) grow_send(m,buf_pointer,1);
}
@ -356,11 +356,11 @@ int AtomVecChargeCuda::pack_exchange(int dim, double *buf)
int AtomVecChargeCuda::unpack_exchange(double *buf)
{
if(cuda->oncpu)
return AtomVecCharge::unpack_exchange(buf);
return AtomVecCharge::unpack_exchange(buf);
double *sublo,*subhi;
int dim=cuda->shared_data.exchange_dim;
if(domain->box_change)
if(domain->box_change)
Cuda_AtomVecChargeCuda_Init(&cuda->shared_data);
if (domain->triclinic == 0) {
sublo = domain->sublo;
@ -376,7 +376,7 @@ int AtomVecChargeCuda::unpack_exchange(double *buf)
int nlocal = atom->nlocal;
int nsend_atoms=static_cast<int> (buf[0]);
if(nsend_atoms>max_nsend) grow_copylist(nsend_atoms+100);
if (nlocal+nsend_atoms+atom->nghost>=atom->nmax) grow_both(nlocal+nsend_atoms*2+atom->nghost);
int naccept = Cuda_AtomVecChargeCuda_UnpackExchange(&cuda->shared_data,nsend_atoms,buf,cu_copylist->dev_data());
cu_copylist->download();
@ -387,9 +387,9 @@ int AtomVecChargeCuda::unpack_exchange(double *buf)
{
if(copylist[j]>-1)
{
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(copylist[j],&buf[m]);
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(copylist[j],&buf[m]);
}
else
m+=static_cast <int> (buf[j+1]);
@ -402,6 +402,3 @@ int AtomVecChargeCuda::unpack_exchange(double *buf)
}
return mfirst;
}