[Haskell-cafe]
Re: blas bindings, why are they so much slower the C?
patperry at stanford.edu
patperry at stanford.edu
Mon Jun 30 01:18:47 EDT 2008
Thanks for the patch, Don. I'm on vacation now, but I'll apply it
when I get back.
As for why "getDot" involves pattern matching, it is because a vector
is either a pointer to raw storage, or a conjugated vector. I wrote a
blog post about this for those of you who are interested (
http://quantile95.com/2008/06/12/blas-data-types/ ).
The current data type is this:
data DVector t n e =
DV { fptr :: !(ForeignPtr e)
, offset :: !Int
, len :: !Int
, stride :: !Int
}
| C !(DVector t n e)
Now, it isn't strictly necessary to use an algebraic data type-- I
could have just used a boolean flag, but the code is a little cleaner
this way. I haven't done any tests to see what the difference in
performance is. I would expect that a pattern match between two
alternatives would be just as fast as checking a boolean flag.
The good news is that this is a constant-time overhead. For larger
vectors, getDot should approach the performance of a raw cblas_ddot
call.
Patrick
More information about the Haskell-Cafe
mailing list