Raymond Toy <[EMAIL PROTECTED]> writes:
> >>>>> "Harvey" == Harvey J Stein <[EMAIL PROTECTED]> writes:
>
> Harvey> The compiler won't unbox the result of (one-normal-rand) and
> Harvey> (callpay), and I still don't know why. Is the problem with
>
> You can't get rid of the boxing for one-normal-rand and callpay in
> general, because it has to box them so that the any caller knows how
> to get the results.
>
> However, you can declare them as inline functions so that they
> will be inlined, and hence, no consing is needed. Or you can use
> CMUCL's block-compilation feature (see the User's manual) to do this
> for you.
>
> Once you do this, I think the speed will be quite a bit better.
I don't understand why it has to box the results of one-normal-rand &
callpay. Once it knows the signature of these fcns, shouldn't it be
able to use them directly, without boxing? Also, as I mentioned in my
reply to Janos, simple fixnum functions don't generate this pointer
conversion note for the return value, whereas equivalent double-float
ones do.
In any case, as for inlining & block compilation, I tried:
(eval-when (compile)
(proclaim '(inline one-normal-rand
callpay)))
and
(compile-file "bsmc-cl-min5" :block-compile t)
didn't help, and I still get 70 compiler notes, mostly having to do
generic arithmetic because things are numbers and not double-floats.
Also, it hated trying to inline the recursive one-normal-rand, so I
changed it first to:
(defun one-normal-rand ()
(declare (values (double-float)))
(loop
(let* ((u (random 1d0))
(u1 (random 1d0))
(v (* SQRT2OVERE (- (* 2d0 u1) 1d0)))
(x (/ v u))
(y (/ (* x x) 4d0)))
(if (or (<= y (- 1d0 u))
(<= y (- (log u))))
(return x)))))
thus getting rid of the recursion, and avoiding labels. Didn't speed
it up, though...
--
Harvey Stein
Bloomberg LP
[EMAIL PROTECTED]