Skip to content

Commit

Permalink
Solved the dma transfer issue. Still one bug to fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkman committed Jan 10, 2011
1 parent 955e3f1 commit b5a322c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions samples/spudma/source/main.c
Expand Up @@ -20,11 +20,11 @@ int main(int argc, const char* argv[])
u32 group_id; u32 group_id;
Lv2SpuThreadAttributes attr = { ptr2ea("mythread"), 8+1, LV2_SPU_THREAD_ATTRIBUTE_NONE }; Lv2SpuThreadAttributes attr = { ptr2ea("mythread"), 8+1, LV2_SPU_THREAD_ATTRIBUTE_NONE };
Lv2SpuThreadArguments arg = { 0, 0, 0, 0 }; Lv2SpuThreadArguments arg = { 0, 0, 0, 0 };
vu32 ret; static vu32 ret __attribute__((aligned(16)));
u32 cause, status; u32 cause, status;
Lv2SpuThreadGroupAttributes grpattr = { 7+1, ptr2ea("mygroup"), 0, 0 }; Lv2SpuThreadGroupAttributes grpattr = { 7+1, ptr2ea("mygroup"), 0, 0 };


char text[17] __attribute__((aligned(16))) = "abCdefGhIJklMnOP"; static char text[17] __attribute__((aligned(16))) = "abCdefGhIJklMnOP";


printf("Initializing 6 SPUs... "); printf("Initializing 6 SPUs... ");
printf("%08x\n", lv2SpuInitialize(6, 0)); printf("%08x\n", lv2SpuInitialize(6, 0));
Expand Down
31 changes: 15 additions & 16 deletions samples/spudma/spu/source/main.c
@@ -1,17 +1,22 @@
#include <spu_intrinsics.h> #include <spu_intrinsics.h>
#include <spu_mfcio.h> #include <spu_mfcio.h>


#define TAG 1

/* wait for dma transfer to be finished */
static void wait_for_completion(void) {
mfc_write_tag_mask(1<<TAG);
spu_mfcstat(MFC_TAG_UPDATE_ALL);
}

int main(uint64_t ea, uint64_t outptr, uint64_t arg3, uint64_t arg4) int main(uint64_t ea, uint64_t outptr, uint64_t arg3, uint64_t arg4)
{ {
/* memory-aligned buffer (vectors always are properly aligned) */ /* memory-aligned buffer (vectors always are properly aligned) */
volatile vec_uchar16 v; volatile vec_uchar16 v;


/* fetch the 16 bytes using dma */ /* fetch the 16 bytes using dma */
mfc_get(&v, ea, 16, 0, 0, 0); mfc_get(&v, ea, 16, TAG, 0, 0);

wait_for_completion();
/* wait for dma transfer to be finished */
mfc_write_tag_mask(1);
spu_mfcstat(MFC_TAG_UPDATE_ALL);


/* compare all characters with the small 'a' character code */ /* compare all characters with the small 'a' character code */
vec_uchar16 cmp = spu_cmpgt(v, spu_splats((unsigned char)('a'-1))); vec_uchar16 cmp = spu_cmpgt(v, spu_splats((unsigned char)('a'-1)));
Expand All @@ -21,19 +26,13 @@ int main(uint64_t ea, uint64_t outptr, uint64_t arg3, uint64_t arg4)
v = v - sub; v = v - sub;


/* send the updated vector to ppe */ /* send the updated vector to ppe */
mfc_put(&v, ea, 16, 0, 0, 0); mfc_put(&v, ea, 16, TAG, 0, 0);

wait_for_completion();
/* wait for dma transfer to be finished */
mfc_write_tag_mask(1);
spu_mfcstat(MFC_TAG_UPDATE_ALL);


/* send a message to inform the ppe program that the work is done */ /* send a message to inform the ppe program that the work is done */
uint32_t ok = 1; uint32_t ok __attribute__((aligned(16))) = 1;
mfc_put(&ok, outptr, 4, 0, 0, 0); mfc_put(&ok, outptr, 4, TAG, 0, 0);

wait_for_completion();
/* wait for dma transfer to be finished */
mfc_write_tag_mask(1);
spu_mfcstat(MFC_TAG_UPDATE_ALL);


return 0; return 0;
} }

0 comments on commit b5a322c

Please sign in to comment.