mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-21 10:11:18 +00:00
Autodetect number of CPU cores for softfilter.
This commit is contained in:
parent
d17392b835
commit
980eefdd8c
@ -156,7 +156,7 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
|
||||
filt->max_height = max_height;
|
||||
|
||||
filt->impl_data = filt->impl->create(input_fmt, input_fmt, max_width, max_height,
|
||||
threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads : 1, cpu_features);
|
||||
threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads : rarch_get_cpu_cores(), cpu_features);
|
||||
if (!filt->impl_data)
|
||||
{
|
||||
RARCH_ERR("Failed to create softfilter state.\n");
|
||||
@ -170,6 +170,8 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
|
||||
goto error;
|
||||
}
|
||||
|
||||
RARCH_LOG("Using %u threads for softfilter.\n", threads);
|
||||
|
||||
filt->packets = (struct softfilter_work_packet*)calloc(threads, sizeof(*filt->packets));
|
||||
if (!filt->packets)
|
||||
{
|
||||
|
@ -71,6 +71,10 @@
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#if defined(BSD) || defined(__APPLE__)
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_COUNTERS 64
|
||||
@ -289,6 +293,40 @@ static void arm_enable_runfast_mode(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned rarch_get_cpu_cores(void)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(_XBOX) // Win32
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
return sysinfo.dwNumberOfProcessors;
|
||||
#elif defined(_SC_NPROCESSORS_ONLN) // Linux, most unix-likes.
|
||||
long ret = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (ret <= 0)
|
||||
return 1;
|
||||
return ret;
|
||||
#elif defined(BSD) || defined(__APPLE__) // BSD
|
||||
// Copypasta from stackoverflow, dunno if it works.
|
||||
int num_cpu = 0;
|
||||
int mib[4];
|
||||
size_t len = sizeof(num_cpu);
|
||||
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_AVAILCPU;
|
||||
sysctl(mib, 2, &num_cpu, &len, NULL, 0);
|
||||
if (num_cpu < 1)
|
||||
{
|
||||
mib[1] = HW_NCPU;
|
||||
sysctl(mib, 2, &num_cpu, &len, NULL, 0);
|
||||
if (num_cpu < 1)
|
||||
num_cpu = 1;
|
||||
}
|
||||
return num_cpu;
|
||||
#else
|
||||
// No idea, assume single core.
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t rarch_get_cpu_features(void)
|
||||
{
|
||||
uint64_t cpu = 0;
|
||||
|
@ -55,6 +55,7 @@ static inline void rarch_perf_stop(struct retro_perf_counter *perf)
|
||||
}
|
||||
|
||||
uint64_t rarch_get_cpu_features(void);
|
||||
unsigned rarch_get_cpu_cores(void);
|
||||
|
||||
// Used internally by RetroArch.
|
||||
#if defined(PERF_TEST) || !defined(RARCH_INTERNAL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user