From c78004bcfacb0dc6399647027b3b1acc013db153 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Sat, 23 Nov 2013 22:36:04 +0000
Subject: [PATCH] Think I found a bug. Fixed it kindof. But neigh of vtx are still buggy. Don't know why

---
 src/timestep.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/timestep.c b/src/timestep.c
index 30d6406..4fa9625 100644
--- a/src/timestep.c
+++ b/src/timestep.c
@@ -2,7 +2,7 @@
 #include<stdio.h>
 #include<math.h>
 #include<pthread.h>
-#include<unistd.h> //usleep requires it
+//#include<unistd.h> //usleep requires it
 //#include "io.h"
 #include "general.h"
 #include "timestep.h"
@@ -76,20 +76,22 @@
         rnvec[0]=drand48();
         rnvec[1]=drand48();
         rnvec[2]=drand48();
+//TODO: you only need to taint (lock) vertices, that could be shared with another partition. You can leave out the rest. How can you test for that? Well, if any of vtx neighbours are in other partition, then you need to lock vertex and that neighbor. Otherwise not!
 
 	/**** THREAD IS POTENTIALLY LOCKED ******/
 	pthread_mutex_lock(data->vtx_tainting_lock); //taint if no other process is tainting or wait until you can taint
 	//	ts_fprintf(stdout, "thID=%d:: Tainting vertex %d, level=%d. Waiting....\n",thID, i, vesicle->vlist->vtx[i]->locked);
 
 	while(vertex_tainted(vesicle->vlist->vtx[i],1,1)){
-		ts_fprintf(stdout, "thID=%d:: Vertex %d is tainted, so I cannot try vertexmove. Level=%d. BU(H)TELJ!\n   neigh. vtxs: ",thID, i, vesicle->vlist->vtx[i]->locked);
+		ts_fprintf(stdout, "thID=%d:: Vertex %d is tainted, so I cannot try vertexmove. Amount=%d. BU(H)TELJ!\n       neigh. vtxs: ",thID, i, vesicle->vlist->vtx[i]->locked);
 		for(j=0; j<vesicle->vlist->vtx[i]->neigh_no; j++){
-			ts_fprintf(stdout, "%d ", vesicle->vlist->vtx[i]->neigh[j]->idx);
+			ts_fprintf(stdout, "%d(a=%d) ", vesicle->vlist->vtx[i]->neigh[j]->idx,  vesicle->vlist->vtx[i]->neigh[j]->locked);
 		}
-		ts_fprintf(stdout, ".\n");
+		ts_fprintf(stdout, ".\n"); 
 	}
+	
 	pthread_mutex_lock(data->vtx_untainting_lock);
-	vertex_taint(vesicle->vlist->vtx[i],2);
+	vertex_taint(vesicle->vlist->vtx[i],1);
 	pthread_mutex_unlock(data->vtx_untainting_lock);
 
 	pthread_mutex_unlock(data->vtx_tainting_lock);
@@ -97,7 +99,7 @@
 
         single_verticle_timestep(vesicle,vesicle->vlist->vtx[i],rnvec);
 	pthread_mutex_lock(data->vtx_untainting_lock);
-	vertex_untaint(vesicle->vlist->vtx[i],2);
+	vertex_untaint(vesicle->vlist->vtx[i],1);
 	pthread_mutex_unlock(data->vtx_untainting_lock);
 //		ts_fprintf(stdout, "Vertex %d should be untainted, level=%d.\n", i, vesicle->vlist->vtx[i]->locked);
     }

--
Gitblit v1.9.3