-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ae/pack-autothread: Revert "pack-objects: Print a message describing the number of threads for packing" pack-objects: Print a message describing the number of threads for packing pack-objects: Add runtime detection of online CPU's
- Loading branch information
Showing
6 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "cache.h" | ||
|
||
#ifdef _WIN32 | ||
# define WIN32_LEAN_AND_MEAN | ||
# include <windows.h> | ||
#elif defined(hpux) || defined(__hpux) || defined(_hpux) | ||
# include <sys/pstat.h> | ||
#endif | ||
|
||
/* | ||
* By doing this in two steps we can at least get | ||
* the function to be somewhat coherent, even | ||
* with this disgusting nest of #ifdefs. | ||
*/ | ||
#ifndef _SC_NPROCESSORS_ONLN | ||
# ifdef _SC_NPROC_ONLN | ||
# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN | ||
# elif defined _SC_CRAY_NCPU | ||
# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU | ||
# endif | ||
#endif | ||
|
||
int online_cpus(void) | ||
{ | ||
#ifdef _SC_NPROCESSORS_ONLN | ||
long ncpus; | ||
#endif | ||
|
||
#ifdef _WIN32 | ||
SYSTEM_INFO info; | ||
GetSystemInfo(&info); | ||
|
||
if ((int)info.dwNumberOfProcessors > 0) | ||
return (int)info.dwNumberOfProcessors; | ||
#elif defined(hpux) || defined(__hpux) || defined(_hpux) | ||
struct pst_dynamic psd; | ||
|
||
if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0)) | ||
return (int)psd.psd_proc_cnt; | ||
#endif | ||
|
||
#ifdef _SC_NPROCESSORS_ONLN | ||
if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0) | ||
return (int)ncpus; | ||
#endif | ||
|
||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef THREAD_COMPAT_H | ||
#define THREAD_COMPAT_H | ||
|
||
extern int online_cpus(void); | ||
|
||
#endif /* THREAD_COMPAT_H */ |