I recently immersed myself in C ++, and my errors seem to get complicated.
I have a vector of objects, each object contains a floating point vector. I decided that I needed to create another flat array containing all the float values of all objects in one. This is a little more complicated than the problem, but the essence of the problem is that when I look at my objects, retrieving the float values, at some point my object vector changes or is distorted in some strange way. (My read operations are all const functions)
Another example was with MPI. I was just starting, so I just wanted to run the same code on two different nodes with my own memory and without data transfer, everything is very simple. To my surprise, I had segmentation errors, and after tracking the clock, I found that one assignment to one variable set a completely different variable to NULL.
So I'm curious how possible it is that read operations can affect my data structures. Just like a seemingly unrelated operation affects another. I could not expect a solution to my problems with these brief descriptions, but any advice would be greatly appreciated.
Update: Here is the code segment, I did not write it initially, because I'm not sure how much can be extracted from it without understanding the whole system.
, , , , , seg . , , , , , .
void xlMasterSlaveGpuEA::FillFlatGenes() {
int stringLength = pop->GetGenome(0).GetLength();
for (int i=0;i<pop->GetPopSize();i++)
for (int j=0;j<stringLength;j++)
flatGenes[(i*stringLength)+j]<< pop->GetGenome(i).GetFloatGene(j);
}
float xlVectorGenome::GetFloatGene(unsigned int i) const {
return GetGene(i);
}
-
float * flatFitness;
:
flatFitness = new float(popSize);
2:
, , . MPI - , MPI - , , , . , , ,
if node 1 then do bottom half of loop
if node 1 then do top half
, , , .. ,