constexpr removed from kernel execution

This commit is contained in:
hamidrezanorouzi 2023-05-06 13:51:03 +03:30
parent 06a431f689
commit 709c5263b1
4 changed files with 23 additions and 15 deletions

View File

@ -380,10 +380,13 @@ bool pFlow::sphereParticles::insertParticles
return false; return false;
} }
auto exclusionListAllPtr = getFieldObjectList(); auto exclusionListAllPtr = getFieldObjectList();
auto newInsertedPtr = pStruct().insertPoints( position, setField, time(), exclusionListAllPtr()); auto newInsertedPtr = pStruct().insertPoints( position, setField, time(), exclusionListAllPtr());
if(!newInsertedPtr) if(!newInsertedPtr)
{ {
fatalErrorInFunction<< fatalErrorInFunction<<

View File

@ -544,18 +544,21 @@ public:
resize(maxInd+1); resize(maxInd+1);
} }
if constexpr (isHostAccessible_)
{
fillSelected(deviceVectorAll(), indices.hostView(), indices.size(), val);
return true;
}else using policy = Kokkos::RangePolicy<
{ execution_space,
fillSelected(deviceVectorAll(), indices.deviceView(), indices.size(), val); Kokkos::IndexType<int32> >;
return true; auto dVec = deviceVectorAll();
} auto dIndex = indices.deviceView();
return false; Kokkos::parallel_for(
"insertSetElement",
policy(0,indices.size()), LAMBDA_HD(int32 i){
dVec(dIndex(i))= val;
});
Kokkos::fence();
return true;
} }
INLINE_FUNCTION_H INLINE_FUNCTION_H
@ -597,13 +600,11 @@ public:
bool insertSetElement(const int32IndexContainer& indices, const Vector<T>& vals) bool insertSetElement(const int32IndexContainer& indices, const Vector<T>& vals)
{ {
//Info<<"start of insertSetElement vecotsingle"<<endInfo;
if(indices.size() == 0)return true; if(indices.size() == 0)return true;
if(indices.size() != vals.size())return false; if(indices.size() != vals.size())return false;
auto maxInd = indices.max(); auto maxInd = indices.max();
/*output<<"maxInd "<< maxInd<<endl;
output<<"size() "<< size()<<endl;*/
if(this->empty() || maxInd > size()-1 ) if(this->empty() || maxInd > size()-1 )
{ {
resize(maxInd+1); resize(maxInd+1);

View File

@ -158,6 +158,7 @@ void* pFlow::setFieldEntry::setPointFieldSelected
if( pointField<VectorDual,Type>::TYPENAME() == fieldTypeName ) if( pointField<VectorDual,Type>::TYPENAME() == fieldTypeName )
{ {
auto& field = owner.lookupObject<pointField<VectorDual,Type>>(fName); auto& field = owner.lookupObject<pointField<VectorDual,Type>>(fName);
if(field.insertSetElement(selected, value)) if(field.insertSetElement(selected, value))
return &field; return &field;

View File

@ -379,11 +379,13 @@ pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::pointStructure::insertPoints
pos) pos)
)return nullptr; )return nullptr;
if(!pointFlag_.insertSetElement( if(!pointFlag_.insertSetElement(
newPointsPtr(), newPointsPtr(),
static_cast<int8>(PointFlag::ACTIVE)) static_cast<int8>(PointFlag::ACTIVE))
)return nullptr; )return nullptr;
setNumMaxPoints(); setNumMaxPoints();
auto minInd = newPointsPtr().min(); auto minInd = newPointsPtr().min();
auto maxInd = newPointsPtr().max(); auto maxInd = newPointsPtr().max();
@ -393,6 +395,7 @@ pFlow::uniquePtr<pFlow::int32IndexContainer> pFlow::pointStructure::insertPoints
for(auto sfEntry:setField) for(auto sfEntry:setField)
{ {
if(void* fieldPtr = if(void* fieldPtr =
sfEntry.setPointFieldSelectedAll( sfEntry.setPointFieldSelectedAll(
owner, owner,