sync Kokkos changes with current master

This commit is contained in:
Steve Plimpton
2021-08-17 14:12:47 -06:00
4 changed files with 95 additions and 36 deletions

View File

@ -257,48 +257,101 @@ void AtomKokkos::grow(unsigned int mask)
return index in ivector or dvector of its location
------------------------------------------------------------------------- */
int AtomKokkos::add_custom(const char *name, int flag)
int AtomKokkos::add_custom(const char *name, int flag, int cols)
{
int index;
if (flag == 0) {
if (flag == 0 && cols == 0) {
index = nivector;
nivector++;
iname = (char **) memory->srealloc(iname, nivector * sizeof(char *), "atom:iname");
iname[index] = utils::strdup(name);
ivector = (int **) memory->srealloc(ivector, nivector * sizeof(int *), "atom:ivector");
memory->create(ivector[index], nmax, "atom:ivector");
} else {
ivname = (char **) memory->srealloc(ivname,nivector*sizeof(char *),
"atom:ivname");
int n = strlen(name) + 1;
ivname[index] = new char[n];
strcpy(ivname[index],name);
ivector = (int **) memory->srealloc(ivector,nivector*sizeof(int *),
"atom:ivector");
memory->create(ivector[index],nmax,"atom:ivector");
} else if (flag == 1 && cols == 0) {
index = ndvector;
ndvector++;
dname = (char **) memory->srealloc(dname, ndvector * sizeof(char *), "atom:dname");
dname[index] = utils::strdup(name);
this->sync(Device, DVECTOR_MASK);
memoryKK->grow_kokkos(k_dvector, dvector, ndvector, nmax, "atom:dvector");
this->modified(Device, DVECTOR_MASK);
}
dvname = (char **) memory->srealloc(dvname,ndvector*sizeof(char *),
"atom:dvname");
int n = strlen(name) + 1;
dvname[index] = new char[n];
strcpy(dvname[index],name);
dvector = (double **) memory->srealloc(dvector,ndvector*sizeof(double *),
"atom:dvector");
this->sync(Device,DVECTOR_MASK);
memoryKK->grow_kokkos(k_dvector,dvector,ndvector,nmax,
"atom:dvector");
this->modified(Device,DVECTOR_MASK);
} else if (flag == 0 && cols) {
index = niarray;
niarray++;
ianame = (char **) memory->srealloc(ianame,niarray*sizeof(char *),
"atom:ianame");
int n = strlen(name) + 1;
ianame[index] = new char[n];
strcpy(ianame[index],name);
iarray = (int ***) memory->srealloc(iarray,niarray*sizeof(int **),
"atom:iarray");
memory->create(iarray[index],nmax,cols,"atom:iarray");
icols = (int *) memory->srealloc(icols,niarray*sizeof(int),"atom:icols");
icols[index] = cols;
} else if (flag == 1 && cols) {
index = ndarray;
ndarray++;
daname = (char **) memory->srealloc(daname,ndarray*sizeof(char *),
"atom:daname");
int n = strlen(name) + 1;
daname[index] = new char[n];
strcpy(daname[index],name);
darray = (double ***) memory->srealloc(darray,ndarray*sizeof(double **),
"atom:darray");
memory->create(darray[index],nmax,cols,"atom:darray");
dcols = (int *) memory->srealloc(dcols,ndarray*sizeof(int),"atom:dcols");
dcols[index] = cols;
}
return index;
}
/* ----------------------------------------------------------------------
remove a custom variable of type flag = 0/1 for int/double at index
free memory for vector and name and set ptrs to a null pointer
ivector/dvector and iname/dname lists never shrink
free memory for vector/array and name and set ptrs to a null pointer
these lists never shrink
------------------------------------------------------------------------- */
void AtomKokkos::remove_custom(int flag, int index)
void AtomKokkos::remove_custom(int index, int flag, int cols)
{
if (flag == 0) {
if (flag == 0 && cols == 0) {
memory->destroy(ivector[index]);
ivector[index] = nullptr;
delete[] iname[index];
iname[index] = nullptr;
} else {
//memoryKK->destroy_kokkos(dvector);
dvector[index] = nullptr;
delete[] dname[index];
dname[index] = nullptr;
ivector[index] = NULL;
delete [] ivname[index];
ivname[index] = NULL;
} else if (flag == 1 && cols == 0) {
dvector[index] = NULL;
delete [] dvname[index];
dvname[index] = NULL;
} else if (flag == 0 && cols) {
memory->destroy(iarray[index]);
iarray[index] = NULL;
delete [] ianame[index];
ianame[index] = NULL;
} else if (flag == 1 && cols) {
memory->destroy(darray[index]);
darray[index] = NULL;
delete [] daname[index];
daname[index] = NULL;
}
}

View File

@ -111,8 +111,8 @@ class AtomKokkos : public Atom {
void sync_overlapping_device(const ExecutionSpace space, unsigned int mask);
virtual void sort();
virtual void grow(unsigned int mask);
int add_custom(const char *, int);
void remove_custom(int, int);
int add_custom(const char *, int, int);
void remove_custom(int, int, int);
virtual void deallocate_topology();
void sync_modify(ExecutionSpace, unsigned int, unsigned int);
private:

View File

@ -1788,7 +1788,7 @@ void PairExp6rxKokkos<DeviceType>::read_file(char *file)
while ((words[nwords++] = strtok(nullptr," \t\n\r\f"))) continue;
for (ispecies = 0; ispecies < nspecies; ispecies++)
if (strcmp(words[0],&atom->dname[ispecies][0]) == 0) break;
if (strcmp(words[0],&atom->dvname[ispecies][0]) == 0) break;
if (ispecies == nspecies) continue;
// load up parameter settings and error check their values
@ -1801,8 +1801,9 @@ void PairExp6rxKokkos<DeviceType>::read_file(char *file)
}
params[nparams].ispecies = ispecies;
params[nparams].name = utils::strdup(&atom->dname[ispecies][0]);
params[nparams].name = utils::strdup(&atom->dvname[ispecies][0]);
params[nparams].potential = utils::strdup(words[1]);
if (strcmp(params[nparams].potential,"exp6") == 0) {
params[nparams].alpha = atof(words[2]);
params[nparams].epsilon = atof(words[3]);

View File

@ -1048,15 +1048,20 @@ void PairTableRXKokkos<DeviceType>::coeff(int narg, char **arg)
site1 = utils::strdup(arg[4]);
int ispecies;
for (ispecies = 0; ispecies < nspecies; ispecies++)
if (strcmp(site1,&atom->dname[ispecies][0]) == 0) break;
for (ispecies = 0; ispecies < nspecies; ispecies++) {
if (strcmp(site1,&atom->dvname[ispecies][0]) == 0) break;
}
if (ispecies == nspecies && strcmp(site1,"1fluid") != 0)
error->all(FLERR,"Site1 name not recognized in pair coefficients");
site2 = utils::strdup(arg[5]);
for (ispecies = 0; ispecies < nspecies; ispecies++)
if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break;
n = strlen(arg[5]) + 1;
site2 = new char[n];
strcpy(site2,arg[5]);
for (ispecies = 0; ispecies < nspecies; ispecies++) {
if (strcmp(site2,&atom->dvname[ispecies][0]) == 0) break;
}
if (ispecies == nspecies && strcmp(site2,"1fluid") != 0)
error->all(FLERR,"Site2 name not recognized in pair coefficients");
@ -1123,7 +1128,7 @@ void PairTableRXKokkos<DeviceType>::coeff(int narg, char **arg)
isite1 = nspecies;
for (int k = 0; k < nspecies; k++) {
if (strcmp(site1, atom->dname[k]) == 0) {
if (strcmp(site1, atom->dvname[k]) == 0) {
isite1 = k;
break;
}
@ -1138,7 +1143,7 @@ void PairTableRXKokkos<DeviceType>::coeff(int narg, char **arg)
isite2 = nspecies;
for (int k = 0; k < nspecies; k++) {
if (strcmp(site2, atom->dname[k]) == 0) {
if (strcmp(site2, atom->dvname[k]) == 0) {
isite2 = ispecies;
break;
}