[Mesa-dev] [PATCH 01/12] nv50/ir: optimize the use of std::tr1::unordered_set

Chih-Wei Huang cwhuang at android-x86.org
Mon May 18 23:54:36 PDT 2015


2015-05-18 1:46 GMT+08:00 Chih-Wei Huang <cwhuang at android-x86.org>:
> 2015-05-16 2:46 GMT+08:00 Ilia Mirkin <imirkin at alum.mit.edu>:
>> Please elaborate why this is necessary. I have, in the past, had
>> requests to move to the C++11 std::unordered_set -- would that work
>> for you? I'd be happy with a #if c++11 is available, use
>> std::unordered_set. Otherwise use std::tr1::unordered_set.
>
> Hi Ilia,
> Thank you for the review.
> The basic goal is to make it be compatible with stlport.
> The stlport (of Android) seems to be buggy to
> instantiate unordered_set<user-defined-type *>.
> I just got a lot of strange errors.
> But instantiating unordered_set<void *>
> (or any built-in type) is fine.
> So the patch avoids instantiating
> unordered_set<user-defined-type *>.
>
> I didn't see your request in the past
> (I'm new to the list)
> But in Android lollipop seems we can use libcxx
> to replace stlport. I'll try this approach later.

I've succeeded to replace stlport by libcxx.
But since libcxx is only available since Android 5.0,
I need to tweak the makefiles more if we hope to
keep mesa be compatible with earlier Android release.

In my experiment of using libcxx with c++11,
I believe this patch is more necessary.
Because we can use a central point to control
(i.e., nv50_ir.h) whether to
use std::unordered_set or std::tr1::unordered_set,
like

#if __cplusplus >= 201103L
#include <unordered_set>
typedef std::unordered_set<void *> voidptr_unordered_set;
#else
#include <tr1/unordered_set>
typedef std::tr1::unordered_set<void *> voidptr_unordered_set;
#endif

template <typename V>
class ptr_unordered_set : public voidptr_unordered_set {
...
};

Besides, the patch makes the generated code smaller
because of instantiating unordered_set just one time.
The size of gallium_dri.so is 10565764 without this patch,
and is 10561668 with this patch.

How do you think about it?

I'll submit the v2 patches after clean them up.


More information about the mesa-dev mailing list