mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
unittest: Add jit compare for jit IR.
This commit is contained in:
parent
2ba63c65f2
commit
e5df318990
2 changed files with 31 additions and 4 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include "Core/MemMap.h"
|
#include "Core/MemMap.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/CoreTiming.h"
|
#include "Core/CoreTiming.h"
|
||||||
|
#include "Core/Config.h"
|
||||||
#include "Core/HLE/HLE.h"
|
#include "Core/HLE/HLE.h"
|
||||||
|
|
||||||
// Temporary hacks around annoying linking errors. Copied from Headless.
|
// Temporary hacks around annoying linking errors. Copied from Headless.
|
||||||
|
@ -55,9 +56,15 @@ HLEFunction UnitTestFakeSyscalls[] = {
|
||||||
{0x1234BEEF, &UnitTestTerminator, "UnitTestTerminator"},
|
{0x1234BEEF, &UnitTestTerminator, "UnitTestTerminator"},
|
||||||
};
|
};
|
||||||
|
|
||||||
double ExecCPUTest() {
|
double ExecCPUTest(bool clearCache = true) {
|
||||||
int blockTicks = 1000000;
|
int blockTicks = 1000000;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
|
if (MIPSComp::jit) {
|
||||||
|
currentMIPS->pc = PSP_GetUserMemoryBase();
|
||||||
|
MIPSComp::JitAt();
|
||||||
|
}
|
||||||
|
|
||||||
double st = time_now_d();
|
double st = time_now_d();
|
||||||
do {
|
do {
|
||||||
for (int j = 0; j < 1000; ++j) {
|
for (int j = 0; j < 1000; ++j) {
|
||||||
|
@ -73,6 +80,17 @@ double ExecCPUTest() {
|
||||||
while (time_now_d() - st < 0.5);
|
while (time_now_d() - st < 0.5);
|
||||||
double elapsed = time_now_d() - st;
|
double elapsed = time_now_d() - st;
|
||||||
|
|
||||||
|
if (MIPSComp::jit) {
|
||||||
|
JitBlockCacheDebugInterface *cache = MIPSComp::jit->GetBlockCacheDebugInterface();
|
||||||
|
if (cache) {
|
||||||
|
JitBlockDebugInfo block = cache->GetBlockDebugInfo(0);
|
||||||
|
WARN_LOG(JIT, "Executed %d target instrs, %d IR, for %d orig", (int)block.targetDisasm.size(), (int)block.irDisasm.size(), (int)block.origDisasm.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clearCache)
|
||||||
|
MIPSComp::jit->ClearCache();
|
||||||
|
}
|
||||||
|
|
||||||
return total / elapsed;
|
return total / elapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +126,7 @@ static void DestroyJitHarness() {
|
||||||
bool TestJit() {
|
bool TestJit() {
|
||||||
SetupJitHarness();
|
SetupJitHarness();
|
||||||
|
|
||||||
|
g_Config.bFastMemory = true;
|
||||||
currentMIPS->pc = PSP_GetUserMemoryBase();
|
currentMIPS->pc = PSP_GetUserMemoryBase();
|
||||||
u32 *p = (u32 *)Memory::GetPointer(currentMIPS->pc);
|
u32 *p = (u32 *)Memory::GetPointer(currentMIPS->pc);
|
||||||
|
|
||||||
|
@ -158,6 +177,7 @@ bool TestJit() {
|
||||||
|
|
||||||
*p++ = MIPS_MAKE_SYSCALL("UnitTestFakeSyscalls", "UnitTestTerminator");
|
*p++ = MIPS_MAKE_SYSCALL("UnitTestFakeSyscalls", "UnitTestTerminator");
|
||||||
*p++ = MIPS_MAKE_BREAK(1);
|
*p++ = MIPS_MAKE_BREAK(1);
|
||||||
|
*p++ = MIPS_MAKE_JR_RA();
|
||||||
|
|
||||||
// Dogfood.
|
// Dogfood.
|
||||||
addr = currentMIPS->pc;
|
addr = currentMIPS->pc;
|
||||||
|
@ -170,11 +190,15 @@ bool TestJit() {
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
double jit_speed = 0.0, interp_speed = 0.0;
|
double jit_speed = 0.0, jit_ir_speed = 0.0, ir_speed = 0.0, interp_speed = 0.0;
|
||||||
if (compileSuccess) {
|
if (compileSuccess) {
|
||||||
interp_speed = ExecCPUTest();
|
interp_speed = ExecCPUTest();
|
||||||
|
mipsr4k.UpdateCore(CPUCore::IR_INTERPRETER);
|
||||||
|
ir_speed = ExecCPUTest();
|
||||||
mipsr4k.UpdateCore(CPUCore::JIT);
|
mipsr4k.UpdateCore(CPUCore::JIT);
|
||||||
jit_speed = ExecCPUTest();
|
jit_speed = ExecCPUTest();
|
||||||
|
mipsr4k.UpdateCore(CPUCore::JIT_IR);
|
||||||
|
jit_ir_speed = ExecCPUTest(false);
|
||||||
|
|
||||||
// Disassemble
|
// Disassemble
|
||||||
JitBlockCacheDebugInterface *cache = MIPSComp::jit->GetBlockCacheDebugInterface();
|
JitBlockCacheDebugInterface *cache = MIPSComp::jit->GetBlockCacheDebugInterface();
|
||||||
|
@ -182,14 +206,14 @@ bool TestJit() {
|
||||||
JitBlockDebugInfo block = cache->GetBlockDebugInfo(0); // Should only be one block.
|
JitBlockDebugInfo block = cache->GetBlockDebugInfo(0); // Should only be one block.
|
||||||
std::vector<std::string> &lines = block.targetDisasm;
|
std::vector<std::string> &lines = block.targetDisasm;
|
||||||
// Cut off at 25 due to the repetition above. Might need tweaking for large instructions.
|
// Cut off at 25 due to the repetition above. Might need tweaking for large instructions.
|
||||||
const int cutoff = 25;
|
const int cutoff = 50;
|
||||||
for (int i = 0; i < std::min((int)lines.size(), cutoff); i++) {
|
for (int i = 0; i < std::min((int)lines.size(), cutoff); i++) {
|
||||||
printf("%s\n", lines[i].c_str());
|
printf("%s\n", lines[i].c_str());
|
||||||
}
|
}
|
||||||
if (lines.size() > cutoff)
|
if (lines.size() > cutoff)
|
||||||
printf("...\n");
|
printf("...\n");
|
||||||
}
|
}
|
||||||
printf("Jit was %fx faster than interp.\n\n", jit_speed / interp_speed);
|
printf("Jit was %fx faster than interp, IR was %fx faster, JIT IR %fx.\n\n", jit_speed / interp_speed, ir_speed / interp_speed, jit_ir_speed / interp_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#include "Common/Render/DrawBuffer.h"
|
#include "Common/Render/DrawBuffer.h"
|
||||||
#include "Common/System/NativeApp.h"
|
#include "Common/System/NativeApp.h"
|
||||||
#include "Common/System/System.h"
|
#include "Common/System/System.h"
|
||||||
|
#include "Common/Thread/ThreadUtil.h"
|
||||||
|
|
||||||
#include "Common/ArmEmitter.h"
|
#include "Common/ArmEmitter.h"
|
||||||
#include "Common/BitScan.h"
|
#include "Common/BitScan.h"
|
||||||
|
@ -1038,6 +1039,8 @@ TestItem availableTests[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
|
SetCurrentThreadName("UnitTest");
|
||||||
|
|
||||||
cpu_info.bNEON = true;
|
cpu_info.bNEON = true;
|
||||||
cpu_info.bVFP = true;
|
cpu_info.bVFP = true;
|
||||||
cpu_info.bVFPv3 = true;
|
cpu_info.bVFPv3 = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue