I'm a beginner at using Julia and I have written a simple molecular dynamic simulation, which works quite well and fast.
Now I'm trying to parallelize my core loop which calculates the forces between each pair of particles. My loop is: for partA = 1:nParts-1 for partB = (partA+1):nParts # Calculate particle-particle distance dr = coords[:,partA] - coords[:,partB]; dr2 = dot(dr,dr) invDr2 = 1.0/dr2; invDr6 = invDr2^3; tforce = invDr2^4 * (invDr6 - 0.5); forces[:,partA] = forces[:,partA] + dr* tforce ; forces[:,partB] = forces[:,partB] - dr* tforce ; end end coords is a array holding the 3 dimensional coordinates for each particle. nParts is the number of particles and forces has the same size as coords and holds the forces for each particle. I tried @parallel for with different reduction operators (I found + and vcat, of course with changing my loop a little bit) which are not documented very well. At least I only found examples for (+) in the help. What is the best way to parallelize this?
