Added option "numprocessors"

-numprocessors <auto|value>
        Specify the number of processors to use for work queues. Specifying
        "auto" will use the value reported by the system or environment 
        variable OSDPROCESSORS. To avoid abuse, this value is internally limited
        to 4 times the number of processors reported by the system. 
        The default is "auto".
This commit is contained in:
Couriersud 2009-12-19 23:12:07 +00:00
parent da19077b98
commit 3af4cd9bec
4 changed files with 50 additions and 12 deletions

View File

@ -43,7 +43,13 @@ Windows performance options
window and all DirectDraw/Direct3D code to execute on a second thread,
which can improve performance on hyperthreaded and multicore systems.
The default is OFF (-nomultithreading).
-numprocessors <auto|value>
Specify the number of processors to use for work queues. Specifying
"auto" will use the value reported by the system or environment
variable OSDPROCESSORS. To avoid abuse, this value is internally limited
to 4 times the number of processors reported by the system.
The default is "auto".
Windows video options

View File

@ -165,6 +165,7 @@ const options_entry mame_win_options[] =
{ NULL, NULL, OPTION_HEADER, "WINDOWS PERFORMANCE OPTIONS" },
{ "priority(-15-1)", "0", 0, "thread priority for the main game thread; range from -15 to 1" },
{ "multithreading;mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" },
{ "numprocessors;np", "auto", 0, "number of processors; this overrides the number the system reports" },
// video options
{ NULL, NULL, OPTION_HEADER, "WINDOWS VIDEO OPTIONS" },
@ -309,6 +310,7 @@ static void output_oslog(running_machine *machine, const char *buffer)
void osd_init(running_machine *machine)
{
int watchdog = options_get_int(mame_options(), WINOPTION_WATCHDOG);
const char *stemp;
// thread priority
if (!options_get_bool(mame_options(), OPTION_DEBUG))
@ -317,6 +319,21 @@ void osd_init(running_machine *machine)
// ensure we get called on the way out
add_exit_callback(machine, osd_exit);
// get number of processors
stemp = options_get_string(mame_options(), WINOPTION_NUMPROCESSORS);
osd_num_processors = 0;
if (strcmp(stemp, "auto") != 0)
{
osd_num_processors = atoi(stemp);
if (osd_num_processors < 1)
{
mame_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n");
osd_num_processors = 0;
}
}
// initialize the subsystems
winvideo_init(machine);
winsound_init(machine);

View File

@ -53,6 +53,7 @@
// performance options
#define WINOPTION_PRIORITY "priority"
#define WINOPTION_MULTITHREADING "multithreading"
#define WINOPTION_NUMPROCESSORS "numprocessors"
// video options
#define WINOPTION_VIDEO "video"
@ -131,6 +132,8 @@
extern const options_entry mame_win_options[];
// defined in winwork.c
extern int osd_num_processors;
//============================================================

View File

@ -174,7 +174,11 @@ struct _osd_work_item
volatile INT32 done; // is the item done?
};
//============================================================
// GLOBAL VARIABLES
//============================================================
int osd_num_processors = 0;
//============================================================
// FUNCTION PROTOTYPES
@ -677,20 +681,28 @@ void osd_work_item_release(osd_work_item *item)
static int effective_num_processors(void)
{
TCHAR *procsoverride;
SYSTEM_INFO info;
int numprocs = 0;
// if the OSDPROCESSORS environment variable is set, use that value if valid
procsoverride = _tgetenv(_T("OSDPROCESSORS"));
if (procsoverride != NULL && _stscanf(procsoverride, _T("%d"), &numprocs) == 1 && numprocs > 0)
return numprocs;
// otherwise, fetch the info from the system
// fetch the info from the system
GetSystemInfo(&info);
// max out at 4 for now since scaling above that seems to do poorly
return MIN(info.dwNumberOfProcessors, 4);
if (osd_num_processors > 0)
{
return MIN(info.dwNumberOfProcessors * 4, osd_num_processors);
}
else
{
TCHAR *procsoverride;
int numprocs = 0;
// if the OSDPROCESSORS environment variable is set, use that value if valid
procsoverride = _tgetenv(_T("OSDPROCESSORS"));
if (procsoverride != NULL && _stscanf(procsoverride, _T("%d"), &numprocs) == 1 && numprocs > 0)
// Be well behaved ...
return MIN(info.dwNumberOfProcessors * 4, numprocs);
// max out at 4 for now since scaling above that seems to do poorly
return MIN(info.dwNumberOfProcessors, 4);
}
}