Re: Help with extended asm syntax and related topics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kai Henningsen wrote:
On Sat, 11 Oct 2008 17:43:33 -0400
John Fine <johnsfine@xxxxxxxxxxx> wrote:

(not on my main topic, but I'd like to
know that too).

How about this?

typedef unsigned int uint;
inline void foo0(uint k, uint n, double const& m, double* s, uint const*
c, double const* v) { #pragma ivdep
while (++k < n) s[ c[k] ] -= m * v[k]; }

template <class Ts, class Tc, class Tv>
inline void foo(uint k, uint n, double const& m, Ts s, Tc c, Tv v)
{ foo0(k, n, m, s, c, v); }

Thanks. Maybe I should have stuck to my main topic. I'm looking at many interacting issues at once. The code I posted is simplified (in the template declaration, not in the asm code) from what I'm actually working on and that caused a few of my side issues to loose something in translation.

In cases similar to the current one, I keep hoping there would be some way to select the right template specialization based on such ability to cast. But I understand that it doesn't work that way. The fall back is to at least check the correctness of the cast after this template is selected, which your suggestion does and my code failed to do (I found and corrected that this morning).

In fact, in the current example, I was wrong about what cast is even legal for some cases. Actually it was (&v[0]) that could be cast to (double const*). v itself might not be possible to cast to (double const*). That would also be easy to cover in your form. Using (&v[0]) trusts that the caller won't use any container with noncontiguous storage. That is safe in the project I'm working on, but not a valid approach for more general tools.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux