Commit b9f99ec0 authored by Martin Reinecke's avatar Martin Reinecke

Merge branch 'thread-qual' into 'master'

Use qualified std::thread to avoid name collisions on AIX

See merge request !31
parents 2c80bd37 56bcb939
This diff is collapsed.
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
namespace { namespace {
using namespace std;
using pocketfft::shape_t; using pocketfft::shape_t;
using pocketfft::stride_t; using pocketfft::stride_t;
using std::size_t;
using std::ptrdiff_t;
namespace py = pybind11; namespace py = pybind11;
...@@ -66,13 +67,13 @@ shape_t makeaxes(const py::array &in, const py::object &axes) ...@@ -66,13 +67,13 @@ shape_t makeaxes(const py::array &in, const py::object &axes)
auto tmp=axes.cast<std::vector<ptrdiff_t>>(); auto tmp=axes.cast<std::vector<ptrdiff_t>>();
auto ndim = in.ndim(); auto ndim = in.ndim();
if ((tmp.size()>size_t(ndim)) || (tmp.size()==0)) if ((tmp.size()>size_t(ndim)) || (tmp.size()==0))
throw runtime_error("bad axes argument"); throw std::runtime_error("bad axes argument");
for (auto& sz: tmp) for (auto& sz: tmp)
{ {
if (sz<0) if (sz<0)
sz += ndim; sz += ndim;
if ((sz>=ndim) || (sz<0)) if ((sz>=ndim) || (sz<0))
throw invalid_argument("axes exceeds dimensionality of output"); throw std::invalid_argument("axes exceeds dimensionality of output");
} }
return shape_t(tmp.begin(), tmp.end()); return shape_t(tmp.begin(), tmp.end());
} }
...@@ -82,7 +83,7 @@ shape_t makeaxes(const py::array &in, const py::object &axes) ...@@ -82,7 +83,7 @@ shape_t makeaxes(const py::array &in, const py::object &axes)
if (py::isinstance<py::array_t<T1>>(arr)) return func<double> args; \ if (py::isinstance<py::array_t<T1>>(arr)) return func<double> args; \
if (py::isinstance<py::array_t<T2>>(arr)) return func<float> args; \ if (py::isinstance<py::array_t<T2>>(arr)) return func<float> args; \
if (py::isinstance<py::array_t<T3>>(arr)) return func<ldbl_t> args; \ if (py::isinstance<py::array_t<T3>>(arr)) return func<ldbl_t> args; \
throw runtime_error("unsupported data type"); \ throw std::runtime_error("unsupported data type"); \
} }
template<typename T> T norm_fct(int inorm, size_t N) template<typename T> T norm_fct(int inorm, size_t N)
...@@ -90,7 +91,7 @@ template<typename T> T norm_fct(int inorm, size_t N) ...@@ -90,7 +91,7 @@ template<typename T> T norm_fct(int inorm, size_t N)
if (inorm==0) return T(1); if (inorm==0) return T(1);
if (inorm==2) return T(1/ldbl_t(N)); if (inorm==2) return T(1/ldbl_t(N));
if (inorm==1) return T(1/sqrt(ldbl_t(N))); if (inorm==1) return T(1/sqrt(ldbl_t(N)));
throw invalid_argument("invalid value for inorm (must be 0, 1, or 2)"); throw std::invalid_argument("invalid value for inorm (must be 0, 1, or 2)");
} }
template<typename T> T norm_fct(int inorm, const shape_t &shape, template<typename T> T norm_fct(int inorm, const shape_t &shape,
...@@ -109,7 +110,7 @@ template<typename T> py::array_t<T> prepare_output(py::object &out_, ...@@ -109,7 +110,7 @@ template<typename T> py::array_t<T> prepare_output(py::object &out_,
if (out_.is_none()) return py::array_t<T>(dims); if (out_.is_none()) return py::array_t<T>(dims);
auto tmp = out_.cast<py::array_t<T>>(); auto tmp = out_.cast<py::array_t<T>>();
if (!tmp.is(out_)) // a new object was created during casting if (!tmp.is(out_)) // a new object was created during casting
throw runtime_error("unexpected data type for output array"); throw std::runtime_error("unexpected data type for output array");
return tmp; return tmp;
} }
...@@ -119,11 +120,11 @@ template<typename T> py::array c2c_internal(const py::array &in, ...@@ -119,11 +120,11 @@ template<typename T> py::array c2c_internal(const py::array &in,
{ {
auto axes = makeaxes(in, axes_); auto axes = makeaxes(in, axes_);
auto dims(copy_shape(in)); auto dims(copy_shape(in));
auto res = prepare_output<complex<T>>(out_, dims); auto res = prepare_output<std::complex<T>>(out_, dims);
auto s_in=copy_strides(in); auto s_in=copy_strides(in);
auto s_out=copy_strides(res); auto s_out=copy_strides(res);
auto d_in=reinterpret_cast<const complex<T> *>(in.data()); auto d_in=reinterpret_cast<const std::complex<T> *>(in.data());
auto d_out=reinterpret_cast<complex<T> *>(res.mutable_data()); auto d_out=reinterpret_cast<std::complex<T> *>(res.mutable_data());
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
T fct = norm_fct<T>(inorm, dims, axes); T fct = norm_fct<T>(inorm, dims, axes);
...@@ -138,18 +139,18 @@ template<typename T> py::array c2c_sym_internal(const py::array &in, ...@@ -138,18 +139,18 @@ template<typename T> py::array c2c_sym_internal(const py::array &in,
{ {
auto axes = makeaxes(in, axes_); auto axes = makeaxes(in, axes_);
auto dims(copy_shape(in)); auto dims(copy_shape(in));
auto res = prepare_output<complex<T>>(out_, dims); auto res = prepare_output<std::complex<T>>(out_, dims);
auto s_in=copy_strides(in); auto s_in=copy_strides(in);
auto s_out=copy_strides(res); auto s_out=copy_strides(res);
auto d_in=reinterpret_cast<const T *>(in.data()); auto d_in=reinterpret_cast<const T *>(in.data());
auto d_out=reinterpret_cast<complex<T> *>(res.mutable_data()); auto d_out=reinterpret_cast<std::complex<T> *>(res.mutable_data());
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
T fct = norm_fct<T>(inorm, dims, axes); T fct = norm_fct<T>(inorm, dims, axes);
pocketfft::r2c(dims, s_in, s_out, axes, forward, d_in, d_out, fct, nthreads); pocketfft::r2c(dims, s_in, s_out, axes, forward, d_in, d_out, fct, nthreads);
// now fill in second half // now fill in second half
using namespace pocketfft::detail; using namespace pocketfft::detail;
ndarr<complex<T>> ares(res.mutable_data(), dims, s_out); ndarr<std::complex<T>> ares(res.mutable_data(), dims, s_out);
rev_iter iter(ares, axes); rev_iter iter(ares, axes);
while(iter.remaining()>0) while(iter.remaining()>0)
{ {
...@@ -179,11 +180,11 @@ template<typename T> py::array r2c_internal(const py::array &in, ...@@ -179,11 +180,11 @@ template<typename T> py::array r2c_internal(const py::array &in,
auto axes = makeaxes(in, axes_); auto axes = makeaxes(in, axes_);
auto dims_in(copy_shape(in)), dims_out(dims_in); auto dims_in(copy_shape(in)), dims_out(dims_in);
dims_out[axes.back()] = (dims_out[axes.back()]>>1)+1; dims_out[axes.back()] = (dims_out[axes.back()]>>1)+1;
py::array res = prepare_output<complex<T>>(out_, dims_out); py::array res = prepare_output<std::complex<T>>(out_, dims_out);
auto s_in=copy_strides(in); auto s_in=copy_strides(in);
auto s_out=copy_strides(res); auto s_out=copy_strides(res);
auto d_in=reinterpret_cast<const T *>(in.data()); auto d_in=reinterpret_cast<const T *>(in.data());
auto d_out=reinterpret_cast<complex<T> *>(res.mutable_data()); auto d_out=reinterpret_cast<std::complex<T> *>(res.mutable_data());
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
T fct = norm_fct<T>(inorm, dims_in, axes); T fct = norm_fct<T>(inorm, dims_in, axes);
...@@ -253,7 +254,7 @@ template<typename T> py::array dct_internal(const py::array &in, ...@@ -253,7 +254,7 @@ template<typename T> py::array dct_internal(const py::array &in,
py::array dct(const py::array &in, int type, const py::object &axes_, py::array dct(const py::array &in, int type, const py::object &axes_,
int inorm, py::object &out_, size_t nthreads) int inorm, py::object &out_, size_t nthreads)
{ {
if ((type<1) || (type>4)) throw invalid_argument("invalid DCT type"); if ((type<1) || (type>4)) throw std::invalid_argument("invalid DCT type");
DISPATCH(in, f64, f32, flong, dct_internal, (in, axes_, type, inorm, out_, DISPATCH(in, f64, f32, flong, dct_internal, (in, axes_, type, inorm, out_,
nthreads)) nthreads))
} }
...@@ -283,7 +284,7 @@ template<typename T> py::array dst_internal(const py::array &in, ...@@ -283,7 +284,7 @@ template<typename T> py::array dst_internal(const py::array &in,
py::array dst(const py::array &in, int type, const py::object &axes_, py::array dst(const py::array &in, int type, const py::object &axes_,
int inorm, py::object &out_, size_t nthreads) int inorm, py::object &out_, size_t nthreads)
{ {
if ((type<1) || (type>4)) throw invalid_argument("invalid DST type"); if ((type<1) || (type>4)) throw std::invalid_argument("invalid DST type");
DISPATCH(in, f64, f32, flong, dst_internal, (in, axes_, type, inorm, DISPATCH(in, f64, f32, flong, dst_internal, (in, axes_, type, inorm,
out_, nthreads)) out_, nthreads))
} }
...@@ -297,12 +298,12 @@ template<typename T> py::array c2r_internal(const py::array &in, ...@@ -297,12 +298,12 @@ template<typename T> py::array c2r_internal(const py::array &in,
shape_t dims_in(copy_shape(in)), dims_out=dims_in; shape_t dims_in(copy_shape(in)), dims_out=dims_in;
if (lastsize==0) lastsize=2*dims_in[axis]-1; if (lastsize==0) lastsize=2*dims_in[axis]-1;
if ((lastsize/2) + 1 != dims_in[axis]) if ((lastsize/2) + 1 != dims_in[axis])
throw invalid_argument("bad lastsize"); throw std::invalid_argument("bad lastsize");
dims_out[axis] = lastsize; dims_out[axis] = lastsize;
py::array res = prepare_output<T>(out_, dims_out); py::array res = prepare_output<T>(out_, dims_out);
auto s_in=copy_strides(in); auto s_in=copy_strides(in);
auto s_out=copy_strides(res); auto s_out=copy_strides(res);
auto d_in=reinterpret_cast<const complex<T> *>(in.data()); auto d_in=reinterpret_cast<const std::complex<T> *>(in.data());
auto d_out=reinterpret_cast<T *>(res.mutable_data()); auto d_out=reinterpret_cast<T *>(res.mutable_data());
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment