Dolphin, the GameCube and Wii emulator - Forums

Full Version: Hyrule Field Slowdown Observation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Well I was browsing through some coding help sites that I found by searching _mm_pause and reading through Msdn..

Sigh, I wish I knew how to code.. I really do want to help to the best of my abilities.

But I solved the compilation errors, here's the actual code (Did require edits to other source files to change YieldCPU to YieldProcessor:

Quote:inline void YieldProcessor()
{
#ifdef _WIN32
Sleep(0);
#elif defined(_M_IX86) || defined(_M_X64)
thr_yield();
#else
sched_yield();
#endif
}

The code above may still need a minor edit. According to MSDN and other coding site, shouldn't YieldCPU(); or YieldProcessor(); be void YieldCPU(void); or void YieldProcessor(void); instead?
Send me the patch to take a look at it ( Actually I don't know how to code either , but my logic says 0+0=1 Tongue )
(03-30-2010, 11:10 AM)James333 Wrote: [ -> ]Send me the patch to take a look at it ( Actually I don't know how to code either , but my logic says 0+0=1 Tongue )

Well it doesn't seem to have any effects on the slowdowns, at least for Twilight Princess it doesn't. I've gone through and tried everything I can think of, perhaps someone else might have a better idea.

So far the code I edited doesn't seem to affect stability or performance, not exactly sure why.

[attachment=3778]
Code:
inline void YieldProcessor() // How this doesn't cause conflicts with the YieldProcessor() function that was in the ifdef before ?
{
#ifdef _WIN32
Sleep(0); // <--Where did this functions came from ? They were present in one of the included files or something like that ?
#elif defined(_M_IX86) || defined(_M_X64)
thr_yield();  // <--Where did this functions came from ? They were present in one of the included files or something like that ?
#else
sched_yield();  // <--Where did this functions came from ? They were present in one of the included files or something like that ?
#endif
}

Besides that you just changed the names
Well the functions obviously had to be included in of the other files else I would of got errors when compiling, seems those functions were already present.
sched_yield is defined in sched.h and should be available on all POSIX compliant systems.
thr_yield is defined in thread.h and seems to be only available on Solaris.
Sleep is defined in windows.h and Windows-only.

Sleep(0) apparently does what other devs intended with YieldCPU, but only on Win32. usleep/nanosleep on *nix dont seem to do this; sched_yield is probably the better idea there.
Try this:
Code:
inline void YieldProcessor()
{
#ifdef _Win32
    Sleep(0);
#else
    sched_yield();
#endif
}
with
Code:
#ifdef _WIN32
#include <windows.h>
#else
#include <sched.h>
#endif
on top of the file, unless those two are already included by chance.
Quote:Sleep(0) apparently does what other devs intended with YieldCPU, but only on Win32

What would it be for Win64 (x86_64) based operating systems such as XP/Vista/W7 x64?

Btw, why do some of the definitions become grayed out in VS2008?

Quote:inline void YieldProcessor()
{
#ifdef _Win32
Sleep(0);
#else
sched_yield();
#endif
}

That code gives me the following errors:

Code:
Error    1    error C3861: 'sched_yield': identifier not found    d:\my documents\emulator svn\dolphin-clean\source\core\common\src\Thread.h    219
If anyone would like try these patches, be sure to report any changes in performance or any issues these patches may cause. Please test with other games besides Zelda: Twilight Princess, by testing other games in addition to Twilight Princess we should be able to see if this has any effect on performance at all for other games since it doesn't seem to affect ZTP all that much if at all.

I've only tested only of the patches and it doesn't seem to affect the slowdowns in Hyrule Field, however it may improve performance for other games. I tried Resident Evil 4 and another game and seemed to get better performance than before the patch.

[attachment=3779]

[attachment=3780]

Similar to thread.h of r3845, with a minor modification that shouldn't make a difference:

[attachment=3781]
Try
Code:
{
#ifdef _WIN32 // interesting _WIN32 works but _Win32 doesn't :)
Sleep(0);
#else
sched_yield();
#endif
}

Your same patches but with the caps corrected Tongue

[attachment=3782][attachment=3783][attachment=3784]
A quick question, why do I only see definitions for _WIN32 and not _WIN64 as well? Wouldn't it make sense to also have definitions for _WIN64 for the 64-bit build of Dolphin?