#endif
u8 bc_ij,bc_ik;
int dnlc;
-#ifdef PTHREADS
- int ret;
- pthread_t kthread[27];
- t_kdata kdata[27];
-#endif
count=moldyn->count;
itom=moldyn->atom;
atom=moldyn->atom;
#endif
-#ifdef PTHREADS
- memset(kdata,0,27*sizeof(t_kdata));
-#endif
-
/* reset energy */
moldyn->energy=0.0;
continue;
/* first loop over atoms k */
-#ifndef PTHREADS
if(moldyn->func3b_k1) {
-#endif
for(k=0;k<27;k++) {
if(ktom==&(itom[i]))
continue;
-#ifdef PTHREADS
- kdata[k].moldyn=moldyn;
- kdata[k].ai=&(itom[i]);
- kdata[k].aj=jtom;
- kdata[k].ak=ktom;
- kdata[k].bc=bc_ik;
- ret=pthread_create(&(kthread[k]),NULL,moldyn->func3b_k1,&(kdata[k]));
- if(ret) {
- perror("[moldyn] create k1 thread");
- return ret;
- }
-#else
moldyn->func3b_k1(moldyn,
&(itom[i]),
jtom,
ktom,
bc_ik|bc_ij);
-#endif
#ifdef STATIC_LISTS
}
}
-#ifndef PTHREADS
}
-#endif
if(moldyn->func3b_j2)
moldyn->func3b_j2(moldyn,
int (*func3b_j1)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
int (*func3b_j2)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
int (*func3b_j3)(struct s_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
-#ifdef PTHREADS
- void *(*func3b_k1)(void *ptr);
-#else
int (*func3b_k1)(struct s_moldyn *moldyn,
t_atom *ai,t_atom *aj,t_atom *ak,u8 bck);
-#endif
int (*func3b_k2)(struct s_moldyn *moldyn,
t_atom *ai,t_atom *aj,t_atom *ak,u8 bck);
void *pot_params;
}
/* albe 3 body potential function (first k loop) */
-#ifdef PTHREADS
-void *albe_mult_3bp_k1(void *ptr) {
-#else
int albe_mult_3bp_k1(t_moldyn *moldyn,
t_atom *ai,t_atom *aj,t_atom *ak,u8 bc) {
-#endif
t_albe_mult_params *params;
t_albe_exchange *exchange;
double cos_theta,h_cos,d2_h_cos2,frac,g,dg,s_r,arg;
double f_c_ik,df_c_ik;
int kcount;
-#ifdef PTHREADS
- t_kdata *kdata;
- t_moldyn *moldyn;
- t_atom *ai,*aj,*ak;
- u8 bc;
-
- kdata=ptr;
- moldyn=kdata->moldyn;
- ai=kdata->ai;
- aj=kdata->aj;
- ak=kdata->ak;
- bc=kdata->bc;
-#endif
params=moldyn->pot_params;
exchange=&(params->exchange);
/* increase k counter */
exchange->kcount++;
-#ifdef PTHREADS
-}
-#else
return 0;
}
-#endif
int albe_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) {
t_albe_exchange exchange; /* exchange between 2bp and 3bp calc */
} t_albe_mult_params;
-#ifdef PTHREADS
-typedef struct s_kdata {
- t_moldyn *moldyn;
- t_atom *ai,*aj,*ak;
- unsigned char bc;
-} t_kdata;
-#endif
-
/* function prototypes */
int albe_mult_set_params(t_moldyn *moldyn,int element1,int elemnt2);
int albe_mult_3bp_j1(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
-#ifdef PTHREADS
-void *albe_mult_3bp_k1(void *ptr);
-#else
int albe_mult_3bp_k1(t_moldyn *moldyn,
t_atom *ai,t_atom *aj,t_atom *ak,u8 bc);
-#endif
int albe_mult_3bp_j2(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc);
int albe_mult_3bp_k2(t_moldyn *moldyn,
t_atom *ai,t_atom *aj,t_atom *ak,u8 bc);
#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
*/
#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;
/* 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<dnlc)?0:1;
#ifdef STATIC_LISTS
q=0;
/* increase k counter */
kcount++;
-#endif // PTHREADS
-
#ifdef STATIC_LISTS
}
#elif LOWMEM_LISTS
L_NO_NEXT_ELEMENT);
#endif
+#endif // PTHREADS
+
}
+#ifdef PTHREADS
+ // join threads
+ for(k=0;k<27;k++) {
+ ret=pthread_join(kthread[k],NULL);
+ if(ret) {
+ perror("[albe fast] join thread");
+ return ret;
+ }
+ }
+#endif
+
/* j2 func here ... */