Vector types

Иван Вайгульт i.vaigult at gmail.com
Fri Sep 21 23:21:10 CEST 2012


I have found answer on my last question :-)

> Expressions which by their nature imply intermediate values, like
> a=b*c+d*e, still use temporaries though.

That is why I can not use mpz_class.

Can you not use a custom allocator with vector<>?

I do not use custom allocator.

I would be satisfied with mpz_array_init, but I need free storage function.

2012/9/22 Иван Вайгульт <i.vaigult at gmail.com>

> What if you need to resize a number?
>
> There can be two desired behaviours.
>
>    - All the cells have constant size. (The most simple)
>    - All the cells sizes aligns by the biggest number on each vector
>    operation. (Difficult to implement efficiently)
>
> Did you measure that cache misses due to this vector take a significant
>> proportion of the time?
>
> Yes, cache mises takes a big overhead, because the total execution time
> depends on row and cols of matrix as O(nm) on each iteration (And the
> number of iteration depends on rows as O(2^(m/2)) in worst case).
>
> About mpz_array_init:
> Is there any non documented way to free allocated data?
>
> (since you are using C++, I'd rather use vector<mpz_class>)
>
> May be, it's good, but what about mixed arithmetic functions? (for example
> mpz_addmull, I have heared that it is little faster than two calls of
> mpz_add and mpz_mul)
> What will happen if I write "a+b*c" in c++?
>
> 2012/9/21 Marc Glisse <marc.glisse at inria.fr>
>
>> On Fri, 21 Sep 2012, Иван Вайгульт wrote:
>>
>>  Hello all,
>>> I am working on known computional geometry problem (double description
>>> method). As you know, it is connected with vector operations. Let's
>>> consider std::vector<mpz_t>. Following the doccumentation, every element
>>> represents structure with couple sizes and pointers to allocated objects.
>>> This way is ineffective, every loop over this container will lost
>>> processor
>>> time due to cache misses. We can avoid it using linear memory, i.e. all
>>> the neighbours elements are alloocated in neighbours memory cells.
>>>
>>
>> What if you need to resize a number? Did you measure that cache misses
>> due to this vector take a significant proportion of the time?
>>
>> (since you are using C++, I'd rather use vector<mpz_class>)
>>
>>
>>  So, the question: Is there any built-in structure that contatins vector
>>> of
>>> mpz_t objects satisfying cache issues I have listed above?
>>>
>>
>> http://gmplib.org/manual/**Integer-Special-Functions.html<http://gmplib.org/manual/Integer-Special-Functions.html>
>>
>> --
>> Marc Glisse
>>
>
>


More information about the gmp-discuss mailing list