Mercurial > hg > Members > kono > Cerium
view TaskManager/Cell/spe/CellDmaManager.cc @ 871:ab3cd3aeacff
fix get segment dma tag zero problem
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 04 Jul 2010 16:56:04 +0900 |
parents | 31d0a5baafdf |
children | ad6903dd6419 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "CellDmaManager.h" #include "Scheduler.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, memaddr 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, memaddr addr, uint32 size, uint32 mask) { if (size == 0) return ; mfc_put((volatile void *)buf, addr, size, mask, 0, 0); } void CellDmaManager::dma_wait(uint32 mask) { (this->*start_dmawait_profile)(); mfc_write_tag_mask(1 << mask); mfc_write_tag_update_all(); mfc_read_tag_status(); __asm__ __volatile__(" sync"); (this->*end_dmawait_profile)(&global_wait_time); } void CellDmaManager::mail_write(memaddr data) { (this->*start_dmawait_profile)(); spu_write_out_mbox((uint32)data); #if 0 if (ABIBIT>32) { unsigned long data0 = (unsigned long)data; spu_write_out_mbox((uint32)(data0>>32)); } #endif (this->*end_dmawait_profile)(&global_mail_time); } memaddr CellDmaManager::mail_read() { (this->*start_dmawait_profile)(); memaddr data = (memaddr)spu_read_in_mbox(); #if 0 if (ABIBIT>32) { data += (spu_read_in_mbox()<<32); } #endif (this->*end_dmawait_profile)(&global_mail_time); return data; } 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); } CellDmaManager::CellDmaManager() { stop_profile(); } void CellDmaManager::start_profile() { start_dmawait_profile = &CellDmaManager::do_start_dmawait_profile; end_dmawait_profile = &CellDmaManager::do_end_dmawait_profile; } void CellDmaManager::stop_profile() { start_dmawait_profile = &CellDmaManager::null_start_dmawait_profile; end_dmawait_profile = &CellDmaManager::null_end_dmawait_profile; } /** * DMA Wait * * @param[in] mask Tag for Wait DMA process */ void CellDmaManager::do_start_dmawait_profile() { wait_time = spu_readch(SPU_RdDec); global_busy_time += busy_time - wait_time; spu_writech(SPU_WrDec, 0xffffffff); } void CellDmaManager::do_end_dmawait_profile(unsigned long long *counter) { wait_time = spu_readch(SPU_RdDec); *counter += 0xffffffff - wait_time; busy_time = wait_time; } void CellDmaManager::null_start_dmawait_profile() {} void CellDmaManager::null_end_dmawait_profile(unsigned long long *counter) {} void CellDmaManager::show_dma_wait(Scheduler *s, int cpu) { double r = ((double)global_busy_time)/((double)( global_busy_time+global_wait_time+global_mail_time ))*100.0; s->printf("spu%d: busy_time = %lld" " wait_time = %lld" " mail_time = %lld" " busy_ratio = %g%%\n", cpu, global_busy_time, global_wait_time, global_mail_time, r); } /* end */