[Cbe-oss-dev] bug in libspe1.2

Kazunori Asayama asayama at sm.sony.co.jp
Wed Apr 25 16:18:33 EST 2007


"Daniel Johansson" <danjo133 at gmail.com> wrote:
> Hello,
> 
> I have found a bug in the libspe1.2 in spu_mfcio.h that ships with sdk2.

The header spu_mfcio.h is not a part of libspe but SPU gcc :-)

> 
> These two defines on row 174 and 175:
> #define mfc_ea2h(ea)   (unsigned int)((unsigned long long)(ea)>>32)
> #define mfc_ea2l(ea)   (unsigned int)(ea)
> 
> They are used by all MFC DMA defines, i.e.
> #define mfc_put(ls,ea,size,tag,tid,rid)spu_mfcdma64(ls,mfc_ea2h(ea),mfc_ea2l(ea),size,tag,MFC_CMD_WORD(tid,rid,MFC_PUT_CMD))
> etc.
> 
> The libspe documentation says that the main-memory address should be
> sent as a void* but these defines treat the void* as a signed int,
> this is a problem if the allocated array is larger than 2<<17, then
> the allocation will be in 0xf??????? range and the resulting 64bit
> address will be wrong.

It doesn't seem a bug.

This header should be used by SPE programs, not by PPE programs. In
other words, in the context of this header, pointers doesn't point to
main-memory addresses but local store addresses, and main-memory
addresses should not be passed via pointers but via unsigned (32 or 64
bits) integers. So any pointers (i.e. local store addresses) should
NOT be passed to mfc_ea2h and/or mfc_ea2l as their arguments.

On the other hand, the libspe spec is written in the context of PPE
(because libspe is a PPE's library), i.e. pointers point to
main-memory addresses. If you are saying about 'spe_mfc_*', make sure
that 'spe_mfc_*' in libspe are different functions from 'mfc_*' in
spu_mfcio.h; spe_mfc_* are PPE-initiated DMAs (DMA proxy) and they are
issued by PPE, while mfc_* are SPE-initiated DMAs and they are issued
by SPEs.

--
(ASAYAMA Kazunori
  (asayama at sm.sony.co.jp))
t



More information about the cbe-oss-dev mailing list