Dummy CPU number hack for systems without the sysconf option.
Former-commit-id: 5a6b14d97f5a1edfdf1e0e5d058d4f8de794d5fc
This commit is contained in:
parent
dd2391abf7
commit
2ccf9e2c5d
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef _QPMS_OSHACKS_H
|
||||||
|
#define _QPMS_OSHACKS_H
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef _SC_NPROCESSORS_ONLN
|
||||||
|
static inline long get_ncpus(void) {
|
||||||
|
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
}
|
||||||
|
#elif (0)
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
static inline long get_ncpus(void) {
|
||||||
|
int32_t ncpu;
|
||||||
|
size_t len = sizeof(ncpu);
|
||||||
|
sysctlbyname("hw.physicalcpu", &ncpu, &len, NULL, 0);
|
||||||
|
return ncpu;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static inline long get_ncpus(void) { return -1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _QPMS_OSHACKS_H
|
|
@ -14,7 +14,6 @@
|
||||||
#include "groups.h"
|
#include "groups.h"
|
||||||
#include "symmetries.h"
|
#include "symmetries.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
#include "quaternions.h"
|
#include "quaternions.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -27,6 +26,7 @@
|
||||||
#include <gsl/gsl_integration.h>
|
#include <gsl/gsl_integration.h>
|
||||||
#include <gsl/gsl_errno.h>
|
#include <gsl/gsl_errno.h>
|
||||||
#include "optim.h"
|
#include "optim.h"
|
||||||
|
#include "oshacks.h"
|
||||||
|
|
||||||
// These are quite arbitrarily chosen constants for the quadrature in qpms_tmatrix_axialsym_fill()
|
// These are quite arbitrarily chosen constants for the quadrature in qpms_tmatrix_axialsym_fill()
|
||||||
#define TMATRIX_AXIALSYM_INTEGRAL_EPSREL (1e-5)
|
#define TMATRIX_AXIALSYM_INTEGRAL_EPSREL (1e-5)
|
||||||
|
@ -850,7 +850,7 @@ qpms_errno_t qpms_tmatrix_axialsym_fill(
|
||||||
QPMS_DEBUG(QPMS_DBGMSG_THREADS, "Using overriding value of %ld thread(s).",
|
QPMS_DEBUG(QPMS_DBGMSG_THREADS, "Using overriding value of %ld thread(s).",
|
||||||
nthreads);
|
nthreads);
|
||||||
} else {
|
} else {
|
||||||
nthreads = sysconf(_SC_NPROCESSORS_ONLN);
|
nthreads = get_ncpus();
|
||||||
if (nthreads < 1) {
|
if (nthreads < 1) {
|
||||||
QPMS_DEBUG(QPMS_DBGMSG_THREADS, "_SC_NPROCESSORS_ONLN returned %ld, using %ld thread(s) instead.",
|
QPMS_DEBUG(QPMS_DBGMSG_THREADS, "_SC_NPROCESSORS_ONLN returned %ld, using %ld thread(s) instead.",
|
||||||
nthreads, qpms_axsym_tmatrix_integration_nthreads_default);
|
nthreads, qpms_axsym_tmatrix_integration_nthreads_default);
|
||||||
|
|
Loading…
Reference in New Issue