From: hackbard Date: Mon, 1 Sep 2008 14:23:14 +0000 (+0200) Subject: fixed static lists + first work on lowmem lists X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=e3e1d8e2f7fc65748c8da0accb9b3e6b0b1eb049;p=physik%2Fposic.git fixed static lists + first work on lowmem lists --- diff --git a/moldyn.c b/moldyn.c index b73cd34..7a9709e 100644 --- a/moldyn.c +++ b/moldyn.c @@ -1308,6 +1308,8 @@ int link_cell_init(t_moldyn *moldyn,u8 vol) { #ifdef STATIC_LISTS lc->subcell=malloc(lc->cells*sizeof(int*)); +#elif LOWMEM_LIST + lc->subcell=malloc(t_lowmem_list); #else lc->subcell=malloc(lc->cells*sizeof(t_list)); #endif @@ -1325,6 +1327,9 @@ int link_cell_init(t_moldyn *moldyn,u8 vol) { #ifdef STATIC_LISTS printf("[moldyn] initializing 'static' linked cells (%d)\n", lc->cells); +#elif LOWMEM_LIST + printf("[moldyn] initializing 'lowmem' linked cells (%d)\n", + lc->cells); #else printf("[moldyn] initializing 'dynamic' linked cells (%d)\n", lc->cells); @@ -1348,6 +1353,17 @@ int link_cell_init(t_moldyn *moldyn,u8 vol) { i,lc->subcell[0],lc->subcell); */ } +#elif LOWMEM_LIST + lc->subcell->head=malloc(lc->cells*sizeof(int)); + if(lc->subcell->head==NULL) { + perror("[moldyn] head init (malloc)"); + return -1; + } + lc->subcell->list=malloc(moldyn->count*sizeof(int)); + if(lc->subcell->list==NULL) { + perror("[moldyn] list init (malloc)"); + return -1; + } #else for(i=0;icells;i++) list_init_f(&(lc->subcell[i])); @@ -1377,7 +1393,9 @@ int link_cell_update(t_moldyn *moldyn) { for(i=0;icells;i++) #ifdef STATIC_LISTS - memset(lc->subcell[i],0,(MAX_ATOMS_PER_LIST+1)*sizeof(int)); + memset(lc->subcell[i],-1,(MAX_ATOMS_PER_LIST+1)*sizeof(int)); +#elif LOWMEM_LIST + lc->subcell->head[i]=-1; #else list_destroy_f(&(lc->subcell[i])); #endif @@ -1389,7 +1407,7 @@ int link_cell_update(t_moldyn *moldyn) { #ifdef STATIC_LISTS p=0; - while(lc->subcell[i+j*nx+k*nx*ny][p]!=0) + while(lc->subcell[i+j*nx+k*nx*ny][p]!=-1) p++; if(p>=MAX_ATOMS_PER_LIST) { @@ -1398,6 +1416,9 @@ int link_cell_update(t_moldyn *moldyn) { } lc->subcell[i+j*nx+k*nx*ny][p]=count; +#elif LOWMEM_LIST + lc->subcell->list[count]=list->subcell->head[i+j*nx+k*nx*ny]; + list->subcell->head=count; #else list_add_immediate_f(&(lc->subcell[i+j*nx+k*nx*ny]), &(atom[count])); @@ -1851,6 +1872,7 @@ int potential_force_calc(t_moldyn *moldyn) { /* reset force, site energy and virial of every atom */ #ifdef PARALLEL + i=omp_get_thread_num(); #pragma omp parallel for private(virial) #endif for(i=0;iatom[neighbour[j][p]]); p++; diff --git a/potentials/albe_fast.c b/potentials/albe_fast.c index 6331064..4523938 100644 --- a/potentials/albe_fast.c +++ b/potentials/albe_fast.c @@ -171,7 +171,7 @@ int albe_potential_force_calc(t_moldyn *moldyn) { #ifdef STATIC_LISTS p=0; - while(neighbour_i[j][p]!=0) { + while(neighbour_i[j][p]!=-1) { jtom=&(atom[neighbour_i[j][p]]); p++; @@ -236,7 +236,7 @@ int albe_potential_force_calc(t_moldyn *moldyn) { #ifdef STATIC_LISTS q=0; - while(neighbour_i[j][q]!=0) { + while(neighbour_i[k][q]!=-1) { ktom=&(atom[neighbour_i[k][q]]); q++; @@ -466,7 +466,7 @@ if(moldyn->time>DSTART&&moldyn->time