KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to parallelize the loop in the following function with OpenMP void CEnergymulti::forcetwobody(vector<CMolecule*> m_mols,CPnt force0,CPnt torque0) { const int nmol=m_mols.size(); vector<CMolecule*> twomols(2); CPnt forcetemp,torquetemp; twomols.clear(); force0.zero(); torque0.zero(); forcetemp.zero(); torquetemp.zero(); #pragma omp parallel for reduction(+:force0,torque0) private(twomols) for(int j=1;j<nmol;j++) { twomols.push_back(m_mols[0]); twomols.push_back(m_mols[j]); CMolecule::polarize_mutual(twomols,false, 1000); twomols[0]->computeMol_Force_and_Torque(forcetemp,torquetemp); force0+=forcetemp; torque0+=torquetemp; forcetemp.zero(); torquetemp.zero(); twomols.clear(); } REAL converter=COUL_K*IKbT; force0*=converter; torque0*=converter; return; } When I compile the code, it gives the following message: EnergyD_multi.cpp: In static member function ‘static void CEnergymulti::forcetwobody(std::vector<CMolecule*, std::allocator<CMolecule*> >, CPnt, CPnt)’: EnergyD_multi.cpp:226: error: ‘torque0’ has invalid type for ‘reduction’ EnergyD_multi.cpp:226: error: ‘force0’ has invalid type for ‘reduction’ I understand that variables 'force0' and 'torque0' are neither double or integer type of data, but of type 'CPnt', a class that is defined to represent three-dimensional vectors in space. For class 'CPnt', operator '+' and '-' have already been defined by operator overloading. So my questions is: is it true that reduction in OpenMP cannot handle such overloaded operators? Is there any alternate ways to parallelize this loop with OpenMP without doing reduction on each component of 'force0' and 'torque0'? Thanks a lot.
Tags (comma-separated)
Save Edits
Cancel