Commit 177c3370 authored by Philippe Virouleau's avatar Philippe Virouleau

Fix others failures with clang

Including:
 - missing data sharing attributes in some pragmas
 - workaround clang's inability to properly capture static const class members
 - enforce a const_iterator when calling erase
parent afc8bfe8
......@@ -108,7 +108,7 @@ public:
// This is applied via std::transform to an array of data.
// It doesn't seem to do anything, but I may be missing something.
template<typename CellClass>
static CellClass *noop(CellClass *c) {
static CellClass *identity(CellClass *c) {
return c;
}
};
......
......@@ -302,7 +302,7 @@ public:
--idx;
}
removed.push_back(indicesToRemove[i]);
FBase::erase(this->begin()+idx);
FBase::erase(this->cbegin()+idx);
}
}
......
......@@ -222,7 +222,7 @@ protected:
FBasicCell::getMultipoleDataFromCell<const CellClass, const multipole_t>);
std::array<const symbolic_data_t*, 8> child_symbolics;
std::transform(children, children+8, child_symbolics.begin(),
FBasicCell::noop<const CellClass>);
FBasicCell::identity<const CellClass>);
kernels[omp_get_thread_num()]->M2M(parent_multipole,
parent_symbolic,
child_multipoles.data(),
......@@ -285,7 +285,7 @@ protected:
do{
const int counter = tree->getInteractionNeighbors(neighbors, neighborPositions, octreeIterator.getCurrentGlobalCoordinate(), idxLevel, separationCriteria);
if(counter){
#pragma omp task firstprivate(octreeIterator, neighbors, neighborPositions, counter,idxLevel)
#pragma omp task firstprivate(octreeIterator, neighbors, neighborPositions, counter, idxLevel, kernels)
{
local_expansion_t* const target_local_exp
= &(octreeIterator.getCurrentCell()->getLocalExpansionData());
......@@ -296,7 +296,7 @@ protected:
FBasicCell::getMultipoleDataFromCell<const CellClass, const multipole_t>);
std::array<const symbolic_data_t*, 342> neighbor_symbolics;
std::transform(neighbors, neighbors+counter, neighbor_symbolics.begin(),
FBasicCell::noop<const CellClass>);
FBasicCell::identity<const CellClass>);
kernels[omp_get_thread_num()]->M2L(
target_local_exp,
......@@ -364,7 +364,7 @@ protected:
FBasicCell::getMultipoleDataFromCell<const CellClass, const multipole_t>);
std::array<const symbolic_data_t*, 342> neighbor_symbolics;
std::transform(neighbors, neighbors+counter, neighbor_symbolics.begin(),
FBasicCell::noop<const CellClass>);
FBasicCell::identity<const CellClass>);
kernels[omp_get_thread_num()]->M2L(
target_local_exp,
......@@ -423,7 +423,7 @@ protected:
FBasicCell::getLocalExpansionDataFromCell<CellClass, local_expansion_t>);
std::array<symbolic_data_t*, 8> child_symbolics;
std::transform(children, children+8, child_symbolics.begin(),
FBasicCell::noop<CellClass>);
FBasicCell::identity<CellClass>);
kernels[omp_get_thread_num()]->L2L(
parent_local_exp,
parent_symbolic,
......
......@@ -349,6 +349,12 @@ protected:
}
typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);
// FIXME: hack around a clang bug
// it apparently can't manage a firstprivate const member
// such as 'tree', but can manage a local copy...
// getting the height first, or making 'tree' shared both
// workaround it.
OctreeClass * const treeAlias = tree;
// for each levels
for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){
......@@ -356,11 +362,11 @@ protected:
const int separationCriteria = (idxLevel != FAbstractAlgorithm::lowerWorkingLevel-1 ? 1 : leafLevelSeparationCriteria);
// for each cells
do{
#pragma omp task default(none) firstprivate(octreeIterator,separationCriteria,idxLevel)
#pragma omp task default(none) firstprivate(octreeIterator, separationCriteria, idxLevel, treeAlias, kernels)
{
const CellClass* neighbors[342];
int neighborPositions[342];
const int counter = tree->getInteractionNeighbors(
const int counter = treeAlias->getInteractionNeighbors(
neighbors, neighborPositions,
octreeIterator.getCurrentGlobalCoordinate(),
idxLevel, separationCriteria);
......@@ -377,7 +383,7 @@ protected:
FBasicCell::getMultipoleDataFromCell<const CellClass, const multipole_t>);
std::array<const symbolic_data_t*, 342> neighbor_symbolics;
std::transform(neighbors, neighbors+counter, neighbor_symbolics.begin(),
FBasicCell::noop<const CellClass>);
FBasicCell::identity<const CellClass>);
kernels[omp_get_thread_num()]->M2L(
target_local_exp,
......
......@@ -139,7 +139,13 @@ protected:
std::vector<BlockInteractions<ParticleGroupClass>>* externalInteractions = &externalInteractionsLeafLevel[idxGroup];
#pragma omp task default(none) firstprivate(idxGroup, containers, externalInteractions)
// FIXME: hack around a clang bug
// it apparently can't manage a firstprivate const member
// such as 'tree', but can manage a local copy...
// getting the height first, or making 'tree' shared both
// workaround it.
OctreeClass * const treeAlias = tree;
#pragma omp task default(none) firstprivate(idxGroup, containers, externalInteractions, treeAlias)
{ // Can be a task(inout:iterCells)
std::vector<OutOfBlockInteraction> outsideInteractions;
const MortonIndex blockStartIdx = containers->getStartingIndex();
......@@ -152,7 +158,7 @@ protected:
MortonIndex interactionsIndexes[26];
int interactionsPosition[26];
FTreeCoordinate coord(mindex);
int counter = coord.getNeighborsIndexes(tree->getHeight(),interactionsIndexes,interactionsPosition);
int counter = coord.getNeighborsIndexes(treeAlias->getHeight(),interactionsIndexes,interactionsPosition);
for(int idxInter = 0 ; idxInter < counter ; ++idxInter){
if( blockStartIdx <= interactionsIndexes[idxInter] && interactionsIndexes[idxInter] < blockEndIdx ){
......@@ -175,7 +181,7 @@ protected:
int currentOutInteraction = 0;
for(int idxLeftGroup = 0 ; idxLeftGroup < idxGroup && currentOutInteraction < int(outsideInteractions.size()) ; ++idxLeftGroup){
ParticleGroupClass* leftContainers = tree->getParticleGroup(idxLeftGroup);
ParticleGroupClass* leftContainers = treeAlias->getParticleGroup(idxLeftGroup);
const MortonIndex blockStartIdxOther = leftContainers->getStartingIndex();
const MortonIndex blockEndIdxOther = leftContainers->getEndingIndex();
......@@ -227,7 +233,13 @@ protected:
std::vector<BlockInteractions<CellContainerClass>>* externalInteractions = &externalInteractionsAllLevel[idxLevel][idxGroup];
#pragma omp task default(none) firstprivate(idxGroup, currentCells, idxLevel, externalInteractions)
// FIXME: hack around a clang bug
// it apparently can't manage a firstprivate const member
// such as 'tree', but can manage a local copy...
// getting the height first, or making 'tree' shared both
// workaround it.
OctreeClass * const treeAlias = tree;
#pragma omp task default(none) firstprivate(idxGroup, currentCells, idxLevel, externalInteractions, treeAlias)
{
std::vector<OutOfBlockInteraction> outsideInteractions;
const MortonIndex blockStartIdx = currentCells->getStartingIndex();
......@@ -262,7 +274,7 @@ protected:
int currentOutInteraction = 0;
for(int idxLeftGroup = 0 ; idxLeftGroup < idxGroup && currentOutInteraction < int(outsideInteractions.size()) ; ++idxLeftGroup){
CellContainerClass* leftCells = tree->getCellGroup(idxLevel, idxLeftGroup);
CellContainerClass* leftCells = treeAlias->getCellGroup(idxLevel, idxLeftGroup);
const MortonIndex blockStartIdxOther = leftCells->getStartingIndex();
const MortonIndex blockEndIdxOther = leftCells->getEndingIndex();
......@@ -377,7 +389,7 @@ protected:
nbSubCellGroups += 1;
}
#pragma omp task default(none) firstprivate(idxLevel, currentCells, subCellGroups, nbSubCellGroups)
#pragma omp task default(none) firstprivate(idxLevel, currentCells, subCellGroups, nbSubCellGroups, kernels)
{
KernelClass*const kernel = kernels[omp_get_thread_num()];
int idxSubCellGroup = 0;
......@@ -452,7 +464,7 @@ protected:
while(iterCells != endCells){
CellContainerClass* currentCells = (*iterCells);
#pragma omp task default(none) firstprivate(currentCells, idxLevel)
#pragma omp task default(none) firstprivate(currentCells, idxLevel, kernels)
{
const MortonIndex blockStartIdx = currentCells->getStartingIndex();
const MortonIndex blockEndIdx = currentCells->getEndingIndex();
......@@ -527,7 +539,7 @@ protected:
CellContainerClass* cellsOther = (*currentInteractions).otherBlock;
const std::vector<OutOfBlockInteraction>* outsideInteractions = &(*currentInteractions).interactions;
#pragma omp task default(none) firstprivate(currentCells, outsideInteractions, cellsOther, idxLevel)
#pragma omp task default(none) firstprivate(currentCells, outsideInteractions, cellsOther, idxLevel, kernels)
{
KernelClass*const kernel = kernels[omp_get_thread_num()];
......@@ -622,7 +634,7 @@ protected:
nbSubCellGroups += 1;
}
#pragma omp task default(none) firstprivate(idxLevel, currentCells, subCellGroups, nbSubCellGroups)
#pragma omp task default(none) firstprivate(idxLevel, currentCells, subCellGroups, nbSubCellGroups, kernels)
{
KernelClass*const kernel = kernels[omp_get_thread_num()];
int idxSubCellGroup = 0;
......@@ -691,7 +703,13 @@ protected:
while(iterParticles != endParticles){
ParticleGroupClass* containers = (*iterParticles);
#pragma omp task default(none) firstprivate(containers)
// FIXME: hack around a clang bug
// it apparently can't manage a firstprivate const member
// such as 'tree', but can manage a local copy...
// getting the height first, or making 'tree' shared both
// workaround it.
OctreeClass * const treeAlias = tree;
#pragma omp task default(none) firstprivate(containers, kernels, treeAlias)
{
const MortonIndex blockStartIdx = containers->getStartingIndex();
const MortonIndex blockEndIdx = containers->getEndingIndex();
......@@ -704,7 +722,7 @@ protected:
MortonIndex interactionsIndexes[26];
int interactionsPosition[26];
FTreeCoordinate coord(mindex);
int counter = coord.getNeighborsIndexes(tree->getHeight(),interactionsIndexes,interactionsPosition);
int counter = coord.getNeighborsIndexes(treeAlias->getHeight(),interactionsIndexes,interactionsPosition);
ParticleContainerClass interactionsObjects[26];
ParticleContainerClass* interactions[26];
......@@ -747,7 +765,7 @@ protected:
ParticleGroupClass* containersOther = (*currentInteractions).otherBlock;
const std::vector<OutOfBlockInteraction>* outsideInteractions = &(*currentInteractions).interactions;
#pragma omp task default(none) firstprivate(containers, containersOther, outsideInteractions)
#pragma omp task default(none) firstprivate(containers, containersOther, outsideInteractions, kernels)
{
KernelClass*const kernel = kernels[omp_get_thread_num()];
for(int outInterIdx = 0 ; outInterIdx < int(outsideInteractions->size()) ; ++outInterIdx){
......@@ -789,7 +807,7 @@ protected:
for(int idxGroup = 0 ; idxGroup < tree->getNbParticleGroup() ; ++idxGroup){
CellContainerClass* leafCells = tree->getCellGroup(tree->getHeight()-1, idxGroup);
ParticleGroupClass* containers = tree->getParticleGroup(idxGroup);
#pragma omp task default(shared) firstprivate(leafCells, containers)
#pragma omp task default(shared) firstprivate(leafCells, containers, kernels)
{
KernelClass*const kernel = kernels[omp_get_thread_num()];
......
......@@ -1228,7 +1228,7 @@ public:
*/
void resize(size_type count, const value_type& values) {
if(count < this->size()) {
this->erase(this->begin() + count, this->end());
this->erase(this->cbegin() + count, this->cend());
} else if(count > this->size()) {
this->insert(this->end(), count - this->size(), values);
}
......
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