[cpp]// find F initially for all allowed pairwise interactions, store the vector and move the particle
for (i=0;iparticleSetLength;i++) {
this->particleSet.interactWithAll(this->particleSet,this->particleSetLength,i);
this->particleSet.accountForInertia();
this->particleSet.addCurrentVectorToMemory();
this->particleSet.moveParticle(distance/2);
}[/cpp]
[cpp]#include "../particle/Particle.h"
#include "tbb/tbb.h"
#include "tbb/parallel_for.h"
#include "tbb/task_scheduler_init.h"
#include "tbb/blocked_range.h"
using namespace tbb;
class FindInitialFandMove {
Particle *const my_p;
int numP;
int dist;
public:
void operator()( const blocked_range& r ) const {
Particle *localParticles = my_p;
int numParticles = numP;
int distance = dist;
for( size_t i=r.begin(); i!=r.end(); ++i ) {
localParticles.interactWithAll(localParticles,numP,(int)i);
localParticles.accountForInertia();
localParticles.addCurrentVectorToMemory();
localParticles.moveParticle(dist/2);
}
}
FindInitialFandMove( Particle localParticles[], int numParticles, int distance) :
my_p(localParticles), numP(numParticles),dist(distance)
{}
};[/cpp]
[cpp]void Capsule::FindInitialFandMove(Particle localParticles[], int numParticles, int distance ) {
parallel_for(blocked_range(0,(size_t)this->particleSetLength), FindInitialFandMove(this->particleSet,this->particleSetLength,this->stepSize));
}
[/cpp]
[cpp]1> I:threadBuildingBlocksincludetbb/parallel_for.h(211) : see declaration of 'tbb::strict_ppl::parallel_for' 1>.capsuleCapsule.cpp(681) : error C2780: 'Function tbb::strict_ppl::parallel_for(Index,Index,Index,Function)' : expects 4 arguments - 2 provided 1> I:threadBuildingBlocksincludetbb/parallel_for.h(206) : see declaration of 'tbb::strict_ppl::parallel_for' 1>.capsuleCapsule.cpp(681) : error C2780: 'void tbb::parallel_for(const Range &,const Body &,tbb::affinity_partitioner &,tbb::task_group_context &)' : expects 4 arguments - 2 provided 1> I:threadBuildingBlocksincludetbb/parallel_for.h(175) : see declaration of 'tbb::parallel_for' 1>.capsuleCapsule.cpp(681) : error C2780: 'void tbb::parallel_for(const Range &,const Body &,const tbb::auto_partitioner &,tbb::task_group_context &)' : expects 4 arguments - 2 provided 1> I:threadBuildingBlocksincludetbb/parallel_for.h(168) : see declaration of 'tbb::parallel_for' 1>.capsuleCapsule.cpp(681) : error C2780: 'void tbb::parallel_for(const Range &,const Body &,const tbb::simple_partitioner &,tbb::task_group_context &)' : expects 4 arguments - 2 provided 1> I:threadBuildingBlocksincludetbb/parallel_for.h(161) : see declaration of 'tbb::parallel_for' 1>.capsuleCapsule.cpp(681) : error C2780: 'void tbb::parallel_for(const Range &,const Body &,tbb::affinity_partitioner &)' : expects 3 arguments - 2 provided 1> I:threadBuildingBlocksincludetbb/parallel_for.h(153) : see declaration of 'tbb::parallel_for' 1>.capsuleCapsule.cpp(681) : error C2780: 'void tbb::parallel_for(const Range &,const Body &,const tbb::auto_partitioner &)' : expects 3 arguments - 2 provided 1> I:threadBuildingBlocksincludetbb/parallel_for.h(146) : see declaration of 'tbb::parallel_for' 1>.capsuleCapsule.cpp(681) : error C2780: 'void tbb::parallel_for(const Range &,const Body &,const tbb::simple_partitioner &)' : expects 3 arguments - 2 provided 1> I:threadBuildingBlocksincludetbb/parallel_for.h(139) : see declaration of 'tbb::parallel_for' 1>.capsuleCapsule.cpp(681) : error C2784: 'void tbb::parallel_for(const Range &,const Body &)' : could not deduce template argument for 'const Body &' from 'void' 1> I:threadBuildingBlocksincludetbb/parallel_for.h(132) : see declaration of 'tbb::parallel_for' [/cpp]
Link Copied
Namespace using-directive's are evil.
Namespace using directives are evil.
I'm still confused because the list of errors starts and ends with "see declaration of" (has something been omitted?), and I would have expected the error with declaration parallel_for.h:139 to instead appear with parallel_for.h:132 (the only overload with the matching number of parameters, in tbb22_20090809oss anyway). At least then I might have some basis to suspect the compiler (now it's just very strange all around). What is the TBB version being used here?
I'm still confused because the list of errors starts and ends with "see declaration of" (has something been omitted?), and I would have expected the error with declaration parallel_for.h:139 to instead appear with parallel_for.h:132.
[cpp]void Capsule::FindInitialFandMove(Particle localParticles[], int numParticles, int distance ) { parallel_for(blocked_range(0,(size_t)this->particleSetLength), FindInitialFandMove(this->particleSet,this->particleSetLength,this->stepSize)); } [/cpp]
[cpp]void Capsule::FindInitialFandMove(Particle localParticles[], int numParticles, int distance ) {
parallel_for(blocked_range(0,(size_t)this->particleSetLength), FindInitialFandMove(this->particleSet,this->particleSetLength,this->stepSize));
}
[/cpp]
[cpp]void Capsule::FindInitialFandMove(Particle localParticles[], int numParticles, int distance ) {
parallel_for(blocked_range(0,(size_t)this->particleSetLength), FindInitialFandMove(this->particleSet,this->particleSetLength,this->stepSize));
}
[/cpp]
For more complete information about compiler optimizations, see our Optimization Notice.