Commit 6efb9622 authored by Yaroslav Gevorkov's avatar Yaroslav Gevorkov
Browse files

add thread count to openMP

parent f1827cdd
......@@ -50,6 +50,7 @@ endif(PINKINDEXER_BUILD_EXECUTABLE)
if(OpenMP_CXX_FOUND)
target_link_libraries(pinkIndexer PUBLIC OpenMP::OpenMP_CXX)
add_definitions(-DOPENMP_AVAILABLE)
endif(OpenMP_CXX_FOUND)
if(EIGEN3_FOUND)
......
......@@ -58,7 +58,7 @@ namespace pinkIndexer
void reducePeakCount(Eigen::Matrix3Xf& ucsDirections, Eigen::Array2Xf& ucsBorderNorms, Eigen::RowVectorXf& intensities,
const Eigen::Matrix2Xf& detectorPeaks_m);
void refine(Lattice& indexedLattice, Eigen::Vector2f& centerShift, const Eigen::Matrix3Xf& ucsDirections, const Eigen::Array2Xf& ucsBorderNorms,
const Eigen::Matrix2Xf& detectorPeaks_m);
const Eigen::Matrix2Xf& detectorPeaks_m, int threadCount);
float getAngleResolution();
int getConsideredPeaksCount();
......
......@@ -4,6 +4,10 @@
#include <fstream>
#include <numeric>
#ifdef OPENMP_AVAILABLE
#include <omp.h>
#endif
using namespace std;
using namespace Eigen;
......@@ -72,7 +76,7 @@ namespace pinkIndexer
Matrix3f bestBasis = bestRotation * sampleLattice.getBasis();
indexedLattice = Lattice(bestBasis);
refine(indexedLattice, centerShift, ucsDirections, ucsBorderNorms, detectorPeaks_m);
refine(indexedLattice, centerShift, ucsDirections, ucsBorderNorms, detectorPeaks_m, threadCount);
indexedLattice.minimize();
indexedLattice.reorder(sampleLattice);
......@@ -83,7 +87,7 @@ namespace pinkIndexer
}
void PinkIndexer::refine(Lattice& indexedLattice, Vector2f& centerShift, const Matrix3Xf& ucsDirections, const Array2Xf& ucsBorderNorms,
const Matrix2Xf& detectorPeaks_m)
const Matrix2Xf& detectorPeaks_m, int threadCount)
{
centerShift.setZero();
......@@ -120,6 +124,10 @@ namespace pinkIndexer
float maxRelativeDeviation = 0.0125;
Array<float, 1, 3> columnDeviationNorms = indexedLattice.getBasis().colwise().norm() * maxRelativeDeviation;
#ifdef OPENMP_AVAILABLE
omp_set_num_threads(threadCount);
#endif
#pragma omp parallel for
for (int i = 0; i < refinementTries; ++i)
{
......@@ -174,6 +182,10 @@ namespace pinkIndexer
float maxRelativeDeviation = 0.0125;
Array<float, 1, 3> columnDeviationNorms = indexedLattice.getBasis().colwise().norm() * maxRelativeDeviation;
#ifdef OPENMP_AVAILABLE
omp_set_num_threads(threadCount);
#endif
#pragma omp parallel for
for (int i = 0; i < refinementTries; ++i)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment