Index: src/CUDAVolCPotential.cu =================================================================== RCS file: /vmd/cvsroot/vmd/src/CUDAVolCPotential.cu,v retrieving revision 1.26 diff -u -r1.26 CUDAVolCPotential.cu --- src/CUDAVolCPotential.cu 27 Mar 2008 19:37:42 -0000 1.26 +++ src/CUDAVolCPotential.cu 28 Jan 2009 12:24:27 -0000 @@ -29,7 +29,6 @@ typedef struct { int threadid; - int threadcount; float* atoms; float* grideners; long int numplane; @@ -37,6 +36,8 @@ long int numpt; long int natoms; float gridspacing; + vmd_mutex_t *loopmutex; + int *loopindex; } enthrparms; /* thread prototype */ @@ -226,6 +227,8 @@ int i; enthrparms *parms; vmd_thread_t * threads; + int loopindex = 0; // global loop index for all threads + vmd_mutex_t loopmutex; // mutex protecting global loop index vmd_timerhandle globaltimer; double totalruntime; @@ -252,11 +255,12 @@ /* allocate array of threads */ threads = (vmd_thread_t *) calloc(numprocs * sizeof(vmd_thread_t), 1); + vmd_mutex_init(&loopmutex); + /* allocate and initialize array of thread parameters */ parms = (enthrparms *) malloc(numprocs * sizeof(enthrparms)); for (i=0; inatoms; const float gridspacing = parms->gridspacing; const int threadid = parms->threadid; - const int threadcount = parms->threadcount; + vmd_mutex_t *loopmutex = parms->loopmutex; + int *i = parms->loopindex; double lasttime, totaltime; cudaSetDevice(threadid); @@ -389,8 +398,12 @@ // For each point in the cube... int iterations=0; - int k; - for (k=threadid; k