projects
/
physik
/
posic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pthreads -> albe fast (beginning)
[physik/posic.git]
/
potentials
/
albe_fast.c
diff --git
a/potentials/albe_fast.c
b/potentials/albe_fast.c
index
4610230
..
05502c6
100644
(file)
--- a/
potentials/albe_fast.c
+++ b/
potentials/albe_fast.c
@@
-29,6
+29,13
@@
#include "../math/math.h"
#include "albe.h"
#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
*/
/*
* virial calculation
*/
@@
-169,6
+176,11
@@
int albe_potential_force_calc(t_moldyn *moldyn) {
#endif
u8 bc_ij,bc_ik;
int dnlc;
#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;
// 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++) {
/* 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;
bc_ik=(k<dnlc)?0:1;
#ifdef STATIC_LISTS
q=0;
@@
-494,8
+517,6
@@
int albe_potential_force_calc(t_moldyn *moldyn) {
/* increase k counter */
kcount++;
/* increase k counter */
kcount++;
-#endif // PTHREADS
-
#ifdef STATIC_LISTS
}
#elif LOWMEM_LISTS
#ifdef STATIC_LISTS
}
#elif LOWMEM_LISTS
@@
-505,8
+526,21
@@
int albe_potential_force_calc(t_moldyn *moldyn) {
L_NO_NEXT_ELEMENT);
#endif
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 ... */
/* j2 func here ... */