Compare commits

...

5 commits

7 changed files with 36 additions and 24 deletions

View file

@ -42,6 +42,7 @@ ENDIF(BUILD_PYTHON)
MESSAGE(STATUS "Using the target ${CosmoTool_local} to build python module")
find_package(ZLIB)
find_library(ZLIB_LIBRARY z)
find_library(DL_LIBRARY dl)
find_library(RT_LIBRARY rt)
@ -82,7 +83,7 @@ SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "4${EXTRA_VERSION}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CosmoToolbox-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_STRIP_FILES "lib/libCosmoTool.so")
SET(CPACK_SOURCE_IGNORE_FILES
SET(CPACK_SOURCE_IGNORE_FILES
"/CVS/;/\\\\.git/;/\\\\.svn/;\\\\.swp$;\\\\.#;/#;.*~;cscope.*;/CMakeFiles/;.*\\\\.cmake;Makefile")
add_subdirectory(src)

View file

@ -16,7 +16,7 @@ ln -fs /usr/bin/cmake3 /usr/bin/cmake
test -d /io/wheelhouse || mkdir /io/wheelhouse
test -d /io/wheelhouse/fix || mkdir /io/wheelhouse/fix
ALL_PYTHON="cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310"
ALL_PYTHON="cp39-cp39 cp310-cp310"
# Compile wheels
for pkg in $ALL_PYTHON; do
@ -24,11 +24,11 @@ for pkg in $ALL_PYTHON; do
# "${PYBIN}/pip" install -r /io/dev-requirements.txt
"${PYBIN}/pip" install setuptools wheel Cython
"${PYBIN}/pip" install -r /io/requirements.txt
"${PYBIN}/pip" wheel -vvv /io/ -w wheelhouse/
"${PYBIN}/pip" wheel -vvv /io/ -w /io/wheelhouse/
done
# Bundle external shared libraries into the wheels
for whl in /io/wheelhouse/cosmotool*.whl; do
for whl in /io/wheelhouse/cosmotool*linux*.whl; do
auditwheel repair "$whl" --plat $PLAT -w /io/wheelhouse/fix
done

View file

@ -9,4 +9,4 @@ if ! [ -e ${d}/setup.py ] ; then
exit 1
fi
podman run -ti --rm -e PLAT=manylinux2010_x86_64 -v ${d}:/io:Z quay.io/pypa/manylinux2010_x86_64 /io/builder/build-wheels.sh
podman run -ti --rm -e PLAT=manylinux2014_x86_64 -v ${d}:/io:Z quay.io/pypa/manylinux2014_x86_64 /io/builder/build-wheels.sh

View file

@ -2,3 +2,7 @@
requires = ["setuptools","wheel","cython"]
build-backend = "setuptools.build_meta"
[tool.towncrier]
directory = "changes"

View file

@ -426,7 +426,7 @@ namespace CosmoTool {
#define CTOOL_HDF5_INSERT_ELEMENT(r, STRUCT, element) \
{ \
::CosmoTool::get_hdf5_data_type<BOOST_PP_TUPLE_ELEM(2, 0, element)> t; \
long position = HOFFSET(STRUCT, BOOST_PP_TUPLE_ELEM(2, 1, element)); \
long position = offsetof(STRUCT, BOOST_PP_TUPLE_ELEM(2, 1, element)); \
const char *field_name = BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 1, element)); \
type.insertMember(field_name, position, t.type()); \
}

View file

@ -72,7 +72,9 @@ namespace CosmoTool {
void
fetchNeighbours(const typename SPHTree::coords &c, SPHState *state = 0);
void fetchNeighbours(const typename SPHTree::coords &c, uint32_t newNsph);
void fetchNeighbours(
const typename SPHTree::coords &c, uint32_t newNsph,
SPHState *state = 0);
void fetchNeighboursOnVolume(
const typename SPHTree::coords &c, ComputePrecision radius);
const typename SPHTree::coords &getCurrentCenter() const {

View file

@ -35,32 +35,38 @@ namespace CosmoTool {
template <typename ValType, int Ndims>
void SPHSmooth<ValType, Ndims>::fetchNeighbours(
const typename SPHTree::coords &c, uint32_t newNngb) {
const typename SPHTree::coords &c, uint32_t newNngb, SPHState *state) {
ComputePrecision d2, max_dist = 0;
uint32_t requested = newNngb;
if (requested > maxNgb) {
maxNgb = requested;
internal.ngb = boost::shared_ptr<P_SPHCell[]>(new P_SPHCell[maxNgb]);
internal.distances =
boost::shared_ptr<CoordType[]>(new CoordType[maxNgb]);
if (state != 0) {
state->distances = boost::shared_ptr<CoordType[]>(new CoordType[newNngb]);
state->ngb = boost::shared_ptr<SPHCell *[]>(new SPHCell *[newNngb]);
} else {
state = &internal;
if (requested > maxNgb) {
maxNgb = requested;
internal.ngb = boost::shared_ptr<P_SPHCell[]>(new P_SPHCell[maxNgb]);
internal.distances =
boost::shared_ptr<CoordType[]>(new CoordType[maxNgb]);
}
}
memcpy(internal.currentCenter, c, sizeof(c));
memcpy(state->currentCenter, c, sizeof(c));
tree->getNearestNeighbours(
c, requested, (SPHCell **)internal.ngb.get(),
(CoordType *)internal.distances.get());
c, requested, (SPHCell **)state->ngb.get(),
(CoordType *)state->distances.get());
internal.currentNgb = 0;
for (uint32_t i = 0; i < requested && (internal.ngb)[i] != 0;
i++, internal.currentNgb++) {
internal.distances[i] = sqrt(internal.distances[i]);
d2 = internal.distances[i];
state->currentNgb = 0;
for (uint32_t i = 0; i < requested && (state->ngb)[i] != 0;
i++, state->currentNgb++) {
state->distances[i] = sqrt(state->distances[i]);
d2 = state->distances[i];
if (d2 > max_dist)
max_dist = d2;
}
internal.smoothRadius = max_dist / 2;
state->smoothRadius = max_dist / 2;
}
template <typename ValType, int Ndims>
@ -206,7 +212,7 @@ namespace CosmoTool {
ComputePrecision d = state->distances[i];
SPHCell &cell = *(state->ngb[i]);
double kernel_value = getKernel(d / state->smoothRadius) / r3;
#pragma omp atomic
#pragma omp atomic update
cell.val.weight += kernel_value;
}
}
@ -241,5 +247,4 @@ namespace CosmoTool {
const SPHSmooth<ValType2, Ndims> &s2) {
return (s1.getSmoothingLen() < s2.getSmoothingLen());
}
}; // namespace CosmoTool