Mercurial > hg > Members > kono > Cerium
view TaskManager/Cell/spe/CellDmaManager.cc @ 319:ec01eee01fd8
light
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 10 Jun 2009 15:09:57 +0900 |
parents | 3e9c0039e15c |
children | 87462f8d3761 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "CellDmaManager.h" /** * DMA Load * * @param[in] buf Buffer of Load Data * @param[in] addr Address of Load Data at Main Memory * @param[in] size Size of Load Data * @param[in] mask DMA tag */ void CellDmaManager::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) { if (size == 0) return ; mfc_get((volatile void *)buf, addr, size, mask, 0, 0); } /** * DMA Store * * @param[in] buf Buffer of Store Data at SPE * @param[in] addr Address of Store Data at Main Memory * @param[in] size Size of Store Data * @param[in] mask DMA tag */ void CellDmaManager::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask) { if (size == 0) return ; mfc_put((volatile void *)buf, addr, size, mask, 0, 0); } /** * DMA Wait * * @param[in] mask Tag for Wait DMA process */ void CellDmaManager::start_dmawait_profile() { wait_time = spu_readch(SPU_RdDec); global_busy_time += busy_time - wait_time; spu_writech(SPU_WrDec, 0xffffffff); } void CellDmaManager::end_dmawait_profile() { wait_time = spu_readch(SPU_RdDec); global_wait_time += 0xffffffff - wait_time; busy_time = wait_time; } void CellDmaManager::show_dma_wait(int cpu) { printf("spu%d: global_wait_time = %lld\n",cpu, global_wait_time); printf("spu%d: global_busy_time = %lld\n",cpu, global_busy_time); printf("spu%d: busy_ratio = %g%%\n",cpu, ((double)global_busy_time)/((double)(global_busy_time+global_wait_time))*100.0); } void CellDmaManager::dma_wait(uint32 mask) { #ifdef SPU_PROFILE start_dmawait_profile(); #endif mfc_write_tag_mask(1 << mask); mfc_write_tag_update_all(); mfc_read_tag_status(); #ifdef SPU_PROFILE end_dmawait_profile(); #endif } void CellDmaManager::mail_write(uint32 data) { spu_write_out_mbox(data); } unsigned int CellDmaManager::mail_read(void) { unsigned int mail = spu_read_in_mbox(); return mail; } void CellDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask) { mfc_getl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length, mask, 0, 0); } void CellDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask) { mfc_putl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length, mask, 0, 0); }