mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-15 00:59:59 +00:00
Properly detect number of cores on WIN32
This commit is contained in:
parent
7158f9f9ed
commit
29f0f9bc18
32
main.c
32
main.c
@ -4165,12 +4165,34 @@ int main (int argc, char *argv[])
|
|||||||
if (unlikely(!current_hash))
|
if (unlikely(!current_hash))
|
||||||
quit (1, "main OOM");
|
quit (1, "main OOM");
|
||||||
|
|
||||||
#ifdef WIN32
|
// Reckon number of cores in the box
|
||||||
opt_n_threads = num_processors = 1;
|
#if defined(WIN32)
|
||||||
#else
|
|
||||||
num_processors = sysconf(_SC_NPROCESSORS_ONLN);
|
DWORD system_am;
|
||||||
|
DWORD process_am;
|
||||||
|
BOOL ok = GetProcessAffinityMask(
|
||||||
|
GetCurrentProcess(),
|
||||||
|
&system_am,
|
||||||
|
&process_am
|
||||||
|
);
|
||||||
|
if (!ok) {
|
||||||
|
applog(LOG_ERR, "couldn't figure out number of processors :(");
|
||||||
|
num_processors = 1;
|
||||||
|
} else {
|
||||||
|
size_t n = 32;
|
||||||
|
num_processors = 0;
|
||||||
|
while (n--)
|
||||||
|
if (process_am & (1<<n))
|
||||||
|
++num_processors;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
num_processors = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
|
||||||
|
#endif /* !WIN32 */
|
||||||
|
|
||||||
opt_n_threads = num_processors;
|
opt_n_threads = num_processors;
|
||||||
#endif /* !WIN32 */
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCL
|
#ifdef HAVE_OPENCL
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user