Compiler bug, surfacing in a map?
- From: "Carl Nettelblad" <cnettel@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Apr 2005 18:54:00 +0200
Hello,
I am currently writing a tool which employs a rather large map in one
central part. The keys are of a custom type, basically 4 wrapped ints,
combined with some additional logic. Changing the storage from a map would
break a lot of things, but performance was still crucial. This got me
started on experimenting with the SSE2 intrinsics in various places.
My "key" class currently begins like this:
class word_sequence
{
public:
int data[4];
word_sequence()
{
for (int x = 0; x < 4; x++)
{
data[x] = -1;
}
}
word_sequence(const word_sequence& source)
{
__m128i dataval = _mm_loadu_si128((__m128i*) source.data);
_mm_storeu_si128((__m128i*) data, dataval);
}
Note the copy constructor. The map itself uses the Boost pool allocator,
with a very large initial size:
typedef map<word_sequence, pair<int, partvector >, less<word_sequence>,
fast_pool_allocator<pair<word_sequence, pair<int, partvector > >,
default_user_allocator_new_delete,
details::pool::null_mutex,
131072> > DATATYPE;
Now, this has worked fine all until I introduced this copy constructor. I
can change by hand so that I use this constructor for assignments in my
code, but not for the map. Then it works. I can also make the initial pool
size even larger. Then it also works. BUT; when the boost pool needs to
reallocate, I'll end up with an access violation a bit down the road, when
the insert method in the map rearranges the tree to satisfy the colouring
requirements. When debugging, it seems like the register that should
containt a pointer to the current node does not containt that pointer at
all, so I get a stray reference down to 0x00000064.
This only happens in a release build. I've tried some different optimization
settings, while still getting it. A pure debug build runs fine.
Is anyone aware of some special requirement on copy constructors in the
context of a STL map? Or a bug in boost::pool? (Or conditions when you're
not allowed to use SIMD intrinsics?) I know that hash_map could be better
and that I should create my own storage if I'm that picky about performance,
but that's not an option right now.
This happens with the Visual C++.NET 2003 compiler. Going to a debug build,
or removing the copy constructor (replacing it with a boiler-plate
member-by-member copy) fixes the problem.
Any insights would be welcome.
/Carl
.
- Follow-Ups:
- Re: Compiler bug, surfacing in a map?
- From: Bo Persson
- Re: Compiler bug, surfacing in a map?
- Prev by Date: Re: copy a list in 1 instruction
- Next by Date: Re: Compiler bug, surfacing in a map?
- Previous by thread: vector of strings to int
- Next by thread: Re: Compiler bug, surfacing in a map?
- Index(es):
Relevant Pages
|