Some control over the launched threads in scatsystem.
Former-commit-id: a67102dcb367b8fe577f9d8896c9a477571c7d6f
This commit is contained in:
parent
f23edf0d71
commit
2ab4c55e13
|
@ -1,12 +1,17 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator
|
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator, scatsystem_set_nthreads
|
||||||
from qpms.symmetries import point_group_info
|
from qpms.symmetries import point_group_info
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
nm = 1e-9
|
nm = 1e-9
|
||||||
|
|
||||||
|
|
||||||
|
if 'SLURM_CPUS_PER_TASK' in os.environ:
|
||||||
|
scatsystem_set_nthreads(os.environ['SLURM_CPUS_PER_TASK'])
|
||||||
|
|
||||||
|
|
||||||
rewrite_output = '--rewrite-output' in sys.argv
|
rewrite_output = '--rewrite-output' in sys.argv
|
||||||
|
|
||||||
cyr_part_height = 50*nm
|
cyr_part_height = 50*nm
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator
|
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator, scatsystem_set_nthreads
|
||||||
from qpms.symmetries import point_group_info
|
from qpms.symmetries import point_group_info
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
if 'SLURM_CPUS_PER_TASK' in os.environ:
|
||||||
|
scatsystem_set_nthreads(os.environ['SLURM_CPUS_PER_TASK'])
|
||||||
|
|
||||||
nm = 1e-9
|
nm = 1e-9
|
||||||
|
|
||||||
rewrite_output = '--rewrite-output' in sys.argv
|
rewrite_output = '--rewrite-output' in sys.argv
|
||||||
|
|
|
@ -1398,6 +1398,10 @@ cdef class Particle:
|
||||||
else:
|
else:
|
||||||
raise ValueError("Position argument has to contain 3 or 2 cartesian coordinates")
|
raise ValueError("Position argument has to contain 3 or 2 cartesian coordinates")
|
||||||
|
|
||||||
|
cpdef void scatsystem_set_nthreads(long n):
|
||||||
|
qpms_scatsystem_set_nthreads(n)
|
||||||
|
return
|
||||||
|
|
||||||
cdef class ScatteringSystem:
|
cdef class ScatteringSystem:
|
||||||
'''
|
'''
|
||||||
Wrapper over the C qpms_scatsys_t structure.
|
Wrapper over the C qpms_scatsys_t structure.
|
||||||
|
|
|
@ -290,6 +290,7 @@ cdef extern from "tmatrices.h":
|
||||||
|
|
||||||
|
|
||||||
cdef extern from "scatsystem.h":
|
cdef extern from "scatsystem.h":
|
||||||
|
void qpms_scatsystem_set_nthreads(long n)
|
||||||
struct qpms_particle_t:
|
struct qpms_particle_t:
|
||||||
cart3_t pos
|
cart3_t pos
|
||||||
const qpms_tmatrix_t *tmatrix
|
const qpms_tmatrix_t *tmatrix
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
#define QPMS_SCATSYS_TMATRIX_RTOL 1e-12
|
#define QPMS_SCATSYS_TMATRIX_RTOL 1e-12
|
||||||
|
|
||||||
long qpms_scatsystem_nthreads_default = 4;
|
long qpms_scatsystem_nthreads_default = 4;
|
||||||
|
long qpms_scatsystem_nthreads_override = 0;
|
||||||
|
|
||||||
|
void qpms_scatsystem_set_nthreads(long n) {
|
||||||
|
qpms_scatsystem_nthreads_override = n;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------ Stupid implementation of qpms_scatsys_apply_symmetry() -------------
|
// ------------ Stupid implementation of qpms_scatsys_apply_symmetry() -------------
|
||||||
|
|
||||||
|
@ -1419,13 +1424,20 @@ complex double *qpms_scatsys_build_modeproblem_matrix_irrep_packed_parallelR(
|
||||||
arg = {ss, &opistartR, &opistartR_mutex, iri, target_packed, k};
|
arg = {ss, &opistartR, &opistartR_mutex, iri, target_packed, k};
|
||||||
|
|
||||||
// FIXME THIS IS NOT PORTABLE:
|
// FIXME THIS IS NOT PORTABLE:
|
||||||
long nthreads = sysconf(_SC_NPROCESSORS_ONLN);
|
long nthreads;
|
||||||
if (nthreads < 1) {
|
if (qpms_scatsystem_nthreads_override > 0) {
|
||||||
QPMS_WARN("_SC_NPROCESSORS_ONLN returned %ld, using %ld thread(s) instead.",
|
nthreads = qpms_scatsystem_nthreads_override;
|
||||||
nthreads, qpms_scatsystem_nthreads_default);
|
QPMS_WARN("Using overriding value of %ld thread(s).",
|
||||||
nthreads = qpms_scatsystem_nthreads_default;
|
nthreads);
|
||||||
} else {
|
} else {
|
||||||
QPMS_DEBUG("_SC_NRPOCESSORS_ONLN returned %ld.", nthreads);
|
nthreads = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
if (nthreads < 1) {
|
||||||
|
QPMS_WARN("_SC_NPROCESSORS_ONLN returned %ld, using %ld thread(s) instead.",
|
||||||
|
nthreads, qpms_scatsystem_nthreads_default);
|
||||||
|
nthreads = qpms_scatsystem_nthreads_default;
|
||||||
|
} else {
|
||||||
|
QPMS_DEBUG("_SC_NRPOCESSORS_ONLN returned %ld.", nthreads);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pthread_t thread_ids[nthreads];
|
pthread_t thread_ids[nthreads];
|
||||||
for(long thi = 0; thi < nthreads; ++thi)
|
for(long thi = 0; thi < nthreads; ++thi)
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
#include "qpms_types.h"
|
#include "qpms_types.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
|
/// Overrides the number of threads spawned by the paralellized functions.
|
||||||
|
/** TODO MORE DOC which are those? */
|
||||||
|
void qpms_scatsystem_set_nthreads(long n);
|
||||||
|
|
||||||
/// A particle, defined by its T-matrix and position.
|
/// A particle, defined by its T-matrix and position.
|
||||||
typedef struct qpms_particle_t {
|
typedef struct qpms_particle_t {
|
||||||
// Does it make sense to ever use other than cartesian coords for this?
|
// Does it make sense to ever use other than cartesian coords for this?
|
||||||
|
|
Loading…
Reference in New Issue