]> hackdaworld.org Git - physik/posic.git/commitdiff
virial calc define + default amount threads -> 2
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Thu, 30 Oct 2008 10:51:14 +0000 (11:51 +0100)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Thu, 30 Oct 2008 10:51:14 +0000 (11:51 +0100)
potentials/albe_fast.c

index 603606e6b9ce081e108f64d7b33f544d009e35d9..0db5f66ea3c1596a3115dc62bbf862947e9d18b0 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifdef PTHREADS
 #include <pthread.h>
-#define MAX_THREADS 4
+#define MAX_THREADS 2
 #endif
 
 #include "../moldyn.h"
@@ -39,12 +39,12 @@ extern pthread_mutex_t emutex;
  * virial calculation
  */
 
-#define albe_v_calc(a,f,d)     a->virial.xx+=f->x*d->x; \
-                               a->virial.yy+=f->y*d->y; \
-                               a->virial.zz+=f->z*d->z; \
-                               a->virial.xy+=f->x*d->y; \
-                               a->virial.xz+=f->x*d->z; \
-                               a->virial.yz+=f->y*d->z
+#define albe_v_calc(a,f,d)     (a)->virial.xx+=(f)->x*(d)->x; \
+                               (a)->virial.yy+=(f)->y*(d)->y; \
+                               (a)->virial.zz+=(f)->z*(d)->z; \
+                               (a)->virial.xy+=(f)->x*(d)->y; \
+                               (a)->virial.xz+=(f)->x*(d)->z; \
+                               (a)->virial.yz+=(f)->y*(d)->z
 
 #ifndef PTHREADS
 
@@ -461,7 +461,8 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
        v3_add(&(jtom->f),&(jtom->f),&force);
 
        /* virial */
-       virial_calc(ai,&force,&(dist_ij));
+       albe_v_calc(ai,&force,&(dist_ij));
+       //virial_calc(ai,&force,&(dist_ij));
 
 #ifdef DEBUG
 if(moldyn->time>DSTART&&moldyn->time<DEND) {
@@ -595,7 +596,8 @@ if(moldyn->time>DSTART&&moldyn->time<DEND) {
 #endif
 
        /* virial */
-       virial_calc(ai,&force,&dist_ij);
+       albe_v_calc(ai,&force,&dist_ij);
+       //virial_calc(ai,&force,&dist_ij);
 
        /* force contribution to atom i */
        v3_scale(&force,&force,-1.0);
@@ -623,7 +625,8 @@ if(moldyn->time>DSTART&&moldyn->time<DEND) {
 #endif
 
        /* virial */
-       virial_calc(ai,&force,&dist_ik);
+       albe_v_calc(ai,&force,&dist_ik);
+       //virial_calc(ai,&force,&dist_ik);
        
        /* force contribution to atom i */
        v3_scale(&force,&force,-1.0);
@@ -1094,7 +1097,8 @@ void *potential_force_thread(void *ptr) {
 
        /* virial */
        pthread_mutex_lock(&(amutex[ai->tag])); 
-       virial_calc(ai,&force,&(dist_ij));
+       albe_v_calc(ai,&force,&(dist_ij));
+       //virial_calc(ai,&force,&(dist_ij));
        pthread_mutex_unlock(&(amutex[ai->tag]));       
 
 #ifdef DEBUG
@@ -1236,7 +1240,8 @@ if(moldyn->time>DSTART&&moldyn->time<DEND) {
 
        /* virial */
        pthread_mutex_lock(&(amutex[ai->tag])); 
-       virial_calc(ai,&force,&dist_ij);
+       albe_v_calc(ai,&force,&dist_ij);
+       //virial_calc(ai,&force,&dist_ij);
 
        /* force contribution to atom i */
        v3_scale(&force,&force,-1.0);
@@ -1268,7 +1273,8 @@ if(moldyn->time>DSTART&&moldyn->time<DEND) {
 
        /* virial */
        pthread_mutex_lock(&(amutex[ai->tag])); 
-       virial_calc(ai,&force,&dist_ik);
+       albe_v_calc(ai,&force,&dist_ik);
+       //virial_calc(ai,&force,&dist_ik);
        
        /* force contribution to atom i */
        v3_scale(&force,&force,-1.0);
@@ -1368,7 +1374,7 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
 
                /* prepare thread data */
                pft_data[j].moldyn=moldyn;
-               pft_data[j].start=j*count/MAX_THREADS;
+               pft_data[j].start=j*(count/MAX_THREADS);
                if(j==MAX_THREADS-1) {
                        pft_data[j].end=count;
                }