X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=potentials%2Falbe_fast.c;h=05502c603f0d41da1aa7a612e387c77c8415ebfc;hb=b4628acf6967b179451bd36f74c2ba312590ecbf;hp=46102303d364ca038496753053a16a056c0403eb;hpb=452a348351ae8a2255809918a05683d2510655ce;p=physik%2Fposic.git diff --git a/potentials/albe_fast.c b/potentials/albe_fast.c index 4610230..05502c6 100644 --- a/potentials/albe_fast.c +++ b/potentials/albe_fast.c @@ -29,6 +29,13 @@ #include "../math/math.h" #include "albe.h" +#ifdef PTHREADS +typedef struct s_kdata { + t_moldyn *moldyn; + t_atom *itom,*jtom; +} t_kdata; +#endif + /* * virial calculation */ @@ -169,6 +176,11 @@ int albe_potential_force_calc(t_moldyn *moldyn) { #endif u8 bc_ij,bc_ik; int dnlc; +#ifdef PTHREADS + int ret; + t_kdata kdata[27]; + pthread_t kthread[27]; +#endif // needed to work t_atom *ai; @@ -354,6 +366,17 @@ int albe_potential_force_calc(t_moldyn *moldyn) { /* first loop over atoms k */ for(k=0;k<27;k++) { +#ifdef PTHREADS + // create threads + kdata.moldyn=moldyn; + kdata.jtom=jtom; + kdata.itom=&(itom[i]); + ret=pthread_create(&(kthread[k]),NULL,k1_thread,&(kdata[k])); + if(ret) { + perror("[albe fast] thread create"); + return ret; + } +#else bc_ik=(k