just some simple profiling for the LLE DSP

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@901 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc
2008-10-17 17:59:16 +00:00
parent 7bbd6fda63
commit 469310dc14
7 changed files with 130 additions and 12 deletions

View File

@ -88,4 +88,48 @@ u32 Memory_Read_U32(u32 _uAddress)
_uAddress &= RAM_MASK;
return Common::swap32(*(u32*)&g_dsp.cpu_ram[_uAddress]);
}
// =============
#if PROFILE
#define PROFILE_MAP_SIZE 0x10000
u64 g_profileMap[PROFILE_MAP_SIZE];
bool g_profile = false;
void ProfilerStart()
{
g_profile = true;
}
void ProfilerAddDelta(int _addr, int _delta)
{
if (g_profile)
{
g_profileMap[_addr] += _delta;
}
}
void ProfilerInit()
{
memset(g_profileMap, 0, sizeof(g_profileMap));
}
void ProfilerDump(uint64 count)
{
FILE* pFile = fopen("c:\\_\\DSP_Prof.txt", "wt");
if (pFile != NULL)
{
fprintf(pFile, "Number of DSP steps: %i\n\n", count);
for (int i=0; i<PROFILE_MAP_SIZE;i++)
{
if (g_profileMap[i] > 0)
{
fprintf(pFile, "0x%04X: %u\n", i, g_profileMap[i]);
}
}
fclose(pFile);
}
}
#endif

View File

@ -65,5 +65,13 @@ typedef const uint32 cuint32;
u16 Memory_Read_U16(u32 _uAddress); // For PB address detection
u32 Memory_Read_U32(u32 _uAddress);
#if PROFILE
void ProfilerDump(uint64 _count);
void ProfilerInit();
void ProfilerAddDelta(int _addr, int _delta);
void ProfilerStart();
#endif
#endif

View File

@ -228,11 +228,25 @@ void gdsp_step()
if (g_dsp.pc == 0x80e7)
{
g_dsp.pc = HLE_ROM_80E7_81F8();
//g_dsp.pc = HLE_ROM_80E7_81F8();
}
g_dsp.err_pc = g_dsp.pc;
#if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1);
if (g_dsp.step_counter == 1)
{
ProfilerInit();
}
if ((g_dsp.step_counter & 0xFFFFF) == 0)
{
ProfilerDump(g_dsp.step_counter);
}
#endif
uint16 opc = dsp_fetch_code();
dsp_op[opc >> 12](opc);

View File

@ -91,5 +91,4 @@ uint16* gdsp_get_irom(void);
uint16* gdsp_get_dram(void);
uint16* gdsp_get_drom(void);
#endif

View File

@ -107,6 +107,10 @@ inline void dsp_op_write_reg(uint8 reg, uint16 val)
inline sint64 dsp_get_long_prod()
{
#if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1);
#endif
sint64 val;
sint64 low_prod;
val = (sint8)g_dsp.r[0x16];
@ -122,6 +126,10 @@ inline sint64 dsp_get_long_prod()
inline void dsp_set_long_prod(sint64 val)
{
#if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1);
#endif
g_dsp.r[0x14] = (uint16)val;
val >>= 16;
g_dsp.r[0x15] = (uint16)val;
@ -139,6 +147,10 @@ inline void dsp_set_long_prod(sint64 val)
inline sint64 dsp_get_long_acc(uint8 reg)
{
#if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1);
#endif
_dbg_assert_(reg < 2);
sint64 val;
sint64 low_acc;
@ -154,6 +166,10 @@ inline sint64 dsp_get_long_acc(uint8 reg)
inline uint64 dsp_get_ulong_acc(uint8 reg)
{
#if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1);
#endif
_dbg_assert_(reg < 2);
uint64 val;
uint64 low_acc;
@ -169,6 +185,10 @@ inline uint64 dsp_get_ulong_acc(uint8 reg)
inline void dsp_set_long_acc(uint8 _reg, sint64 val)
{
#if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1);
#endif
_dbg_assert_(_reg < 2);
g_dsp.r[0x1c + _reg] = (uint16)val;
val >>= 16;
@ -208,6 +228,10 @@ inline sint16 dsp_get_acc_h(uint8 _reg)
inline sint64 dsp_get_long_acx(uint8 _reg)
{
#if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1);
#endif
_dbg_assert_(_reg < 2);
sint64 val = (sint16)g_dsp.r[0x1a + _reg];
val <<= 16;

View File

@ -66,7 +66,7 @@ bool AXTask(u32& _uMail);
bool bCanWork = false;
// Set this if you want to log audio. search for log_ai in this file to see the filename.
static bool log_ai = false;
static bool log_ai = true;
WaveFileWriter g_wave_writer;
// ==============
@ -258,11 +258,12 @@ void DSP_Initialize(DSPInitialize _dspInitialize)
// --------------
// Dump UCode to file...
FILE* t = fopen("DSP_UC_09CD143F.txt", "wb");
if(t) {
FILE* t = fopen("C:\\_\\DSP_UC_09CD143F.txt", "wb");
if (t != NULL)
{
gd_globals_t gdg;
gd_dis_file(&gdg, "DSP_UC_09CD143F.bin", t);
fclose(t);
gd_dis_file(&gdg, "C:\\_\\DSP_UC_09CD143F.bin", t);
fclose(t);
}
// --------------
@ -353,6 +354,13 @@ void DSP_WriteMailboxHigh(bool _CPUMailbox, u16 _uHighMail)
ErrorLog("Mailbox isnt empty ... strange");
}
#if PROFILE
if ((_uHighMail) == 0xBABE)
{
ProfilerStart();
}
#endif
gdsp_mbox_write_h(GDSP_MBOX_CPU, _uHighMail);
}
else