Commit c6084316 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

Operators.h: disable threading if !blasIsThreadSafe

parent 047c094c
......@@ -356,8 +356,7 @@ public:
}
RealType truncateBasis(const typename PsimagLite::Vector<RealType>::Type& eigs,
const VectorSizeType& removedIndices,
SizeType initialSizeOfHashTable)
const VectorSizeType& removedIndices)
{
dmrgTransformed_=true;
......
......@@ -189,12 +189,11 @@ public:
const typename PsimagLite::Vector<RealType>::Type& eigs,
const VectorSizeType& removedIndices,
const PairSizeSizeType& startEnd,
SizeType initialSizeOfHashTable)
bool blasIsThreadSafe)
{
BasisType &parent = *this;
RealType error = parent.truncateBasis(eigs,removedIndices, initialSizeOfHashTable);
RealType error = BasisType::truncateBasis(eigs, removedIndices);
operators_.changeBasis(ftransform,this,startEnd);
operators_.changeBasis(ftransform, this, startEnd, blasIsThreadSafe);
return error;
}
......
......@@ -316,10 +316,14 @@ public:
void changeBasis(const BlockDiagonalMatrixType& ftransform,
const BasisType* thisBasis,
const PairSizeSizeType& startEnd)
const PairSizeSizeType& startEnd,
bool blasIsThreadSafe)
{
typedef PsimagLite::Parallelizer<MyLoop> ParallelizerType;
ParallelizerType threadObject(PsimagLite::Concurrency::codeSectionParams);
SizeType threads = (blasIsThreadSafe) ? PsimagLite::Concurrency::
codeSectionParams.npthreads : 1;
PsimagLite::CodeSectionParams codeSectionParams(threads);
ParallelizerType threadObject(codeSectionParams);
MyLoop helper(reducedOpImpl_,operators_,ftransform,thisBasis,startEnd);
......
......@@ -159,11 +159,11 @@ public:
if (direction == ProgramGlobals::DirectionEnum::EXPAND_SYSTEM) {
changeBasis(pS,target,keptStates,direction, &dmS);
assert(dmS);
truncateBasis(pS,lrs_.right(), *dmS, direction, keptStates);
truncateBasis(pS,lrs_.right(), *dmS, direction);
} else {
changeBasis(pE,target,keptStates,direction, &dmS);
assert(dmS);
truncateBasis(pE,lrs_.left(), *dmS, direction, keptStates);
truncateBasis(pE,lrs_.left(), *dmS, direction);
}
delete dmS;
......@@ -194,8 +194,7 @@ public:
truncateBasis(sBasis,
lrs_.right(),
*dmS,
ProgramGlobals::DirectionEnum::EXPAND_SYSTEM,
keptStates);
ProgramGlobals::DirectionEnum::EXPAND_SYSTEM);
delete dmS;
dmS = 0;
......@@ -209,8 +208,7 @@ public:
truncateBasis(eBasis,
lrs_.left(),
*dmE,
ProgramGlobals::DirectionEnum::EXPAND_ENVIRON,
keptStates);
ProgramGlobals::DirectionEnum::EXPAND_ENVIRON);
delete dmE;
dmE = 0;
}
......@@ -288,8 +286,7 @@ private:
void truncateBasis(BasisWithOperatorsType& rPrime,
const BasisWithOperatorsType& oppoBasis,
const DensityMatrixBaseType& dms,
ProgramGlobals::DirectionEnum direction,
SizeType keptStates)
ProgramGlobals::DirectionEnum direction)
{
bool expandSys = (direction == ProgramGlobals::DirectionEnum::EXPAND_SYSTEM);
const BasisWithOperatorsType& basis = (expandSys) ? lrs_.left() : lrs_.right();
......@@ -307,14 +304,13 @@ private:
cache.transform.truncate(cache.removedIndices);
const SizeType ten = 10;
const SizeType initialSizeOfHashTable = std::max(ten, keptStates);
const bool blasIsThreadSafe = (parameters_.options.find("blasIsThreadSafe") !=
PsimagLite::String::npos);
rPrime.truncateBasis(cache.transform,
cache.eigs,
cache.removedIndices,
startEnd,
initialSizeOfHashTable);
blasIsThreadSafe);
LeftRightSuperType* lrs = 0;
if (expandSys)
lrs = new LeftRightSuperType(rPrime,
......
Markdown is supported
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