Reference Information. Therefore, I am working on raytracer .. for my construction of the spatial partitioning scheme, I first had this code:
if (msize <= 2) {
Model **models = new Model*[msize];
for (uint i=0; i<msize; ++i)
models[i] = &mlist[i];
*arrayPtr = Node(models, msize);
... increment arrayPtr ...
return;
}
Basically, after creating this spatial tree, the rays cross the tree looking for Models that are all stored in one large array. Leaf nodes contain pointers to an array of model pointers .
Then I realized that hey, there is no reason for me to add this extra level of indirection; if I arrange my models correctly, I can get leaf nodes to point to a large array of models. Models adjacent to each other in a large array will belong to this node sheet, so the leaves will contain pointers to Models. So I did it and tested it, leaving everything else unchanged.
Now you might think that this will obviously speed up the program. Well, this speeds up the single-threaded version (about 10%), but it slows down multithreading (about 15%! This is pretty important if you do a lot of optimization.) I'm pretty sure the loss is how to handle this - I thought that the indirection was bad, I thought the reduction in memory usage was good, especially for multithreading .. not a single node or Model sheet is written there, all records are performed for a separate data structure.
Any pointers / suggestions on how to analyze the problem would be great.
Some different statistics: cachegrind tells me that for a double indirect ratio approach there are fewer ref / cache cache errors, but more refs / cache data is missing. The difference is not so big, although for both.
: , :
class Node {
ushort type;
union {
ushort axisID;
ushort childrenSize;
};
union {
Model **models;
Node *rightChild;
};
float leftPlane, rightPlane;
... public methods and stuff ...
}
Model **models Model *models, . Model , Shape Material. , Material, .